diff options
author | Fabien Parent <fparent@baylibre.com> | 2015-09-02 15:50:36 +0200 |
---|---|---|
committer | Johan Hovold <johan@hovoldconsulting.com> | 2015-09-02 16:24:49 +0200 |
commit | c011d558e19aa9b6bb739426f5553bf3e1ad5a69 (patch) | |
tree | ee7753d1706c4d632cb821ccd0f92e2b3c081ef9 /drivers | |
parent | 144670c2ae3f9b452e021a9032b25730d296ba53 (diff) |
greybus: es2: dynamically allocate array for cport <-> ep mapping
In order to be able to dynamically determine the number of CPorts supported
by the UniPro IP instead of hardcoding the value we need to dynamically
allocate the array that is doing the cport-ep mapping.
Signed-off-by: Fabien Parent <fparent@baylibre.com>
Reviewed-by: Johan Hovold <johan@hovoldconsulting.com>
Signed-off-by: Johan Hovold <johan@hovoldconsulting.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/staging/greybus/es2.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c index 4b1f34fe1a60..909ca6acae1c 100644 --- a/drivers/staging/greybus/es2.c +++ b/drivers/staging/greybus/es2.c @@ -108,7 +108,7 @@ struct es1_ap_dev { bool cport_out_urb_cancelled[NUM_CPORT_OUT_URB]; spinlock_t cport_out_urb_lock; - int cport_to_ep[CPORT_COUNT]; + int *cport_to_ep; }; struct cport_to_ep { @@ -443,6 +443,7 @@ static void ap_disconnect(struct usb_interface *interface) usb_set_intfdata(interface, NULL); udev = es1->usb_dev; greybus_remove_hd(es1->hd); + kfree(es1->cport_to_ep); usb_put_dev(udev); } @@ -678,6 +679,13 @@ static int ap_probe(struct usb_interface *interface, endpoint = &udev->ep0.desc; es1->control_endpoint = endpoint->bEndpointAddress; + es1->cport_to_ep = kcalloc(hd->num_cports, sizeof(*es1->cport_to_ep), + GFP_KERNEL); + if (!es1->cport_to_ep) { + retval = -ENOMEM; + goto error; + } + /* find all 3 of our endpoints */ iface_desc = interface->cur_altsetting; for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { |