On Mon, 9 Apr 2012, James Haigh wrote: > Hello. > > I've been told this is the right place to ask, correct me if I'm wrong. This is the right place. > I don't think the ability to limit a port to 100mA current draw is > exposed by the drivers. It isn't exposed because there's no way to do it. > The use-case for this is to avoid a battery > powered device such as a phone from draining the battery of a laptop > while travelling. Data transfer is all that's needed here. It is also > wasteful to charge one battery from another. > > In the interests of saving energy, and prolonging battery-life, please > could a mechanism to restrict to 100mA be implemented. I could then > set up an automatic ACPI response to AC power to allow 500mA and > charge the phone, but battery-to-battery transfer is inefficient and > should be avoided. I'm sorry; what you're asking for is not possible. The USB controller hardware most commonly used in desktop and laptop systems does not offer any way for software to restrict the amount of current. In USB, the amount of current used is determined by the device, not by the host. If you want to reduce a phone's usage to 100 mA, you have to do it by telling the phone -- telling the host won't accomplish anything. Furthermore, what makes you think that even at 100 mA, the phone's battery isn't being recharged (just more slowly)? > Apparently USB ports can be disabled, and when this occurs no power is > supplied. No, power is still supplied when the port is disabled. > However, I think the ability to disable a port is also not > exposed by the USB drivers. It isn't. However it is possible to suspend a port. While this doesn't restrict the amount of current either, almost all USB devices will drastically reduce their power consumption when suspended. Of course, you can't use a device while it is suspended, so this might not help. > There are many use-cases for this. In the interest of saving > electricity, it is desirable to unplug unused devices. USB ports can > be plugged only about 1500 times before they ware out, and sometimes > the ports are fairly inaccessible behind the base unit of a computer. > Some badly designed devices will often need resetting by physically > replugging. If a USB device is plugged into a host device that is > remotely monitored, it is not possible to physically reconnect the > device. A less serious and more fun use-case is the automation of USB > 'decorations', which simply use the 5V power supply. > > It seems an oversight that USB devices cannot be programmatically > disconnected and reconnected in GNU/Linux OSes. I would appreciate it > if they could, if possible, and I know for sure that others would too. Disconnecting and reconnecting are physical acts -- they require somebody to unplug and replug a cable. There is no way to do these things in software. (Not unless your computer has a robot hand that can unplug and replug USB cables :-) > It has been suggested that I should send a patch in, but I am no > kernel or driver developer, and I'm better off contributing to Free > software projects that are achievable at my skill-level. If you want > me to file these 2 issues/feature-requests somewhere, tell me where > and I will. Filing a feature request won't help. 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