2021-02-07 00:12:15

by Kumar Kartikeya Dwivedi

[permalink] [raw]
Subject: [PATCH] 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?

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

diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
index a30b4f5b1..6983c3e31 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -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;

diff --git a/drivers/staging/emxx_udc/emxx_udc.h b/drivers/staging/emxx_udc/emxx_udc.h
index bca614d69..b3c4ccbe5 100644
--- a/drivers/staging/emxx_udc/emxx_udc.h
+++ b/drivers/staging/emxx_udc/emxx_udc.h
@@ -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) */

--
2.29.2


2021-02-07 06:37:55

by Stephen Rothwell

[permalink] [raw]
Subject: Re: [PATCH] staging: emxx_udc: Fix incorrectly defined global

Hi Kumar,

On Sun, 7 Feb 2021 05:30:31 +0530 Kumar Kartikeya Dwivedi <[email protected]> wrote:
>
> 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?
>
> 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?

> ---
> drivers/staging/emxx_udc/emxx_udc.c | 3 +++
> drivers/staging/emxx_udc/emxx_udc.h | 4 ++--
> 2 files changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
> index a30b4f5b1..6983c3e31 100644
> --- a/drivers/staging/emxx_udc/emxx_udc.c
> +++ b/drivers/staging/emxx_udc/emxx_udc.c
> @@ -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;
>
> diff --git a/drivers/staging/emxx_udc/emxx_udc.h b/drivers/staging/emxx_udc/emxx_udc.h
> index bca614d69..b3c4ccbe5 100644
> --- a/drivers/staging/emxx_udc/emxx_udc.h
> +++ b/drivers/staging/emxx_udc/emxx_udc.h
> @@ -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) */
>
> --
> 2.29.2
>

--
Cheers,
Stephen Rothwell


Attachments:
(No filename) (499.00 B)
OpenPGP digital signature

2021-02-07 07:41:44

by Kumar Kartikeya Dwivedi

[permalink] [raw]
Subject: Re: [PATCH] staging: emxx_udc: Fix incorrectly defined global

On Sun, Feb 07, 2021 at 12:04:41PM IST, Stephen Rothwell wrote:
>
> 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?
>

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?

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

diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
index a30b4f5b1..3536c03ff 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -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;

diff --git a/drivers/staging/emxx_udc/emxx_udc.h b/drivers/staging/emxx_udc/emxx_udc.h
index bca614d69..c9e37a1b8 100644
--- a/drivers/staging/emxx_udc/emxx_udc.h
+++ b/drivers/staging/emxx_udc/emxx_udc.h
@@ -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) */

--
2.29.2

--
Kartikeya

2021-02-07 08:35:34

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] staging: emxx_udc: Fix incorrectly defined global

On Sun, Feb 07, 2021 at 05:30:31AM +0530, Kumar Kartikeya Dwivedi wrote:
> 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?
>
> 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(-)
>
> diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
> index a30b4f5b1..6983c3e31 100644
> --- a/drivers/staging/emxx_udc/emxx_udc.c
> +++ b/drivers/staging/emxx_udc/emxx_udc.c
> @@ -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

2021-02-07 08:38:12

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH] staging: emxx_udc: Fix incorrectly defined global

On Sun, Feb 07, 2021 at 01:08:27PM +0530, Kumar Kartikeya Dwivedi wrote:
> On Sun, Feb 07, 2021 at 12:04:41PM IST, Stephen Rothwell wrote:
> >
> > 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?
> >
>
> 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

2021-02-07 08:49:05

by Kumar Kartikeya Dwivedi

[permalink] [raw]
Subject: [PATCH v2] 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?

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

diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
index a30b4f5b1..3536c03ff 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -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;

diff --git a/drivers/staging/emxx_udc/emxx_udc.h b/drivers/staging/emxx_udc/emxx_udc.h
index bca614d69..c9e37a1b8 100644
--- a/drivers/staging/emxx_udc/emxx_udc.h
+++ b/drivers/staging/emxx_udc/emxx_udc.h
@@ -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) */

--
2.29.2

2021-02-07 08:53:54

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v2] staging: emxx_udc: Make incorrectly defined global static

On Sun, Feb 07, 2021 at 02:16:58PM +0530, Kumar Kartikeya Dwivedi wrote:
> 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?
>
> 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

2021-02-07 09:11:34

by Kumar Kartikeya Dwivedi

[permalink] [raw]
Subject: [PATCH v3] 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?

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
---
drivers/staging/emxx_udc/emxx_udc.c | 3 +++
drivers/staging/emxx_udc/emxx_udc.h | 2 --
2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
index a30b4f5b1..3536c03ff 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -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;

diff --git a/drivers/staging/emxx_udc/emxx_udc.h b/drivers/staging/emxx_udc/emxx_udc.h
index bca614d69..c9e37a1b8 100644
--- a/drivers/staging/emxx_udc/emxx_udc.h
+++ b/drivers/staging/emxx_udc/emxx_udc.h
@@ -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) */

--
2.29.2

2021-02-07 09:20:33

by Greg Kroah-Hartman

[permalink] [raw]
Subject: Re: [PATCH v3] staging: emxx_udc: Make incorrectly defined global static

On Sun, Feb 07, 2021 at 02:29:12PM +0530, Kumar Kartikeya Dwivedi wrote:
> 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?
>
> 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

2021-02-08 10:32:59

by Geert Uytterhoeven

[permalink] [raw]
Subject: Re: [PATCH] staging: emxx_udc: Fix incorrectly defined global

Hi Kumar,

CC Nishad, Magnus, linux-renesas-soc,

On Sun, Feb 7, 2021 at 8:40 AM Kumar Kartikeya Dwivedi <[email protected]> wrote:
> On Sun, Feb 07, 2021 at 12:04:41PM IST, Stephen Rothwell wrote:
> > 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?
> >
>
> 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?
>
> Signed-off-by: Kumar Kartikeya Dwivedi <[email protected]>

Thanks for your patch!

> --- a/drivers/staging/emxx_udc/emxx_udc.c
> +++ b/drivers/staging/emxx_udc/emxx_udc.c
> @@ -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?

> +
> static const char driver_name[] = "emxx_udc";
> static const char driver_desc[] = DRIVER_DESC;
>
> diff --git a/drivers/staging/emxx_udc/emxx_udc.h b/drivers/staging/emxx_udc/emxx_udc.h
> index bca614d69..c9e37a1b8 100644
> --- a/drivers/staging/emxx_udc/emxx_udc.h
> +++ b/drivers/staging/emxx_udc/emxx_udc.h
> @@ -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