On Sat, 17 Nov 2012, Lan Tianyu wrote: > This patch is to add runtime pm callback for usb port device. > Set/clear PORT_POWER feature in the resume/suspend callbak. > Add portnum for struct usb_port to record port number. Do > pm_rumtime_get_sync/put(portdev) when a device is plugged/unplugged > to prevent it from being power off when it is active. > --- a/drivers/usb/core/hub.c > +++ b/drivers/usb/core/hub.c > @@ -1922,6 +1936,9 @@ void usb_disconnect(struct usb_device **pdev) > > sysfs_remove_link(&udev->dev.kobj, "port"); > sysfs_remove_link(&port_dev->dev.kobj, "device"); > + > + /* put the related port to idle when device is unplugged */ This comment isn't needed. Besides, it's wrong -- in most cases the port won't go to idle, because it will be forbidden to do runtime PM. > + pm_runtime_put(&port_dev->dev); > } > > usb_remove_ep_devs(&udev->ep0); > @@ -2232,6 +2249,9 @@ int usb_new_device(struct usb_device *udev) > sysfs_remove_link(&udev->dev.kobj, "port"); > goto fail; > } > + > + /* resume the related port device */ This comment is wrong too. It's not needed anyway. > + pm_runtime_get_sync(&port_dev->dev); > } > > (void) usb_create_ep_devs(&udev->dev, &udev->ep0, udev); > --- a/drivers/usb/core/hub.h > +++ b/drivers/usb/core/hub.h > @@ -38,6 +38,7 @@ > #include <linux/freezer.h> > #include <linux/random.h> > #include <linux/uaccess.h> > +#include <linux/pm_qos.h> Does hub.c require linux/pm_qos.h? If not, move this #include line to port.c. > --- a/drivers/usb/core/port.c > +++ b/drivers/usb/core/port.c > +static int usb_port_runtime_idle(struct device *dev) > +{ > + struct usb_port *port_dev = to_usb_port(dev); > + > + return pm_runtime_suspend(&port_dev->dev); > +} This function isn't needed... > + > +static const struct dev_pm_ops usb_port_pm_ops = { > +#ifdef CONFIG_USB_SUSPEND > +.runtime_suspend = usb_port_runtime_suspend, > +.runtime_resume = usb_port_runtime_resume, > +.runtime_idle = usb_port_runtime_idle, Instead, use pm_generic_runtime_idle here. 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