From f1eec30ac83cf95d0607a1c736cf42b44846bad8 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Sat, 30 Aug 2014 17:18:14 -0700 Subject: [PATCH] greybus: first framework for the es1 ap controller --- drivers/staging/greybus/es1-ap-usb.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/staging/greybus/es1-ap-usb.c b/drivers/staging/greybus/es1-ap-usb.c index 05c724881b07..991a53846e79 100644 --- a/drivers/staging/greybus/es1-ap-usb.c +++ b/drivers/staging/greybus/es1-ap-usb.c @@ -18,17 +18,40 @@ static const struct usb_device_id id_table[] = { }; MODULE_DEVICE_TABLE(usb, id_table); +/* + * 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 int ap_probe(struct usb_interface *interface, const struct usb_device_id *id) { + if (es1_ap_dev) { + dev_err(&interface->dev, "Already have a es1_ap_dev???\n"); + return -ENODEV; + } + es1_ap_dev = kzalloc(sizeof(*es1_ap_dev), GFP_KERNEL); + if (!es1_ap_dev) + return -ENOMEM; + es1_ap_dev->usb_intf = interface; + usb_set_intfdata(interface, es1_ap_dev); return 0; } static void ap_disconnect(struct usb_interface *interface) { + es1_ap_dev = usb_get_intfdata(interface); + + /* Tear down everything! */ + kfree(es1_ap_dev); + es1_ap_dev = NULL; } -- 2.39.5