Skip to content

Commit 7056783

Browse files
committed
Merge branch 'net-urb-alloc-failure'
Wolfram Sang says: ==================== net: don't print error when allocating urb fails This per-subsystem series is part of a tree wide cleanup. usb_alloc_urb() uses kmalloc which already prints enough information on failure. So, let's simply remove those "allocation failed" messages from drivers like we did already for other -ENOMEM cases. gkh acked this approach when we talked about it at LCJ in Tokyo a few weeks ago. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents 6176e89 + eb36333 commit 7056783

File tree

16 files changed

+27
-102
lines changed

16 files changed

+27
-102
lines changed

drivers/net/can/usb/ems_usb.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,6 @@ static int ems_usb_start(struct ems_usb *dev)
600600
/* create a URB, and a buffer for it */
601601
urb = usb_alloc_urb(0, GFP_KERNEL);
602602
if (!urb) {
603-
netdev_err(netdev, "No memory left for URBs\n");
604603
err = -ENOMEM;
605604
break;
606605
}
@@ -752,10 +751,8 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne
752751

753752
/* create a URB, and a buffer for it, and copy the data to the URB */
754753
urb = usb_alloc_urb(0, GFP_ATOMIC);
755-
if (!urb) {
756-
netdev_err(netdev, "No memory left for URBs\n");
754+
if (!urb)
757755
goto nomem;
758-
}
759756

