summaryrefslogtreecommitdiffstats
path: root/drivers/staging/greybus/es2.c
diff options
context:
space:
mode:
authorJohan Hovold <johan@hovoldconsulting.com>2016-05-11 10:18:01 +0200
committerGreg Kroah-Hartman <gregkh@google.com>2016-05-13 15:30:05 +0200
commit050615076699e537b26ed0934e105e78e7f1e765 (patch)
tree0324727c7a2aaa47e76d5baea810c5872220891d /drivers/staging/greybus/es2.c
parentbe5d01f10bdb782d31039930a9414c2f880e3430 (diff)
downloadop-kernel-dev-050615076699e537b26ed0934e105e78e7f1e765.zip
op-kernel-dev-050615076699e537b26ed0934e105e78e7f1e765.tar.gz
greybus: es2: clean up CDSI CPort reservation
Clean up the CDSI CPort reservation by adding a host-device helper and CPort defines. Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat (limited to 'drivers/staging/greybus/es2.c')
-rw-r--r--drivers/staging/greybus/es2.c25
1 files changed, 16 insertions, 9 deletions
diff --git a/drivers/staging/greybus/es2.c b/drivers/staging/greybus/es2.c
index f8bc3ec..c8ee779 100644
--- a/drivers/staging/greybus/es2.c
+++ b/drivers/staging/greybus/es2.c
@@ -18,6 +18,11 @@
#include "connection.h"
#include "greybus_trace.h"
+
+/* Fixed CPort numbers */
+#define ES2_CPORT_CDSI0 16
+#define ES2_CPORT_CDSI1 17
+
/* Memory sizes for the buffers sent to/from the ES2 controller */
#define ES2_GBUF_MSG_SIZE_MAX 2048
@@ -941,7 +946,6 @@ static int ap_probe(struct usb_interface *interface,
int retval;
int i;
int num_cports;
- int cport_id;
udev = usb_get_dev(interface_to_usbdev(interface));
@@ -960,14 +964,6 @@ static int ap_probe(struct usb_interface *interface,
return PTR_ERR(hd);
}
- /*
- * CPorts 16 and 17 are reserved for CDSI0 and CDSI1, make sure they
- * won't be allocated dynamically.
- */
- do {
- cport_id = ida_simple_get(&hd->cport_id_map, 16, 18, GFP_KERNEL);
- } while (cport_id > 0);
-
es2 = hd_to_es2(hd);
es2->hd = hd;
es2->usb_intf = interface;
@@ -976,6 +972,17 @@ static int ap_probe(struct usb_interface *interface,
INIT_KFIFO(es2->apb_log_fifo);
usb_set_intfdata(interface, es2);
+ /*
+ * Reserve the CDSI0 and CDSI1 CPorts so they won't be allocated
+ * dynamically.
+ */
+ retval = gb_hd_cport_reserve(hd, ES2_CPORT_CDSI0);
+ if (retval)
+ goto error;
+ retval = gb_hd_cport_reserve(hd, ES2_CPORT_CDSI1);
+ if (retval)
+ goto error;
+
es2->cport_to_ep = kcalloc(hd->num_cports, sizeof(*es2->cport_to_ep),
GFP_KERNEL);
if (!es2->cport_to_ep) {
OpenPOWER on IntegriCloud