Re: [RFC PATCH 1/2] usb: usb port power off mechanism add "auto" option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux