public inbox for linux-hwmon@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hwmon: (dell-smm): make struct dell_smm_data *data __maybe_unused
@ 2021-09-18  5:13 Jackie Liu
  2021-09-21 18:54 ` Pali Rohár
  0 siblings, 1 reply; 2+ messages in thread
From: Jackie Liu @ 2021-09-18  5:13 UTC (permalink / raw)
  To: pali, jdelvare, linux; +Cc: linux-hwmon, liu.yun, W_Armin

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(-)

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hwmon: (dell-smm): make struct dell_smm_data *data __maybe_unused
  2021-09-18  5:13 [PATCH] hwmon: (dell-smm): make struct dell_smm_data *data __maybe_unused Jackie Liu
@ 2021-09-21 18:54 ` Pali Rohár
  0 siblings, 0 replies; 2+ messages in thread
From: Pali Rohár @ 2021-09-21 18:54 UTC (permalink / raw)
  To: Jackie Liu; +Cc: jdelvare, linux, linux-hwmon, W_Armin

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
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-21 18:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-18  5:13 [PATCH] hwmon: (dell-smm): make struct dell_smm_data *data __maybe_unused Jackie Liu
2021-09-21 18:54 ` Pali Rohár

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox