aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/class
diff options
context:
space:
mode:
authorJohan Hovold <jhovold@gmail.com>2011-03-22 06:12:23 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-04-13 19:18:33 -0400
commit74f5e1babde76149c2bb35ca5dbf4d0b9b38f161 (patch)
treee1decdeda369dd635e8a1c4def9c7582c623560c /drivers/usb/class
parent94d4c8919de3ae9e2e029ed121adfed43803bb5d (diff)
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>
Diffstat (limited to 'drivers/usb/class')
-rw-r--r--drivers/usb/class/cdc-acm.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index f239e3bd6423..519c7b933508 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1177,8 +1177,17 @@ made_compressed_probe:
1177 goto alloc_fail5; 1177 goto alloc_fail5;
1178 } 1178 }
1179 for (i = 0; i < num_rx_buf; i++) { 1179 for (i = 0; i < num_rx_buf; i++) {
1180 struct acm_rb *rb = &(acm->rb[i]);
1180 struct acm_ru *rcv = &(acm->ru[i]); 1181 struct acm_ru *rcv = &(acm->ru[i]);
1181 1182
1183 rb->base = usb_alloc_coherent(acm->dev, readsize, GFP_KERNEL,
1184 &rb->dma);
1185 if (!rb->base) {
1186 dev_err(&intf->dev, "out of memory "
1187 "(read bufs usb_alloc_coherent)\n");
1188 goto alloc_fail6;
1189 }
1190
1182 rcv->urb = usb_alloc_urb(0, GFP_KERNEL); 1191 rcv->urb = usb_alloc_urb(0, GFP_KERNEL);
1183 if (rcv->urb == NULL) { 1192 if (rcv->urb == NULL) {
1184 dev_err(&intf->dev, 1193 dev_err(&intf->dev,
@@ -1189,17 +1198,6 @@ made_compressed_probe:
1189 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP; 1198 rcv->urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
1190 rcv->instance = acm; 1199 rcv->instance = acm;
1191 } 1200 }
1192 for (i = 0; i < num_rx_buf; i++) {
1193 struct acm_rb *rb = &(acm->rb[i]);
1194
1195 rb->base = usb_alloc_coherent(acm->dev, readsize,
1196 GFP_KERNEL, &rb->dma);
1197 if (!rb->base) {
1198 dev_err(&intf->dev,
1199 "out of memory (read bufs usb_alloc_coherent)\n");
1200 goto alloc_fail7;
1201 }
1202 }
1203 for (i = 0; i < ACM_NW; i++) { 1201 for (i = 0; i < ACM_NW; i++) {
1204 struct acm_wb *snd = &(acm->wb[i]); 1202 struct acm_wb *snd = &(acm->wb[i]);
1205 1203
@@ -1207,7 +1205,7 @@ made_compressed_probe:
1207 if (snd->urb == NULL) { 1205 if (snd->urb == NULL) {
1208 dev_err(&intf->dev, 1206 dev_err(&intf->dev,
1209 "out of memory (write urbs usb_alloc_urb)\n"); 1207 "out of memory (write urbs usb_alloc_urb)\n");
1210 goto alloc_fail8; 1208 goto alloc_fail7;
1211 } 1209 }
1212 1210
1213 if (usb_endpoint_xfer_int(epwrite)) 1211 if (usb_endpoint_xfer_int(epwrite))
@@ -1226,7 +1224,7 @@ made_compressed_probe:
1226 1224
1227 i = device_create_file(&intf->dev, &dev_attr_bmCapabilities); 1225 i = device_create_file(&intf->dev, &dev_attr_bmCapabilities);
1228 if (i < 0) 1226 if (i < 0)
1229 goto alloc_fail8; 1227 goto alloc_fail7;
1230 1228
1231 if (cfd) { /* export the country data */ 1229 if (cfd) { /* export the country data */
1232 acm->country_codes = kmalloc(cfd->bLength - 4, GFP_KERNEL); 1230 acm->country_codes = kmalloc(cfd->bLength - 4, GFP_KERNEL);
@@ -1278,14 +1276,13 @@ skip_countries:
1278 acm_table[minor] = acm; 1276 acm_table[minor] = acm;
1279 1277
1280 return 0; 1278 return 0;
1281alloc_fail8: 1279alloc_fail7:
1282 for (i = 0; i < ACM_NW; i++) 1280 for (i = 0; i < ACM_NW; i++)
1283 usb_free_urb(acm->wb[i].urb); 1281 usb_free_urb(acm->wb[i].urb);
1284alloc_fail7:
1285 acm_read_buffers_free(acm);
1286alloc_fail6: 1282alloc_fail6:
1287 for (i = 0; i < num_rx_buf; i++) 1283 for (i = 0; i < num_rx_buf; i++)
1288 usb_free_urb(acm->ru[i].urb); 1284 usb_free_urb(acm->ru[i].urb);
1285 acm_read_buffers_free(acm);
1289 usb_free_urb(acm->ctrlurb); 1286 usb_free_urb(acm->ctrlurb);
1290alloc_fail5: 1287alloc_fail5:
1291 acm_write_buffers_free(acm); 1288 acm_write_buffers_free(acm);