Skip to content

Commit

Permalink
Merge branch 'net-urb-alloc-failure'
Browse files Browse the repository at this point in the history
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 <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Aug 13, 2016
2 parents 6176e89 + eb36333 commit 7056783
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 102 deletions.
9 changes: 2 additions & 7 deletions drivers/net/can/usb/ems_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,6 @@ static int ems_usb_start(struct ems_usb *dev)
/* create a URB, and a buffer for it */
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) {
netdev_err(netdev, "No memory left for URBs\n");
err = -ENOMEM;
break;
}
Expand Down Expand Up @@ -752,10 +751,8 @@ static netdev_tx_t ems_usb_start_xmit(struct sk_buff *skb, struct net_device *ne

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

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

dev->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!dev->intr_urb) {
dev_err(&intf->dev, "Couldn't alloc intr URB\n");
if (!dev->intr_urb)
goto cleanup_candev;
}

dev->intr_in_buffer = kzalloc(INTR_IN_BUFFER_SIZE, GFP_KERNEL);
if (!dev->intr_in_buffer)
Expand Down
3 changes: 0 additions & 3 deletions drivers/net/can/usb/esd_usb2.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,8 +558,6 @@ static int esd_usb2_setup_rx_urbs(struct esd_usb2 *dev)
/* create a URB, and a buffer for it */
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) {
dev_warn(dev->udev->dev.parent,
"No memory left for URBs\n");
err = -ENOMEM;
break;
}
Expand Down Expand Up @@ -730,7 +728,6 @@ static netdev_tx_t esd_usb2_start_xmit(struct sk_buff *skb,
/* create a URB, and a buffer for it, and copy the data to the URB */
urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) {
netdev_err(netdev, "No memory left for URBs\n");
stats->tx_dropped++;
dev_kfree_skb(skb);
goto nourbmem;
Expand Down
9 changes: 2 additions & 7 deletions drivers/net/can/usb/gs_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,8 @@ static netdev_tx_t gs_can_start_xmit(struct sk_buff *skb,

/* create a URB, and a buffer for it */
urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) {
netdev_err(netdev, "No memory left for URB\n");
if (!urb)
goto nomem_urb;
}

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

/* alloc rx urb */
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) {
netdev_err(netdev,
"No memory left for URB\n");
if (!urb)
return -ENOMEM;
}

/* alloc rx buffer */
buf = usb_alloc_coherent(dev->udev,
Expand Down
7 changes: 1 addition & 6 deletions drivers/net/can/usb/kvaser_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -787,10 +787,8 @@ static int kvaser_usb_simple_msg_async(struct kvaser_usb_net_priv *priv,
int err;

urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) {
netdev_err(netdev, "No memory left for URBs\n");
if (!urb)
return -ENOMEM;
}

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

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

urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) {
netdev_err(netdev, "No memory left for URBs\n");
stats->tx_dropped++;
dev_kfree_skb(skb);
return NETDEV_TX_OK;
Expand Down
6 changes: 1 addition & 5 deletions drivers/net/can/usb/peak_usb/pcan_usb_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,6 @@ static int peak_usb_start(struct peak_usb_device *dev)
/* create a URB, and a buffer for it, to receive usb messages */
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) {
netdev_err(netdev, "No memory left for URBs\n");
err = -ENOMEM;
break;
}
Expand Down Expand Up @@ -454,7 +453,6 @@ static int peak_usb_start(struct peak_usb_device *dev)
/* create a URB and a buffer for it, to transmit usb messages */
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) {
netdev_err(netdev, "No memory left for URBs\n");
err = -ENOMEM;
break;
}
Expand Down Expand Up @@ -651,10 +649,8 @@ static int peak_usb_restart(struct peak_usb_device *dev)

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

