aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2013-11-01 06:16:41 -0400
committerDavid S. Miller <davem@davemloft.net>2013-11-02 02:02:01 -0400
commitff1632aa8581b7103ac2af1ea3cb4a415eb9d6ad (patch)
tree68e0defc09478750e76e6c18af12c741992e2683
parent3e515665a76ad8f60a1c05968cc6a5b2f2701171 (diff)
net: cdc_ncm: remove redundant endpoint pointers
No need to duplicate stuff already in the common usbnet struct. We still need to keep our special find_endpoints function because we need explicit control over the selected altsetting. Cc: Alexey Orishko <alexey.orishko@gmail.com> Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/usb/cdc_ncm.c38
-rw-r--r--include/linux/usb/cdc_ncm.h3
2 files changed, 19 insertions, 22 deletions
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index bfab8796730f..a989bd5290a6 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -292,9 +292,9 @@ max_dgram_err:
292} 292}
293 293
294static void 294static void
295cdc_ncm_find_endpoints(struct cdc_ncm_ctx *ctx, struct usb_interface *intf) 295cdc_ncm_find_endpoints(struct usbnet *dev, struct usb_interface *intf)
296{ 296{
297 struct usb_host_endpoint *e; 297 struct usb_host_endpoint *e, *in = NULL, *out = NULL;
298 u8 ep; 298 u8 ep;
299 299
300 for (ep = 0; ep < intf->cur_altsetting->desc.bNumEndpoints; ep++) { 300 for (ep = 0; ep < intf->cur_altsetting->desc.bNumEndpoints; ep++) {
@@ -303,18 +303,18 @@ cdc_ncm_find_endpoints(struct cdc_ncm_ctx *ctx, struct usb_interface *intf)
303 switch (e->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { 303 switch (e->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
304 case USB_ENDPOINT_XFER_INT: 304 case USB_ENDPOINT_XFER_INT:
305 if (usb_endpoint_dir_in(&e->desc)) { 305 if (usb_endpoint_dir_in(&e->desc)) {
306 if (ctx->status_ep == NULL) 306 if (!dev->status)
307 ctx->status_ep = e; 307 dev->status = e;
308 } 308 }
309 break; 309 break;
310 310
311 case USB_ENDPOINT_XFER_BULK: 311 case USB_ENDPOINT_XFER_BULK:
312 if (usb_endpoint_dir_in(&e->desc)) { 312 if (usb_endpoint_dir_in(&e->desc)) {
313 if (ctx->in_ep == NULL) 313 if (!in)
314 ctx->in_ep = e; 314 in = e;
315 } else { 315 } else {
316 if (ctx->out_ep == NULL) 316 if (!out)
317 ctx->out_ep = e; 317 out = e;
318 } 318 }
319 break; 319 break;
320 320
@@ -322,6 +322,14 @@ cdc_ncm_find_endpoints(struct cdc_ncm_ctx *ctx, struct usb_interface *intf)
322 break; 322 break;
323 } 323 }
324 } 324 }
325 if (in && !dev->in)
326 dev->in = usb_rcvbulkpipe(dev->udev,
327 in->desc.bEndpointAddress &
328 USB_ENDPOINT_NUMBER_MASK);
329 if (out && !dev->out)
330 dev->out = usb_sndbulkpipe(dev->udev,
331 out->desc.bEndpointAddress &
332 USB_ENDPOINT_NUMBER_MASK);
325} 333}
326 334
327static void cdc_ncm_free(struct cdc_ncm_ctx *ctx) 335static void cdc_ncm_free(struct cdc_ncm_ctx *ctx)
@@ -477,11 +485,9 @@ advance:
477 if (temp) 485 if (temp)
478 goto error2; 486 goto error2;
479 487
480 cdc_ncm_find_endpoints(ctx, ctx->data); 488 cdc_ncm_find_endpoints(dev, ctx->data);
481 cdc_ncm_find_endpoints(ctx, ctx->control); 489 cdc_ncm_find_endpoints(dev, ctx->control);
482 490 if (!dev->in || !dev->out || !dev->status)
483 if ((ctx->in_ep == NULL) || (ctx->out_ep == NULL) ||
484 (ctx->status_ep == NULL))
485 goto error2; 491 goto error2;
486 492
487 dev->net->ethtool_ops = &cdc_ncm_ethtool_ops; 493 dev->net->ethtool_ops = &cdc_ncm_ethtool_ops;
@@ -496,12 +502,6 @@ advance:
496 dev_info(&dev->udev->dev, "MAC-Address: %pM\n", dev->net->dev_addr); 502 dev_info(&dev->udev->dev, "MAC-Address: %pM\n", dev->net->dev_addr);
497 } 503 }
498 504
499
500 dev->in = usb_rcvbulkpipe(dev->udev,
501 ctx->in_ep->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
502 dev->out = usb_sndbulkpipe(dev->udev,
503 ctx->out_ep->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
504 dev->status = ctx->status_ep;
505 dev->rx_urb_size = ctx->rx_max; 505 dev->rx_urb_size = ctx->rx_max;
506 506
507 /* cdc_ncm_setup will override dwNtbOutMaxSize if it is 507 /* cdc_ncm_setup will override dwNtbOutMaxSize if it is
diff --git a/include/linux/usb/cdc_ncm.h b/include/linux/usb/cdc_ncm.h
index c14e00fb1667..36e1e153ca2d 100644
--- a/include/linux/usb/cdc_ncm.h
+++ b/include/linux/usb/cdc_ncm.h
@@ -100,9 +100,6 @@ struct cdc_ncm_ctx {
100 100
101 struct net_device *netdev; 101 struct net_device *netdev;
102 struct usb_device *udev; 102 struct usb_device *udev;
103 struct usb_host_endpoint *in_ep;
104 struct usb_host_endpoint *out_ep;
105 struct usb_host_endpoint *status_ep;
106 struct usb_interface *control; 103 struct usb_interface *control;
107 struct usb_interface *data; 104 struct usb_interface *data;
108 105