linux-hwmon.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] hwmon: dell-smm-hwmon: remove unused variable warning
@ 2021-09-20 12:14 Arnd Bergmann
  2021-09-20 12:31 ` Pali Rohár
  2021-09-20 22:19 ` kernel test robot
  0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2021-09-20 12:14 UTC (permalink / raw)
  To: Pali Rohár, Jean Delvare, Guenter Roeck, Armin Wolf
  Cc: Arnd Bergmann, Carlos Alberto Lopez Perez,
	Sebastian Andrzej Siewior, Sebastian Oechsle, linux-hwmon,
	linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

When procfs is disabled, the code produces a warning
for an unused variable:

drivers/hwmon/dell-smm-hwmon.c: In function 'i8k_init_procfs':
drivers/hwmon/dell-smm-hwmon.c:624:31: error: unused variable 'data' [-Werror=unused-variable]
  624 |         struct dell_smm_data *data = dev_get_drvdata(dev);
      |                               ^~~~

Remove that local variable and just pass dev_get_drvdata(dev)
directly.

Fixes: ba04d73c26ed ("hwmon: (dell-smm-hwmon) Move variables into a driver private data structure")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/hwmon/dell-smm-hwmon.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
index 774c1b0715d9..0a3ce22c78e6 100644
--- a/drivers/hwmon/dell-smm-hwmon.c
+++ b/drivers/hwmon/dell-smm-hwmon.c
@@ -621,10 +621,8 @@ 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);
-
 	/* Register the proc entry */
-	proc_create_data("i8k", 0, NULL, &i8k_proc_ops, data);
+	proc_create_data("i8k", 0, NULL, &i8k_proc_ops, dev_get_drvdata(dev));
 
 	devm_add_action_or_reset(dev, i8k_exit_procfs, NULL);
 }
-- 
2.29.2


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

* Re: [PATCH] hwmon: dell-smm-hwmon: remove unused variable warning
  2021-09-20 12:14 [PATCH] hwmon: dell-smm-hwmon: remove unused variable warning Arnd Bergmann
@ 2021-09-20 12:31 ` Pali Rohár
  2021-09-20 13:14   ` Arnd Bergmann
  2021-09-20 22:19 ` kernel test robot
  1 sibling, 1 reply; 5+ messages in thread
From: Pali Rohár @ 2021-09-20 12:31 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Jean Delvare, Guenter Roeck, Armin Wolf, Arnd Bergmann,
	Carlos Alberto Lopez Perez, Sebastian Andrzej Siewior,
	Sebastian Oechsle, linux-hwmon, linux-kernel

Hello!

On Monday 20 September 2021 14:14:16 Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> When procfs is disabled

... then the i8k_init_procfs function should not be called as the
purpose of I8K code / config option is to export functionality over
procfs. So when procfs is disabled then this i8k is noop.

Patch which do not allow compilation of I8K when procfs is not enabled
is pending here:

https://lore.kernel.org/linux-hwmon/20210910071921.16777-1-rdunlap@infradead.org/

Ideally please test or review it. As you are not the first one who
spotted -Werror problems with i8k and tried to workaround it.

https://lore.kernel.org/linux-hwmon/20210915151759.cxcbzxd74weg4qw6@pali/

For compatibility reasons I still have I8K enabled, so I have not
triggered this issue yet.

Anyway, do you know if somebody on desktop / laptop (which is the only
option where this i8k driver makes sense to be enabled) really using
kernel without procfs? I would like to know if this warning / error is
just artificial configuration generated by test scripts (and cannot be
hit by any user) or if there is a real user who will be affected by this
issue.

> the code produces a warning
> for an unused variable:
> 
> drivers/hwmon/dell-smm-hwmon.c: In function 'i8k_init_procfs':
> drivers/hwmon/dell-smm-hwmon.c:624:31: error: unused variable 'data' [-Werror=unused-variable]
>   624 |         struct dell_smm_data *data = dev_get_drvdata(dev);
>       |                               ^~~~

I'm starting to hate this -Werror decision... but seems that we have to
deal with it and together cleanup code as much as possible.

> Remove that local variable and just pass dev_get_drvdata(dev)
> directly.
> 
> Fixes: ba04d73c26ed ("hwmon: (dell-smm-hwmon) Move variables into a driver private data structure")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/hwmon/dell-smm-hwmon.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/hwmon/dell-smm-hwmon.c b/drivers/hwmon/dell-smm-hwmon.c
> index 774c1b0715d9..0a3ce22c78e6 100644
> --- a/drivers/hwmon/dell-smm-hwmon.c
> +++ b/drivers/hwmon/dell-smm-hwmon.c
> @@ -621,10 +621,8 @@ 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);
> -
>  	/* Register the proc entry */
> -	proc_create_data("i8k", 0, NULL, &i8k_proc_ops, data);
> +	proc_create_data("i8k", 0, NULL, &i8k_proc_ops, dev_get_drvdata(dev));
>  
>  	devm_add_action_or_reset(dev, i8k_exit_procfs, NULL);
>  }
> -- 
> 2.29.2
> 

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

* Re: [PATCH] hwmon: dell-smm-hwmon: remove unused variable warning
  2021-09-20 12:31 ` Pali Rohár
