All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: emxx_udc: Remove unused device_desc declaration
@ 2018-10-04  5:56 Nathan Chancellor
  2018-10-05 21:05 ` Nick Desaulniers
  0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2018-10-04  5:56 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: devel, linux-kernel, Nick Desaulniers, Nathan Chancellor

Clang warns:

drivers/staging/emxx_udc/emxx_udc.c:1373:37: warning: variable
'device_desc' is not needed and will not be emitted
[-Wunneeded-internal-declaration]
static struct usb_device_descriptor device_desc = {
                                    ^
1 warning generated.

This definition hasn't been attached to anything since the driver was
introduced in commit 33aa8d45a4fe ("staging: emxx_udc: Add Emma Mobile
USB Gadget driver") and neither GCC nor Clang emit any reference to the
variable in the final assembly. The only reason GCC doesn't warn about
this variable being unused is the sizeof function.

Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---

This seems kind of wrong given this is a USB driver but there isn't an
instance of a platform_driver in the kernel tree having a usb device
descriptor declaration so I'm unsure of how to handle this warning aside
from just removing the definition but I'm certainly open to suggestions.

 drivers/staging/emxx_udc/emxx_udc.c | 19 -------------------
 1 file changed, 19 deletions(-)

diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
index 0e8d3f232fe9..65cc3d9af972 100644
--- a/drivers/staging/emxx_udc/emxx_udc.c
+++ b/drivers/staging/emxx_udc/emxx_udc.c
@@ -1368,25 +1368,6 @@ static void _nbu2ss_set_endpoint_stall(
 	}
 }
 
-/*-------------------------------------------------------------------------*/
-/* Device Descriptor */
-static struct usb_device_descriptor device_desc = {
-	.bLength              = sizeof(device_desc),
-	.bDescriptorType      = USB_DT_DEVICE,
-	.bcdUSB               = cpu_to_le16(0x0200),
-	.bDeviceClass         = USB_CLASS_VENDOR_SPEC,
-	.bDeviceSubClass      = 0x00,
-	.bDeviceProtocol      = 0x00,
-	.bMaxPacketSize0      = 64,
-	.idVendor             = cpu_to_le16(0x0409),
-	.idProduct            = cpu_to_le16(0xfff0),
-	.bcdDevice            = 0xffff,
-	.iManufacturer        = 0x00,
-	.iProduct             = 0x00,
-	.iSerialNumber        = 0x00,
-	.bNumConfigurations   = 0x01,
-};
-
 /*-------------------------------------------------------------------------*/
 static void _nbu2ss_set_test_mode(struct nbu2ss_udc *udc, u32 mode)
 {
-- 
2.19.0


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

* Re: [PATCH] staging: emxx_udc: Remove unused device_desc declaration
  2018-10-04  5:56 [PATCH] staging: emxx_udc: Remove unused device_desc declaration Nathan Chancellor
@ 2018-10-05 21:05 ` Nick Desaulniers
  2018-10-09 13:09   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Nick Desaulniers @ 2018-10-05 21:05 UTC (permalink / raw)
  To: Nathan Chancellor; +Cc: Greg KH, devel, LKML, damm+renesas, Arnd Bergmann

