On Tue, 23 Dec 2014, Deepak Das wrote: > On 22 December 2014 at 22:13, Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote: > > 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. > > Yes, this is really annoying. I am not able to think of any practical > use-case of > this code. If you want to remove it, I don't think anybody will object. > >> 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. > > > > Yes, Correct. port will not work but that is what we needed. We need to provide > userspace application control over port power for some specific requirement. > Port will work again if we turn the port power back on. Userspace can control the port power if you first unbind the hub driver. In fact, I posted a program to do this years ago: http://marc.info/?l=linux-usb&m=127162615232234&w=2 > > 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. > > > Yes, we don't need remote wakeup so if hub supports per port power control then > it should be turn on/off by using Set/clearPortFeature which is done by libusb > control transfer function. > By using libusb function we are just following "11.11 Hub Port Power Control" > section of USB 2.0 spec which says it's possible by set/clearPortFeature. > Please correct me If I misunderstood. Just because the hardware is capable of doing something, that doesn't mean the operating system will permit users to do it. 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