Re: [PATCH 7/8] iio: adc: ad7606: Switch to xxx_get_device_match_data

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

 



On Sat, 14 Sep 2024 11:21:34 +0200
Guillaume Stols <gstols@xxxxxxxxxxxx> wrote:

> On 8/17/24 17:33, Jonathan Cameron wrote:
> > On Thu, 15 Aug 2024 12:12:01 +0000
> > Guillaume Stols <gstols@xxxxxxxxxxxx> wrote:
> >  
> >> On the parallel version, the current implementation is only compatible
> >> with id tables and won't work with fx_nodes. So in this commit, the goal
> >> is to switch to use get_device_match_data, in order to simplify the
> >> logic of retrieving chip data.
> >>
> >> Also, chip info is moved in the .h file so to be accessible to all the
> >> driver files that can set a pointer to the corresponding chip as the
> >> driver data.  
> > This means each driver gets their own copy.
> >
> > Better to use an extern in the header and keep the actual data
> > in the core module.  
> 
> ack.
> 
> Given your previous comment about introducing 
> platform_device_get_match_data, I guess I should instead do it directly 
> in the driver's probe, like its done in axp20x_adc.c ? Somehting like that:
> 
> if (!dev_fwnode(&pdev->dev)) {
>      const struct platform_device_id *id;
> 
>      id = platform_get_device_id(pdev);
>      chip_info = (const struct ad7606_chip_info *)id->driver_data;
> } else {
>      struct device *dev = &pdev->dev;
>      chip_info = device_get_match_data(dev);
> }

Yes, something along those lines makes sense.

If there are enough instances of this we can have a standard
definition for this similar to the i2c / spi ones that defaults
to device_get_match_data() if available, and falls back to the old
way if not.

If you want to add that great, if not it can be a separate
bit of work for another day.

Jonathan









[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