Hi Biju On Sun, Sep 10, 2023 at 05:54:31PM +0100, Biju Das wrote: > 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 s/Unify/Align ? As the tables are still separate.. > 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@xxxxxxxxxxxxxx> Reviewed-by: Jacopo Mondi <jacopo.mondi+renesas@xxxxxxxxxxxxxxxx> Thanks j > --- > drivers/media/i2c/mt9v032.c | 21 ++++++++++----------- > 1 file changed, 10 insertions(+), 11 deletions(-) > > diff --git a/drivers/media/i2c/mt9v032.c b/drivers/media/i2c/mt9v032.c > index 00e7bc6e3235..0f448aa27e53 100644 > --- a/drivers/media/i2c/mt9v032.c > +++ b/drivers/media/i2c/mt9v032.c > @@ -1046,7 +1046,6 @@ mt9v032_get_pdata(struct i2c_client *client) > > 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); > -- > 2.25.1 >