aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/usb
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2014-05-16 15:48:20 -0400
committerDavid S. Miller <davem@davemloft.net>2014-05-16 22:39:01 -0400
commit08c74fc901a2e91de762d99ba3d493281862e29a (patch)
tree595e6d8ff7c1d561e430c953213b1435184fc752 /drivers/net/usb
parentf8afb73da3758a9543f4b7c70caa59a18d864c9b (diff)
net: cdc_ncm: split .bind device initialization
Now that we have split out the part of the device setup which MUST be done with the data interface in altsetting 0, we can delay the rest of the initialization. This allows us to move some of post-init buffer size config from bind to the appropriate setup function. The purpose of this refactoring is to collect all code adjusting the rx_max and tx_max buffers in one place, so that it is easier to call it from multiple call sites. Signed-off-by: Bjørn Mork <bjorn@mork.no> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/usb')
-rw-r--r--drivers/net/usb/cdc_ncm.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index b70e061e3473..7a3de73c8ded 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -118,6 +118,21 @@ static void cdc_ncm_update_rxtx_max(struct usbnet *dev, u32 new_rx, u32 new_tx)
118 if (val != ctx->tx_max) 118 if (val != ctx->tx_max)
119 dev_info(&dev->intf->dev, "setting tx_max = %u\n", val); 119 dev_info(&dev->intf->dev, "setting tx_max = %u\n", val);
120 ctx->tx_max = val; 120 ctx->tx_max = val;
121
122 /* Adding a pad byte here if necessary simplifies the handling
123 * in cdc_ncm_fill_tx_frame, making tx_max always represent
124 * the real skb max size.
125 *
126 * We cannot use dev->maxpacket here because this is called from
127 * .bind which is called before usbnet sets up dev->maxpacket
128 */
129 if (ctx->tx_max != le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize) &&
130 ctx->tx_max % usb_maxpacket(dev->udev, dev->out, 1) == 0)
131 ctx->tx_max++;
132
133 /* usbnet use these values for sizing tx/rx queues */
134 dev->hard_mtu = ctx->tx_max;
135 dev->rx_urb_size = ctx->rx_max;
121} 136}
122 137
123/* helpers for NCM and MBIM differences */ 138/* helpers for NCM and MBIM differences */
@@ -323,9 +338,6 @@ static int cdc_ncm_setup(struct usbnet *dev)
323{ 338{
324 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0]; 339 struct cdc_ncm_ctx *ctx = (struct cdc_ncm_ctx *)dev->data[0];
325 340
326 /* initialize basic device settings */
327 cdc_ncm_init(dev);
328
329 /* clamp rx_max and tx_max and inform device */ 341 /* clamp rx_max and tx_max and inform device */
330 cdc_ncm_update_rxtx_max(dev, le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize), 342 cdc_ncm_update_rxtx_max(dev, le32_to_cpu(ctx->ncm_parm.dwNtbInMaxSize),
331 le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize)); 343 le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize));
@@ -532,8 +544,8 @@ advance:
532 goto error2; 544 goto error2;
533 } 545 }
534 546
535 /* initialize data interface */ 547 /* initialize basic device settings */
536 if (cdc_ncm_setup(dev)) 548 if (cdc_ncm_init(dev))
537 goto error2; 549 goto error2;
538 550
539 /* configure data interface */ 551 /* configure data interface */
@@ -562,18 +574,8 @@ advance:
562 dev_info(&intf->dev, "MAC-Address: %pM\n", dev->net->dev_addr); 574 dev_info(&intf->dev, "MAC-Address: %pM\n", dev->net->dev_addr);
563 } 575 }
564 576
565 /* usbnet use these values for sizing tx/rx queues */ 577 /* finish setting up the device specific data */
566 dev->hard_mtu = ctx->tx_max; 578 cdc_ncm_setup(dev);
567 dev->rx_urb_size = ctx->rx_max;
568
569 /* cdc_ncm_setup will override dwNtbOutMaxSize if it is
570 * outside the sane range. Adding a pad byte here if necessary
571 * simplifies the handling in cdc_ncm_fill_tx_frame, making
572 * tx_max always represent the real skb max size.
573 */
574 if (ctx->tx_max != le32_to_cpu(ctx->ncm_parm.dwNtbOutMaxSize) &&
575 ctx->tx_max % usb_maxpacket(dev->udev, dev->out, 1) == 0)
576 ctx->tx_max++;
577 579
578 return 0; 580 return 0;
579 581