Re: [PATCH 25/38] iio:chemical:atlas-sensor: Drop of_match_ptr and use generic fw accessors

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

 



On Thu, Sep 10, 2020 at 10:35 AM Jonathan Cameron <jic23@xxxxxxxxxx> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
>
> of_match_ptr() prevents use of this driver with ACPI via PRP0001 and is
> an example of an anti pattern I'm trying to remove from IIO.
> Hence drop from this driver and use generic fw accessors to check
> if there is a fw_node and get the id.
>
> It might be neater to use pointers rather than indexes for
> the device_data but that is another issue and should be handled
> separately.
>
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@xxxxxxxxxx>
> Cc: Matt Ranostay <matt.ranostay@xxxxxxxxxxxx>

Acked-by: Matt Ranostay <matt.ranostay@xxxxxxxxxxxx>

> ---
>  drivers/iio/chemical/atlas-sensor.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/iio/chemical/atlas-sensor.c b/drivers/iio/chemical/atlas-sensor.c
> index 43069636fcd5..cdab9d04dedd 100644
> --- a/drivers/iio/chemical/atlas-sensor.c
> +++ b/drivers/iio/chemical/atlas-sensor.c
> @@ -15,7 +15,7 @@
>  #include <linux/irq.h>
>  #include <linux/irq_work.h>
>  #include <linux/i2c.h>
> -#include <linux/of_device.h>
> +#include <linux/mod_devicetable.h>
>  #include <linux/regmap.h>
>  #include <linux/iio/iio.h>
>  #include <linux/iio/buffer.h>
> @@ -620,7 +620,6 @@ static int atlas_probe(struct i2c_client *client,
>  {
>         struct atlas_data *data;
>         struct atlas_device *chip;
> -       const struct of_device_id *of_id;
>         struct iio_trigger *trig;
>         struct iio_dev *indio_dev;
>         int ret;
> @@ -629,11 +628,10 @@ static int atlas_probe(struct i2c_client *client,
>         if (!indio_dev)
>                 return -ENOMEM;
>
> -       of_id = of_match_device(atlas_dt_ids, &client->dev);
> -       if (!of_id)
> +       if (!dev_fwnode(&client->dev))
>                 chip = &atlas_devices[id->driver_data];
>         else
> -               chip = &atlas_devices[(unsigned long)of_id->data];
> +               chip = &atlas_devices[(unsigned long)device_get_match_data(&client->dev)];
>
>         indio_dev->info = &atlas_info;
>         indio_dev->name = ATLAS_DRV_NAME;
> @@ -775,7 +773,7 @@ static const struct dev_pm_ops atlas_pm_ops = {
>  static struct i2c_driver atlas_driver = {
>         .driver = {
>                 .name   = ATLAS_DRV_NAME,
> -               .of_match_table = of_match_ptr(atlas_dt_ids),
> +               .of_match_table = atlas_dt_ids,
>                 .pm     = &atlas_pm_ops,
>         },
>         .probe          = atlas_probe,
> --
> 2.28.0
>



[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