Re: [PATCH v3 2/2] iio: pressure: driver for Honeywell HSC/SSC series pressure sensors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux