On Tue, 8 Jan 2013, Lan Tianyu wrote:

> On 2013年01月08日 02:44, Alan Stern wrote:
> > On Sun, 6 Jan 2013, Lan Tianyu wrote:
> > 
> >> This patch is to expose usb port's pm qos flags(pm_qos_no_power_off,
> >> pm_qos_remote_wakeup) to user space. User can set pm_qos_no_power_off
> >> flag to prohibit the port from being power off.
> > 
> >> @@ -165,8 +166,12 @@ int usb_hub_create_port_device(struct usb_hub *hub, 
> >> int port1)
> >>    if (retval)
> >>            goto error_register;
> >>  
> >> -  pm_runtime_set_active(&port_dev->dev);
> >> -  pm_runtime_enable(&port_dev->dev);
> >> +  if (!dev_pm_qos_expose_flags(&port_dev->dev,
> >> +                  PM_QOS_FLAG_NO_POWER_OFF)) {
> >> +          pm_runtime_set_active(&port_dev->dev);
> >> +          pm_runtime_enable(&port_dev->dev);
> >> +  }
> > 
> > I don't understand this.  Why does this code need to be conditional?
> > 
> If expose pm qos flag failed, user space couldn't prevent device from
> being powered off. This will be dangerous. So for safety, disable port's
> runtime pm if it failed.

Then the pm_runtime_enable call should be conditional, but the 
pm_runtime_set_active call should not be.  You also might add a comment 
explaining this.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to