Commit ff1632aa authored by Bjørn Mork's avatar Bjørn Mork Committed by David S. Miller

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: default avatarBjørn Mork <bjorn@mork.no>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3e515665
...@@ -292,9 +292,9 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx) ...@@ -292,9 +292,9 @@ static u8 cdc_ncm_setup(struct cdc_ncm_ctx *ctx)
} }
static void static void
cdc_ncm_find_endpoints(struct cdc_ncm_ctx *ctx, struct usb_interface *intf) cdc_ncm_find_endpoints(struct usbnet *dev, struct usb_interface *intf)
{ {
struct usb_host_endpoint *e; struct usb_host_endpoint *e, *in = NULL, *out = NULL;
u8 ep; u8 ep;
for (ep = 0; ep < intf->cur_altsetting->desc.bNumEndpoints; ep++) { 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,18 +303,18 @@ cdc_ncm_find_endpoints(struct cdc_ncm_ctx *ctx, struct usb_interface *intf)
switch (e->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) { switch (e->desc.bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) {
case USB_ENDPOINT_XFER_INT: case USB_ENDPOINT_XFER_INT:
if (usb_endpoint_dir_in(&e->desc)) { if (usb_endpoint_dir_in(&e->desc)) {
if (ctx->status_ep == NULL) if (!dev->status)
ctx->status_ep = e; dev->status = e;
} }
break; break;
case USB_ENDPOINT_XFER_BULK: case USB_ENDPOINT_XFER_BULK:
if (usb_endpoint_dir_in(&e->desc)) { if (usb_endpoint_dir_in(&e->desc)) {
if (ctx->in_ep == NULL) if (!in)
ctx->in_ep = e; in = e;
} else { } else {
if (ctx->out_ep == NULL) if (!out)
ctx->out_ep = e; out = e;
} }
break; break;
...@@ -322,6 +322,14 @@ cdc_ncm_find_endpoints(struct cdc_ncm_ctx *ctx, struct usb_interface *intf) ...@@ -322,6 +322,14 @@ cdc_ncm_find_endpoints(struct cdc_ncm_ctx *ctx, struct usb_interface *intf)
break; break;
} }
} }
if (in && !dev->in)
dev->in = usb_rcvbulkpipe(dev->udev,
in->desc.bEndpointAddress &
USB_ENDPOINT_NUMBER_MASK);
if (out && !dev->out)
dev->out = usb_sndbulkpipe(dev->udev,
out->desc.bEndpointAddress &
USB_ENDPOINT_NUMBER_MASK);
} }
static void cdc_ncm_free(struct cdc_ncm_ctx *ctx) static void cdc_ncm_free(struct cdc_ncm_ctx *ctx)
...@@ -477,11 +485,9 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_ ...@@ -477,11 +485,9 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
if (temp) if (temp)
goto error2; goto error2;
cdc_ncm_find_endpoints(ctx, ctx->data); cdc_ncm_find_endpoints(dev, ctx->data);
cdc_ncm_find_endpoints(ctx, ctx->control); cdc_ncm_find_endpoints(dev, ctx->control);
if (!dev->in || !dev->out || !dev->status)
if ((ctx->in_ep == NULL) || (ctx->out_ep == NULL) ||
(ctx->status_ep == NULL))
goto error2; goto error2;
dev->net->ethtool_ops = &cdc_ncm_ethtool_ops; dev->net->ethtool_ops = &cdc_ncm_ethtool_ops;
...@@ -496,12 +502,6 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_ ...@@ -496,12 +502,6 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct usb_interface *intf, u8 data_
dev_info(&dev->udev->dev, "MAC-Address: %pM\n", dev->net->dev_addr); dev_info(&dev->udev->dev, "MAC-Address: %pM\n", dev->net->dev_addr);
} }
dev->in = usb_rcvbulkpipe(dev->udev,
ctx->in_ep->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
dev->out = usb_sndbulkpipe(dev->udev,
ctx->out_ep->desc.bEndpointAddress & USB_ENDPOINT_NUMBER_MASK);
dev->status = ctx->status_ep;
dev->rx_urb_size = ctx->rx_max; dev->rx_urb_size = ctx->rx_max;
/* cdc_ncm_setup will override dwNtbOutMaxSize if it is /* cdc_ncm_setup will override dwNtbOutMaxSize if it is
......
...@@ -100,9 +100,6 @@ struct cdc_ncm_ctx { ...@@ -100,9 +100,6 @@ struct cdc_ncm_ctx {
struct net_device *netdev; struct net_device *netdev;
struct usb_device *udev; struct usb_device *udev;
struct usb_host_endpoint *in_ep;
struct usb_host_endpoint *out_ep;
struct usb_host_endpoint *status_ep;
struct usb_interface *control; struct usb_interface *control;
struct usb_interface *data; struct usb_interface *data;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment