On Mon, 22 Dec 2014, Deepak Das wrote: > Can somebody please help me to find the test-case/use-case of > following snippet of code in drivers/usb/core/hub.c:hub_port_connect() > :- > > /* maybe switch power back on (e.g. root hub was reset) */ > if (hub_is_port_power_switchable(hub) > && !port_is_power_on(hub, portstatus)) > set_port_feature(hdev, port1, USB_PORT_FEAT_POWER); The use case is that for unknown reasons, the hub turned off power to the port. I doubt that this case ever happens, though. > Our use case is to switch the power off on any hub port if hub > supports per port power control but currently port is turned back ON > due to above code snippet. You mustn't switch off port power; only the hub driver is allowed to do that. If the power is switched off then the port won't work. > we are turning the power off by using following libusb control > transfer function :- > > libusb_control_transfer( handle, > (tU8)LIBUSB_ENDPOINT_OUT | USB_RT_PORT, > (tU8)LIBUSB_REQUEST_CLEAR_FEATURE, > USB_PORT_FEAT_POWER, > PortID, > NULL, > 0, > USB_TIMEOUT ); This is an invalid thing to do, and as you found out, it doesn't work anyway. If you really insist on turning off the port power and leaving it off, you can do this simply by unbinding the hub driver from the hub. But then power will be turned off for _all_ the ports on that hub, and it won't function as a hub any more. > In which way root hub can be reset or was reset and code flow will > reach above statement in hub_port_connect() and turn PORT_POWER back > ON the port? > > I tried to search for the use-case through git log and google but > failed to understand. The Linux USB stack supports turning off port power only under a very limited set of conditions. For example, if the port is hard-wired or not connected at all, and if remote wakeup is not required. Alan Stern -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html