From 30b358e8437893e397525f998d9cb00e3d9edc31 Mon Sep 17 00:00:00 2001 From: yangkai Date: Tue, 13 Nov 2012 17:07:23 +0800 Subject: [PATCH] 1. use gadget connect status instead of msc_connect_flag; 2. reset gadget delayed status for setconfig --- drivers/usb/gadget/composite.c | 18 +++++++++++++++++- drivers/usb/gadget/f_mass_storage.c | 17 ----------------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 2e295e8c5567..0c6101d4423c 100755 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -72,7 +72,7 @@ module_param(iSerialNumber, charp, 0); MODULE_PARM_DESC(iSerialNumber, "SerialNumber string"); static char composite_manufacturer[50]; - +static int gadget_connected = 0; /*-------------------------------------------------------------------------*/ /** @@ -420,6 +420,9 @@ static int set_config(struct usb_composite_dev *cdev, goto done; cdev->config = c; + + /* reset delay status to zero every time usb reconnect */ + cdev->delayed_status = 0; /* Initialize all interfaces by setting them to altsetting zero. */ for (tmp = 0; tmp < MAX_CONFIG_INTERFACES; tmp++) { @@ -474,6 +477,9 @@ static int set_config(struct usb_composite_dev *cdev, /* when we return, be sure our power usage is valid */ power = c->bMaxPower ? (2 * c->bMaxPower) : CONFIG_USB_GADGET_VBUS_DRAW; + + /* usb gadget connect flag */ + gadget_connected = 1; done: usb_gadget_vbus_draw(gadget, power); @@ -1053,10 +1059,17 @@ static void composite_disconnect(struct usb_gadget *gadget) reset_config(cdev); if (composite->disconnect) composite->disconnect(cdev); + /* usb gadget connect flag */ + gadget_connected = 0; spin_unlock_irqrestore(&cdev->lock, flags); } /*-------------------------------------------------------------------------*/ +int get_gadget_connect_flag( void ) +{ + return gadget_connected; +} +EXPORT_SYMBOL(get_gadget_connect_flag); static ssize_t composite_show_suspended(struct device *dev, struct device_attribute *attr, @@ -1370,6 +1383,9 @@ void usb_composite_setup_continue(struct usb_composite_dev *cdev) composite_setup_complete(cdev->gadget->ep0, req); } } + else{ + WARN(cdev, "%s: Unexpected delayed status 0x%x\n", __func__, cdev->delayed_status); + } spin_unlock_irqrestore(&cdev->lock, flags); } diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c index daea926edef3..eada7597c15e 100755 --- a/drivers/usb/gadget/f_mass_storage.c +++ b/drivers/usb/gadget/f_mass_storage.c @@ -307,21 +307,6 @@ #include #include -static int usb_msc_connected; /*usb charge status*/ - -static void set_msc_connect_flag( int connected ) -{ - printk("%s status = %d 20101216\n" , __func__, connected); - if( usb_msc_connected == connected ) - return; - usb_msc_connected = connected;//usb mass storage is ok -} - -int get_msc_connect_flag( void ) -{ - return usb_msc_connected; -} -EXPORT_SYMBOL(get_msc_connect_flag); #endif /*------------------------------------------------------------------------*/ @@ -2675,8 +2660,6 @@ static void fsg_disable(struct usb_function *f) struct fsg_dev *fsg = fsg_from_func(f); fsg->common->new_fsg = NULL; raise_exception(fsg->common, FSG_STATE_CONFIG_CHANGE); - // yk 201009 - set_msc_connect_flag(0); } -- 2.34.1