usb: langwell_udc: set vbus_active flag according to state
authorHao Wu <hao.wu@intel.com>
Thu, 25 Aug 2011 11:20:32 +0000 (12:20 +0100)
committermgross <mark.gross@intel.com>
Wed, 9 Nov 2011 20:38:14 +0000 (12:38 -0800)
This patch adds active bit setting in order to avoid issues
with composite gadget on pullup functions which query on this
bit.

Change-Id: I063bcd6021b2b322854d6e94e850c5fae6266b28
Signed-off-by: Hao Wu <hao.wu@intel.com>
Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
drivers/usb/gadget/langwell_udc.c

index bcbada5..7423dae 100644 (file)
@@ -3530,8 +3530,10 @@ static struct pci_driver langwell_pci_driver = {
 #ifdef OTG_TRANSCEIVER
 static int intel_mid_start_peripheral(struct intel_mid_otg_xceiv *iotg)
 {
-       struct pci_dev  *pdev;
-       int             retval;
+       struct langwell_udc     *dev = the_controller;
+       struct pci_dev          *pdev;
+       unsigned long           flags;
+       int                     retval;
 
        if (iotg == NULL)
                return -EINVAL;
@@ -3542,13 +3544,21 @@ static int intel_mid_start_peripheral(struct intel_mid_otg_xceiv *iotg)
        if (retval)
                dev_dbg(&pdev->dev, "Failed to start peripheral driver\n");
 
+       if (dev) {
+               spin_lock_irqsave(&dev->lock, flags);
+               dev->vbus_active = 1;
+               spin_unlock_irqrestore(&dev->lock, flags);
+       }
+
        return retval;
 }
 
 static int intel_mid_stop_peripheral(struct intel_mid_otg_xceiv *iotg)
 {
-       struct pci_dev  *pdev;
-       int             retval;
+       struct langwell_udc     *dev = the_controller;
+       struct pci_dev          *pdev;
+       unsigned long           flags;
+       int                     retval;
 
        if (iotg == NULL)
                return -EINVAL;
@@ -3559,6 +3569,12 @@ static int intel_mid_stop_peripheral(struct intel_mid_otg_xceiv *iotg)
        if (retval)
                dev_dbg(&pdev->dev, "Failed to stop peripheral driver\n");
 
+       if (dev) {
+               spin_lock_irqsave(&dev->lock, flags);
+               dev->vbus_active = 0;
+               spin_unlock_irqrestore(&dev->lock, flags);
+       }
+
        return retval;
 }