Commit 6f83ab76 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

greybus: es1-ap-usb: more init framework added.

parent f1eec30a
...@@ -18,19 +18,31 @@ static const struct usb_device_id id_table[] = { ...@@ -18,19 +18,31 @@ static const struct usb_device_id id_table[] = {
}; };
MODULE_DEVICE_TABLE(usb, 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 * Hack, we "know" we will only have one of these at any one time, so only
* create one static structure pointer. * create one static structure pointer.
*/ */
struct es1_ap_dev { static struct es1_ap_dev *es1_ap_dev;
struct usb_interface *usb_intf;
} *es1_ap_dev;
static int ap_probe(struct usb_interface *interface, static int ap_probe(struct usb_interface *interface,
const struct usb_device_id *id) 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) { if (es1_ap_dev) {
dev_err(&interface->dev, "Already have a es1_ap_dev???\n"); dev_err(&interface->dev, "Already have a es1_ap_dev???\n");
return -ENODEV; return -ENODEV;
...@@ -39,7 +51,30 @@ static int ap_probe(struct usb_interface *interface, ...@@ -39,7 +51,30 @@ static int ap_probe(struct usb_interface *interface,
if (!es1_ap_dev) if (!es1_ap_dev)
return -ENOMEM; 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_intf = interface;
es1_ap_dev->usb_dev = usb_get_dev(interface_to_usbdev(interface));
usb_set_intfdata(interface, es1_ap_dev); usb_set_intfdata(interface, es1_ap_dev);
return 0; return 0;
} }
...@@ -50,6 +85,8 @@ static void ap_disconnect(struct usb_interface *interface) ...@@ -50,6 +85,8 @@ static void ap_disconnect(struct usb_interface *interface)
/* Tear down everything! */ /* Tear down everything! */
usb_put_dev(es1_ap_dev->usb_dev);
kfree(es1_ap_dev->ap_buffer);
kfree(es1_ap_dev); kfree(es1_ap_dev);
es1_ap_dev = NULL; es1_ap_dev = NULL;
......
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