[PATCH v1 01/21] hwmon: Fix the type of 'config' in struct hwmon_channel_info to u64

Guenter Roeck linux at roeck-us.net
Tue Jan 21 09:32:23 PST 2025


On 1/21/25 09:05, Russell King (Oracle) wrote:
> On Tue, Jan 21, 2025 at 02:44:59PM +0800, Huisong Li wrote:
>>    */
>>   struct hwmon_channel_info {
>>   	enum hwmon_sensor_types type;
>> -	const u32 *config;
>> +	const u64 *config;
>>   };
>>   
>>   #define HWMON_CHANNEL_INFO(stype, ...)		\
>>   	(&(const struct hwmon_channel_info) {	\
>>   		.type = hwmon_##stype,		\
>> -		.config = (const u32 []) {	\
>> +		.config = (const u64 []) {	\
>>   			__VA_ARGS__, 0		\
>>   		}				\
>>   	})
> 
> I'm sorry, but... no. Just no. Have you tried building with only your
> first patch?
> 
> It will cause the compiler to barf on, e.g. the following:
> 
> static u32 marvell_hwmon_chip_config[] = {
> ...
> 
> static const struct hwmon_channel_info marvell_hwmon_chip = {
>          .type = hwmon_chip,
>          .config = marvell_hwmon_chip_config,
> };
> 
> I suggest that you rearrange your series: first, do the conversions
> to HWMON_CHANNEL_INFO() in the drivers you have.
> 
> At this point, if all the drivers that assign to hw_channel_info.config
> have been converted, this patch 1 is then suitable.
> 
> If there are still drivers that assign a u32 array to
> hw_channel_info.config, then you need to consider how to handle
> that without causing regressions. You can't cast it between a u32
> array and u64 array to silence the warning, because config[1]
> won't point at the next entry.
> 
> I think your only option would be to combine the conversion of struct
> hwmon_channel_info and the other drivers into a single patch. Slightly
> annoying, but without introducing more preprocessor yuckiness, I don't
> see another way.
> 

This is moot because the series does not explain which attributes
would be added ... and it turns out the to-be-added attributes would be
non-standard and thus not be acceptable anyway. On top of that, if the
size of configuration fields ever becomes an issue, I would look for a
much less invasive solution.

The author of this series did not contact me before submitting it,
and I did not have a chance to prevent it from being submitted.
Still, sorry for the noise.

Guenter




More information about the linux-arm-kernel mailing list