/* also allocate enough space for the commands to send */
buf = kmalloc(PCAN_USB_MAX_CMD_LEN, GFP_ATOMIC);
Expand Down
5 changes: 1 addition & 4 deletions drivers/net/can/usb/usb_8dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,10 +623,8 @@ static netdev_tx_t usb_8dev_start_xmit(struct sk_buff *skb,

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

buf = usb_alloc_coherent(priv->udev, size, GFP_ATOMIC,
&urb->transfer_dma);
Expand Down Expand Up @@ -748,7 +746,6 @@ static int usb_8dev_start(struct usb_8dev_priv *priv)
/* create a URB, and a buffer for it */
urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) {
netdev_err(netdev, "No memory left for URBs\n");
err = -ENOMEM;
break;
}
Expand Down
20 changes: 5 additions & 15 deletions drivers/net/usb/hso.c
Original file line number Diff line number Diff line change
Expand Up @@ -2300,10 +2300,8 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,
serial->rx_data_length = rx_size;
for (i = 0; i < serial->num_rx_urbs; i++) {
serial->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
if (!serial->rx_urb[i]) {
dev_err(dev, "Could not allocate urb?\n");
if (!serial->rx_urb[i])
goto exit;
}
serial->rx_urb[i]->transfer_buffer = NULL;
serial->rx_urb[i]->transfer_buffer_length = 0;
serial->rx_data[i] = kzalloc(serial->rx_data_length,
Expand All @@ -2314,10 +2312,8 @@ static int hso_serial_common_create(struct hso_serial *serial, int num_urbs,

/* TX, allocate urb and initialize */
serial->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!serial->tx_urb) {
dev_err(dev, "Could not allocate urb?\n");
if (!serial->tx_urb)
goto exit;
}
serial->tx_urb->transfer_buffer = NULL;
serial->tx_urb->transfer_buffer_length = 0;
/* prepare our TX buffer */
Expand Down Expand Up @@ -2555,20 +2551,16 @@ static struct hso_device *hso_create_net_device(struct usb_interface *interface,
/* start allocating */
for (i = 0; i < MUX_BULK_RX_BUF_COUNT; i++) {
hso_net->mux_bulk_rx_urb_pool[i] = usb_alloc_urb(0, GFP_KERNEL);
if (!hso_net->mux_bulk_rx_urb_pool[i]) {
dev_err(&interface->dev, "Could not allocate rx urb\n");
if (!hso_net->mux_bulk_rx_urb_pool[i])
goto exit;
}
hso_net->mux_bulk_rx_buf_pool[i] = kzalloc(MUX_BULK_RX_BUF_SIZE,
GFP_KERNEL);
if (!hso_net->mux_bulk_rx_buf_pool[i])
goto exit;
}
hso_net->mux_bulk_tx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!hso_net->mux_bulk_tx_urb) {
dev_err(&interface->dev, "Could not allocate tx urb\n");
if (!hso_net->mux_bulk_tx_urb)
goto exit;
}
hso_net->mux_bulk_tx_buf = kzalloc(MUX_BULK_TX_BUF_SIZE, GFP_KERNEL);
if (!hso_net->mux_bulk_tx_buf)
goto exit;
Expand Down Expand Up @@ -2787,10 +2779,8 @@ struct hso_shared_int *hso_create_shared_int(struct usb_interface *interface)
}

mux->shared_intr_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!mux->shared_intr_urb) {
dev_err(&interface->dev, "Could not allocate intr urb?\n");
if (!mux->shared_intr_urb)
goto exit;
}
mux->shared_intr_buf =
kzalloc(le16_to_cpu(mux->intr_endp->wMaxPacketSize),
GFP_KERNEL);
Expand Down
4 changes: 1 addition & 3 deletions drivers/net/usb/lan78xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -3002,10 +3002,8 @@ static void lan78xx_tx_bh(struct lan78xx_net *dev)

gso_skb:
urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) {
netif_dbg(dev, tx_err, dev->net, "no urb\n");
if (!urb)
goto drop;
}

entry = (struct skb_data *)skb->cb;
entry->urb = urb;
Expand Down
5 changes: 1 addition & 4 deletions drivers/net/usb/usbnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -2062,11 +2062,8 @@ int usbnet_write_cmd_async(struct usbnet *dev, u8 cmd, u8 reqtype,
cmd, reqtype, value, index, size);

urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb) {
netdev_err(dev->net, "Error allocating URB in"
" %s!\n", __func__);
if (!urb)
goto fail;
}

if (data) {
buf = kmemdup(data, size, GFP_ATOMIC);
Expand Down
1 change: 0 additions & 1 deletion drivers/net/wimax/i2400m/usb-notif.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ int i2400mu_notification_setup(struct i2400mu *i2400mu)
i2400mu->notif_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!i2400mu->notif_urb) {
ret = -ENOMEM;
dev_err(dev, "notification: cannot allocate URB\n");
goto error_alloc_urb;
}
epd = usb_get_epd(i2400mu->usb_iface,
Expand Down
9 changes: 2 additions & 7 deletions drivers/net/wireless/ath/ar5523/ar5523.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,10 +706,8 @@ static int ar5523_alloc_rx_bufs(struct ar5523 *ar)

data->ar = ar;
data->urb = usb_alloc_urb(0, GFP_KERNEL);
if (!data->urb) {
ar5523_err(ar, "could not allocate rx data urb\n");
if (!data->urb)
goto err;
}
list_add_tail(&data->list, &ar->rx_data_free);
atomic_inc(&ar->rx_data_free_cnt);
}
Expand Down Expand Up @@ -824,7 +822,6 @@ static void ar5523_tx_work_locked(struct ar5523 *ar)

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