@ 2021-09-20 13:14   ` Arnd Bergmann
  2021-09-20 14:19     ` Guenter Roeck
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2021-09-20 13:14 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Jean Delvare, Guenter Roeck, Armin Wolf, Arnd Bergmann,
	Carlos Alberto Lopez Perez, Sebastian Andrzej Siewior,
	Sebastian Oechsle, linux-hwmon, Linux Kernel Mailing List

On Mon, Sep 20, 2021 at 2:31 PM Pali Rohár <pali@kernel.org> wrote:
> On Monday 20 September 2021 14:14:16 Arnd Bergmann wrote:
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > When procfs is disabled
>
> ... then the i8k_init_procfs function should not be called as the
> purpose of I8K code / config option is to export functionality over
> procfs. So when procfs is disabled then this i8k is noop.
>
> Patch which do not allow compilation of I8K when procfs is not enabled
> is pending here:
>
> https://lore.kernel.org/linux-hwmon/20210910071921.16777-1-rdunlap@infradead.org/
>
> Ideally please test or review it. As you are not the first one who
> spotted -Werror problems with i8k and tried to workaround it.

Ok, I'm now using that version in my randconfig tree, it looks sensible
and it addresses another problem. I'll let you know if something else
comes up with that patch applied, but I'm sure it fixes the issue
I reported. Feel free to add

Reported-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>

to Randy's patch if you like.

> > the code produces a warning
> > for an unused variable:
> >
> > drivers/hwmon/dell-smm-hwmon.c: In function 'i8k_init_procfs':
> > drivers/hwmon/dell-smm-hwmon.c:624:31: error: unused variable 'data' [-Werror=unused-variable]
> >   624 |         struct dell_smm_data *data = dev_get_drvdata(dev);
> >       |                               ^~~~
>
> I'm starting to hate this -Werror decision... but seems that we have to
> deal with it and together cleanup code as much as possible.

Oh, I totally would have sent you my patch without the -Werror change
as well ;-)

       Arnd

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

* Re: [PATCH] hwmon: dell-smm-hwmon: remove unused variable warning
  2021-09-20 13:14   ` Arnd Bergmann
@ 2021-09-20 14:19     ` Guenter Roeck
  0 siblings, 0 replies; 5+ messages in thread
From: Guenter Roeck @ 2021-09-20 14:19 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Pali Rohár, Jean Delvare, Armin Wolf, Arnd Bergmann,
	Carlos Alberto Lopez Perez, Sebastian Andrzej Siewior,
	Sebastian Oechsle, linux-hwmon, Linux Kernel Mailing List

On Mon, Sep 20, 2021 at 03:14:40PM +0200, Arnd Bergmann wrote:
> On Mon, Sep 20, 2021 at 2:31 PM Pali Rohár <pali@kernel.org> wrote:
> > On Monday 20 September 2021 14:14:16 Arnd Bergmann wrote:
> > > From: Arnd Bergmann <arnd@arndb.de>
> > >
> > > When procfs is disabled
> >
> > ... then the i8k_init_procfs function should not be called as the
> > purpose of I8K code / config option is to export functionality over
> > procfs. So when procfs is disabled then this i8k is noop.
> >
> > Patch which do not allow compilation of I8K when procfs is not enabled
> > is pending here:
> >
> > https://lore.kernel.org/linux-hwmon/20210910071921.16777-1-rdunlap@infradead.org/
> >
> > Ideally please test or review it. As you are not the first one who
> > spotted -Werror problems with i8k and tried to workaround it.
> 
> Ok, I'm now using that version in my randconfig tree, it looks sensible
> and it addresses another problem. I'll let you know if something else
> comes up with that patch applied, but I'm sure it fixes the issue
> I reported. Feel free to add
> 
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> 
> to Randy's patch if you like.
> 
You'd have to reply to the patch. This is in x86 world and I can not apply
it, or at least not without Ack from an x86 maintainer. They went ballistic
on me once for doing that, and I won't do it again.