On Wed, Oct 3, 2018 at 10:56 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns:
>
> drivers/staging/emxx_udc/emxx_udc.c:1373:37: warning: variable
> 'device_desc' is not needed and will not be emitted
> [-Wunneeded-internal-declaration]
> static struct usb_device_descriptor device_desc = {
>                                     ^
> 1 warning generated.
>
> This definition hasn't been attached to anything since the driver was
> introduced in commit 33aa8d45a4fe ("staging: emxx_udc: Add Emma Mobile
> USB Gadget driver") and neither GCC nor Clang emit any reference to the
> variable in the final assembly. The only reason GCC doesn't warn about
> this variable being unused is the sizeof function.
>
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> ---
>
> This seems kind of wrong given this is a USB driver but there isn't an
> instance of a platform_driver in the kernel tree having a usb device
> descriptor declaration so I'm unsure of how to handle this warning aside
> from just removing the definition but I'm certainly open to suggestions.

In drivers under drivers/usb/gadget/legacy/{ether|mass_storage|hid}.c,
it seems that addresses of instances of `struct usb_device_descriptor`
are stored in instances of `struct usb_composite_driver eth_driver`
that are passed to module_usb_composite_driver().

drivers/staging/emxx_udc/emxx_udc.c doesn't mention anything about
being a composite driver, and I don't know if there are multiple
devices to warrant a composite driver?  Composite seems to imply "more
than one gadget" while the path to drivers using this interface under
drivers/usb/gadget/legacy/ seem to imply there's a modern (non-legacy)
usb gadget interface that could potentially be used instead.

If this was never intended to be a composite usb driver, or there's
some reason why it doesn't make sense for it to be one, then this code
is likely dead and your fix is correct.  If it's not, maybe folks who
know more about the USB interfaces have another solution to make this
a composite usb driver?

>
>  drivers/staging/emxx_udc/emxx_udc.c | 19 -------------------
>  1 file changed, 19 deletions(-)
>
> diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c
> index 0e8d3f232fe9..65cc3d9af972 100644
> --- a/drivers/staging/emxx_udc/emxx_udc.c
> +++ b/drivers/staging/emxx_udc/emxx_udc.c
> @@ -1368,25 +1368,6 @@ static void _nbu2ss_set_endpoint_stall(
>         }
>  }
>
> -/*-------------------------------------------------------------------------*/
> -/* Device Descriptor */
> -static struct usb_device_descriptor device_desc = {
> -       .bLength              = sizeof(device_desc),
> -       .bDescriptorType      = USB_DT_DEVICE,
> -       .bcdUSB               = cpu_to_le16(0x0200),
> -       .bDeviceClass         = USB_CLASS_VENDOR_SPEC,
> -       .bDeviceSubClass      = 0x00,
> -       .bDeviceProtocol      = 0x00,
> -       .bMaxPacketSize0      = 64,
> -       .idVendor             = cpu_to_le16(0x0409),
> -       .idProduct            = cpu_to_le16(0xfff0),
> -       .bcdDevice            = 0xffff,
> -       .iManufacturer        = 0x00,
> -       .iProduct             = 0x00,
> -       .iSerialNumber        = 0x00,
> -       .bNumConfigurations   = 0x01,
> -};
> -
>  /*-------------------------------------------------------------------------*/
>  static void _nbu2ss_set_test_mode(struct nbu2ss_udc *udc, u32 mode)
>  {
> --
> 2.19.0
>


-- 
Thanks,
~Nick Desaulniers

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

* Re: [PATCH] staging: emxx_udc: Remove unused device_desc declaration
  2018-10-05 21:05 ` Nick Desaulniers
@ 2018-10-09 13:09   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2018-10-09 13:09 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Nathan Chancellor, devel, damm+renesas, LKML, Arnd Bergmann

On Fri, Oct 05, 2018 at 02:05:45PM -0700, Nick Desaulniers wrote:
> On Wed, Oct 3, 2018 at 10:56 PM Nathan Chancellor
> <natechancellor@gmail.com> wrote:
> >
> > Clang warns:
> >
> > drivers/staging/emxx_udc/emxx_udc.c:1373:37: warning: variable
> > 'device_desc' is not needed and will not be emitted
> > [-Wunneeded-internal-declaration]
> > static struct usb_device_descriptor device_desc = {
> >                                     ^
> > 1 warning generated.
> >
> > This definition hasn't been attached to anything since the driver was
> > introduced in commit 33aa8d45a4fe ("staging: emxx_udc: Add Emma Mobile
> > USB Gadget driver") and neither GCC nor Clang emit any reference to the
> > variable in the final assembly. The only reason GCC doesn't warn about
> > this variable being unused is the sizeof function.
> >
> > Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> > ---
> >
> > This seems kind of wrong given this is a USB driver but there isn't an
> > instance of a platform_driver in the kernel tree having a usb device
> > descriptor declaration so I'm unsure of how to handle this warning aside
> > from just removing the definition but I'm certainly open to suggestions.
> 
> In drivers under drivers/usb/gadget/legacy/{ether|mass_storage|hid}.c,
> it seems that addresses of instances of `struct usb_device_descriptor`
> are stored in instances of `struct usb_composite_driver eth_driver`
> that are passed to module_usb_composite_driver().
> 
> drivers/staging/emxx_udc/emxx_udc.c doesn't mention anything about
> being a composite driver, and I don't know if there are multiple
> devices to warrant a composite driver?  Composite seems to imply "more
> than one gadget" while the path to drivers using this interface under
> drivers/usb/gadget/legacy/ seem to imply there's a modern (non-legacy)
> usb gadget interface that could potentially be used instead.
> 
> If this was never intended to be a composite usb driver, or there's
> some reason why it doesn't make sense for it to be one, then this code
> is likely dead and your fix is correct.  If it's not, maybe folks who
> know more about the USB interfaces have another solution to make this
> a composite usb driver?

I'll take the patch, the code looks wrong, it should not be needed here.

thanks,

greg k-h

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

end of thread, other threads:[~2018-10-09 13:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-04  5:56 [PATCH] staging: emxx_udc: Remove unused device_desc declaration Nathan Chancellor
2018-10-05 21:05 ` Nick Desaulniers
2018-10-09 13:09   ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.