[PATCH v2 5/6] platform-x86: lenovo-wmi-other: Consolidate name into single const

Derek J. Clark posted 6 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH v2 5/6] platform-x86: lenovo-wmi-other: Consolidate name into single const
Posted by Derek J. Clark 1 month, 2 weeks ago
In the next patch a power supply extension is added which requires
a name attribute. Instead of creating a third const macro with the
same information, replace LWMI_OM_FW_ATTR_BASE_PATH and
LWMI_OM_HWMON_NAME with LWMI_OM_NAME and use that everywhere.

Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
---
 drivers/platform/x86/lenovo/wmi-other.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/x86/lenovo/wmi-other.c
index 876834af838e0..8e52f692f8605 100644
--- a/drivers/platform/x86/lenovo/wmi-other.c
+++ b/drivers/platform/x86/lenovo/wmi-other.c
@@ -92,14 +92,13 @@ enum lwmi_feature_id_gpu {
 #define LWMI_FAN_NR 4
 #define LWMI_FAN_ID(x) ((x) + LWMI_FAN_ID_BASE)
 
+#define LWMI_FAN_DIV 100
+
 #define LWMI_ATTR_ID_FAN_RPM(x)                                   \
 	LWMI_ATTR_ID(LWMI_DEVICE_ID_FAN, LWMI_FEATURE_ID_FAN_RPM, \
 		     LWMI_GZ_THERMAL_MODE_NONE, LWMI_FAN_ID(x))
 
-#define LWMI_FAN_DIV 100
-
-#define LWMI_OM_FW_ATTR_BASE_PATH "lenovo-wmi-other"
-#define LWMI_OM_HWMON_NAME "lenovo_wmi_other"
+#define LWMI_OM_NAME "lenovo-wmi-other"
 
 static BLOCKING_NOTIFIER_HEAD(om_chain_head);
 static DEFINE_IDA(lwmi_om_ida);
@@ -454,7 +453,7 @@ static void lwmi_om_hwmon_add(struct lwmi_om_priv *priv)
 	}
 
 	priv->hwmon_dev = hwmon_device_register_with_info(&priv->wdev->dev,
-							  LWMI_OM_HWMON_NAME, priv,
+							  LWMI_OM_NAME, priv,
 							  &lwmi_om_hwmon_chip_info,
 							  NULL);
 	if (IS_ERR(priv->hwmon_dev)) {
@@ -1253,8 +1252,7 @@ static int lwmi_om_fw_attr_add(struct lwmi_om_priv *priv)
 
 	priv->fw_attr_dev = device_create(&firmware_attributes_class, NULL,
 					  MKDEV(0, 0), NULL, "%s-%u",
-					  LWMI_OM_FW_ATTR_BASE_PATH,
-					  priv->ida_id);
+					  LWMI_OM_NAME, priv->ida_id);
 	if (IS_ERR(priv->fw_attr_dev)) {
 		err = PTR_ERR(priv->fw_attr_dev);
 		goto err_free_ida;
-- 
2.52.0
Re: [PATCH v2 5/6] platform-x86: lenovo-wmi-other: Consolidate name into single const
Posted by Kurt Borja 1 month, 2 weeks ago
On Sun Feb 15, 2026 at 1:12 AM -05, Derek J. Clark wrote:
> In the next patch a power supply extension is added which requires
> a name attribute. Instead of creating a third const macro with the
> same information, replace LWMI_OM_FW_ATTR_BASE_PATH and
> LWMI_OM_HWMON_NAME with LWMI_OM_NAME and use that everywhere.
>
> Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
> ---
>  drivers/platform/x86/lenovo/wmi-other.c | 12 +++++-------
>  1 file changed, 5 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/x86/lenovo/wmi-other.c
> index 876834af838e0..8e52f692f8605 100644
> --- a/drivers/platform/x86/lenovo/wmi-other.c
> +++ b/drivers/platform/x86/lenovo/wmi-other.c
> @@ -92,14 +92,13 @@ enum lwmi_feature_id_gpu {
>  #define LWMI_FAN_NR 4
>  #define LWMI_FAN_ID(x) ((x) + LWMI_FAN_ID_BASE)
>  
> +#define LWMI_FAN_DIV 100
> +
>  #define LWMI_ATTR_ID_FAN_RPM(x)                                   \
>  	LWMI_ATTR_ID(LWMI_DEVICE_ID_FAN, LWMI_FEATURE_ID_FAN_RPM, \
>  		     LWMI_GZ_THERMAL_MODE_NONE, LWMI_FAN_ID(x))
>  
> -#define LWMI_FAN_DIV 100
> -
> -#define LWMI_OM_FW_ATTR_BASE_PATH "lenovo-wmi-other"
> -#define LWMI_OM_HWMON_NAME "lenovo_wmi_other"
> +#define LWMI_OM_NAME "lenovo-wmi-other"

Hi Derek,

This name doesn't work for HWMON because the core forbids dashes '-'
(see [1]).

>  
>  static BLOCKING_NOTIFIER_HEAD(om_chain_head);
>  static DEFINE_IDA(lwmi_om_ida);
> @@ -454,7 +453,7 @@ static void lwmi_om_hwmon_add(struct lwmi_om_priv *priv)
>  	}
>  
>  	priv->hwmon_dev = hwmon_device_register_with_info(&priv->wdev->dev,
> -							  LWMI_OM_HWMON_NAME, priv,
> +							  LWMI_OM_NAME, priv,
>  							  &lwmi_om_hwmon_chip_info,
>  							  NULL);
>  	if (IS_ERR(priv->hwmon_dev)) {
> @@ -1253,8 +1252,7 @@ static int lwmi_om_fw_attr_add(struct lwmi_om_priv *priv)
>  
>  	priv->fw_attr_dev = device_create(&firmware_attributes_class, NULL,
>  					  MKDEV(0, 0), NULL, "%s-%u",
> -					  LWMI_OM_FW_ATTR_BASE_PATH,
> -					  priv->ida_id);
> +					  LWMI_OM_NAME, priv->ida_id);
>  	if (IS_ERR(priv->fw_attr_dev)) {
>  		err = PTR_ERR(priv->fw_attr_dev);
>  		goto err_free_ida;

[1] https://elixir.bootlin.com/linux/v6.19-rc5/source/drivers/hwmon/hwmon.c#L910

-- 
Thanks,
 ~ Kurt
Re: [PATCH v2 5/6] platform-x86: lenovo-wmi-other: Consolidate name into single const
Posted by Derek J. Clark 1 month, 2 weeks ago
On February 14, 2026 10:56:24 PM PST, Kurt Borja <kuurtb@gmail.com> wrote:
>On Sun Feb 15, 2026 at 1:12 AM -05, Derek J. Clark wrote:
>> In the next patch a power supply extension is added which requires
>> a name attribute. Instead of creating a third const macro with the
>> same information, replace LWMI_OM_FW_ATTR_BASE_PATH and
>> LWMI_OM_HWMON_NAME with LWMI_OM_NAME and use that everywhere.
>>
>> Signed-off-by: Derek J. Clark <derekjohn.clark@gmail.com>
>> ---
>>  drivers/platform/x86/lenovo/wmi-other.c | 12 +++++-------
>>  1 file changed, 5 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/platform/x86/lenovo/wmi-other.c b/drivers/platform/x86/lenovo/wmi-other.c
>> index 876834af838e0..8e52f692f8605 100644
>> --- a/drivers/platform/x86/lenovo/wmi-other.c
>> +++ b/drivers/platform/x86/lenovo/wmi-other.c
>> @@ -92,14 +92,13 @@ enum lwmi_feature_id_gpu {
>>  #define LWMI_FAN_NR 4
>>  #define LWMI_FAN_ID(x) ((x) + LWMI_FAN_ID_BASE)
>>  
>> +#define LWMI_FAN_DIV 100
>> +
>>  #define LWMI_ATTR_ID_FAN_RPM(x)                                   \
>>  	LWMI_ATTR_ID(LWMI_DEVICE_ID_FAN, LWMI_FEATURE_ID_FAN_RPM, \
>>  		     LWMI_GZ_THERMAL_MODE_NONE, LWMI_FAN_ID(x))
>>  
>> -#define LWMI_FAN_DIV 100
>> -
>> -#define LWMI_OM_FW_ATTR_BASE_PATH "lenovo-wmi-other"
>> -#define LWMI_OM_HWMON_NAME "lenovo_wmi_other"
>> +#define LWMI_OM_NAME "lenovo-wmi-other"
>
>Hi Derek,
>
>This name doesn't work for HWMON because the core forbids dashes '-'
>(see [1]).
>

Ah, well shoot. I'll restore that in v3. Attention to detail...

Thanks,
Derek

>>  
>>  static BLOCKING_NOTIFIER_HEAD(om_chain_head);
>>  static DEFINE_IDA(lwmi_om_ida);
>> @@ -454,7 +453,7 @@ static void lwmi_om_hwmon_add(struct lwmi_om_priv *priv)
>>  	}
>>  
>>  	priv->hwmon_dev = hwmon_device_register_with_info(&priv->wdev->dev,
>> -							  LWMI_OM_HWMON_NAME, priv,
>> +							  LWMI_OM_NAME, priv,
>>  							  &lwmi_om_hwmon_chip_info,
>>  							  NULL);
>>  	if (IS_ERR(priv->hwmon_dev)) {
>> @@ -1253,8 +1252,7 @@ static int lwmi_om_fw_attr_add(struct lwmi_om_priv *priv)
>>  
>>  	priv->fw_attr_dev = device_create(&firmware_attributes_class, NULL,
>>  					  MKDEV(0, 0), NULL, "%s-%u",
>> -					  LWMI_OM_FW_ATTR_BASE_PATH,
>> -					  priv->ida_id);
>> +					  LWMI_OM_NAME, priv->ida_id);
>>  	if (IS_ERR(priv->fw_attr_dev)) {
>>  		err = PTR_ERR(priv->fw_attr_dev);
>>  		goto err_free_ida;
>
>[1] https://elixir.bootlin.com/linux/v6.19-rc5/source/drivers/hwmon/hwmon.c#L910
>