diff mbox series

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

Message ID 20210918051300.1171578-1-liu.yun@linux.dev (mailing list archive)
State Rejected
Headers show
Series hwmon: (dell-smm): make struct dell_smm_data *data __maybe_unused | expand

Commit Message

Jackie Liu Sept. 18, 2021, 5:13 a.m. UTC
From: Jackie Liu <liuyun01@kylinos.cn>

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 <W_Armin@gmx.de>
Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
---
 drivers/hwmon/dell-smm-hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Pali Rohár Sept. 21, 2021, 6:54 p.m. UTC | #1
On Saturday 18 September 2021 13:13:00 Jackie Liu wrote:
> From: Jackie Liu <liuyun01@kylinos.cn>
> 
> 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.

See: https://lore.kernel.org/linux-hwmon/20210920121421.93297-1-arnd@kernel.org/t/#u

> Fixes: ba04d73c26ed ("hwmon: (dell-smm-hwmon) Move variables into a driver private data structure")
> Cc: Armin Wolf <W_Armin@gmx.de>
> Signed-off-by: Jackie Liu <liuyun01@kylinos.cn>
> ---
>  drivers/hwmon/dell-smm-hwmon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
> index 774c1b0715d9..d73f4a4bd96e 100644
> --- a/drivers/hwmon/dell-smm-hwmon.c
> +++ b/drivers/hwmon/dell-smm-hwmon.c
> @@ -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);
> -- 
> 2.25.1
>
diff mbox series

Patch

diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index 774c1b0715d9..d73f4a4bd96e 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -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);