diff mbox series

iio: chemical: vz89x: Convert enum->pointer for data in the match tables

Message ID 20230812172718.232718-1-biju.das.jz@bp.renesas.com (mailing list archive)
State Superseded
Headers show
Series iio: chemical: vz89x: Convert enum->pointer for data in the match tables | expand

Commit Message

Biju Das Aug. 12, 2023, 5:27 p.m. UTC
Convert enum->pointer for data in the match tables, so that
device_get_match_data() can do match against OF/ACPI/I2C tables, once i2c
bus type match support added to it.

Replace enum->struct *vz89x_chip_data for data in the match table. Simplify
the probe() by replacing device_get_match_data() and ID lookup for
retrieving data by i2c_get_match_data().

While at it, drop unused variables id and chip_id from probe().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/iio/chemical/vz89x.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

Comments

Andy Shevchenko Aug. 15, 2023, 2:50 p.m. UTC | #1
On Sat, Aug 12, 2023 at 06:27:18PM +0100, Biju Das wrote:
> Convert enum->pointer for data in the match tables, so that
> device_get_match_data() can do match against OF/ACPI/I2C tables, once i2c
> bus type match support added to it.
> 
> Replace enum->struct *vz89x_chip_data for data in the match table. Simplify
> the probe() by replacing device_get_match_data() and ID lookup for
> retrieving data by i2c_get_match_data().

> While at it, drop unused variables id and chip_id from probe().

So, I'm not going to repeat, you have to fix this in all commit messages like
this.

Otherwise,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Biju Das Aug. 18, 2023, 2:59 p.m. UTC | #2
Hi Andy Shevchenko,

> Subject: Re: [PATCH] iio: chemical: vz89x: Convert enum->pointer for data
> in the match tables
> 
> On Sat, Aug 12, 2023 at 06:27:18PM +0100, Biju Das wrote:
> > Convert enum->pointer for data in the match tables, so that
> > device_get_match_data() can do match against OF/ACPI/I2C tables, once
> > i2c bus type match support added to it.
> >
> > Replace enum->struct *vz89x_chip_data for data in the match table.
> > Simplify the probe() by replacing device_get_match_data() and ID
> > lookup for retrieving data by i2c_get_match_data().
> 
> > While at it, drop unused variables id and chip_id from probe().
> 
> So, I'm not going to repeat, you have to fix this in all commit messages
> like this.

Agreed.

Cheers,
Biju

> 
> Otherwise,
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> 
> --
> With Best Regards,
> Andy Shevchenko
>
diff mbox series

Patch

diff --git a/drivers/iio/chemical/vz89x.c b/drivers/iio/chemical/vz89x.c
index 13555f4f401a..5b358bcd311b 100644
--- a/drivers/iio/chemical/vz89x.c
+++ b/drivers/iio/chemical/vz89x.c
@@ -342,19 +342,17 @@  static const struct vz89x_chip_data vz89x_chips[] = {
 };
 
 static const struct of_device_id vz89x_dt_ids[] = {
-	{ .compatible = "sgx,vz89x", .data = (void *) VZ89X },
-	{ .compatible = "sgx,vz89te", .data = (void *) VZ89TE },
+	{ .compatible = "sgx,vz89x", .data = &vz89x_chips[VZ89X] },
+	{ .compatible = "sgx,vz89te", .data = &vz89x_chips[VZ89TE] },
 	{ }
 };
 MODULE_DEVICE_TABLE(of, vz89x_dt_ids);
 
 static int vz89x_probe(struct i2c_client *client)
 {
-	const struct i2c_device_id *id = i2c_client_get_device_id(client);
 	struct device *dev = &client->dev;
 	struct iio_dev *indio_dev;
 	struct vz89x_data *data;
-	int chip_id;
 
 	indio_dev = devm_iio_device_alloc(dev, sizeof(*data));
 	if (!indio_dev)
@@ -369,14 +367,10 @@  static int vz89x_probe(struct i2c_client *client)
 	else
 		return -EOPNOTSUPP;
 
-	if (!dev_fwnode(dev))
-		chip_id = id->driver_data;
-	else
-		chip_id = (unsigned long)device_get_match_data(dev);
+	data->chip = i2c_get_match_data(client);
 
 	i2c_set_clientdata(client, indio_dev);
 	data->client = client;
-	data->chip = &vz89x_chips[chip_id];
 	data->last_update = jiffies - HZ;
 	mutex_init(&data->lock);
 
@@ -391,8 +385,8 @@  static int vz89x_probe(struct i2c_client *client)
 }
 
 static const struct i2c_device_id vz89x_id[] = {
-	{ "vz89x", VZ89X },
-	{ "vz89te", VZ89TE },
+	{ "vz89x", (kernel_ulong_t)&vz89x_chips[VZ89X] },
+	{ "vz89te", (kernel_ulong_t)&vz89x_chips[VZ89TE] },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, vz89x_id);