Re: drivers/hwmon/tmp513.c:163:10: error: 'const struct regmap_config' has no member named 'reg_bits'

Javier Carrasco
2024-10-01T18:53:12Z

On 01/10/2024 20:19, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: e32cde8d2bd7d251a8f9b434143977ddf13dcec6
> commit: 4bc82dd20be09fa133bf3116be6afc933497f860 hwmon: (tmp513) Constify struct regmap_config
> date: 3 months ago
> config: x86_64-randconfig-r133-20240215 (https://download.01.org/0day-ci/archive/20241002/202410020246.2cTDDx0X-lkp@intel.com/config)
> compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241002/202410020246.2cTDDx0X-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/202410020246.2cTDDx0X-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
> drivers/hwmon/tmp513.c:162:21: error: variable 'tmp51x_regmap_config' has initializer but incomplete type
> 162 | static const struct regmap_config tmp51x_regmap_config = {
> | ^~~~~~~~~~~~~
>>> drivers/hwmon/tmp513.c:163:10: error: 'const struct regmap_config' has no member named 'reg_bits'
> 163 | .reg_bits = 8,
> | ^~~~~~~~
> drivers/hwmon/tmp513.c:163:21: warning: excess elements in struct initializer
> 163 | .reg_bits = 8,
> | ^
> drivers/hwmon/tmp513.c:163:21: note: (near initialization for 'tmp51x_regmap_config')
>>> drivers/hwmon/tmp513.c:164:10: error: 'const struct regmap_config' has no member named 'val_bits'
> 164 | .val_bits = 16,
> | ^~~~~~~~
> drivers/hwmon/tmp513.c:164:21: warning: excess elements in struct initializer
> 164 | .val_bits = 16,
> | ^~
> drivers/hwmon/tmp513.c:164:21: note: (near initialization for 'tmp51x_regmap_config')
>>> drivers/hwmon/tmp513.c:165:10: error: 'const struct regmap_config' has no member named 'max_register'
> 165 | .max_register = TMP51X_MAX_REGISTER_ADDR,
> | ^~~~~~~~~~~~
> drivers/hwmon/tmp513.c:79:41: warning: excess elements in struct initializer
> 79 | #define TMP51X_MAX_REGISTER_ADDR 0xFF
> | ^~~~
> drivers/hwmon/tmp513.c:165:25: note: in expansion of macro 'TMP51X_MAX_REGISTER_ADDR'
> 165 | .max_register = TMP51X_MAX_REGISTER_ADDR,
> | ^~~~~~~~~~~~~~~~~~~~~~~~
> drivers/hwmon/tmp513.c:79:41: note: (near initialization for 'tmp51x_regmap_config')
> 79 | #define TMP51X_MAX_REGISTER_ADDR 0xFF
> | ^~~~
> drivers/hwmon/tmp513.c:165:25: note: in expansion of macro 'TMP51X_MAX_REGISTER_ADDR'
> 165 | .max_register = TMP51X_MAX_REGISTER_ADDR,
> | ^~~~~~~~~~~~~~~~~~~~~~~~
> drivers/hwmon/tmp513.c: In function 'tmp51x_probe':
> drivers/hwmon/tmp513.c:726:24: error: implicit declaration of function 'devm_regmap_init_i2c' [-Werror=implicit-function-declaration]
> 726 | data->regmap = devm_regmap_init_i2c(client, &tmp51x_regmap_config);
> | ^~~~~~~~~~~~~~~~~~~~
> drivers/hwmon/tmp513.c:726:22: warning: assignment to 'struct regmap *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
> 726 | data->regmap = devm_regmap_init_i2c(client, &tmp51x_regmap_config);
> | ^
> drivers/hwmon/tmp513.c: At top level:
> drivers/hwmon/tmp513.c:756:1: warning: data definition has no type or storage class
> 756 | module_i2c_driver(tmp51x_driver);
> | ^~~~~~~~~~~~~~~~~
> drivers/hwmon/tmp513.c:756:1: error: type defaults to 'int' in declaration of 'module_i2c_driver' [-Werror=implicit-int]
> drivers/hwmon/tmp513.c:756:1: warning: parameter names (without types) in function declaration
> drivers/hwmon/tmp513.c:162:35: error: storage size of 'tmp51x_regmap_config' isn't known
> 162 | static const struct regmap_config tmp51x_regmap_config = {
> | ^~~~~~~~~~~~~~~~~~~~
> drivers/hwmon/tmp513.c:747:26: warning: 'tmp51x_driver' defined but not used [-Wunused-variable]
> 747 | static struct i2c_driver tmp51x_driver = {
> | ^~~~~~~~~~~~~
> cc1: some warnings being treated as errors
>
>
> vim +163 drivers/hwmon/tmp513.c
>
> 59dfa75e5d82a1 Eric Tremblay 2019-11-12 161
> 4bc82dd20be09f Javier Carrasco 2024-07-02 162 static const struct regmap_config tmp51x_regmap_config = {
> 59dfa75e5d82a1 Eric Tremblay 2019-11-12 @163 .reg_bits = 8,
> 59dfa75e5d82a1 Eric Tremblay 2019-11-12 @164 .val_bits = 16,
> 59dfa75e5d82a1 Eric Tremblay 2019-11-12 @165 .max_register = TMP51X_MAX_REGISTER_ADDR,
> 59dfa75e5d82a1 Eric Tremblay 2019-11-12 166 };
> 59dfa75e5d82a1 Eric Tremblay 2019-11-12 167
>
> :::::: The code at line 163 was first introduced by commit
> :::::: 59dfa75e5d82a1e1b3d090a1d51fc14f66844576 hwmon: Add driver for Texas Instruments TMP512/513 sensor chips.
>
> :::::: TO: Eric Tremblay <etremblay@distech-controls.com>
> :::::: CC: Guenter Roeck <linux@roeck-us.net>
>

The bug is not in that commit, the Kconfig entry for this driver is
missing a 'select REGMAP_I2C'. I just tested it and then it builds
without any issues.

I can send a patch to fix that, but I would like to know what commit it
really fixes: the one that introduced the driver as it already used
regmap and did not include the required select? Or the one from this
report because it triggered, even though it is not the real source of
the issue?

Thanks and best regards,
Javier Carrasco