Re: [RFC PATCH 1/5] mfd: 88pm88x: differences with respect to the PMIC RFC series

From: Lee Jones
Date: Fri Jan 12 2024 - 02:58:41 EST


On Thu, 11 Jan 2024, Karel Balej wrote:

> On Thu Jan 11, 2024 at 4:25 PM CET, Lee Jones wrote:
>
> [...]
>
> > > > > diff --git a/include/linux/mfd/88pm88x.h b/include/linux/mfd/88pm88x.h
> > > > > index a34c57447827..9a335f6b9c07 100644
> > > > > --- a/include/linux/mfd/88pm88x.h
> > > > > +++ b/include/linux/mfd/88pm88x.h
> > > > > @@ -49,6 +49,8 @@ struct pm88x_data {
> > > > > unsigned int whoami;
> > > > > struct reg_sequence *presets;
> > > > > unsigned int num_presets;
> > > > > + struct mfd_cell *devs;
> > > > > + unsigned int num_devs;
> > > >
> > > > Why are you adding extra abstraction?
> > >
> > > Right, this is probably not necessary now since I'm only implementing
> > > support for one of the chips - it's just that I keep thinking about it
> > > as a driver for both of them and thus tend to write it a bit more
> > > abstractly. Shall I then drop this and also the `presets` member which
> > > is also chip-specific?
> >
> > Even if you were to support multiple devices, this strategy is unusual
> > and isn't likely to be accepted.
>
> May I please ask what the recommended strategy is then? `switch`ing on
> the chip ID? I have taken this approach because it seemed to produce a
> cleaner/more straightforward code in comparison to that. Or are you only
> talking about the chip cells/subdevices in particular?

I'd have to see the implementation, but the general exception I'm taking
here is storing the use-once MFD cell data inside a data structure. If
you were to match on device ID it's *sometimes* acceptable to store the
pointers in local variables.

--
Lee Jones [李琼斯]