USB: cdc-acm: clean up read urb allocation
Allocate read urbs and read buffers in the same loop during probe. Signed-off-by: Johan Hovold <jhovold@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
This commit is contained in:
parent
94d4c8919d
commit
74f5e1babd
1 changed files with 13 additions and 16 deletions
|
@ -1177,8 +1177,17 @@ made_compressed_probe:
|
||||||
goto alloc_fail5;
|
goto alloc_fail5;
|
||||||
}
|
}
|
||||||
for (i = 0; i < num_rx_buf; i++) {
|
for (i = 0; i < num_rx_buf; i++) {
|
||||||
|
struct acm_rb *rb = &(acm->rb[i]);
|
||||||
struct acm_ru *rcv = &(acm->ru[i]);
|
struct acm_ru *rcv = &(acm->ru[i]);
|
||||||
|
|
||||||
|
rb->base = usb_alloc_coherent(acm->dev, readsize, GFP_KERNEL,
|
||||||
|
&rb->dma);
|
||||||
|
if (!rb->base) {
|
||||||
|
dev_err(&intf->dev, "out of memory "
|
||||||
|
"(read bufs usb_alloc_coherent)\n");
|
||||||
|
goto alloc_fail6;
|
||||||
|
}
|
||||||
|
|
||||||
rcv->urb = usb_alloc_urb(0, GFP_KERNEL);
|
rcv->urb = usb_alloc_urb(0, GFP_KERNEL);
|
||||||
if (rcv->urb == NULL) {
|
if (rcv->urb == NULL) {
|
||||||
dev_err(&intf->dev,
|
dev_err(&intf->dev,
|
||||||
|
@ -1189,17 +1198,6 @@ made_compressed_probe:
|
||||||
rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
||||||
rcv->instance = acm;
|
rcv->instance = acm;
|
||||||
}
|
}
|
||||||
for (i = 0; i < num_rx_buf; i++) {
|
|
||||||
struct acm_rb *rb = &(acm->rb[i]);
|
|
||||||
|
|
||||||
rb->base = usb_alloc_coherent(acm->dev, readsize,
|
|
||||||
GFP_KERNEL, &rb->dma);
|
|
||||||
if (!rb->base) {
|
|
||||||
dev_err(&intf->dev,
|
|
||||||
"out of memory (read bufs usb_alloc_coherent)\n");
|
|
||||||
goto alloc_fail7;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i = 0; i < ACM_NW; i++) {
|
for (i = 0; i < ACM_NW; i++) {
|
||||||
struct acm_wb *snd = &(acm->wb[i]);
|
struct acm_wb *snd = &(acm->wb[i]);
|
||||||
|
|
||||||
|
@ -1207,7 +1205,7 @@ made_compressed_probe:
|
||||||
if (snd->urb == NULL) {
|
if (snd->urb == NULL) {
|
||||||
dev_err(&intf->dev,
|
dev_err(&intf->dev,
|
||||||
"out of memory (write urbs usb_alloc_urb)\n");
|
"out of memory (write urbs usb_alloc_urb)\n");
|
||||||
goto alloc_fail8;
|
goto alloc_fail7;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usb_endpoint_xfer_int(epwrite))
|
if (usb_endpoint_xfer_int(epwrite))
|
||||||
|
@ -1226,7 +1224,7 @@ made_compressed_probe:
|
||||||
|
|
||||||
i = device_create_file(&intf->dev, &dev_attr_bmCapabilities);
|
i = device_create_file(&intf->dev, &dev_attr_bmCapabilities);
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
goto alloc_fail8;
|
goto alloc_fail7;
|
||||||
|
|
||||||
if (cfd) { /* export the country data */
|
if (cfd) { /* export the country data */
|
||||||
acm->country_codes = kmalloc(cfd->bLength - 4, GFP_KERNEL);
|
acm->country_codes = kmalloc(cfd->bLength - 4, GFP_KERNEL);
|
||||||
|
@ -1278,14 +1276,13 @@ skip_countries:
|
||||||
acm_table[minor] = acm;
|
acm_table[minor] = acm;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
alloc_fail8:
|
alloc_fail7:
|
||||||
for (i = 0; i < ACM_NW; i++)
|
for (i = 0; i < ACM_NW; i++)
|
||||||
usb_free_urb(acm->wb[i].urb);
|
usb_free_urb(acm->wb[i].urb);
|
||||||
alloc_fail7:
|
|
||||||
acm_read_buffers_free(acm);
|
|
||||||
alloc_fail6:
|
alloc_fail6:
|
||||||
for (i = 0; i < num_rx_buf; i++)
|
for (i = 0; i < num_rx_buf; i++)
|
||||||
usb_free_urb(acm->ru[i].urb);
|
usb_free_urb(acm->ru[i].urb);
|
||||||
|
acm_read_buffers_free(acm);
|
||||||
usb_free_urb(acm->ctrlurb);
|
usb_free_urb(acm->ctrlurb);
|
||||||
alloc_fail5:
|
alloc_fail5:
|
||||||
acm_write_buffers_free(acm);
|
acm_write_buffers_free(acm);
|
||||||
|
|
Loading…
Reference in a new issue