iio: potentiometer: ds1803: Convert enum->pointer for data in the ID table
authorBiju Das <biju.das.jz@bp.renesas.com>
Sat, 12 Aug 2023 14:41:06 +0000 (15:41 +0100)
committerJonathan Cameron <jonathan.cameron@huawei.com>
Tue, 12 Sep 2023 09:42:03 +0000 (10:42 +0100)
Convert enum->pointer for data in the ID table, 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 *ds1803_cfg for data in the ID table and simplify
ds1803_probe() by replacing device_get_match_data() with
i2c_get_match_data().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Link: https://lore.kernel.org/r/20230812144106.163355-1-biju.das.jz@bp.renesas.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/potentiometer/ds1803.c

index fc183e0790dafb989a1260a6e10526dc458b61db..e0526dd0e3cbb02243f271a4ee3ddec2a043776e 100644 (file)
@@ -204,7 +204,6 @@ static const struct iio_info ds1803_info = {
 
 static int ds1803_probe(struct i2c_client *client)
 {
-       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct device *dev = &client->dev;
        struct ds1803_data *data;
        struct iio_dev *indio_dev;
@@ -217,9 +216,7 @@ static int ds1803_probe(struct i2c_client *client)
 
        data = iio_priv(indio_dev);
        data->client = client;
-       data->cfg = device_get_match_data(dev);
-       if (!data->cfg)
-               data->cfg = &ds1803_cfg[id->driver_data];
+       data->cfg = i2c_get_match_data(client);
 
        indio_dev->info = &ds1803_info;
        indio_dev->channels = data->cfg->channels;
@@ -239,10 +236,10 @@ static const struct of_device_id ds1803_dt_ids[] = {
 MODULE_DEVICE_TABLE(of, ds1803_dt_ids);
 
 static const struct i2c_device_id ds1803_id[] = {
-       { "ds1803-010", DS1803_010 },
-       { "ds1803-050", DS1803_050 },
-       { "ds1803-100", DS1803_100 },
-       { "ds3502", DS3502 },
+       { "ds1803-010", (kernel_ulong_t)&ds1803_cfg[DS1803_010] },
+       { "ds1803-050", (kernel_ulong_t)&ds1803_cfg[DS1803_050] },
+       { "ds1803-100", (kernel_ulong_t)&ds1803_cfg[DS1803_100] },
+       { "ds3502", (kernel_ulong_t)&ds1803_cfg[DS3502] },
        {}
 };
 MODULE_DEVICE_TABLE(i2c, ds1803_id);