[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZWtU836_yYWgMYZp@sunspire>
Date: Sat, 2 Dec 2023 18:01:55 +0200
From: Petre Rodan <petre.rodan@...dimension.ro>
To: Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc: Jonathan Cameron <jic23@...nel.org>, linux-kernel@...r.kernel.org,
linux-iio@...r.kernel.org, Lars-Peter Clausen <lars@...afoo.de>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Angel Iglesias <ang.iglesiasg@...il.com>,
Matti Vaittinen <mazziesaccount@...il.com>,
Andreas Klinger <ak@...klinger.de>,
Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>
Subject: Re: [PATCH v3 2/2] iio: pressure: driver for Honeywell HSC/SSC
series pressure sensors
Hello!
On Fri, Dec 01, 2023 at 06:24:53PM +0000, Jonathan Cameron wrote:
> > > > +static int hsc_spi_probe(struct spi_device *spi)
> > > > +{
> > > > + struct iio_dev *indio_dev;
> > > > + struct hsc_data *hsc;
> > > > + struct device *dev = &spi->dev;
> > > > +
> > > > + indio_dev = devm_iio_device_alloc(dev, sizeof(*hsc));
> > > > + if (!indio_dev)
> > > > + return -ENOMEM;
> > > > +
> > > > + hsc = iio_priv(indio_dev);
> > > > + hsc->xfer = hsc_spi_xfer;
> > >
> > > Also, pass the callback and spi->dev into hsc probe. Easy to use
> > > a container_of() to get back to the struct spi_device *spi
> >
> > I'd rather simply pass along the client struct.
> >
>
> I don't like the fact it has to be a void *
>
> The core code has no idea what is in there. At least we constraint it
> somewhat with a struct device.
but ...
that is the nice part. the core code never needs to know what exactly is behind
that pointer, since it only gets used by the i2c/spi module that provided that
pointer in the first place. I've never seen a better use of void * :)
I could define a
struct client_handle;
in the .h, use a pointer to that that as function argument, do a lot of
castings, but I feel like it's still a void * with extra steps.
cheers,
peter
Powered by blists - more mailing lists