760757
buf = usb_alloc_coherent(dev->udev, size, GFP_ATOMIC, &urb->transfer_dma);
761758
if (!buf) {
@@ -1007,10 +1004,8 @@ static int ems_usb_probe(struct usb_interface *intf,
10071004
dev->tx_contexts[i].echo_index = MAX_TX_URBS;
10081005

10091006
dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
1010-
if (!dev->intr_urb) {
1011-
dev_err(&intf->dev, "Couldn't alloc intr URB\n");
1007+
if (!dev->intr_urb)
10121008
goto cleanup_candev;
1013-
}
10141009

10151010
dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL);
10161011
if (!dev->intr_in_buffer)

drivers/net/can/usb/esd_usb2.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -558,8 +558,6 @@ static int esd_usb2_setup_rx_urbs(struct esd_usb2 *dev)
558558
/* create a URB, and a buffer for it */
559559
urb = usb_alloc_urb(0, GFP_KERNEL);
560560
if (!urb) {
561-
dev_warn(dev->udev->dev.parent,
562-
"No memory left for URBs\n");
563561
err = -ENOMEM;
564562
break;
565563
}
@@ -730,7 +728,6 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb,
730728
/* create a URB, and a buffer for it, and copy the data to the URB */
731729
urb = usb_alloc_urb(0, GFP_ATOMIC);
732730
if (!urb) {
733-
netdev_err(netdev, "No memory left for URBs\n");
734731
stats->tx_dropped++;
735732
dev_kfree_skb(skb);
736733
goto nourbmem;

drivers/net/can/usb/gs_usb.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,8 @@ static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,
493493

494494
/* create a URB, and a buffer for it */
495495
urb = usb_alloc_urb(0, GFP_ATOMIC);
496-
if (!urb) {
497-
netdev_err(netdev, "No memory left for URB\n");
496+
if (!urb)
498497
goto nomem_urb;
499-
}
500498

501499
hf = usb_alloc_coherent(dev->udev, sizeof(*hf), GFP_ATOMIC,
502500
&urb->transfer_dma);
@@ -600,11 +598,8 @@ static int gs_can_open(struct net_device *netdev)
600598

601599
/* alloc rx urb */
602600
urb = usb_alloc_urb(0, GFP_KERNEL);
603-
if (!urb) {
604-
netdev_err(netdev,
605-
"No memory left for URB\n");
601+
if (!urb)
606602
return -ENOMEM;
607-
}
608603

609604
/* alloc rx buffer */
610605
buf = usb_alloc_coherent(dev->udev,

drivers/net/can/usb/kvaser_usb.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -787,10 +787,8 @@ static int kvaser_usb_simple_msg_async(struct kvaser_usb_net_priv *priv,
787787
int err;
788788

789789
urb = usb_alloc_urb(0, GFP_ATOMIC);
790-
if (!urb) {
791-
netdev_err(netdev, "No memory left for URBs\n");
790+
if (!urb)
792791
return -ENOMEM;
793-
}
794792

795793
buf = kmalloc(sizeof(struct kvaser_msg), GFP_ATOMIC);
796794
if (!buf) {
@@ -1393,8 +1391,6 @@ static int kvaser_usb_setup_rx_urbs(struct kvaser_usb *dev)
13931391

13941392
urb = usb_alloc_urb(0, GFP_KERNEL);
13951393
if (!urb) {
1396-
dev_warn(dev->udev->dev.parent,
1397-
"No memory left for URBs\n");
13981394
err = -ENOMEM;
13991395
break;
14001396
}
@@ -1670,7 +1666,6 @@ static netdev_tx_t kvaser_usb_start_xmit(struct sk_buff *skb,
16701666

16711667
urb = usb_alloc_urb(0, GFP_ATOMIC);
16721668
if (!urb) {
1673-
netdev_err(netdev, "No memory left for URBs\n");
16741669
stats->tx_dropped++;
16751670
dev_kfree_skb(skb);
16761671
return NETDEV_TX_OK;

drivers/net/can/usb/peak_usb/pcan_usb_core.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,6 @@ static int peak_usb_start(struct peak_usb_device *dev)
399399
/* create a URB, and a buffer for it, to receive usb messages */
400400
urb = usb_alloc_urb(0, GFP_KERNEL);
401401
if (!urb) {
402-
netdev_err(netdev, "No memory left for URBs\n");
403402
err = -ENOMEM;
404403
break;
405404
}
@@ -454,7 +453,6 @@ static int peak_usb_start(struct peak_usb_device *dev)
454453
/* create a URB and a buffer for it, to transmit usb messages */
455454
urb = usb_alloc_urb(0, GFP_KERNEL);
456455
if (!urb) {
457-
netdev_err(netdev, "No memory left for URBs\n");
458456
err = -ENOMEM;
459457
break;
460458
}
@@ -651,10 +649,8 @@ static int peak_usb_restart(struct peak_usb_device *dev)
651649

652650
/* first allocate a urb to handle the asynchronous steps */
653651
urb = usb_alloc_urb(0, GFP_ATOMIC);
654-
if (!urb) {
655-
netdev_err(dev->netdev, "no memory left for urb\n");
652+
if (!urb)
656653
return -ENOMEM;
657-
}
658654

659655
/* also allocate enough space for the commands to send */
660656
buf = kmalloc(PCAN_USB_MAX_CMD_LEN, GFP_ATOMIC);

drivers/net/can/usb/usb_8dev.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,8 @@ static netdev_tx_t usb_8dev_start_xmit(struct sk_buff *skb,
623623

624624
/* create a URB, and a buffer for it, and copy the data to the URB */
625625
urb = usb_alloc_urb(0, GFP_ATOMIC);
626-
if (!urb) {
627-
netdev_err(netdev, "No memory left for URBs\n");
626+
if (!urb)
628627
goto nomem;
629-
}
630628

631629
buf = usb_alloc_coherent(priv->udev, size, GFP_ATOMIC,
632630
&urb->transfer_dma);
@@ -748,7 +746,6 @@ static int usb_8dev_start(struct usb_8dev_priv *priv)
748746
/* create a URB, and a buffer for it */
749747
urb = usb_alloc_urb(0, GFP_KERNEL);
750748
if (!urb) {
751-
netdev_err(netdev, "No memory left for URBs\n");
752749
err = -ENOMEM;
753750
break;
754751
}

drivers/net/usb/hso.c

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,10 +2300,8 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
23002300
serial->rx_data_length = rx_size;
23012301
for (i = 0; i < serial->num_rx_urbs; i++) {
23022302
serial->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
2303-
if (!serial->rx_urb[i]) {
2304-
dev_err(dev, "Could not allocate urb?\n");
2303+
if (!serial->rx_urb[i])
23052304
goto exit;
2306-
}
23072305
serial->rx_urb[i]->transfer_buffer = NULL;
23082306
serial->rx_urb[i]->transfer_buffer_length = 0;
23092307
serial->rx_data[i] = kzalloc(serial->rx_data_length,
@@ -2314,10 +2312,8 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
23142312

23152313
/* TX, allocate urb and initialize */
23162314
serial->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
2317-
if (!serial->tx_urb) {
2318-
dev_err(dev, "Could not allocate urb?\n");
2315+
if (!serial->tx_urb)
23192316
goto exit;
2320-
}
23212317
serial->tx_urb->transfer_buffer = NULL;
23222318
serial->tx_urb->transfer_buffer_length = 0;
23232319
/* prepare our TX buffer */
@@ -2555,20 +2551,16 @@ static struct hso_device *hso_create_net_device(struct usb_interface *interface,
25552551
/* start allocating */
25562552
for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) {
25572553
hso_net->mux_bulk_rx_urb_pool[i] = usb_alloc_urb(0, GFP_KERNEL);
2558-
if (!hso_net->mux_bulk_rx_urb_pool[i]) {
2559-
dev_err(&interface->dev, "Could not allocate rx urb\n");
2554+
if (!hso_net->mux_bulk_rx_urb_pool[i])
25602555
goto exit;
2561-
}
25622556
hso_net->mux_bulk_rx_buf_pool[i] = kzalloc(MUX_BULK_RX_BUF_SIZE,
25632557
GFP_KERNEL);
25642558
if (!hso_net->mux_bulk_rx_buf_pool[i])
25652559
goto exit;
25662560
}
25672561
hso_net->mux_bulk_tx_urb = usb_alloc_urb(0, GFP_KERNEL);
2568-
if (!hso_net->mux_bulk_tx_urb) {
2569-
dev_err(&interface->dev, "Could not allocate tx urb\n");
2562+
if (!hso_net->mux_bulk_tx_urb)
25702563
goto exit;
2571-
}
25722564
hso_net->mux_bulk_tx_buf = kzalloc(MUX_BULK_TX_BUF_SIZE, GFP_KERNEL);
25732565
if (!hso_net->mux_bulk_tx_buf)
25742566
goto exit;
@@ -2787,10 +2779,8 @@ struct hso_shared_int *hso_create_shared_int(struct usb_interface *interface)
27872779
}
27882780

27892781
mux->shared_intr_urb = usb_alloc_urb(0, GFP_KERNEL);
2790-
if (!mux->shared_intr_urb) {
2791-
dev_err(&interface->dev, "Could not allocate intr urb?\n");
2782+
if (!mux->shared_intr_urb)
27922783
goto exit;
2793-
}
27942784
mux->shared_intr_buf =
27952785
kzalloc(le16_to_cpu(mux->intr_endp->wMaxPacketSize),
27962786
GFP_KERNEL);

drivers/net/usb/lan78xx.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3002,10 +3002,8 @@ static void lan78xx_tx_bh(struct lan78xx_net *dev)
30023002

30033003
gso_skb:
30043004
urb = usb_alloc_urb(0, GFP_ATOMIC);
3005-
if (!urb) {
3006-
netif_dbg(dev, tx_err, dev->net, "no urb\n");
3005+
if (!urb)
30073006
goto drop;
3008-
}
30093007

30103008
entry = (struct skb_data *)skb->cb;
30113009
entry->urb = urb;

drivers/net/usb/usbnet.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,11 +2062,8 @@ int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype,
20622062
cmd, reqtype, value, index, size);
20632063

20642064
urb = usb_alloc_urb(0, GFP_ATOMIC);
2065-
if (!urb) {
2066-
netdev_err(dev->net, "Error allocating URB in"
2067-
" %s!\n", __func__);
2065+
if (!urb)
20682066
goto fail;
2069-
}
20702067

20712068
if (data) {
20722069
buf = kmemdup(data, size, GFP_ATOMIC);

drivers/net/wimax/i2400m/usb-notif.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ int i2400mu_notification_setup(struct i2400mu *i2400mu)
206206
i2400mu->notif_urb = usb_alloc_urb(0, GFP_KERNEL);
207207
if (!i2400mu->notif_urb) {
208208
ret = -ENOMEM;
209-
dev_err(dev, "notification: cannot allocate URB\n");
210209
goto error_alloc_urb;
211210
}
212211
epd = usb_get_epd(i2400mu->usb_iface,

drivers/net/wireless/ath/ar5523/ar5523.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -706,10 +706,8 @@ static int ar5523_alloc_rx_bufs(struct ar5523 *ar)
706706

707707
data->ar = ar;
708708
data->urb = usb_alloc_urb(0, GFP_KERNEL);
709-
if (!data->urb) {
710-
ar5523_err(ar, "could not allocate rx data urb\n");
709+
if (!data->urb)
711710
goto err;
712-
}
713711
list_add_tail(&data->list, &ar->rx_data_free);
714712
atomic_inc(&ar->rx_data_free_cnt);
715713
}
@@ -824,7 +822,6 @@ static void ar5523_tx_work_locked(struct ar5523 *ar)
824822

825823
urb = usb_alloc_urb(0, GFP_KERNEL);
826824
if (!urb) {
827-
ar5523_err(ar, "Failed to allocate TX urb\n");
828825
ieee80211_free_txskb(ar->hw, skb);
829826
continue;
830827
}
@@ -949,10 +946,8 @@ static int ar5523_alloc_tx_cmd(struct ar5523 *ar)
949946
init_completion(&cmd->done);
950947

951948
cmd->urb_tx = usb_alloc_urb(0, GFP_KERNEL);
952-
if (!cmd->urb_tx) {
953-
ar5523_err(ar, "could not allocate urb\n");
949+
if (!cmd->urb_tx)
954950
return -ENOMEM;
955-
}
956951
cmd->buf_tx = usb_alloc_coherent(ar->dev, AR5523_MAX_TXCMDSZ,
957952
GFP_KERNEL,
958953
&cmd->urb_tx->transfer_dma);

drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,15 +1099,11 @@ struct brcmf_usbdev *brcmf_usb_attach(struct brcmf_usbdev_info *devinfo,
10991099
devinfo->tx_freecount = ntxq;
11001100

11011101
devinfo->ctl_urb = usb_alloc_urb(0, GFP_ATOMIC);
1102-
if (!devinfo->ctl_urb) {
1103-
brcmf_err("usb_alloc_urb (ctl) failed\n");
1102+
if (!devinfo->ctl_urb)
11041103
goto error;
1105-
}
11061104
devinfo->bulk_urb = usb_alloc_urb(0, GFP_ATOMIC);
1107-
if (!devinfo->bulk_urb) {
1108-
brcmf_err("usb_alloc_urb (bulk) failed\n");
1105+
if (!devinfo->bulk_urb)
11091106
goto error;
1110-
}
11111107

11121108
return &devinfo->bus_pub;
11131109

drivers/net/wireless/intersil/orinoco/orinoco_usb.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,10 +1613,8 @@ static int ezusb_probe(struct usb_interface *interface,
16131613
}
16141614

16151615
upriv->read_urb = usb_alloc_urb(0, GFP_KERNEL);
1616-
if (!upriv->read_urb) {
1617-
err("No free urbs available");
1616+
if (!upriv->read_urb)
16181617
goto error;
1619-
}
16201618
if (le16_to_cpu(ep->wMaxPacketSize) != 64)
16211619
pr_warn("bulk in: wMaxPacketSize!= 64\n");
16221620
if (ep->bEndpointAddress != (2 | USB_DIR_IN))

drivers/net/wireless/marvell/libertas_tf/if_usb.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -198,22 +198,16 @@ static int if_usb_probe(struct usb_interface *intf,
198198
}
199199

200200
cardp->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
201-
if (!cardp->rx_urb) {
202-
lbtf_deb_usbd(&udev->dev, "Rx URB allocation failed\n");
201+
if (!cardp->rx_urb)
203202
goto dealloc;
204-
}
205203

206204
cardp->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
207-
if (!cardp->tx_urb) {
208-
lbtf_deb_usbd(&udev->dev, "Tx URB allocation failed\n");
205+
if (!cardp->tx_urb)
209206
goto dealloc;
210-
}
211207

212208
cardp->cmd_urb = usb_alloc_urb(0, GFP_KERNEL);
213-
if (!cardp->cmd_urb) {
214-
lbtf_deb_usbd(&udev->dev, "Cmd URB allocation failed\n");
209+
if (!cardp->cmd_urb)
215210
goto dealloc;
216-
}
217211

218212
cardp->ep_out_buf = kmalloc(MRVDRV_ETH_TX_PACKET_BUFFER_SIZE,
219213
GFP_KERNEL);

drivers/net/wireless/marvell/mwifiex/usb.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -657,11 +657,8 @@ static int mwifiex_usb_tx_init(struct mwifiex_adapter *adapter)
657657
card->tx_cmd.ep = card->tx_cmd_ep;
658658

659659
card->tx_cmd.urb = usb_alloc_urb(0, GFP_KERNEL);
660-
if (!card->tx_cmd.urb) {
661-
mwifiex_dbg(adapter, ERROR,
662-
"tx_cmd.urb allocation failed\n");
660+
if (!card->tx_cmd.urb)
663661
return -ENOMEM;
664-
}
665662

666663
for (i = 0; i < MWIFIEX_TX_DATA_PORT; i++) {
667664
port = &card->port[i];
@@ -677,11 +674,8 @@ static int mwifiex_usb_tx_init(struct mwifiex_adapter *adapter)
677674
port->tx_data_list[j].ep = port->tx_data_ep;
678675
port->tx_data_list[j].urb =
679676
usb_alloc_urb(0, GFP_KERNEL);
680-
if (!port->tx_data_list[j].urb) {
681-
mwifiex_dbg(adapter, ERROR,
682-
"urb allocation failed\n");
677+
if (!port->tx_data_list[j].urb)
683678
return -ENOMEM;
684-
}
685679
}
686680
}
687681

@@ -697,10 +691,8 @@ static int mwifiex_usb_rx_init(struct mwifiex_adapter *adapter)
697691
card->rx_cmd.ep = card->rx_cmd_ep;
698692

699693
card->rx_cmd.urb = usb_alloc_urb(0, GFP_KERNEL);
700-
if (!card->rx_cmd.urb) {
701-
mwifiex_dbg(adapter, ERROR, "rx_cmd.urb allocation failed\n");
694+
if (!card->rx_cmd.urb)
702695
return -ENOMEM;
703-
}
704696

705697
card->rx_cmd.skb = dev_alloc_skb(MWIFIEX_RX_CMD_BUF_SIZE);
706698
if (!card->rx_cmd.skb)
@@ -714,11 +706,8 @@ static int mwifiex_usb_rx_init(struct mwifiex_adapter *adapter)
714706
card->rx_data_list[i].ep = card->rx_data_ep;
715707

716708
card->rx_data_list[i].urb = usb_alloc_urb(0, GFP_KERNEL);
717-
if (!card->rx_data_list[i].urb) {
718-
mwifiex_dbg(adapter, ERROR,
719-
"rx_data_list[] urb allocation failed\n");
709+
if (!card->rx_data_list[i].urb)
720710
return -1;
721-
}
722711
if (mwifiex_usb_submit_rx_urb(&card->rx_data_list[i],
723712
MWIFIEX_RX_DATA_BUF_SIZE))
724713
return -1;

0 commit comments

Comments
 (0)