[PATCH 3/7] media: i2c: dw9719: Add driver_data matching

André Apitzsch via B4 Relay posted 7 patches 1 month, 2 weeks ago
[PATCH 3/7] media: i2c: dw9719: Add driver_data matching
Posted by André Apitzsch via B4 Relay 1 month, 2 weeks ago
From: Val Packett <val@packett.cool>

In preparation for adding models with different register sets, start
assigning the model based on the i2c match data.

Signed-off-by: Val Packett <val@packett.cool>
Signed-off-by: André Apitzsch <git@apitzsch.eu>
---
 drivers/media/i2c/dw9719.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/media/i2c/dw9719.c b/drivers/media/i2c/dw9719.c
index 5ed0042fce18acd9e6ce9f6cf6c6982e36fed275..7ce66eaede5a2a1ba9c4c30c0efc5fafcca339a0 100644
--- a/drivers/media/i2c/dw9719.c
+++ b/drivers/media/i2c/dw9719.c
@@ -282,6 +282,8 @@ static int dw9719_probe(struct i2c_client *client)
 	if (!dw9719)
 		return -ENOMEM;
 
+	dw9719->model = (enum dw9719_model)i2c_get_match_data(client);
+
 	dw9719->regmap = devm_cci_regmap_init_i2c(client, 8);
 	if (IS_ERR(dw9719->regmap))
 		return PTR_ERR(dw9719->regmap);
@@ -361,8 +363,8 @@ static void dw9719_remove(struct i2c_client *client)
 }
 
 static const struct i2c_device_id dw9719_id_table[] = {
-	{ "dw9719" },
-	{ "dw9761" },
+	{ "dw9719", .driver_data = DW9719 },
+	{ "dw9761", .driver_data = DW9761 },
 	{ }
 };
 MODULE_DEVICE_TABLE(i2c, dw9719_id_table);

-- 
2.50.1


Re: [PATCH 3/7] media: i2c: dw9719: Add driver_data matching
Posted by Sakari Ailus 1 month, 2 weeks ago
Hi André, Val,

On Sun, Aug 17, 2025 at 07:09:22PM +0200, André Apitzsch via B4 Relay wrote:
> From: Val Packett <val@packett.cool>
> 
> In preparation for adding models with different register sets, start
> assigning the model based on the i2c match data.
> 
> Signed-off-by: Val Packett <val@packett.cool>
> Signed-off-by: André Apitzsch <git@apitzsch.eu>
> ---
>  drivers/media/i2c/dw9719.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/media/i2c/dw9719.c b/drivers/media/i2c/dw9719.c
> index 5ed0042fce18acd9e6ce9f6cf6c6982e36fed275..7ce66eaede5a2a1ba9c4c30c0efc5fafcca339a0 100644
> --- a/drivers/media/i2c/dw9719.c
> +++ b/drivers/media/i2c/dw9719.c
> @@ -282,6 +282,8 @@ static int dw9719_probe(struct i2c_client *client)
>  	if (!dw9719)
>  		return -ENOMEM;
>  
> +	dw9719->model = (enum dw9719_model)i2c_get_match_data(client);
> +
>  	dw9719->regmap = devm_cci_regmap_init_i2c(client, 8);
>  	if (IS_ERR(dw9719->regmap))
>  		return PTR_ERR(dw9719->regmap);
> @@ -361,8 +363,8 @@ static void dw9719_remove(struct i2c_client *client)
>  }
>  
>  static const struct i2c_device_id dw9719_id_table[] = {
> -	{ "dw9719" },
> -	{ "dw9761" },
> +	{ "dw9719", .driver_data = DW9719 },
> +	{ "dw9761", .driver_data = DW9761 },

Does something still depend on the I²C device ID table? Couldn't we just
remove it?

>  	{ }
>  };
>  MODULE_DEVICE_TABLE(i2c, dw9719_id_table);
> 

-- 
Kind regards,

Sakari Ailus
Re: [PATCH 3/7] media: i2c: dw9719: Add driver_data matching
Posted by kernel test robot 1 month, 2 weeks ago
Hi André,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 1357b2649c026b51353c84ddd32bc963e8999603]

url:    https://github.com/intel-lab-lkp/linux/commits/Andr-Apitzsch-via-B4-Relay/dt-bindings-media-i2c-Add-DW9718S-DW9719-and-DW9761-VCM/20250818-011316
base:   1357b2649c026b51353c84ddd32bc963e8999603
patch link:    https://lore.kernel.org/r/20250817-dw9719-v1-3-426f46c69a5a%40apitzsch.eu
patch subject: [PATCH 3/7] media: i2c: dw9719: Add driver_data matching
config: riscv-randconfig-002-20250818 (https://download.01.org/0day-ci/archive/20250818/202508180429.GKdrjNK9-lkp@intel.com/config)
compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 93d24b6b7b148c47a2fa228a4ef31524fa1d9f3f)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250818/202508180429.GKdrjNK9-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202508180429.GKdrjNK9-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/media/i2c/dw9719.c:285:18: warning: cast to smaller integer type 'enum dw9719_model' from 'const void *' [-Wvoid-pointer-to-enum-cast]
     285 |         dw9719->model = (enum dw9719_model)i2c_get_match_data(client);
         |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1 warning generated.


vim +285 drivers/media/i2c/dw9719.c

   275	
   276	static int dw9719_probe(struct i2c_client *client)
   277	{
   278		struct dw9719_device *dw9719;
   279		int ret;
   280	
   281		dw9719 = devm_kzalloc(&client->dev, sizeof(*dw9719), GFP_KERNEL);
   282		if (!dw9719)
   283			return -ENOMEM;
   284	
 > 285		dw9719->model = (enum dw9719_model)i2c_get_match_data(client);
   286	
   287		dw9719->regmap = devm_cci_regmap_init_i2c(client, 8);
   288		if (IS_ERR(dw9719->regmap))
   289			return PTR_ERR(dw9719->regmap);
   290	
   291		dw9719->dev = &client->dev;
   292	
   293		dw9719->regulator = devm_regulator_get(&client->dev, "vdd");
   294		if (IS_ERR(dw9719->regulator))
   295			return dev_err_probe(&client->dev, PTR_ERR(dw9719->regulator),
   296					     "getting regulator\n");
   297	
   298		v4l2_i2c_subdev_init(&dw9719->sd, client, &dw9719_ops);
   299		dw9719->sd.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE;
   300		dw9719->sd.internal_ops = &dw9719_internal_ops;
   301	
   302		ret = dw9719_init_controls(dw9719);
   303		if (ret)
   304			return ret;
   305	
   306		ret = media_entity_pads_init(&dw9719->sd.entity, 0, NULL);
   307		if (ret < 0)
   308			goto err_free_ctrl_handler;
   309	
   310		dw9719->sd.entity.function = MEDIA_ENT_F_LENS;
   311	
   312		/*
   313		 * We need the driver to work in the event that pm runtime is disable in
   314		 * the kernel, so power up and verify the chip now. In the event that
   315		 * runtime pm is disabled this will leave the chip on, so that the lens
   316		 * will work.
   317		 */
   318	
   319		ret = dw9719_power_up(dw9719, true);
   320		if (ret)
   321			goto err_cleanup_media;
   322	
   323		pm_runtime_set_active(&client->dev);
   324		pm_runtime_get_noresume(&client->dev);
   325		pm_runtime_enable(&client->dev);
   326	
   327		ret = v4l2_async_register_subdev(&dw9719->sd);
   328		if (ret < 0)
   329			goto err_pm_runtime;
   330	
   331		pm_runtime_set_autosuspend_delay(&client->dev, 1000);
   332		pm_runtime_use_autosuspend(&client->dev);
   333		pm_runtime_put_autosuspend(&client->dev);
   334	
   335		return ret;
   336	
   337	err_pm_runtime:
   338		pm_runtime_disable(&client->dev);
   339		pm_runtime_put_noidle(&client->dev);
   340		dw9719_power_down(dw9719);
   341	err_cleanup_media:
   342		media_entity_cleanup(&dw9719->sd.entity);
   343	err_free_ctrl_handler:
   344		v4l2_ctrl_handler_free(&dw9719->ctrls.handler);
   345	
   346		return ret;
   347	}
   348	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki