media: i2c: mt9v032: Extend match support for OF tables
authorBiju Das <biju.das.jz@bp.renesas.com>
Sun, 10 Sep 2023 16:54:31 +0000 (17:54 +0100)
committerHans Verkuil <hverkuil-cisco@xs4all.nl>
Wed, 27 Sep 2023 07:39:57 +0000 (09:39 +0200)
The driver has an OF match table, still, it uses an ID lookup table for
retrieving match data. Currently, the driver is working on the
assumption that an I2C device registered via OF will always match a
legacy I2C device ID. The correct approach is to have an OF device ID
table using i2c_get_match_data() if the devices are registered via OF/ID.

Unify the OF/ID table by using mt9v032_model_info as match data for both
these tables and replace the ID lookup table for the match data by
i2c_get_match_data() and simplifly probe().

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
drivers/media/i2c/mt9v032.c

index 00e7bc6e3235c669647ea912f076bf1a8f31a19e..0f448aa27e532a7c74138a813d8222fc97609a4f 100644 (file)
@@ -1046,7 +1046,6 @@ done:
 
 static int mt9v032_probe(struct i2c_client *client)
 {
-       const struct i2c_device_id *did = i2c_client_get_device_id(client);
        struct mt9v032_platform_data *pdata = mt9v032_get_pdata(client);
        struct mt9v032 *mt9v032;
        unsigned int i;
@@ -1076,7 +1075,7 @@ static int mt9v032_probe(struct i2c_client *client)
 
        mutex_init(&mt9v032->power_lock);
        mt9v032->pdata = pdata;
-       mt9v032->model = (const void *)did->driver_data;
+       mt9v032->model = i2c_get_match_data(client);
 
        v4l2_ctrl_handler_init(&mt9v032->ctrls, 11 +
                               ARRAY_SIZE(mt9v032_aegc_controls));
@@ -1272,20 +1271,20 @@ static const struct i2c_device_id mt9v032_id[] = {
        { "mt9v032m", (kernel_ulong_t)&mt9v032_models[MT9V032_MODEL_V032_MONO] },
        { "mt9v034", (kernel_ulong_t)&mt9v032_models[MT9V032_MODEL_V034_COLOR] },
        { "mt9v034m", (kernel_ulong_t)&mt9v032_models[MT9V032_MODEL_V034_MONO] },
-       { }
+       { /* Sentinel */ }
 };
 MODULE_DEVICE_TABLE(i2c, mt9v032_id);
 
 #if IS_ENABLED(CONFIG_OF)
 static const struct of_device_id mt9v032_of_match[] = {
-       { .compatible = "aptina,mt9v022" },
-       { .compatible = "aptina,mt9v022m" },
-       { .compatible = "aptina,mt9v024" },
-       { .compatible = "aptina,mt9v024m" },
-       { .compatible = "aptina,mt9v032" },
-       { .compatible = "aptina,mt9v032m" },
-       { .compatible = "aptina,mt9v034" },
-       { .compatible = "aptina,mt9v034m" },
+       { .compatible = "aptina,mt9v022", .data = &mt9v032_models[MT9V032_MODEL_V022_COLOR] },
+       { .compatible = "aptina,mt9v022m", .data = &mt9v032_models[MT9V032_MODEL_V022_MONO] },
+       { .compatible = "aptina,mt9v024", .data = &mt9v032_models[MT9V032_MODEL_V024_COLOR] },
+       { .compatible = "aptina,mt9v024m", .data = &mt9v032_models[MT9V032_MODEL_V024_MONO] },
+       { .compatible = "aptina,mt9v032", .data = &mt9v032_models[MT9V032_MODEL_V032_COLOR] },
+       { .compatible = "aptina,mt9v032m", .data = &mt9v032_models[MT9V032_MODEL_V032_MONO] },
+       { .compatible = "aptina,mt9v034", .data = &mt9v032_models[MT9V032_MODEL_V034_COLOR] },
+       { .compatible = "aptina,mt9v034m", .data = &mt9v032_models[MT9V032_MODEL_V034_MONO] },
        { /* Sentinel */ }
 };
 MODULE_DEVICE_TABLE(of, mt9v032_of_match);