[PATCH 1/3] hwmon: (pmbus/mpq7932) Get page count based on chip info

Saravanan Sekar posted 3 patches 2 years, 3 months ago
There is a newer version of this series
[PATCH 1/3] hwmon: (pmbus/mpq7932) Get page count based on chip info
Posted by Saravanan Sekar 2 years, 3 months ago
Get page count using compatible match to support the series of chipsets
which differs in number of regualator/page.

Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
---
 drivers/hwmon/pmbus/mpq7932.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/hwmon/pmbus/mpq7932.c b/drivers/hwmon/pmbus/mpq7932.c
index 865d42edda1a..af3e5e9590c8 100644
--- a/drivers/hwmon/pmbus/mpq7932.c
+++ b/drivers/hwmon/pmbus/mpq7932.c
@@ -105,7 +105,7 @@ static int mpq7932_probe(struct i2c_client *client)
 		return -ENOMEM;
 
 	info = &data->info;
-	info->pages = MPQ7932_NUM_PAGES;
+	info->pages = (int)device_get_match_data(&client->dev);
 	info->format[PSC_VOLTAGE_OUT] = direct;
 	info->m[PSC_VOLTAGE_OUT] = 160;
 	info->b[PSC_VOLTAGE_OUT] = -33;
@@ -115,7 +115,7 @@ static int mpq7932_probe(struct i2c_client *client)
 	}
 
 #if IS_ENABLED(CONFIG_SENSORS_MPQ7932_REGULATOR)
-	info->num_regulators = ARRAY_SIZE(mpq7932_regulators_desc);
+	info->num_regulators = info->pages;
 	info->reg_desc = mpq7932_regulators_desc;
 #endif
 
@@ -129,7 +129,7 @@ static int mpq7932_probe(struct i2c_client *client)
 }
 
 static const struct of_device_id mpq7932_of_match[] = {
-	{ .compatible = "mps,mpq7932"},
+	{ .compatible = "mps,mpq7932", .data = (void *)MPQ7932_NUM_PAGES },
 	{},
 };
 MODULE_DEVICE_TABLE(of, mpq7932_of_match);
