summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Goby <benoit@android.com>2012-03-19 18:56:52 -0700
committerJohn Stultz <john.stultz@linaro.org>2016-02-16 13:51:54 -0800
commitb3479c8467733c27fed142bcd43f50da4357188f (patch)
tree21cdc9c847b0e0eab75215de702583ac92781d77
parent3daf0db436a9d96f5d3ac43f5e6d315178e3184a (diff)
usb: gadget: adb: Only enable the gadget when adbd is ready
When adb is enabled, only connect the gadget when adbd is ready. If adbd dies or is restarted (e.g. "adb root"), the gadget is disconnected when the adb device is close, and it is re-connected once adb re-open the device. - Add callbacks to adb, similar to FunctionFs callbacks, to notify the gadget when the daemon is ready or closed. - Refcount calls to android_enable/android_disable to enable the gadget only once all the function daemons are ready. - Add enable/disble to android_usb_function to notify the function when it is added/removed from the list of enabled functions. Change-Id: Id54ff85aec9cf8715c94b4f9bd6137a79ad58bfc Signed-off-by: Benoit Goby <benoit@android.com>
-rw-r--r--drivers/usb/gadget/f_adb.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/usb/gadget/f_adb.c b/drivers/usb/gadget/f_adb.c
index 3827715f832d..1629ffb5b979 100644
--- a/drivers/usb/gadget/f_adb.c
+++ b/drivers/usb/gadget/f_adb.c
@@ -111,6 +111,8 @@ static struct usb_descriptor_header *hs_adb_descs[] = {
NULL,
};
+static void adb_ready_callback(void);
+static void adb_closed_callback(void);
/* temporary variable used between adb_open() and adb_gadget_bind() */
static struct adb_dev *_adb_dev;
@@ -407,7 +409,7 @@ static ssize_t adb_write(struct file *fp, const char __user *buf,
static int adb_open(struct inode *ip, struct file *fp)
{
- printk(KERN_INFO "adb_open\n");
+ pr_info("adb_open\n");
if (!_adb_dev)
return -ENODEV;
@@ -419,12 +421,17 @@ static int adb_open(struct inode *ip, struct file *fp)
/* clear the error latch */
_adb_dev->error = 0;
+ adb_ready_callback();
+
return 0;
}
static int adb_release(struct inode *ip, struct file *fp)
{
- printk(KERN_INFO "adb_release\n");
+ pr_info("adb_release\n");
+
+ adb_closed_callback();
+
adb_unlock(&_adb_dev->open_excl);
return 0;
}