public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <jdelvare@suse.de>
To: Andi Shyti <andi.shyti@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
	Nathan Chancellor <nathan@kernel.org>, Tom Rix <trix@redhat.com>,
	linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org,
	llvm@lists.linux.dev, kernel test robot <lkp@intel.com>
Subject: Re: [PATCH] i2c/busses: fix -Wmissing-variable-declarations
Date: Thu, 10 Aug 2023 17:13:08 +0200	[thread overview]
Message-ID: <20230810171308.5d5c591f@endymion.delvare> (raw)
In-Reply-To: <20230809191310.atpqztlpgdbdvc5m@intel.intel>

Hi Andi, Nick,

On Wed, 09 Aug 2023 21:13:10 +0200, Andi Shyti wrote:
> On Tue, Aug 08, 2023 at 09:56:16AM -0700, Nick Desaulniers wrote:
> > I'm looking to enable -Wmissing-variable-declarations behind W=1. 0day
> > bot spotted the following instance:
> > 
> >   drivers/i2c/busses/i2c-amd756.c:286:20: warning: no previous extern
> >   declaration for non-static variable 'amd756_smbus'
> >   [-Wmissing-variable-declarations]
> >   286 | struct i2c_adapter amd756_smbus = {
> >       |                    ^
> >   drivers/i2c/busses/i2c-amd756.c:286:1: note: declare 'static' if the
> >   variable is not intended to be used outside of this translation unit
> >   286 | struct i2c_adapter amd756_smbus = {
> >       | ^
> > 
> > This symbol is referenced by more than one translation unit, so create
> > then include the correct header for their declarations.
> > 
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes: https://lore.kernel.org/llvm/202308081000.tTL1ElTr-lkp@intel.com/
> > Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>  
> 
> You might want to have a Fixes tag here and
> 
> Cc: Jean Delvare <jdelvare@suse.com>

Fixes tag would cause unnecessary worry, with people backporting the
patch while it doesn't actually fix anything. No need for that.

> 
> [...]
> 
> > --- /dev/null
> > +++ b/drivers/i2c/busses/i2c-amd756.h
> > @@ -0,0 +1,3 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */  
> 
> Please, leave a space here.
> 
> And you might also want to have something like:
> 
> #ifndef __I2C_AMD_756_H__
> #define __I2C_AMD_756_H__
> 
> > +#include <linux/i2c.h>  
> 
> space here.
> 
> > +extern struct i2c_adapter amd756_smbus;  
> 
> #endif /* __I2C_AMD_756_H__ */
> 
> Jean, any opinion on this patch, I don't really know this driver,
> but is there a way to avoid this extern declaration.

Thanks for your review. I would personally not bother with a header
file, this is unnecessary burden. Just add the extern declaration to
i2c-amd756.c as was already done in i2c-amd756-s4882.c. The whole thing
is a horrible hack anyway and there won't be more occurrences of it, so
the more simple it stays, the better.

Some history: I wrote the pseudo-driver i2c-amd756-s4882 when the
i2c-core did not yet support multiplexing. Nowadays, proper support
would be implemented using i2c-mux-* and i2c-amd756-s4882.c would go
away entirely. Actually, I very much doubt any of these 2007 Tyan
server boards is still in activity today, so maybe we should just
delete the driver.

Note that i2c-nforce2.c will need the same fix as struct i2c_adapter
nforce2_smbus is extern as well.

-- 
Jean Delvare
SUSE L3 Support

      reply	other threads:[~2023-08-10 15:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-08 16:56 [PATCH] i2c/busses: fix -Wmissing-variable-declarations Nick Desaulniers
2023-08-09 19:13 ` Andi Shyti
2023-08-10 15:13   ` Jean Delvare [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230810171308.5d5c591f@endymion.delvare \
    --to=jdelvare@suse.de \
    --cc=andi.shyti@kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=trix@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox