aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@google.com>2016-08-17 10:37:39 -0400
committerGreg Kroah-Hartman <gregkh@google.com>2016-09-02 08:20:56 -0400
commit7330c48ec09367e8da65e3ebf642b6c37bf244e3 (patch)
treed7c4d316699db3ab24c6c41f84273a50c200b4cd /drivers/staging
parent403074b50b66f1a6cd038bd9f60119d69916a928 (diff)
greybus: es2: remove bulk_in array
We only care about one bulk IN endpoint for cports, and one for ARPC, so drop the array of bulk IN endpoints to simplify things. Reviewed-by: Johan Hovold <johan@hovoldconsulting.com> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging')
-rw-r--r--drivers/staging/greybus/es2.c93
1 files changed, 38 insertions, 55 deletions
diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c
index c6c078642e92..69123b7ee94b 100644
--- a/drivers/staging/greybus/es2.c
+++ b/drivers/staging/greybus/es2.c
@@ -114,7 +114,7 @@ struct es2_ap_dev {
114 struct usb_interface *usb_intf; 114 struct usb_interface *usb_intf;
115 struct gb_host_device *hd; 115 struct gb_host_device *hd;
116 116
117 struct es2_cport_in cport_in[NUM_BULKS]; 117 struct es2_cport_in cport_in;
118 __u8 cport_out_endpoint; 118 __u8 cport_out_endpoint;
119 struct urb *cport_out_urb[NUM_CPORT_OUT_URB]; 119 struct urb *cport_out_urb[NUM_CPORT_OUT_URB];
120 bool cport_out_urb_busy[NUM_CPORT_OUT_URB]; 120 bool cport_out_urb_busy[NUM_CPORT_OUT_URB];
@@ -920,7 +920,6 @@ static int check_urb_status(struct urb *urb)
920static void es2_destroy(struct es2_ap_dev *es2) 920static void es2_destroy(struct es2_ap_dev *es2)
921{ 921{
922 struct usb_device *udev; 922 struct usb_device *udev;
923 int bulk_in;
924 int i; 923 int i;
925 924
926 debugfs_remove(es2->apb_log_enable_dentry); 925 debugfs_remove(es2->apb_log_enable_dentry);
@@ -948,18 +947,10 @@ static void es2_destroy(struct es2_ap_dev *es2)
948 es2->arpc_buffer[i] = NULL; 947 es2->arpc_buffer[i] = NULL;
949 } 948 }
950 949
951 for (bulk_in = 0; bulk_in < NUM_BULKS; bulk_in++) { 950 for (i = 0; i < NUM_CPORT_IN_URB; ++i) {
952 struct es2_cport_in *cport_in = &es2->cport_in[bulk_in]; 951 usb_free_urb(es2->cport_in.urb[i]);
953 952 kfree(es2->cport_in.buffer[i]);
954 for (i = 0; i < NUM_CPORT_IN_URB; ++i) { 953 es2->cport_in.buffer[i] = NULL;
955 struct urb *urb = cport_in->urb[i];
956
957 if (!urb)
958 break;
959 usb_free_urb(urb);
960 kfree(cport_in->buffer[i]);
961 cport_in->buffer[i] = NULL;
962 }
963 } 954 }
964 955
965 /* release reserved CDSI0 and CDSI1 cports */ 956 /* release reserved CDSI0 and CDSI1 cports */
@@ -1412,11 +1403,12 @@ static int ap_probe(struct usb_interface *interface,
1412 struct usb_device *udev; 1403 struct usb_device *udev;
1413 struct usb_host_interface *iface_desc; 1404 struct usb_host_interface *iface_desc;
1414 struct usb_endpoint_descriptor *endpoint; 1405 struct usb_endpoint_descriptor *endpoint;
1415 int bulk_in = 0;
1416 int retval; 1406 int retval;
1417 int i; 1407 int i;
1418 int num_cports; 1408 int num_cports;
1419 bool bulk_out_found = false; 1409 bool bulk_out_found = false;
1410 bool bulk_in_found = false;
1411 bool arpc_in_found = false;
1420 1412
1421 udev = usb_get_dev(interface_to_usbdev(interface)); 1413 udev = usb_get_dev(interface_to_usbdev(interface));
1422 1414
@@ -1460,13 +1452,15 @@ static int ap_probe(struct usb_interface *interface,
1460 endpoint = &iface_desc->endpoint[i].desc; 1452 endpoint = &iface_desc->endpoint[i].desc;
1461 1453
1462 if (usb_endpoint_is_bulk_in(endpoint)) { 1454 if (usb_endpoint_is_bulk_in(endpoint)) {
1463 if (bulk_in < NUM_BULKS) 1455 if (!bulk_in_found) {
1464 es2->cport_in[bulk_in].endpoint = 1456 es2->cport_in.endpoint =
1465 endpoint->bEndpointAddress; 1457 endpoint->bEndpointAddress;
1466 else 1458 bulk_in_found = true;
1459 } else if (!arpc_in_found) {
1467 es2->arpc_endpoint_in = 1460 es2->arpc_endpoint_in =
1468 endpoint->bEndpointAddress; 1461 endpoint->bEndpointAddress;
1469 bulk_in++; 1462 arpc_in_found = true;
1463 }
1470 } else if (usb_endpoint_is_bulk_out(endpoint) && 1464 } else if (usb_endpoint_is_bulk_out(endpoint) &&
1471 (!bulk_out_found)) { 1465 (!bulk_out_found)) {
1472 es2->cport_out_endpoint = endpoint->bEndpointAddress; 1466 es2->cport_out_endpoint = endpoint->bEndpointAddress;
@@ -1477,41 +1471,36 @@ static int ap_probe(struct usb_interface *interface,
1477 endpoint->bEndpointAddress); 1471 endpoint->bEndpointAddress);
1478 } 1472 }
1479 } 1473 }
1480 if (bulk_in != NUM_BULKS_IN || !bulk_out_found) { 1474 if (!bulk_in_found || !arpc_in_found || !bulk_out_found) {
1481 dev_err(&udev->dev, "Not enough endpoints found in device, aborting!\n"); 1475 dev_err(&udev->dev, "Not enough endpoints found in device, aborting!\n");
1482 retval = -ENODEV; 1476 retval = -ENODEV;
1483 goto error; 1477 goto error;
1484 } 1478 }
1485 1479
1486 /* Allocate buffers for our cport in messages */ 1480 /* Allocate buffers for our cport in messages */
1487 for (bulk_in = 0; bulk_in < NUM_BULKS; bulk_in++) { 1481 for (i = 0; i < NUM_CPORT_IN_URB; ++i) {
1488 struct es2_cport_in *cport_in = &es2->cport_in[bulk_in]; 1482 struct urb *urb;
1489 1483 u8 *buffer;
1490 for (i = 0; i < NUM_CPORT_IN_URB; ++i) {
1491 struct urb *urb;
1492 u8 *buffer;
1493 1484
1494 urb = usb_alloc_urb(0, GFP_KERNEL); 1485 urb = usb_alloc_urb(0, GFP_KERNEL);
1495 if (!urb) { 1486 if (!urb) {
1496 retval = -ENOMEM; 1487 retval = -ENOMEM;
1497 goto error; 1488 goto error;
1498 } 1489 }
1499 cport_in->urb[i] = urb; 1490 es2->cport_in.urb[i] = urb;
1500 1491
1501 buffer = kmalloc(ES2_GBUF_MSG_SIZE_MAX, GFP_KERNEL); 1492 buffer = kmalloc(ES2_GBUF_MSG_SIZE_MAX, GFP_KERNEL);
1502 if (!buffer) { 1493 if (!buffer) {
1503 retval = -ENOMEM; 1494 retval = -ENOMEM;
1504 goto error; 1495 goto error;
1505 } 1496 }
1506 1497
1507 usb_fill_bulk_urb(urb, udev, 1498 usb_fill_bulk_urb(urb, udev,
1508 usb_rcvbulkpipe(udev, 1499 usb_rcvbulkpipe(udev, es2->cport_in.endpoint),
1509 cport_in->endpoint), 1500 buffer, ES2_GBUF_MSG_SIZE_MAX,
1510 buffer, ES2_GBUF_MSG_SIZE_MAX, 1501 cport_in_callback, hd);
1511 cport_in_callback, hd);
1512 1502
1513 cport_in->buffer[i] = buffer; 1503 es2->cport_in.buffer[i] = buffer;
1514 }
1515 } 1504 }
1516 1505
1517 /* Allocate buffers for ARPC in messages */ 1506 /* Allocate buffers for ARPC in messages */
@@ -1571,17 +1560,13 @@ static int ap_probe(struct usb_interface *interface,
1571 if (retval) 1560 if (retval)
1572 goto err_disable_arpc_in; 1561 goto err_disable_arpc_in;
1573 1562
1574 for (i = 0; i < NUM_BULKS; ++i) { 1563 retval = es2_cport_in_enable(es2, &es2->cport_in);
1575 retval = es2_cport_in_enable(es2, &es2->cport_in[i]); 1564 if (retval)
1576 if (retval) 1565 goto err_hd_del;
1577 goto err_disable_cport_in;
1578 }
1579 1566
1580 return 0; 1567 return 0;
1581 1568
1582err_disable_cport_in: 1569err_hd_del:
1583 for (--i; i >= 0; --i)
1584 es2_cport_in_disable(es2, &es2->cport_in[i]);
1585 gb_hd_del(hd); 1570 gb_hd_del(hd);
1586err_disable_arpc_in: 1571err_disable_arpc_in:
1587 es2_arpc_in_disable(es2); 1572 es2_arpc_in_disable(es2);
@@ -1594,12 +1579,10 @@ error:
1594static void ap_disconnect(struct usb_interface *interface) 1579static void ap_disconnect(struct usb_interface *interface)
1595{ 1580{
1596 struct es2_ap_dev *es2 = usb_get_intfdata(interface); 1581 struct es2_ap_dev *es2 = usb_get_intfdata(interface);
1597 int i;
1598 1582
1599 gb_hd_del(es2->hd); 1583 gb_hd_del(es2->hd);
1600 1584
1601 for (i = 0; i < NUM_BULKS; ++i) 1585 es2_cport_in_disable(es2, &es2->cport_in);
1602 es2_cport_in_disable(es2, &es2->cport_in[i]);
1603 es2_arpc_in_disable(es2); 1586 es2_arpc_in_disable(es2);
1604 1587
1605 es2_destroy(es2); 1588 es2_destroy(es2);