diff options
author | Benoit Goby <benoit@android.com> | 2012-11-05 18:47:08 -0800 |
---|---|---|
committer | Arve Hjønnevåg <arve@android.com> | 2013-07-01 15:51:56 -0700 |
commit | de8cff675b3de92ad4bb18a69cfe19091e810f49 (patch) | |
tree | ed0b96d94764a020902723eedaf609b1fe5b85b6 /drivers/usb/gadget/android.c | |
parent | b94f8f691c550d1e07c21d6c672b916377c9d6d4 (diff) |
usb: gadget: Fix android gadget driver build
Removed obsolete f_adb function
Change-Id: Idfb4110429bc0ea63f493c68ad667f49ca471987
Signed-off-by: Benoit Goby <benoit@android.com>
Diffstat (limited to 'drivers/usb/gadget/android.c')
-rw-r--r-- | drivers/usb/gadget/android.c | 165 |
1 files changed, 35 insertions, 130 deletions
diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c index 23b5c46eadf..11d247cc0e9 100644 --- a/drivers/usb/gadget/android.c +++ b/drivers/usb/gadget/android.c @@ -30,24 +30,11 @@ #include "gadget_chips.h" -/* - * Kbuild is not very cooperative with respect to linking separately - * compiled library objects into one module. So for now we won't use - * separate compilation ... ensuring init/exit sections work to shrink - * the runtime footprint, and giving us at least some parts of what - * a "gcc --combine ... part1.c part2.c part3.c ... " build would. - */ -#include "usbstring.c" -#include "config.c" -#include "epautoconf.c" -#include "composite.c" - #include "f_fs.c" #include "f_audio_source.c" #include "f_mass_storage.c" #include "u_serial.c" #include "f_acm.c" -#include "f_adb.c" #include "f_mtp.c" #include "f_accessory.c" #define USB_ETH_RNDIS y @@ -376,99 +363,6 @@ static void functionfs_release_dev_callback(struct ffs_data *ffs_data) { } -struct adb_data { - bool opened; - bool enabled; -}; - -static int -adb_function_init(struct android_usb_function *f, - struct usb_composite_dev *cdev) -{ - f->config = kzalloc(sizeof(struct adb_data), GFP_KERNEL); - if (!f->config) - return -ENOMEM; - - return adb_setup(); -} - -static void adb_function_cleanup(struct android_usb_function *f) -{ - adb_cleanup(); - kfree(f->config); -} - -static int -adb_function_bind_config(struct android_usb_function *f, - struct usb_configuration *c) -{ - return adb_bind_config(c); -} - -static void adb_android_function_enable(struct android_usb_function *f) -{ - struct android_dev *dev = _android_dev; - struct adb_data *data = f->config; - - data->enabled = true; - - /* Disable the gadget until adbd is ready */ - if (!data->opened) - android_disable(dev); -} - -static void adb_android_function_disable(struct android_usb_function *f) -{ - struct android_dev *dev = _android_dev; - struct adb_data *data = f->config; - - data->enabled = false; - - /* Balance the disable that was called in closed_callback */ - if (!data->opened) - android_enable(dev); -} - -static struct android_usb_function adb_function = { - .name = "adb", - .enable = adb_android_function_enable, - .disable = adb_android_function_disable, - .init = adb_function_init, - .cleanup = adb_function_cleanup, - .bind_config = adb_function_bind_config, -}; - -static void adb_ready_callback(void) -{ - struct android_dev *dev = _android_dev; - struct adb_data *data = adb_function.config; - - mutex_lock(&dev->mutex); - - data->opened = true; - - if (data->enabled) - android_enable(dev); - - mutex_unlock(&dev->mutex); -} - -static void adb_closed_callback(void) -{ - struct android_dev *dev = _android_dev; - struct adb_data *data = adb_function.config; - - mutex_lock(&dev->mutex); - - data->opened = false; - - if (data->enabled) - android_disable(dev); - - mutex_unlock(&dev->mutex); -} - - #define MAX_ACM_INSTANCES 4 struct acm_function_config { int instances; @@ -985,7 +879,6 @@ static struct android_usb_function audio_source_function = { static struct android_usb_function *supported_functions[] = { &ffs_function, - &adb_function, &acm_function, &mtp_function, &ptp_function, @@ -1417,13 +1310,8 @@ static int android_usb_unbind(struct usb_composite_dev *cdev) return 0; } -static struct usb_composite_driver android_usb_driver = { - .name = "android_usb", - .dev = &device_desc, - .strings = dev_strings, - .unbind = android_usb_unbind, - .max_speed = USB_SPEED_HIGH, -}; +/* HACK: android needs to override setup for accessory to work */ +static int (*composite_setup)(struct usb_gadget *gadget, const struct usb_ctrlrequest *c); static int android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c) @@ -1436,7 +1324,6 @@ android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c) unsigned long flags; req->zero = 0; - req->complete = composite_setup_complete; req->length = 0; gadget->ep0->driver_data = cdev; @@ -1470,25 +1357,30 @@ android_setup(struct usb_gadget *gadget, const struct usb_ctrlrequest *c) return value; } -static void android_disconnect(struct usb_gadget *gadget) +static void android_disconnect(struct usb_composite_dev *cdev) { struct android_dev *dev = _android_dev; - struct usb_composite_dev *cdev = get_gadget_data(gadget); - unsigned long flags; - composite_disconnect(gadget); /* accessory HID support can be active while the accessory function is not actually enabled, so we need to inform it when we are disconnected. */ acc_disconnect(); - spin_lock_irqsave(&cdev->lock, flags); dev->connected = 0; schedule_work(&dev->work); - spin_unlock_irqrestore(&cdev->lock, flags); } +static struct usb_composite_driver android_usb_driver = { + .name = "android_usb", + .dev = &device_desc, + .strings = dev_strings, + .bind = android_bind, + .unbind = android_usb_unbind, + .disconnect = android_disconnect, + .max_speed = USB_SPEED_HIGH, +}; + static int android_create_device(struct android_dev *dev) { struct device_attribute **attrs = android_usb_attributes; @@ -1523,8 +1415,10 @@ static int __init init(void) return PTR_ERR(android_class); dev = kzalloc(sizeof(*dev), GFP_KERNEL); - if (!dev) - return -ENOMEM; + if (!dev) { + err = -ENOMEM; + goto err_dev; + } dev->disable_depth = 1; dev->functions = supported_functions; @@ -1534,18 +1428,29 @@ static int __init init(void) err = android_create_device(dev); if (err) { - class_destroy(android_class); - kfree(dev); - return err; + pr_err("%s: failed to create android device %d", __func__, err); + goto err_create; } _android_dev = dev; - /* Override composite driver functions */ - composite_driver.setup = android_setup; - composite_driver.disconnect = android_disconnect; + err = usb_composite_probe(&android_usb_driver); + if (err) { + pr_err("%s: failed to probe driver %d", __func__, err); + goto err_create; + } + + /* HACK: exchange composite's setup with ours */ + composite_setup = android_usb_driver.gadget_driver.setup; + android_usb_driver.gadget_driver.setup = android_setup; - return usb_composite_probe(&android_usb_driver, android_bind); + return 0; + +err_create: + kfree(dev); +err_dev: + class_destroy(android_class); + return err; } module_init(init); |