* [PATCH] net: cdc_ncm: use IAD provided by the USB core
@ 2013-01-26 9:36 Bjørn Mork
2013-01-28 0:28 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Bjørn Mork @ 2013-01-26 9:36 UTC (permalink / raw)
To: netdev
Cc: linux-usb, Oliver Neukum, Bjørn Mork, Greg Suarez,
Alexey Orishko
commit 9992c2e (net: cdc_ncm: workaround for missing CDC Union)
added code to lookup an IAD for the interface we are probing.
This is redundant. The USB core has already done the lookup
and saved the result in the USB interface struct. Use that
instead.
Cc: Greg Suarez <gsuarez@smithmicro.com>
Cc: Alexey Orishko <alexey.orishko@stericsson.com>
Signed-off-by: Bjørn Mork <bjorn@mork.no>
---
Hello,
I just realized that my workaround for the missing CDC Union was
unnecessarily complex. I was not aware of the per-interface
intf_assoc pointer.
Guess this cleanup may come a little too late for 3.8, but that's
up to David to decide of course. FWIW, the patch touches *only*
code which were added by commit 9992c2e.
Bjørn
drivers/net/usb/cdc_ncm.c | 28 ++++------------------------
1 file changed, 4 insertions(+), 24 deletions(-)
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index f94711c..9197b2c 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -344,23 +344,6 @@ static const struct ethtool_ops cdc_ncm_ethtool_ops = {
.nway_reset = usbnet_nway_reset,
};
-/* return first slave interface if an IAD matches the given master */
-static struct usb_interface *get_iad_slave(struct usb_device *udev,
- struct usb_interface *master) {
- int i;
- struct usb_interface_assoc_descriptor *iad;
- u8 mnum = master->cur_altsetting->desc.bInterfaceNumber;
-
- for (i = 0; i < USB_MAXIADS; i++) {
- iad = udev->actconfig->intf_assoc[i];
- if (!iad)
- break;
- if (iad->bFirstInterface == mnum && iad->bInterfaceCount == 2)
- return usb_ifnum_to_if(udev, mnum + 1);
- }
- return NULL;
-}
-
int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_altsetting)
{
struct cdc_ncm_ctx *ctx;
@@ -453,13 +436,10 @@ advance:
}
/* some buggy devices have an IAD but no CDC Union */
- if (!ctx->union_desc) {
- dev_dbg(&intf->dev, "missing CDC Union descriptor\n");
- ctx->data = get_iad_slave(dev->udev, intf);
- if (ctx->data) {
- ctx->control = intf;
- dev_dbg(&intf->dev, "got slave from IAD\n");
- }
+ if (!ctx->union_desc && intf->intf_assoc && intf->intf_assoc->bInterfaceCount == 2) {
+ ctx->control = intf;
+ ctx->data = usb_ifnum_to_if(dev->udev, intf->cur_altsetting->desc.bInterfaceNumber + 1);
+ dev_dbg(&intf->dev, "CDC Union missing - got slave from IAD\n");
}
/* check if we got everything */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: cdc_ncm: use IAD provided by the USB core
2013-01-26 9:36 [PATCH] net: cdc_ncm: use IAD provided by the USB core Bjørn Mork
@ 2013-01-28 0:28 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2013-01-28 0:28 UTC (permalink / raw)
To: bjorn; +Cc: netdev, linux-usb, oliver, gsuarez, alexey.orishko
From: Bjørn Mork <bjorn@mork.no>
Date: Sat, 26 Jan 2013 10:36:59 +0100
> commit 9992c2e (net: cdc_ncm: workaround for missing CDC Union)
> added code to lookup an IAD for the interface we are probing.
> This is redundant. The USB core has already done the lookup
> and saved the result in the USB interface struct. Use that
> instead.
>
> Cc: Greg Suarez <gsuarez@smithmicro.com>
> Cc: Alexey Orishko <alexey.orishko@stericsson.com>
> Signed-off-by: Bjørn Mork <bjorn@mork.no>
Applied to 'net'.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-01-28 0:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-26 9:36 [PATCH] net: cdc_ncm: use IAD provided by the USB core Bjørn Mork
2013-01-28 0:28 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).