Commit 7330c48e authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

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: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 403074b5
...@@ -114,7 +114,7 @@ struct es2_ap_dev { ...@@ -114,7 +114,7 @@ struct es2_ap_dev {
struct usb_interface *usb_intf; struct usb_interface *usb_intf;
struct gb_host_device *hd; struct gb_host_device *hd;
struct es2_cport_in cport_in[NUM_BULKS]; struct es2_cport_in cport_in;
__u8 cport_out_endpoint; __u8 cport_out_endpoint;
struct urb *cport_out_urb[NUM_CPORT_OUT_URB]; struct urb *cport_out_urb[NUM_CPORT_OUT_URB];
bool cport_out_urb_busy[NUM_CPORT_OUT_URB]; bool cport_out_urb_busy[NUM_CPORT_OUT_URB];
...@@ -920,7 +920,6 @@ static int check_urb_status(struct urb *urb) ...@@ -920,7 +920,6 @@ static int check_urb_status(struct urb *urb)
static void es2_destroy(struct es2_ap_dev *es2) static void es2_destroy(struct es2_ap_dev *es2)
{ {
struct usb_device *udev; struct usb_device *udev;
int bulk_in;
int i; int i;
debugfs_remove(es2->apb_log_enable_dentry); debugfs_remove(es2->apb_log_enable_dentry);
...@@ -948,18 +947,10 @@ static void es2_destroy(struct es2_ap_dev *es2) ...@@ -948,18 +947,10 @@ static void es2_destroy(struct es2_ap_dev *es2)
es2->arpc_buffer[i] = NULL; es2->arpc_buffer[i] = NULL;
} }
for (bulk_in = 0; bulk_in < NUM_BULKS; bulk_in++) { for (i = 0; i < NUM_CPORT_IN_URB; ++i) {
struct es2_cport_in *cport_in = &es2->cport_in[bulk_in]; usb_free_urb(es2->cport_in.urb[i]);
kfree(es2->cport_in.buffer[i]);
for (i = 0; i < NUM_CPORT_IN_URB; ++i) { es2->cport_in.buffer[i] = NULL;
struct urb *urb = cport_in->urb[i];
if (!urb)
break;
usb_free_urb(urb);
kfree(cport_in->buffer[i]);
cport_in->buffer[i] = NULL;
}
} }
/* release reserved CDSI0 and CDSI1 cports */ /* release reserved CDSI0 and CDSI1 cports */
...@@ -1412,11 +1403,12 @@ static int ap_probe(struct usb_interface *interface, ...@@ -1412,11 +1403,12 @@ static int ap_probe(struct usb_interface *interface,
struct usb_device *udev; struct usb_device *udev;
struct usb_host_interface *iface_desc; struct usb_host_interface *iface_desc;
struct usb_endpoint_descriptor *endpoint; struct usb_endpoint_descriptor *endpoint;
int bulk_in = 0;
int retval; int retval;
int i; int i;
int num_cports; int num_cports;
bool bulk_out_found = false; bool bulk_out_found = false;
bool bulk_in_found = false;
bool arpc_in_found = false;
udev = usb_get_dev(interface_to_usbdev(interface)); udev = usb_get_dev(interface_to_usbdev(interface));
...@@ -1460,13 +1452,15 @@ static int ap_probe(struct usb_interface *interface, ...@@ -1460,13 +1452,15 @@ static int ap_probe(struct usb_interface *interface,
endpoint = &iface_desc->endpoint[i].desc; endpoint = &iface_desc->endpoint[i].desc;
if (usb_endpoint_is_bulk_in(endpoint)) { if (usb_endpoint_is_bulk_in(endpoint)) {
if (bulk_in < NUM_BULKS) if (!bulk_in_found) {
es2->cport_in[bulk_in].endpoint = es2->cport_in.endpoint =
endpoint->bEndpointAddress; endpoint->bEndpointAddress;
else bulk_in_found = true;
} else if (!arpc_in_found) {
es2->arpc_endpoint_in = es2->arpc_endpoint_in =
endpoint->bEndpointAddress; endpoint->bEndpointAddress;
bulk_in++; arpc_in_found = true;
}
} else if (usb_endpoint_is_bulk_out(endpoint) && } else if (usb_endpoint_is_bulk_out(endpoint) &&
(!bulk_out_found)) { (!bulk_out_found)) {
es2->cport_out_endpoint = endpoint->bEndpointAddress; es2->cport_out_endpoint = endpoint->bEndpointAddress;
...@@ -1477,41 +1471,36 @@ static int ap_probe(struct usb_interface *interface, ...@@ -1477,41 +1471,36 @@ static int ap_probe(struct usb_interface *interface,
endpoint->bEndpointAddress); endpoint->bEndpointAddress);
} }
} }
if (bulk_in != NUM_BULKS_IN || !bulk_out_found) { if (!bulk_in_found || !arpc_in_found || !bulk_out_found) {
dev_err(&udev->dev, "Not enough endpoints found in device, aborting!\n"); dev_err(&udev->dev, "Not enough endpoints found in device, aborting!\n");
retval = -ENODEV; retval = -ENODEV;
goto error; goto error;
} }
/* Allocate buffers for our cport in messages */ /* Allocate buffers for our cport in messages */
for (bulk_in = 0; bulk_in < NUM_BULKS; bulk_in++) { for (i = 0; i < NUM_CPORT_IN_URB; ++i) {
struct es2_cport_in *cport_in = &es2->cport_in[bulk_in]; struct urb *urb;
u8 *buffer;
for (i = 0; i < NUM_CPORT_IN_URB; ++i) {
struct urb *urb;
u8 *buffer;
urb = usb_alloc_urb(0, GFP_KERNEL); urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) { if (!urb) {
retval = -ENOMEM; retval = -ENOMEM;
goto error; goto error;
} }
cport_in->urb[i] = urb; es2->cport_in.urb[i] = urb;
buffer = kmalloc(ES2_GBUF_MSG_SIZE_MAX, GFP_KERNEL); buffer = kmalloc(ES2_GBUF_MSG_SIZE_MAX, GFP_KERNEL);
if (!buffer) { if (!buffer) {
retval = -ENOMEM; retval = -ENOMEM;
goto error; goto error;
} }
usb_fill_bulk_urb(urb, udev, usb_fill_bulk_urb(urb, udev,
usb_rcvbulkpipe(udev, usb_rcvbulkpipe(udev, es2->cport_in.endpoint),
cport_in->endpoint), buffer, ES2_GBUF_MSG_SIZE_MAX,
buffer, ES2_GBUF_MSG_SIZE_MAX, cport_in_callback, hd);
cport_in_callback, hd);
cport_in->buffer[i] = buffer; es2->cport_in.buffer[i] = buffer;
}
} }
/* Allocate buffers for ARPC in messages */ /* Allocate buffers for ARPC in messages */
...@@ -1571,17 +1560,13 @@ static int ap_probe(struct usb_interface *interface, ...@@ -1571,17 +1560,13 @@ static int ap_probe(struct usb_interface *interface,
if (retval) if (retval)
goto err_disable_arpc_in; goto err_disable_arpc_in;
for (i = 0; i < NUM_BULKS; ++i) { retval = es2_cport_in_enable(es2, &es2->cport_in);
retval = es2_cport_in_enable(es2, &es2->cport_in[i]); if (retval)
if (retval) goto err_hd_del;
goto err_disable_cport_in;
}
return 0; return 0;
err_disable_cport_in: err_hd_del:
for (--i; i >= 0; --i)
es2_cport_in_disable(es2, &es2->cport_in[i]);
gb_hd_del(hd); gb_hd_del(hd);
err_disable_arpc_in: err_disable_arpc_in:
es2_arpc_in_disable(es2); es2_arpc_in_disable(es2);
...@@ -1594,12 +1579,10 @@ static int ap_probe(struct usb_interface *interface, ...@@ -1594,12 +1579,10 @@ static int ap_probe(struct usb_interface *interface,
static void ap_disconnect(struct usb_interface *interface) static void ap_disconnect(struct usb_interface *interface)
{ {
struct es2_ap_dev *es2 = usb_get_intfdata(interface); struct es2_ap_dev *es2 = usb_get_intfdata(interface);
int i;
gb_hd_del(es2->hd); gb_hd_del(es2->hd);
for (i = 0; i < NUM_BULKS; ++i) es2_cport_in_disable(es2, &es2->cport_in);
es2_cport_in_disable(es2, &es2->cport_in[i]);
es2_arpc_in_disable(es2); es2_arpc_in_disable(es2);
es2_destroy(es2); es2_destroy(es2);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment