staging: emxx_udc: Fix incorrectly defined global
PATCH 1/1 staging: emxx_udc: Fix incorrectly defined global
The global gpio_desc pointer and int were defined in the header, instead put the definitions in the translation unit and add an extern declaration for consumers of the header (currently only one, which is perhaps why the linker didn't complain about symbol collisions).
This fixes sparse related warnings for this driver:drivers/staging/emxx_udc/emxx_udc.c: note: in included file:drivers/staging/emxx_udc/emxx_udc.h:23:18: warning: symbol 'vbus_gpio' was not declared. Should it be static? drivers/staging/emxx_udc/emxx_udc.h:24:5: warning: symbol 'vbus_irq' was not declared. Should it be static?
--- drivers/staging/emxx_udc/emxx_udc.c | 3 +++ drivers/staging/emxx_udc/emxx_udc.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/staging/emxx_udc/emxx_udc.c +3 -0
@@ -34,6 +34,9 @@#define DRIVER_DESC "EMXX UDC driver"#define DMA_ADDR_INVALID (~(dma_addr_t)0) +struct gpio_desc *vbus_gpio; +int vbus_irq; +static const char driver_name[] ="emxx_udc" ;static const char driver_desc[] =DRIVER_DESC ;
drivers/staging/emxx_udc/emxx_udc.h +2 -2
@@ -20,8 +20,8 @@/* below hacked up for staging integration */ #define GPIO_VBUS 0/* GPIO_P153 on KZM9D */ #define INT_VBUS 0/* IRQ for GPIO_P153 */ -struct gpio_desc *vbus_gpio; -int vbus_irq; +extern struct gpio_desc *vbus_gpio; +extern int vbus_irq;/*------------ Board dependence(Wait) */
Signature · 1 line
2.29.2
Hi Kumar,
Quoted 6 lines · On Sun, 7 Feb 2021 05:30:31 +0530 Kumar Kartikeya Dwivedi <[email protected]>…
The global
gpio_descpointer and int were defined in the header, instead put the definitions in the translation unit and add an extern declaration for consumers of the header (currently only one, which is perhaps why the linker didn't complain about symbol collisions).
Quoted 6 lines
This fixes sparse related warnings for this driver:
drivers/staging/emxx_udc/emxx_udc.c: note: in included file:drivers/staging/emxx_udc/emxx_udc.h:23:18: warning: symbol 'vbus_gpio' was not declared. Should it be static?drivers/staging/emxx_udc/emxx_udc.h:24:5: warning: symbol 'vbus_irq' was not declared. Should it be static?Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>
Given that drivers/staging/emxx_udc/emxx_udc.h is only included by drivers/staging/emxx_udc/emxx_udc.c, shouldn't these variables just be declared static in emxx_udc.c and removed from emxx_udc.h?
Quoted 37 lines
--- drivers/staging/emxx_udc/emxx_udc.c | 3 +++ drivers/staging/emxx_udc/emxx_udc.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)drivers/staging/emxx_udc/emxx_udc.c +3
-0@@ -34,6 +34,9 @@#define DRIVER_DESC "EMXX UDC driver"#define DMA_ADDR_INVALID (~(dma_addr_t)0) +struct gpio_desc *vbus_gpio; +int vbus_irq; +static const char driver_name[] ="emxx_udc" ;static const char driver_desc[] =DRIVER_DESC ;drivers/staging/emxx_udc/emxx_udc.h +2
-2@@ -20,8 +20,8 @@/* below hacked up for staging integration */ #define GPIO_VBUS 0/* GPIO_P153 on KZM9D */ #define INT_VBUS 0/* IRQ for GPIO_P153 */ -struct gpio_desc *vbus_gpio; -int vbus_irq; +extern struct gpio_desc *vbus_gpio; +extern int vbus_irq;/*------------ Board dependence(Wait) */ Signature · 1 line
2.29.2
Signature · 2 lines
Cheers, Stephen Rothwell
Quoted 5 lines · Stephen Rothwell
Given that
drivers/staging/emxx_udc/emxx_udc.his only included bydrivers/staging/emxx_udc/emxx_udc.c, shouldn't these variables just be declared static inemxx_udc.cand removed fromemxx_udc.h?
Either would be correct. I went this way because it was originally trying to (incorrectly) define a global variable instead. I guess they can be static now and when more users are added, the linkage can be adjusted as needed.
Here's another version of the patch:
--
From 5835ad916ceeba620c85bc32f52ecd69f21f8dab Mon Sep 17 00:00:00 2001
From: Kumar Kartikeya Dwivedi <[email protected]>
Date: Sun, 7 Feb 2021 12:53:39 +0530
Subject: [PATCH] staging: emxx_udc: Make incorrectly defined global static
The global gpio_desc pointer and int vbus_irq were defined in the header, instead put the definitions in the translation unit and make them static as there's only a single consumer in emxx_udc.c.
This fixes the following sparse warnings for this driver:drivers/staging/emxx_udc/emxx_udc.c: note: in included file:drivers/staging/emxx_udc/emxx_udc.h:23:18: warning: symbol 'vbus_gpio' was not declared. Should it be static? drivers/staging/emxx_udc/emxx_udc.h:24:5: warning: symbol 'vbus_irq' was not declared. Should it be static?
--- drivers/staging/emxx_udc/emxx_udc.c | 3 +++ drivers/staging/emxx_udc/emxx_udc.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/staging/emxx_udc/emxx_udc.c +3 -0
@@ -34,6 +34,9 @@#define DRIVER_DESC "EMXX UDC driver"#define DMA_ADDR_INVALID (~(dma_addr_t)0) +static struct gpio_desc *vbus_gpio; +static int vbus_irq; +static const char driver_name[] ="emxx_udc" ;static const char driver_desc[] =DRIVER_DESC ;
drivers/staging/emxx_udc/emxx_udc.h +0 -2
@@ -20,8 +20,6 @@/* below hacked up for staging integration */ #define GPIO_VBUS 0/* GPIO_P153 on KZM9D */ #define INT_VBUS 0/* IRQ for GPIO_P153 */ -struct gpio_desc *vbus_gpio; -int vbus_irq;/*------------ Board dependence(Wait) */
Signature · 4 lines
2.29.2 -- Kartikeya
Greg KH
maintainerQuoted 7 lines · Kumar Kartikeya Dwivedi
Quoted 5 lines · Stephen Rothwell
Given that
drivers/staging/emxx_udc/emxx_udc.his only included bydrivers/staging/emxx_udc/emxx_udc.c, shouldn't these variables just be declared static inemxx_udc.cand removed fromemxx_udc.h?
Quoted 5 lines
Either would be correct. I went this way because it was originally trying to (incorrectly) define a global variable instead. I guess they can be static now and when more users are added, the linkage can be adjusted as needed.
Here's another version of the patch:
<snip>
Please resend in the proper format that a second version of a patch should be in (the documentation describes how to do this.)
thanks,
greg k-h
PATCH v2 1/1 staging: emxx_udc: Make incorrectly defined global static
The global gpio_desc pointer and int vbus_irq were defined in the header, instead put the definitions in the translation unit and make them static as there's only a single consumer, and these symbols shouldn't pollute the global namespace.
This fixes the following sparse warnings for this driver:drivers/staging/emxx_udc/emxx_udc.c: note: in included file:drivers/staging/emxx_udc/emxx_udc.h:23:18: warning: symbol 'vbus_gpio' was not declared. Should it be static? drivers/staging/emxx_udc/emxx_udc.h:24:5:
warning: symbol 'vbus_irq' was not declared. Should it be static?
--- drivers/staging/emxx_udc/emxx_udc.c | 3 +++ drivers/staging/emxx_udc/emxx_udc.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/staging/emxx_udc/emxx_udc.c +3 -0
@@ -34,6 +34,9 @@#define DRIVER_DESC "EMXX UDC driver"#define DMA_ADDR_INVALID (~(dma_addr_t)0) +static struct gpio_desc *vbus_gpio; +static int vbus_irq; +static const char driver_name[] ="emxx_udc" ;static const char driver_desc[] =DRIVER_DESC ;
drivers/staging/emxx_udc/emxx_udc.h +0 -2
@@ -20,8 +20,6 @@/* below hacked up for staging integration */ #define GPIO_VBUS 0/* GPIO_P153 on KZM9D */ #define INT_VBUS 0/* IRQ for GPIO_P153 */ -struct gpio_desc *vbus_gpio; -int vbus_irq;/*------------ Board dependence(Wait) */
Signature · 1 line
2.29.2
Greg KH
maintainerRe: [PATCH v2] staging: emxx_udc: Make incorrectly defined global static
Quoted 11 lines · Kumar Kartikeya Dwivedi
The global
gpio_descpointer and intvbus_irqwere defined in the header, instead put the definitions in the translation unit and make them static as there's only a single consumer, and these symbols shouldn't pollute the global namespace.This fixes the following sparse warnings for this driver:
drivers/staging/emxx_udc/emxx_udc.c: note: in included file:drivers/staging/emxx_udc/emxx_udc.h:23:18: warning: symbol 'vbus_gpio' was not declared. Should it be static?drivers/staging/emxx_udc/emxx_udc.h:24:5:
warning: symbol 'vbus_irq' was not declared. Should it be static?
Quoted 5 lines
Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>--- drivers/staging/emxx_udc/emxx_udc.c | 3 +++ drivers/staging/emxx_udc/emxx_udc.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-)
Hi,
This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.
You are receiving this message because of the following common error(s) as indicated below:
- This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/SubmittingPatches for what needs to be done here to properly describe this.
If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.
thanks,
greg k-h's patch email bot
PATCH v3 1/1 staging: emxx_udc: Make incorrectly defined global static
The global gpio_desc pointer and int vbus_irq were defined in the header, instead put the definitions in the translation unit and make them static as there's only a single consumer, and these symbols shouldn't pollute the global namespace.
This fixes the following sparse warnings for this driver:drivers/staging/emxx_udc/emxx_udc.c: note: in included file:drivers/staging/emxx_udc/emxx_udc.h:23:18: warning: symbol 'vbus_gpio' was not declared. Should it be static? drivers/staging/emxx_udc/emxx_udc.h:24:5:
warning: symbol 'vbus_irq' was not declared. Should it be static?
---
Changes in v1:
Switch to variable with static linkage instead of extern Changes in v2:
Resend a versioned patch
Changes in v3:
Include version changelog below the marker
--- drivers/staging/emxx_udc/emxx_udc.c | 3 +++ drivers/staging/emxx_udc/emxx_udc.h | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-)
drivers/staging/emxx_udc/emxx_udc.c +3 -0
@@ -34,6 +34,9 @@#define DRIVER_DESC "EMXX UDC driver"#define DMA_ADDR_INVALID (~(dma_addr_t)0) +static struct gpio_desc *vbus_gpio; +static int vbus_irq; +static const char driver_name[] ="emxx_udc" ;static const char driver_desc[] =DRIVER_DESC ;
drivers/staging/emxx_udc/emxx_udc.h +0 -2
@@ -20,8 +20,6 @@/* below hacked up for staging integration */ #define GPIO_VBUS 0/* GPIO_P153 on KZM9D */ #define INT_VBUS 0/* IRQ for GPIO_P153 */ -struct gpio_desc *vbus_gpio; -int vbus_irq;/*------------ Board dependence(Wait) */
Signature · 1 line
2.29.2
Greg KH
maintainerRe: [PATCH v3] staging: emxx_udc: Make incorrectly defined global static
Quoted 11 lines · Kumar Kartikeya Dwivedi
The global
gpio_descpointer and intvbus_irqwere defined in the header, instead put the definitions in the translation unit and make them static as there's only a single consumer, and these symbols shouldn't pollute the global namespace.This fixes the following sparse warnings for this driver:
drivers/staging/emxx_udc/emxx_udc.c: note: in included file:drivers/staging/emxx_udc/emxx_udc.h:23:18: warning: symbol 'vbus_gpio' was not declared. Should it be static?drivers/staging/emxx_udc/emxx_udc.h:24:5:
warning: symbol 'vbus_irq' was not declared. Should it be static?
Quoted 8 lines
Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>---
Changes in v1:
Switch to variable with static linkage instead of extern Changes in v2:
Resend a versioned patch
Changes in v3:
Include version changelog below the marker
Much better, thanks, now queued up.
greg k-h
Hi Kumar,
CC Nishad, Magnus, linux-renesas-soc,
Quoted 22 lines · Kumar Kartikeya Dwivedi
Quoted 4 lines · Stephen Rothwell
Given that
drivers/staging/emxx_udc/emxx_udc.his only included bydrivers/staging/emxx_udc/emxx_udc.c, shouldn't these variables just be declared static inemxx_udc.cand removed fromemxx_udc.h?Either would be correct. I went this way because it was originally trying to (incorrectly) define a global variable instead. I guess they can be static now and when more users are added, the linkage can be adjusted as needed.
Here's another version of the patch:
--
From5835ad916ceeba620c85bc32f52ecd69f21f8dabMon Sep 17 00:00:00 2001
From: Kumar Kartikeya Dwivedi <[email protected]>
Date: Sun, 7 Feb 2021 12:53:39 +0530
Subject: [PATCH] staging:emxx_udc: Make incorrectly defined global staticThe global
gpio_descpointer and intvbus_irqwere defined in the header, instead put the definitions in the translation unit and make them static as there's only a single consumer inemxx_udc.c.
Quoted 8 lines
This fixes the following sparse warnings for this driver:
drivers/staging/emxx_udc/emxx_udc.c: note: in included file:drivers/staging/emxx_udc/emxx_udc.h:23:18: warning: symbol 'vbus_gpio' was not declared. Should it be static?drivers/staging/emxx_udc/emxx_udc.h:24:5: warning: symbol 'vbus_irq' was not declared. Should it be static?Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>
Thanks for your patch!
drivers/staging/emxx_udc/emxx_udc.c line 38
Quoted 8 lines
drivers/staging/emxx_udc/emxx_udc.c +2
-0@@ -34,6 +34,9 @@#define DRIVER_DESC "EMXX UDC driver"#define DMA_ADDR_INVALID (~(dma_addr_t)0) +static struct gpio_desc *vbus_gpio; +static int vbus_irq;
While I agree these must be static, I expect the driver to be still broken, as vbus_gpio is never set?
Commit 48101806c52203f6 ("Staging: emxx_udc: Switch to the gpio descriptor interface") introduced both variables, which was presumably never tested.
Magnus: perhaps we should just remove this driver?
Quoted 9 lines
drivers/staging/emxx_udc/emxx_udc.c +1
-0+static const char driver_name[] ="emxx_udc" ;static const char driver_desc[] =DRIVER_DESC ;drivers/staging/emxx_udc/emxx_udc.h +0
-0
drivers/staging/emxx_udc/emxx_udc.h line 24
Quoted 5 lines
drivers/staging/emxx_udc/emxx_udc.h +0
-2@@ -20,8 +20,6 @@/* below hacked up for staging integration */ #define GPIO_VBUS 0/* GPIO_P153 on KZM9D */ #define INT_VBUS 0/* IRQ for GPIO_P153 */ -struct gpio_desc *vbus_gpio; -int vbus_irq;
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Greg KH
maintainerQuoted 21 lines · Kumar Kartikeya Dwivedi
The global
gpio_descpointer and int were defined in the header, instead put the definitions in the translation unit and add an extern declaration for consumers of the header (currently only one, which is perhaps why the linker didn't complain about symbol collisions).This fixes sparse related warnings for this driver:
drivers/staging/emxx_udc/emxx_udc.c: note: in included file:drivers/staging/emxx_udc/emxx_udc.h:23:18: warning: symbol 'vbus_gpio' was not declared. Should it be static?drivers/staging/emxx_udc/emxx_udc.h:24:5: warning: symbol 'vbus_irq' was not declared. Should it be static?Signed-off-by Kumar Kartikeya Dwivedi <[email protected]>--- drivers/staging/emxx_udc/emxx_udc.c | 3 +++ drivers/staging/emxx_udc/emxx_udc.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-)drivers/staging/emxx_udc/emxx_udc.c +0
-0
drivers/staging/emxx_udc/emxx_udc.c line 38
Quoted 5 lines
drivers/staging/emxx_udc/emxx_udc.c +2
-0@@ -34,6 +34,9 @@#define DRIVER_DESC "EMXX UDC driver"#define DMA_ADDR_INVALID (~(dma_addr_t)0) +struct gpio_desc *vbus_gpio; +int vbus_irq;
A tiny driver can not create global variables with generic names like this, sorry. That will polute the global namespace.
thanks,
greg k-h