From: wlf Date: Wed, 5 Mar 2014 07:48:45 +0000 (+0800) Subject: USB: add gadget_connected and fsg.luns[1] for usb gadget X-Git-Tag: firefly_0821_release~6204 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=05427aa0c9def989a8bb5d2d94cec2550312bff4;p=firefly-linux-kernel-4.4.55.git USB: add gadget_connected and fsg.luns[1] for usb gadget --- diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c old mode 100644 new mode 100755 index 6712beb388c6..5d4b9628e3ec --- a/drivers/usb/gadget/android.c +++ b/drivers/usb/gadget/android.c @@ -763,8 +763,9 @@ static int mass_storage_function_init(struct android_usb_function *f, if (!config) return -ENOMEM; - config->fsg.nluns = 1; + config->fsg.nluns = 2; config->fsg.luns[0].removable = 1; + config->fsg.luns[1].removable = 1; common = fsg_common_init(NULL, cdev, &config->fsg); if (IS_ERR(common)) { @@ -775,6 +776,9 @@ static int mass_storage_function_init(struct android_usb_function *f, err = sysfs_create_link(&f->dev->kobj, &common->luns[0].dev.kobj, "lun"); + err = sysfs_create_link(&f->dev->kobj, + &common->luns[1].dev.kobj, + "lun1"); if (err) { kfree(config); return err; diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index b331472cd307..fd045a6d04e1 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -21,6 +21,7 @@ #include #include +static int gadget_connected = 0; /* * The code in this file is utility code, used to build a gadget driver * from one or more "function" drivers, one or more "configuration" @@ -698,6 +699,8 @@ static int set_config(struct usb_composite_dev *cdev, /* when we return, be sure our power usage is valid */ power = c->MaxPower ? c->MaxPower : CONFIG_USB_GADGET_VBUS_DRAW; + /* usb gadget connect flag */ + gadget_connected = 1; done: usb_gadget_vbus_draw(gadget, power); if (result >= 0 && cdev->delayed_status) @@ -1497,9 +1500,15 @@ void composite_disconnect(struct usb_gadget *gadget) reset_config(cdev); if (cdev->driver->disconnect) cdev->driver->disconnect(cdev); + /* usb gadget connect flag */ + gadget_connected = 0; spin_unlock_irqrestore(&cdev->lock, flags); } +int get_gadget_connect_flag( void ) +{ + return gadget_connected; +} /*-------------------------------------------------------------------------*/ static ssize_t composite_show_suspended(struct device *dev,