media: i2c: video-i2c: Convert enum->pointer for data in the match tables
authorBiju Das <biju.das.jz@bp.renesas.com>
Sun, 20 Aug 2023 07:58:46 +0000 (08:58 +0100)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 27 Sep 2023 07:39:56 +0000 (09:39 +0200)
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 *video_i2c_chip 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().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/i2c/video-i2c.c

index 537ebd9fa8d7406822c6123a2de9d7a45933e4bd..178bd06cc2ed506c3e4aa74bd359dfcf66d3d189 100644 (file)
@@ -759,7 +759,6 @@ static void video_i2c_release(struct video_device *vdev)
 
 static int video_i2c_probe(struct i2c_client *client)
 {
-       const struct i2c_device_id *id = i2c_client_get_device_id(client);
        struct video_i2c_data *data;
        struct v4l2_device *v4l2_dev;
        struct vb2_queue *queue;
@@ -769,11 +768,8 @@ static int video_i2c_probe(struct i2c_client *client)
        if (!data)
                return -ENOMEM;
 
-       if (dev_fwnode(&client->dev))
-               data->chip = device_get_match_data(&client->dev);
-       else if (id)
-               data->chip = &video_i2c_chip[id->driver_data];
-       else
+       data->chip = i2c_get_match_data(client);
+       if (!data->chip)
                goto error_free_device;
 
        data->regmap = regmap_init_i2c(client, data->chip->regmap_config);
@@ -940,8 +936,8 @@ static const struct dev_pm_ops video_i2c_pm_ops = {
 };
 
 static const struct i2c_device_id video_i2c_id_table[] = {
-       { "amg88xx", AMG88XX },
-       { "mlx90640", MLX90640 },
+       { "amg88xx", (kernel_ulong_t)&video_i2c_chip[AMG88XX] },
+       { "mlx90640", (kernel_ulong_t)&video_i2c_chip[MLX90640] },
        {}
 };
 MODULE_DEVICE_TABLE(i2c, video_i2c_id_table);