On Wed, Dec 24, 2014 at 11:25:09AM -0500, Alan Stern wrote: > On Wed, 24 Dec 2014, Peter Chen wrote: > > > On Tue, Dec 23, 2014 at 03:15:45PM -0500, Alan Stern wrote: > > > On Tue, 23 Dec 2014, Peter Chen wrote: > > > > > > > > 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, any reasons/limitations we do not support it (by libusb)? > > > > > > For the same reason we don't allow userspace to interfere with any > > > device: When a kernel driver is in charge of a device, any changes the > > > user wants to make must go through the driver. If users were allowed > > > to make changes to a device without telling the driver, then the driver > > > would not be able to do its job properly. > > > > Why we can't turn port power off without unbinding driver? > > I see we can reset device at devio, why we can reset a device, but > > can't turn its port off? > > That's more or less a quirk of history. If we were doing it now, I > might say that a user program should not be allowed to reset a device > unless it has claimed at least one of the device's interfaces. > > However, that question does not have the right point of view. The > problem with turning off port power isn't that it interferes with the > driver of the device attached to that port; the problem is that it > interferes with the hub driver. > > On the other hand, it would make sense to allow an exception for the > case where userspace owns the port. The (untested) patch below would > be acceptable, and it would allow Deepak to do what he wants. Thanks for explaining it, but I am still not understand why we need unbind the interface when we go to turn the port power off or reset the port if the port is owned by kernel. I often need to do continual plug in/out usb device test, in order to emulate it, I just toggle the power (vbus on <--> vbus off), I did not find anything wrong. -- Best Regards, Peter Chen -- 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