usb: gadget: dummy_hcd: Fix wrong power status bit clear/reset in dummy_hub_control()
authorYuyang Du <yuyang.du@intel.com>
Thu, 23 Mar 2017 20:06:11 +0000 (04:06 +0800)
committerFelipe Balbi <felipe.balbi@linux.intel.com>
Tue, 11 Apr 2017 07:58:21 +0000 (10:58 +0300)
This fixes the commit: 1cd8fd2887e1 ("usb: gadget: dummy_hcd: add
SuperSpeed support").

In the case of ClearPortFeature and USB_PORT_FEAT_POWER, simply clear
the right bit regardless of what the wValue is.

Acked-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Yuyang Du <yuyang.du@intel.com>
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
drivers/usb/gadget/udc/dummy_hcd.c

index 8cabc5944d5f1d834db7dd2186777cd79536016b..c79081952ea068c770887298ed1c5483f0e61dac 100644 (file)
@@ -2062,16 +2062,13 @@ static int dummy_hub_control(
                        }
                        break;
                case USB_PORT_FEAT_POWER:
-                       if (hcd->speed == HCD_USB3) {
-                               if (dum_hcd->port_status & USB_PORT_STAT_POWER)
-                                       dev_dbg(dummy_dev(dum_hcd),
-                                               "power-off\n");
-                       } else
-                               if (dum_hcd->port_status &
-                                                       USB_SS_PORT_STAT_POWER)
-                                       dev_dbg(dummy_dev(dum_hcd),
-                                               "power-off\n");
-                       /* FALLS THROUGH */
+                       dev_dbg(dummy_dev(dum_hcd), "power-off\n");
+                       if (hcd->speed == HCD_USB3)
+                               dum_hcd->port_status &= ~USB_SS_PORT_STAT_POWER;
+                       else
+                               dum_hcd->port_status &= ~USB_PORT_STAT_POWER;
+                       set_link_state(dum_hcd);
+                       break;
                default:
                        dum_hcd->port_status &= ~(1 << wValue);
                        set_link_state(dum_hcd);
@@ -2242,14 +2239,13 @@ static int dummy_hub_control(
                                if ((dum_hcd->port_status &
                                     USB_SS_PORT_STAT_POWER) != 0) {
                                        dum_hcd->port_status |= (1 << wValue);
-                                       set_link_state(dum_hcd);
                                }
                        } else
                                if ((dum_hcd->port_status &
                                     USB_PORT_STAT_POWER) != 0) {
                                        dum_hcd->port_status |= (1 << wValue);
-                                       set_link_state(dum_hcd);
                                }
+                       set_link_state(dum_hcd);
                }
                break;
        case GetPortErrorCount: