Skip to contentSkip to conversation

hwmon: (dell-smm): make struct dell_smm_data *data __maybe_unused

PATCH In review Jackie Liu 2 participants 2 messages Sep 18, 2021 – Sep 21, 2021

Subsystems (2)
lore
Share & tools
lore

Jackie Liu

author
#0 lore raw

PATCH 1/1 hwmon: (dell-smm): make struct dell_smm_data *data __maybe_unused

From: Jackie Liu <[email protected]>

The compiler warns when the data are actually unused:

drivers/hwmon/dell-smm-hwmon.c: In function ‘i8k_init_procfs’:
drivers/hwmon/dell-smm-hwmon.c:624:24: error: unused variable ‘data’ [-Werror=unused-variable]

    624 |  struct dell_smm_data *data = dev_get_drvdata(dev);
        |                        ^~~~

[Why]
If CONFIG_PROC_FS=n, proc_create_data is NULL, data is unused.

[Fix]
Mark them __maybe_unused to suppress that warning as well.

Fixes ba04d73c26ed ("hwmon: (dell-smm-hwmon) Move variables into a driver private data structure")
Cc Armin Wolf <[email protected]>
---
 drivers/hwmon/dell-smm-hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/dell-smm-hwmon.c +1 -1
index 774c1b0715d9..d73f4a4bd96e 100644
@@ -621,7 +621,7 @@ static void i8k_exit_procfs(void *param)
 
 static void __init i8k_init_procfs(struct device *dev)
 {
-	struct dell_smm_data *data = dev_get_drvdata(dev);
+	struct dell_smm_data __maybe_unused *data = dev_get_drvdata(dev);
 
 	/* Register the proc entry */
 	proc_create_data("i8k", 0, NULL, &i8k_proc_ops, data);
Signature · 1 line
2.25.1
maintainer
#1 lore raw
Quoted 6 lines · On Saturday 18 September 2021 13:13:00 Jackie Liu wrote:

From: Jackie Liu <[email protected]>

The compiler warns when the data are actually unused:

drivers/hwmon/dell-smm-hwmon.c: In function ‘i8k_init_procfs’:
drivers/hwmon/dell-smm-hwmon.c:624:24: error: unused variable ‘data’ [-Werror=unused-variable]

Quoted 8 lines
    624 |  struct dell_smm_data *data = dev_get_drvdata(dev);
        |                        ^~~~

[Why]
If CONFIG_PROC_FS=n, proc_create_data is NULL, data is unused.

[Fix]
Mark them __maybe_unused to suppress that warning as well.

See: https://lore.kernel.org/linux-hwmon/[email protected]/t/#u

Quoted 23 lines
Fixes ba04d73c26ed ("hwmon: (dell-smm-hwmon) Move variables into a driver private data structure")
Cc Armin Wolf <[email protected]>
---
 drivers/hwmon/dell-smm-hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/dell-smm-hwmon.c +1 -1
index 774c1b0715d9..d73f4a4bd96e 100644
@@ -621,7 +621,7 @@ static void i8k_exit_procfs(void *param)
 
 static void __init i8k_init_procfs(struct device *dev)
 {
-	struct dell_smm_data *data = dev_get_drvdata(dev);
+	struct dell_smm_data __maybe_unused *data = dev_get_drvdata(dev);
 
 	/* Register the proc entry */
 	proc_create_data("i8k", 0, NULL, &i8k_proc_ops, data);
Signature · 1 line
2.25.1