diff mbox series

usb: gadget: ether: Fix warnings about unused code

Message ID 20200604200804.5759-1-trini@konsulko.com
State New
Headers show
Series usb: gadget: ether: Fix warnings about unused code | expand

Commit Message

Tom Rini June 4, 2020, 8:08 p.m. UTC
When building this with clang we see a few new warnings.  There are a
handful of structs that we declare and use only in the case of
!defined(CONFIG_USB_ETH_CDC) && defined(CONFIG_USB_ETH_SUBSET) so update
the guards used to match this as well as cover all members rather than
just a few.  Finally, eth_is_promisc() is only called by
eth_start_xmit() which is under and #if 0 and immediately follows the
function.  Move the #if 0 up.

Cc: Lukasz Majewski <lukma at denx.de>
Cc: Marek Vasut <marex at denx.de>
Signed-off-by: Tom Rini <trini at konsulko.com>
---
 drivers/usb/gadget/ether.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

Comments

Lukasz Majewski Aug. 25, 2020, 9:55 a.m. UTC | #1
Hi Tom,

> When building this with clang we see a few new warnings.  There are a

> handful of structs that we declare and use only in the case of

> !defined(CONFIG_USB_ETH_CDC) && defined(CONFIG_USB_ETH_SUBSET) so

> update the guards used to match this as well as cover all members

> rather than just a few.  Finally, eth_is_promisc() is only called by

> eth_start_xmit() which is under and #if 0 and immediately follows the

> function.  Move the #if 0 up.

> 


Could you double check this patch and rebase it on top of newest master.

As it is now it causes following build break:
https://travis-ci.org/github/lmajewski/u-boot-dfu/jobs/720654040

Thanks in advance,
Ɓukasz

> Cc: Lukasz Majewski <lukma@denx.de>

> Cc: Marek Vasut <marex@denx.de>

> Signed-off-by: Tom Rini <trini@konsulko.com>

> ---

>  drivers/usb/gadget/ether.c | 11 +++--------

>  1 file changed, 3 insertions(+), 8 deletions(-)

> 

> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c

> index 6f04523f15e9..0daaf36f68f7 100644

> --- a/drivers/usb/gadget/ether.c

> +++ b/drivers/usb/gadget/ether.c

> @@ -476,14 +476,12 @@ static const struct usb_cdc_acm_descriptor

> acm_descriptor = { 

>  #endif

>  

> -#ifndef CONFIG_USB_ETH_CDC

> -

> +#if !defined(CONFIG_USB_ETH_CDC) && defined(CONFIG_USB_ETH_SUBSET)

>  /*

>   * "SAFE" loosely follows CDC WMC MDLM, violating the spec in various

>   * ways:  data endpoints live in the control interface, there's no

> data

>   * interface, and it's not used to talk to a cell phone radio.

>   */

> -

>  static const struct usb_cdc_mdlm_desc mdlm_desc = {

>  	.bLength =		sizeof mdlm_desc,

>  	.bDescriptorType =	USB_DT_CS_INTERFACE,

> @@ -501,7 +499,6 @@ static const struct usb_cdc_mdlm_desc mdlm_desc =

> {

>   * can't really use its struct.  All we do here is say that we're

> using

>   * the submode of "SAFE" which directly matches the CDC Subset.

>   */

> -#ifdef CONFIG_USB_ETH_SUBSET

>  static const u8 mdlm_detail_desc[] = {

>  	6,

>  	USB_DT_CS_INTERFACE,

> @@ -511,9 +508,6 @@ static const u8 mdlm_detail_desc[] = {

>  	0,	/* network control capabilities (none) */

>  	0,	/* network data capabilities ("raw" encapsulation)

> */ };

> -#endif

> -

> -#endif

>  

>  static const struct usb_cdc_ether_desc ether_desc = {

>  	.bLength =		sizeof(ether_desc),

> @@ -527,6 +521,7 @@ static const struct usb_cdc_ether_desc ether_desc

> = { .wNumberMCFilters =	__constant_cpu_to_le16(0),

>  	.bNumberPowerFilters =	0,

>  };

> +#endif

>  

>  #if defined(CONFIG_USB_ETH_CDC) || defined(CONFIG_USB_ETH_RNDIS)

>  

> @@ -1643,6 +1638,7 @@ static void tx_complete(struct usb_ep *ep,

> struct usb_request *req) packet_sent = 1;

>  }

>  

> +#if 0

>  static inline int eth_is_promisc(struct eth_dev *dev)

>  {

>  	/* no filters for the CDC subset; always promisc */

> @@ -1651,7 +1647,6 @@ static inline int eth_is_promisc(struct eth_dev

> *dev) return dev->cdc_filter & USB_CDC_PACKET_TYPE_PROMISCUOUS;

>  }

>  

> -#if 0

>  static int eth_start_xmit (struct sk_buff *skb, struct net_device

> *net) {

>  	struct eth_dev		*dev = netdev_priv(net);





Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@denx.de
Tom Rini Aug. 25, 2020, 12:50 p.m. UTC | #2
On Tue, Aug 25, 2020 at 11:55:17AM +0200, Lukasz Majewski wrote:
> Hi Tom,

> 

> > When building this with clang we see a few new warnings.  There are a

> > handful of structs that we declare and use only in the case of

> > !defined(CONFIG_USB_ETH_CDC) && defined(CONFIG_USB_ETH_SUBSET) so

> > update the guards used to match this as well as cover all members

> > rather than just a few.  Finally, eth_is_promisc() is only called by

> > eth_start_xmit() which is under and #if 0 and immediately follows the

> > function.  Move the #if 0 up.

> > 

> 

> Could you double check this patch and rebase it on top of newest master.

> 

> As it is now it causes following build break:

> https://travis-ci.org/github/lmajewski/u-boot-dfu/jobs/720654040


Lets just set it aside then.  It was fine at the time but I've put down
my experiment of building various targets with clang for now.

-- 
Tom
diff mbox series

Patch

diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
index 6f04523f15e9..0daaf36f68f7 100644
--- a/drivers/usb/gadget/ether.c
+++ b/drivers/usb/gadget/ether.c
@@ -476,14 +476,12 @@  static const struct usb_cdc_acm_descriptor acm_descriptor = {
 
 #endif
 
-#ifndef CONFIG_USB_ETH_CDC
-
+#if !defined(CONFIG_USB_ETH_CDC) && defined(CONFIG_USB_ETH_SUBSET)
 /*
  * "SAFE" loosely follows CDC WMC MDLM, violating the spec in various
  * ways:  data endpoints live in the control interface, there's no data
  * interface, and it's not used to talk to a cell phone radio.
  */
-
 static const struct usb_cdc_mdlm_desc mdlm_desc = {
 	.bLength =		sizeof mdlm_desc,
 	.bDescriptorType =	USB_DT_CS_INTERFACE,
@@ -501,7 +499,6 @@  static const struct usb_cdc_mdlm_desc mdlm_desc = {
  * can't really use its struct.  All we do here is say that we're using
  * the submode of "SAFE" which directly matches the CDC Subset.
  */
-#ifdef CONFIG_USB_ETH_SUBSET
 static const u8 mdlm_detail_desc[] = {
 	6,
 	USB_DT_CS_INTERFACE,
@@ -511,9 +508,6 @@  static const u8 mdlm_detail_desc[] = {
 	0,	/* network control capabilities (none) */
 	0,	/* network data capabilities ("raw" encapsulation) */
 };
-#endif
-
-#endif
 
 static const struct usb_cdc_ether_desc ether_desc = {
 	.bLength =		sizeof(ether_desc),
@@ -527,6 +521,7 @@  static const struct usb_cdc_ether_desc ether_desc = {
 	.wNumberMCFilters =	__constant_cpu_to_le16(0),
 	.bNumberPowerFilters =	0,
 };
+#endif
 
 #if defined(CONFIG_USB_ETH_CDC) || defined(CONFIG_USB_ETH_RNDIS)
 
@@ -1643,6 +1638,7 @@  static void tx_complete(struct usb_ep *ep, struct usb_request *req)
 	packet_sent = 1;
 }
 
+#if 0
 static inline int eth_is_promisc(struct eth_dev *dev)
 {
 	/* no filters for the CDC subset; always promisc */
@@ -1651,7 +1647,6 @@  static inline int eth_is_promisc(struct eth_dev *dev)
 	return dev->cdc_filter & USB_CDC_PACKET_TYPE_PROMISCUOUS;
 }
 
-#if 0
 static int eth_start_xmit (struct sk_buff *skb, struct net_device *net)
 {
 	struct eth_dev		*dev = netdev_priv(net);