public inbox for linux-i2c@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c/busses: fix -Wmissing-variable-declarations
@ 2023-08-08 16:56 Nick Desaulniers
  2023-08-09 19:13 ` Andi Shyti
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Desaulniers @ 2023-08-08 16:56 UTC (permalink / raw)
  To: Jean Delvare, Andi Shyti
  Cc: Nathan Chancellor, Tom Rix, linux-kernel, linux-i2c, llvm,
	kernel test robot, Nick Desaulniers

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>
---
 drivers/i2c/busses/i2c-amd756-s4882.c | 3 +--
 drivers/i2c/busses/i2c-amd756.c       | 1 +
 drivers/i2c/busses/i2c-amd756.h       | 3 +++
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
index 063274388a75..8156cfc43df3 100644
--- a/drivers/i2c/busses/i2c-amd756-s4882.c
+++ b/drivers/i2c/busses/i2c-amd756-s4882.c
@@ -26,8 +26,7 @@
 #include <linux/init.h>
 #include <linux/i2c.h>
 #include <linux/mutex.h>
-
-extern struct i2c_adapter amd756_smbus;
+#include "i2c-amd756.h"
 
 static struct i2c_adapter *s4882_adapter;
 static struct i2c_algorithm *s4882_algo;
diff --git a/drivers/i2c/busses/i2c-amd756.c b/drivers/i2c/busses/i2c-amd756.c
index ef1307a258e9..af77374d2ab3 100644
--- a/drivers/i2c/busses/i2c-amd756.c
+++ b/drivers/i2c/busses/i2c-amd756.c
@@ -31,6 +31,7 @@
 #include <linux/i2c.h>
 #include <linux/acpi.h>
 #include <linux/io.h>
+#include "i2c-amd756.h"
 
 /* AMD756 SMBus address offsets */
 #define SMB_ADDR_OFFSET		0xE0
diff --git a/drivers/i2c/busses/i2c-amd756.h b/drivers/i2c/busses/i2c-amd756.h
new file mode 100644
index 000000000000..88698266d6d8
--- /dev/null
+++ b/drivers/i2c/busses/i2c-amd756.h
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/i2c.h>
+extern struct i2c_adapter amd756_smbus;

---
base-commit: 14f9643dc90adea074a0ffb7a17d337eafc6a5cc
change-id: 20230808-i2c-amd_static-81e5c27a84ce

Best regards,
-- 
Nick Desaulniers <ndesaulniers@google.com>


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

end of thread, other threads:[~2023-08-10 15:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox