diff options
author | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2020-09-10 19:32:31 +0200 |
---|---|---|
committer | Jonathan Cameron <Jonathan.Cameron@huawei.com> | 2020-09-21 19:41:32 +0200 |
commit | 6ac282edd653d28b4d64744c7ad05e9a4e1aeaf4 (patch) | |
tree | c1dacc7a30474ce7070f966b1e1fbb91d04e20e5 /drivers/iio | |
parent | iio:chemical:sgp30: Use local variable dev to simplify code (diff) | |
download | linux-6ac282edd653d28b4d64744c7ad05e9a4e1aeaf4.tar.xz linux-6ac282edd653d28b4d64744c7ad05e9a4e1aeaf4.zip |
iio:chemical:sgp30: Drop of_match_ptr and use generic fw accessors
This change allow the driver to be used with ACPI PRP0001 and removes
an antipattern that I want to avoid being copied into new IIO drivers.
The handling of match_data uses a different approach as
device_get_match_data doesn't distinguish between no match, and
a match but with NULL data.
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Andreas Brauchli <andreas.brauchli@sensirion.com>
Link: https://lore.kernel.org/r/20200910173242.621168-28-jic23@kernel.org
Diffstat (limited to 'drivers/iio')
-rw-r--r-- | drivers/iio/chemical/sgp30.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/iio/chemical/sgp30.c b/drivers/iio/chemical/sgp30.c index 410565aa20b6..c2d93b9796ce 100644 --- a/drivers/iio/chemical/sgp30.c +++ b/drivers/iio/chemical/sgp30.c @@ -20,9 +20,9 @@ #include <linux/delay.h> #include <linux/kthread.h> #include <linux/module.h> +#include <linux/mod_devicetable.h> #include <linux/mutex.h> #include <linux/i2c.h> -#include <linux/of_device.h> #include <linux/iio/iio.h> #include <linux/iio/sysfs.h> @@ -501,7 +501,6 @@ static int sgp_probe(struct i2c_client *client, struct device *dev = &client->dev; struct iio_dev *indio_dev; struct sgp_data *data; - const struct of_device_id *of_id; unsigned long product_id; int ret; @@ -509,9 +508,8 @@ static int sgp_probe(struct i2c_client *client, if (!indio_dev) return -ENOMEM; - of_id = of_match_device(sgp_dt_ids, dev); - if (of_id) - product_id = (unsigned long)of_id->data; + if (dev_fwnode(dev)) + product_id = (unsigned long)device_get_match_data(dev); else product_id = id->driver_data; @@ -576,7 +574,7 @@ MODULE_DEVICE_TABLE(of, sgp_dt_ids); static struct i2c_driver sgp_driver = { .driver = { .name = "sgp30", - .of_match_table = of_match_ptr(sgp_dt_ids), + .of_match_table = sgp_dt_ids, }, .probe = sgp_probe, .remove = sgp_remove, |