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
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html