-- 
2.34.1
Re: [PATCH 1/3] hwmon: (pmbus/mpq7932) Get page count based on chip info
Posted by kernel test robot 2 years, 3 months ago
Hi Saravanan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on groeck-staging/hwmon-next]
[also build test WARNING on broonie-regulator/for-next linus/master v6.6-rc1 next-20230911]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Saravanan-Sekar/hwmon-pmbus-mpq7932-Get-page-count-based-on-chip-info/20230911-114451
base:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
patch link:    https://lore.kernel.org/r/20230911034150.181880-2-saravanan%40linumiz.com
patch subject: [PATCH 1/3] hwmon: (pmbus/mpq7932) Get page count based on chip info
config: x86_64-randconfig-005-20230911 (https://download.01.org/0day-ci/archive/20230911/202309111406.BSKHGe9U-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230911/202309111406.BSKHGe9U-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/202309111406.BSKHGe9U-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/hwmon/pmbus/mpq7932.c:108:16: warning: cast to smaller integer type 'int' from 'const void *' [-Wvoid-pointer-to-int-cast]
           info->pages = (int)device_get_match_data(&client->dev);
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   1 warning generated.


vim +108 drivers/hwmon/pmbus/mpq7932.c

    95	
    96	static int mpq7932_probe(struct i2c_client *client)
    97	{
    98		struct mpq7932_data *data;
    99		struct pmbus_driver_info *info;
   100		struct device *dev = &client->dev;
   101		int i;
   102	
   103		data = devm_kzalloc(dev, sizeof(struct mpq7932_data), GFP_KERNEL);
   104		if (!data)
   105			return -ENOMEM;
   106	
   107		info = &data->info;
 > 108		info->pages = (int)device_get_match_data(&client->dev);
   109		info->format[PSC_VOLTAGE_OUT] = direct;
   110		info->m[PSC_VOLTAGE_OUT] = 160;
   111		info->b[PSC_VOLTAGE_OUT] = -33;
   112		for (i = 0; i < info->pages; i++) {
   113			info->func[i] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
   114					| PMBUS_HAVE_STATUS_TEMP;
   115		}
   116	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH 1/3] hwmon: (pmbus/mpq7932) Get page count based on chip info
Posted by kernel test robot 2 years, 3 months ago
Hi Saravanan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on groeck-staging/hwmon-next]
[also build test WARNING on broonie-regulator/for-next linus/master v6.6-rc1 next-20230911]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Saravanan-Sekar/hwmon-pmbus-mpq7932-Get-page-count-based-on-chip-info/20230911-114451
base:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
patch link:    https://lore.kernel.org/r/20230911034150.181880-2-saravanan%40linumiz.com
patch subject: [PATCH 1/3] hwmon: (pmbus/mpq7932) Get page count based on chip info
config: alpha-allyesconfig (https://download.01.org/0day-ci/archive/20230911/202309111345.BXkwu3pD-lkp@intel.com/config)
compiler: alpha-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230911/202309111345.BXkwu3pD-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/202309111345.BXkwu3pD-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/hwmon/pmbus/mpq7932.c: In function 'mpq7932_probe':
>> drivers/hwmon/pmbus/mpq7932.c:108:23: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
     108 |         info->pages = (int)device_get_match_data(&client->dev);
         |                       ^


vim +108 drivers/hwmon/pmbus/mpq7932.c

    95	
    96	static int mpq7932_probe(struct i2c_client *client)
    97	{
    98		struct mpq7932_data *data;
    99		struct pmbus_driver_info *info;
   100		struct device *dev = &client->dev;
   101		int i;
   102	
   103		data = devm_kzalloc(dev, sizeof(struct mpq7932_data), GFP_KERNEL);
   104		if (!data)
   105			return -ENOMEM;
   106	
   107		info = &data->info;
 > 108		info->pages = (int)device_get_match_data(&client->dev);
   109		info->format[PSC_VOLTAGE_OUT] = direct;
   110		info->m[PSC_VOLTAGE_OUT] = 160;
   111		info->b[PSC_VOLTAGE_OUT] = -33;
   112		for (i = 0; i < info->pages; i++) {
   113			info->func[i] = PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT
   114					| PMBUS_HAVE_STATUS_TEMP;
   115		}
   116	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH 1/3] hwmon: (pmbus/mpq7932) Get page count based on chip info
Posted by Guenter Roeck 2 years, 3 months ago
On 9/10/23 20:41, Saravanan Sekar wrote:
> Get page count using compatible match to support the series of chipsets
> which differs in number of regualator/page.
> 
> Signed-off-by: Saravanan Sekar <saravanan@linumiz.com>
> ---
>   drivers/hwmon/pmbus/mpq7932.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/pmbus/mpq7932.c b/drivers/hwmon/pmbus/mpq7932.c
> index 865d42edda1a..af3e5e9590c8 100644
> --- a/drivers/hwmon/pmbus/mpq7932.c
> +++ b/drivers/hwmon/pmbus/mpq7932.c
> @@ -105,7 +105,7 @@ static int mpq7932_probe(struct i2c_client *client)
>   		return -ENOMEM;
>   
>   	info = &data->info;
> -	info->pages = MPQ7932_NUM_PAGES;
> +	info->pages = (int)device_get_match_data(&client->dev);

I kind of doubt that this works without generating a compiler warning.

Also, does this work with CONFIG_OF=n ?

Guenter

>   	info->format[PSC_VOLTAGE_OUT] = direct;
>   	info->m[PSC_VOLTAGE_OUT] = 160;
>   	info->b[PSC_VOLTAGE_OUT] = -33;
> @@ -115,7 +115,7 @@ static int mpq7932_probe(struct i2c_client *client)
>   	}
>   
>   #if IS_ENABLED(CONFIG_SENSORS_MPQ7932_REGULATOR)
> -	info->num_regulators = ARRAY_SIZE(mpq7932_regulators_desc);
> +	info->num_regulators = info->pages;
>   	info->reg_desc = mpq7932_regulators_desc;
>   #endif
>   
> @@ -129,7 +129,7 @@ static int mpq7932_probe(struct i2c_client *client)
>   }
>   
>   static const struct of_device_id mpq7932_of_match[] = {
> -	{ .compatible = "mps,mpq7932"},
> +	{ .compatible = "mps,mpq7932", .data = (void *)MPQ7932_NUM_PAGES },
>   	{},
>   };
>   MODULE_DEVICE_TABLE(of, mpq7932_of_match);