cmd->urb_tx = usb_alloc_urb(0, GFP_KERNEL);
if (!cmd->urb_tx) {
ar5523_err(ar, "could not allocate urb\n");
if (!cmd->urb_tx)
return -ENOMEM;
}
cmd->buf_tx = usb_alloc_coherent(ar->dev, AR5523_MAX_TXCMDSZ,
GFP_KERNEL,
&cmd->urb_tx->transfer_dma);
Expand Down
8 changes: 2 additions & 6 deletions drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1099,15 +1099,11 @@ struct brcmf_usbdev *brcmf_usb_attach(struct brcmf_usbdev_info *devinfo,
devinfo->tx_freecount = ntxq;

devinfo->ctl_urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!devinfo->ctl_urb) {
brcmf_err("usb_alloc_urb (ctl) failed\n");
if (!devinfo->ctl_urb)
goto error;
}
devinfo->bulk_urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!devinfo->bulk_urb) {
brcmf_err("usb_alloc_urb (bulk) failed\n");
if (!devinfo->bulk_urb)
goto error;
}

return &devinfo->bus_pub;

Expand Down
4 changes: 1 addition & 3 deletions drivers/net/wireless/intersil/orinoco/orinoco_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -1613,10 +1613,8 @@ static int ezusb_probe(struct usb_interface *interface,
}

upriv->read_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!upriv->read_urb) {
err("No free urbs available");
if (!upriv->read_urb)
goto error;
}
if (le16_to_cpu(ep->wMaxPacketSize) != 64)
pr_warn("bulk in: wMaxPacketSize!= 64\n");
if (ep->bEndpointAddress != (2 | USB_DIR_IN))
Expand Down
12 changes: 3 additions & 9 deletions drivers/net/wireless/marvell/libertas_tf/if_usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,22 +198,16 @@ static int if_usb_probe(struct usb_interface *intf,
}

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

cardp->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!cardp->tx_urb) {
lbtf_deb_usbd(&udev->dev, "Tx URB allocation failed\n");
if (!cardp->tx_urb)
goto dealloc;
}

cardp->cmd_urb = usb_alloc_urb(0, GFP_KERNEL);
if (!cardp->cmd_urb) {
lbtf_deb_usbd(&udev->dev, "Cmd URB allocation failed\n");
if (!cardp->cmd_urb)
goto dealloc;
}

cardp->ep_out_buf = kmalloc(MRVDRV_ETH_TX_PACKET_BUFFER_SIZE,
GFP_KERNEL);
Expand Down
19 changes: 4 additions & 15 deletions drivers/net/wireless/marvell/mwifiex/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,11 +657,8 @@ static int mwifiex_usb_tx_init(struct mwifiex_adapter *adapter)
card->tx_cmd.ep = card->tx_cmd_ep;

card->tx_cmd.urb = usb_alloc_urb(0, GFP_KERNEL);
if (!card->tx_cmd.urb) {
mwifiex_dbg(adapter, ERROR,
"tx_cmd.urb allocation failed\n");
if (!card->tx_cmd.urb)
return -ENOMEM;
}

for (i = 0; i < MWIFIEX_TX_DATA_PORT; i++) {
port = &card->port[i];
Expand All @@ -677,11 +674,8 @@ static int mwifiex_usb_tx_init(struct mwifiex_adapter *adapter)
port->tx_data_list[j].ep = port->tx_data_ep;
port->tx_data_list[j].urb =
usb_alloc_urb(0, GFP_KERNEL);
if (!port->tx_data_list[j].urb) {
mwifiex_dbg(adapter, ERROR,
"urb allocation failed\n");
if (!port->tx_data_list[j].urb)
return -ENOMEM;
}
}
}

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

card->rx_cmd.urb = usb_alloc_urb(0, GFP_KERNEL);
if (!card->rx_cmd.urb) {
mwifiex_dbg(adapter, ERROR, "rx_cmd.urb allocation failed\n");
if (!card->rx_cmd.urb)
return -ENOMEM;
}

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

card->rx_data_list[i].urb = usb_alloc_urb(0, GFP_KERNEL);
if (!card->rx_data_list[i].urb) {
mwifiex_dbg(adapter, ERROR,
"rx_data_list[] urb allocation failed\n");
if (!card->rx_data_list[i].urb)
return -1;
}
if (mwifiex_usb_submit_rx_urb(&card->rx_data_list[i],
MWIFIEX_RX_DATA_BUF_SIZE))
return -1;
Expand Down
Loading

0 comments on commit 7056783

Please sign in to comment.