Guenter

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

* Re: [PATCH] hwmon: dell-smm-hwmon: remove unused variable warning
  2021-09-20 12:14 [PATCH] hwmon: dell-smm-hwmon: remove unused variable warning Arnd Bergmann
  2021-09-20 12:31 ` Pali Rohár
@ 2021-09-20 22:19 ` kernel test robot
  1 sibling, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-09-20 22:19 UTC (permalink / raw)
  To: Arnd Bergmann, Pali Rohár, Jean Delvare, Guenter Roeck, Armin Wolf
  Cc: llvm, kbuild-all, Arnd Bergmann, Carlos Alberto Lopez Perez,
	Sebastian Andrzej Siewior, Sebastian Oechsle, linux-hwmon,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2868 bytes --]

Hi Arnd,

I love your patch! Yet something to improve:

[auto build test ERROR on groeck-staging/hwmon-next]
[also build test ERROR on v5.15-rc2 next-20210920]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Arnd-Bergmann/hwmon-dell-smm-hwmon-remove-unused-variable-warning/20210920-201938
base:   https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next
config: x86_64-buildonly-randconfig-r002-20210920 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project c8b3d7d6d6de37af68b2f379d0e37304f78e115f)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/79c5da5ded917bfb113669f400fc547dcbe49b97
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Arnd-Bergmann/hwmon-dell-smm-hwmon-remove-unused-variable-warning/20210920-201938
        git checkout 79c5da5ded917bfb113669f400fc547dcbe49b97
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 ARCH=x86_64 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> drivers/hwmon/dell-smm-hwmon.c:609:30: error: unused variable 'i8k_proc_ops' [-Werror,-Wunused-const-variable]
   static const struct proc_ops i8k_proc_ops = {
                                ^
   1 error generated.


vim +/i8k_proc_ops +609 drivers/hwmon/dell-smm-hwmon.c

^1da177e4c3f4152 drivers/char/i8k.c             Linus Torvalds  2005-04-16  608  
97a32539b9568bb6 drivers/hwmon/dell-smm-hwmon.c Alexey Dobriyan 2020-02-03 @609  static const struct proc_ops i8k_proc_ops = {
97a32539b9568bb6 drivers/hwmon/dell-smm-hwmon.c Alexey Dobriyan 2020-02-03  610  	.proc_open	= i8k_open_fs,
97a32539b9568bb6 drivers/hwmon/dell-smm-hwmon.c Alexey Dobriyan 2020-02-03  611  	.proc_read	= seq_read,
97a32539b9568bb6 drivers/hwmon/dell-smm-hwmon.c Alexey Dobriyan 2020-02-03  612  	.proc_lseek	= seq_lseek,
97a32539b9568bb6 drivers/hwmon/dell-smm-hwmon.c Alexey Dobriyan 2020-02-03  613  	.proc_release	= single_release,
97a32539b9568bb6 drivers/hwmon/dell-smm-hwmon.c Alexey Dobriyan 2020-02-03  614  	.proc_ioctl	= i8k_ioctl,
039ae58503f33491 drivers/hwmon/dell-smm-hwmon.c Pali Rohár      2015-05-14  615  };
039ae58503f33491 drivers/hwmon/dell-smm-hwmon.c Pali Rohár      2015-05-14  616  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33489 bytes --]

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

end of thread, other threads:[~2021-09-22  2:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 12:14 [PATCH] hwmon: dell-smm-hwmon: remove unused variable warning Arnd Bergmann
2021-09-20 12:31 ` Pali Rohár
2021-09-20 13:14   ` Arnd Bergmann
2021-09-20 14:19     ` Guenter Roeck
2021-09-20 22:19 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).