于 2012/8/22 22:39, Alan Stern 写道:
On Wed, 22 Aug 2012, Lan Tianyu wrote:
You forgot to change the logic in hub_power_on(). You have to handle
the USB_PORT_POWER_AUTO case.
Yeah. Thanks for reminder.
How about following?
@@ -858,7 +860,14 @@ static unsigned hub_power_on(struct usb_hub *hub,
bool do_delay)
if (hub->ports[port1 - 1]->port_power_policy
== USB_PORT_POWER_ON)
set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER);
- else
+ else if (hub->ports[port1 - 1]->port_power_policy
+ == USB_PORT_POWER_AUTO) {
+ if (hub->ports[port1 - 1]->connect_type
+ == USB_PORT_NOT_USED
+ && !hub->ports[port1 - 1]->child)
+ clear_port_feature(hub->hdev, port1,
+ USB_PORT_FEAT_POWER);
+ } else
clear_port_feature(hub->hdev, port1,
USB_PORT_FEAT_POWER);
This doesn't handle all the cases, and it has duplicated code. It
would be better to do something like this:
p = &hub->ports[port1 - 1];
if (p->port_power_policy == USB_PORT_POWER_OFF ||
(p->port_power_policy == USB_PORT_POWER_AUTO &&
p->connect_type == USB_PORT_NOT_USED &&
!p->child))
clear_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER);
else
set_port_feature(hub->hdev, port1, USB_PORT_FEAT_POWER);
Alan Stern
OK. I get it. Thanks.
--
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
--
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