On 2012年08月21日 23:03, Alan Stern wrote: > On Tue, 21 Aug 2012, Lan Tianyu wrote: > >> This patch is to add "auto" option to attribute portX/control. >> When echo "auto", the port's feature PORT_POWER would be clear >> if the port's connect type was mark not-used(connectability and >> visibility are both cleared) and with no device attached. > >> @@ -4741,6 +4746,18 @@ static ssize_t store_port_power_control(struct device *dev, >> usb_autopm_put_interface(intf); >> if (ret < 0) >> return -EIO; >> + } else if (len == sizeof(auto_string) - 1 >> + && strncmp(buf, auto_string, len) == 0) { >> + hub_port->port_power_policy = USB_PORT_POWER_AUTO; >> + if (hub_port->connect_type >> + == USB_PORT_NOT_USED && !hub_port->child) { > > Minor style issue: When you indent a continuation line, the level of > indenting should be different from the lines that follow so that it > doesn't look as though the continuation line is part of the "if" block. > OK. >> + usb_autopm_get_interface(intf); >> + ret = clear_port_feature(hdev, port1, >> + USB_PORT_FEAT_POWER); >> + usb_autopm_put_interface(intf); >> + if (ret < 0) >> + return -EIO; >> + } >> } else >> return -EINVAL; > > 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); > > Alan Stern > -- Best regards Tianyu Lan -- 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