From 6f83ab76b8e6ed3d9b8187ffd97bfd68c8a9a045 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 30 Aug 2014 17:30:04 -0700 Subject: [PATCH] greybus: es1-ap-usb: more init framework added. --- drivers/staging/greybus/es1-ap-usb.c | 45 +++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/drivers/staging/greybus/es1-ap-usb.c b/drivers/staging/greybus/es1-ap-usb.c index 991a53846e79..bebef6dbae7b 100644 --- a/drivers/staging/greybus/es1-ap-usb.c +++ b/drivers/staging/greybus/es1-ap-usb.c @@ -18,19 +18,31 @@ static const struct usb_device_id id_table[] = { }; MODULE_DEVICE_TABLE(usb, id_table); +struct es1_ap_dev { + struct usb_device *usb_dev; + struct usb_interface *usb_intf; + + __u8 ap_in_endpoint; + __u8 ap_out_endpoint; + u8 *ap_buffer; + +}; + /* * Hack, we "know" we will only have one of these at any one time, so only * create one static structure pointer. */ -struct es1_ap_dev { - struct usb_interface *usb_intf; - -} *es1_ap_dev; +static struct es1_ap_dev *es1_ap_dev; static int ap_probe(struct usb_interface *interface, const struct usb_device_id *id) { + struct usb_host_interface *iface_desc; + struct usb_endpoint_descriptor *endpoint; + size_t buffer_size; + int i; + if (es1_ap_dev) { dev_err(&interface->dev, "Already have a es1_ap_dev???\n"); return -ENODEV; @@ -39,7 +51,30 @@ static int ap_probe(struct usb_interface *interface, if (!es1_ap_dev) return -ENOMEM; + // FIXME + // figure out endpoint for talking to the AP. + iface_desc = interface->cur_altsetting; + for (i = 0; i < iface_desc->desc.bNumEndpoints; ++i) { + endpoint = &iface_desc->endpoint[i].desc; + + if (usb_endpoint_is_bulk_in(endpoint)) { + buffer_size = usb_endpoint_maxp(endpoint); + // FIXME - Save buffer_size? + es1_ap_dev->ap_in_endpoint = endpoint->bEndpointAddress; + } + if (usb_endpoint_is_bulk_out(endpoint)) { + // FIXME - anything else about this we need? + es1_ap_dev->ap_out_endpoint = endpoint->bEndpointAddress; + } + // FIXME - properly exit once found the AP endpoint + // FIXME - set up cport endpoints + } + + // FIXME - allocate buffer + // FIXME = start up talking, then create the gb "devices" based on what the AP tells us. + es1_ap_dev->usb_intf = interface; + es1_ap_dev->usb_dev = usb_get_dev(interface_to_usbdev(interface)); usb_set_intfdata(interface, es1_ap_dev); return 0; } @@ -50,6 +85,8 @@ static void ap_disconnect(struct usb_interface *interface) /* Tear down everything! */ + usb_put_dev(es1_ap_dev->usb_dev); + kfree(es1_ap_dev->ap_buffer); kfree(es1_ap_dev); es1_ap_dev = NULL; -- 2.39.5