diff mbox series

[29/38] iio:chemical:vz89x: Drop of_match_ptr protection and use generic fw accessors

Message ID 20200910173242.621168-30-jic23@kernel.org
State New
Headers show
Series iio: remaining easy of_match_ptr removal and related. | expand

Commit Message

Jonathan Cameron Sept. 10, 2020, 5:32 p.m. UTC
From: Jonathan Cameron <Jonathan.Cameron@huawei.com>

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>
Cc: Matt Ranostay <matt.ranostay@konsulko.com>
---
 drivers/iio/chemical/vz89x.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

Comments

Matt Ranostay Sept. 15, 2020, 7:03 p.m. UTC | #1
On Thu, Sep 10, 2020 at 10:35 AM Jonathan Cameron <jic23@kernel.org> wrote:
>
> From: Jonathan Cameron <Jonathan.Cameron@huawei.com>
>
> 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>
> Cc: Matt Ranostay <matt.ranostay@konsulko.com>

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

> ---
>  drivers/iio/chemical/vz89x.c | 11 ++++-------
>  1 file changed, 4 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/iio/chemical/vz89x.c b/drivers/iio/chemical/vz89x.c
> index 3cd469578590..23b22a5f5c1c 100644
> --- a/drivers/iio/chemical/vz89x.c
> +++ b/drivers/iio/chemical/vz89x.c
> @@ -10,8 +10,7 @@
>  #include <linux/mutex.h>
>  #include <linux/init.h>
>  #include <linux/i2c.h>
> -#include <linux/of.h>
> -#include <linux/of_device.h>
> +#include <linux/mod_devicetable.h>
>
>  #include <linux/iio/iio.h>
>  #include <linux/iio/sysfs.h>
> @@ -355,7 +354,6 @@ static int vz89x_probe(struct i2c_client *client,
>         struct device *dev = &client->dev;
>         struct iio_dev *indio_dev;
>         struct vz89x_data *data;
> -       const struct of_device_id *of_id;
>         int chip_id;
>
>         indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
> @@ -371,11 +369,10 @@ static int vz89x_probe(struct i2c_client *client,
>         else
>                 return -EOPNOTSUPP;
>
> -       of_id = of_match_device(vz89x_dt_ids, dev);
> -       if (!of_id)
> +       if (!dev_fwnode(dev))
>                 chip_id = id->driver_data;
>         else
> -               chip_id = (unsigned long)of_id->data;
> +               chip_id = (unsigned long)device_get_match_data(dev);
>
>         i2c_set_clientdata(client, indio_dev);
>         data->client = client;
> @@ -403,7 +400,7 @@ MODULE_DEVICE_TABLE(i2c, vz89x_id);
>  static struct i2c_driver vz89x_driver = {
>         .driver = {
>                 .name   = "vz89x",
> -               .of_match_table = of_match_ptr(vz89x_dt_ids),
> +               .of_match_table = vz89x_dt_ids,
>         },
>         .probe = vz89x_probe,
>         .id_table = vz89x_id,
> --
> 2.28.0
>
diff mbox series

Patch

diff --git a/drivers/iio/chemical/vz89x.c b/drivers/iio/chemical/vz89x.c
index 3cd469578590..23b22a5f5c1c 100644
--- a/drivers/iio/chemical/vz89x.c
+++ b/drivers/iio/chemical/vz89x.c
@@ -10,8 +10,7 @@ 
 #include <linux/mutex.h>
 #include <linux/init.h>
 #include <linux/i2c.h>
-#include <linux/of.h>
-#include <linux/of_device.h>
+#include <linux/mod_devicetable.h>
 
 #include <linux/iio/iio.h>
 #include <linux/iio/sysfs.h>
@@ -355,7 +354,6 @@  static int vz89x_probe(struct i2c_client *client,
 	struct device *dev = &client->dev;
 	struct iio_dev *indio_dev;
 	struct vz89x_data *data;
-	const struct of_device_id *of_id;
 	int chip_id;
 
 	indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
@@ -371,11 +369,10 @@  static int vz89x_probe(struct i2c_client *client,
 	else
 		return -EOPNOTSUPP;
 
-	of_id = of_match_device(vz89x_dt_ids, dev);
-	if (!of_id)
+	if (!dev_fwnode(dev))
 		chip_id = id->driver_data;
 	else
-		chip_id = (unsigned long)of_id->data;
+		chip_id = (unsigned long)device_get_match_data(dev);
 
 	i2c_set_clientdata(client, indio_dev);
 	data->client = client;
@@ -403,7 +400,7 @@  MODULE_DEVICE_TABLE(i2c, vz89x_id);
 static struct i2c_driver vz89x_driver = {
 	.driver = {
 		.name	= "vz89x",
-		.of_match_table = of_match_ptr(vz89x_dt_ids),
+		.of_match_table = vz89x_dt_ids,
 	},
 	.probe = vz89x_probe,
 	.id_table = vz89x_id,