]> git.karo-electronics.de Git - linux-beck.git/commitdiff
USB: remove the auto_pm flag
authorAlan Stern <stern@rowland.harvard.edu>
Fri, 13 Nov 2009 16:53:59 +0000 (11:53 -0500)
committerGreg Kroah-Hartman <gregkh@suse.de>
Fri, 11 Dec 2009 19:55:21 +0000 (11:55 -0800)
This patch (as1302) removes the auto_pm flag from struct usb_device.
The flag's only purpose was to distinguish between autosuspends and
external suspends, but that information is now available in the
pm_message_t argument passed to suspend methods.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Documentation/usb/power-management.txt
drivers/bluetooth/btusb.c
drivers/hid/usbhid/hid-core.c
drivers/net/wimax/i2400m/usb.c
drivers/usb/core/driver.c
drivers/usb/serial/option.c
drivers/usb/serial/sierra.c
include/linux/usb.h

index ad642615ad4cf370d5ded0e3c80f7bb6aa89a9a9..8817368203d6412e2c5a8546c7d0a54c8c469c70 100644 (file)
@@ -423,15 +423,16 @@ an URB had completed too recently.
 
 External suspend calls should never be allowed to fail in this way,
 only autosuspend calls.  The driver can tell them apart by checking
 
 External suspend calls should never be allowed to fail in this way,
 only autosuspend calls.  The driver can tell them apart by checking
-udev->auto_pm; this flag will be set to 1 for internal PM events
-(autosuspend or autoresume) and 0 for external PM events.
+the PM_EVENT_AUTO bit in the message.event argument to the suspend
+method; this bit will be set for internal PM events (autosuspend) and
+clear for external PM events.
 
 Many of the ingredients in the autosuspend framework are oriented
 towards interfaces: The usb_interface structure contains the
 pm_usage_cnt field, and the usb_autopm_* routines take an interface
 pointer as their argument.  But somewhat confusingly, a few of the
 
 Many of the ingredients in the autosuspend framework are oriented
 towards interfaces: The usb_interface structure contains the
 pm_usage_cnt field, and the usb_autopm_* routines take an interface
 pointer as their argument.  But somewhat confusingly, a few of the
-pieces (usb_mark_last_busy() and udev->auto_pm) use the usb_device
-structure instead.  Drivers need to keep this straight; they can call
+pieces (i.e., usb_mark_last_busy()) use the usb_device structure
+instead.  Drivers need to keep this straight; they can call
 interface_to_usbdev() to find the device structure for a given
 interface.
 
 interface_to_usbdev() to find the device structure for a given
 interface.
 
index 44bc8bbabf5474948d59eb8ce15cff6bef11b819..4d29059967517f2a54c02eabc55ef76f84ba1855 100644 (file)
@@ -1066,7 +1066,7 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
                return 0;
 
        spin_lock_irq(&data->txlock);
                return 0;
 
        spin_lock_irq(&data->txlock);
-       if (!(interface_to_usbdev(intf)->auto_pm && data->tx_in_flight)) {
+       if (!((message.event & PM_EVENT_AUTO) && data->tx_in_flight)) {
                set_bit(BTUSB_SUSPENDING, &data->flags);
                spin_unlock_irq(&data->txlock);
        } else {
                set_bit(BTUSB_SUSPENDING, &data->flags);
                spin_unlock_irq(&data->txlock);
        } else {
index 0258289f3b3e649f04e5447f0d53221d1df07222..e2997a8d5e1b4b726ac9b62f0d60e2647ae37ce4 100644 (file)
@@ -1253,10 +1253,9 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
 {
        struct hid_device *hid = usb_get_intfdata(intf);
        struct usbhid_device *usbhid = hid->driver_data;
 {
        struct hid_device *hid = usb_get_intfdata(intf);
        struct usbhid_device *usbhid = hid->driver_data;
-       struct usb_device *udev = interface_to_usbdev(intf);
        int status;
 
        int status;
 
-       if (udev->auto_pm) {
+       if (message.event & PM_EVENT_AUTO) {
                spin_lock_irq(&usbhid->lock);   /* Sync with error handler */
                if (!test_bit(HID_RESET_PENDING, &usbhid->iofl)
                    && !test_bit(HID_CLEAR_HALT, &usbhid->iofl)
                spin_lock_irq(&usbhid->lock);   /* Sync with error handler */
                if (!test_bit(HID_RESET_PENDING, &usbhid->iofl)
                    && !test_bit(HID_CLEAR_HALT, &usbhid->iofl)
@@ -1281,7 +1280,7 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
                        return -EIO;
        }
 
                        return -EIO;
        }
 
-       if (!ignoreled && udev->auto_pm) {
+       if (!ignoreled && (message.event & PM_EVENT_AUTO)) {
                spin_lock_irq(&usbhid->lock);
                if (test_bit(HID_LED_ON, &usbhid->iofl)) {
                        spin_unlock_irq(&usbhid->lock);
                spin_lock_irq(&usbhid->lock);
                if (test_bit(HID_LED_ON, &usbhid->iofl)) {
                        spin_unlock_irq(&usbhid->lock);
@@ -1294,7 +1293,8 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
        hid_cancel_delayed_stuff(usbhid);
        hid_cease_io(usbhid);
 
        hid_cancel_delayed_stuff(usbhid);
        hid_cease_io(usbhid);
 
-       if (udev->auto_pm && test_bit(HID_KEYS_PRESSED, &usbhid->iofl)) {
+       if ((message.event & PM_EVENT_AUTO) &&
+                       test_bit(HID_KEYS_PRESSED, &usbhid->iofl)) {
                /* lost race against keypresses */
                status = hid_start_in(hid);
                if (status < 0)
                /* lost race against keypresses */
                status = hid_start_in(hid);
                if (status < 0)
index 47e84ef355c58862ba7632345ca964da57f5e692..3b48681f8a0d50c8db077e8fccd93021a4239f1c 100644 (file)
@@ -579,7 +579,7 @@ void i2400mu_disconnect(struct usb_interface *iface)
  *
  *    As well, the device might refuse going to sleep for whichever
  *    reason. In this case we just fail. For system suspend/hibernate,
  *
  *    As well, the device might refuse going to sleep for whichever
  *    reason. In this case we just fail. For system suspend/hibernate,
- *    we *can't* fail. We look at usb_dev->auto_pm to see if the
+ *    we *can't* fail. We check PM_EVENT_AUTO to see if the
  *    suspend call comes from the USB stack or from the system and act
  *    in consequence.
  *
  *    suspend call comes from the USB stack or from the system and act
  *    in consequence.
  *
@@ -591,14 +591,11 @@ int i2400mu_suspend(struct usb_interface *iface, pm_message_t pm_msg)
        int result = 0;
        struct device *dev = &iface->dev;
        struct i2400mu *i2400mu = usb_get_intfdata(iface);
        int result = 0;
        struct device *dev = &iface->dev;
        struct i2400mu *i2400mu = usb_get_intfdata(iface);
-#ifdef CONFIG_PM
-       struct usb_device *usb_dev = i2400mu->usb_dev;
-#endif
        unsigned is_autosuspend = 0;
        struct i2400m *i2400m = &i2400mu->i2400m;
 
 #ifdef CONFIG_PM
        unsigned is_autosuspend = 0;
        struct i2400m *i2400m = &i2400mu->i2400m;
 
 #ifdef CONFIG_PM
-       if (usb_dev->auto_pm > 0)
+       if (pm_msg.event & PM_EVENT_AUTO)
                is_autosuspend = 1;
 #endif
 
                is_autosuspend = 1;
 #endif
 
index 4f864472c5c4db4eea4004cd49e902cb4acd75c9..8016a296010ef47cf97ddf2a953b60d3ff25dcab 100644 (file)
@@ -1341,7 +1341,6 @@ static int usb_autopm_do_device(struct usb_device *udev, int inc_usage_cnt)
        int     status = 0;
 
        usb_pm_lock(udev);
        int     status = 0;
 
        usb_pm_lock(udev);
-       udev->auto_pm = 1;
        udev->pm_usage_cnt += inc_usage_cnt;
        WARN_ON(udev->pm_usage_cnt < 0);
        if (inc_usage_cnt)
        udev->pm_usage_cnt += inc_usage_cnt;
        WARN_ON(udev->pm_usage_cnt < 0);
        if (inc_usage_cnt)
@@ -1473,7 +1472,6 @@ static int usb_autopm_do_interface(struct usb_interface *intf,
        if (intf->condition == USB_INTERFACE_UNBOUND)
                status = -ENODEV;
        else {
        if (intf->condition == USB_INTERFACE_UNBOUND)
                status = -ENODEV;
        else {
-               udev->auto_pm = 1;
                atomic_add(inc_usage_cnt, &intf->pm_usage_cnt);
                udev->last_busy = jiffies;
                if (inc_usage_cnt >= 0 &&
                atomic_add(inc_usage_cnt, &intf->pm_usage_cnt);
                udev->last_busy = jiffies;
                if (inc_usage_cnt >= 0 &&
@@ -1707,7 +1705,6 @@ int usb_external_suspend_device(struct usb_device *udev, pm_message_t msg)
 
        do_unbind_rebind(udev, DO_UNBIND);
        usb_pm_lock(udev);
 
        do_unbind_rebind(udev, DO_UNBIND);
        usb_pm_lock(udev);
-       udev->auto_pm = 0;
        status = usb_suspend_both(udev, msg);
        usb_pm_unlock(udev);
        return status;
        status = usb_suspend_both(udev, msg);
        usb_pm_unlock(udev);
        return status;
@@ -1730,7 +1727,6 @@ int usb_external_resume_device(struct usb_device *udev, pm_message_t msg)
        int     status;
 
        usb_pm_lock(udev);
        int     status;
 
        usb_pm_lock(udev);
-       udev->auto_pm = 0;
        status = usb_resume_both(udev, msg);
        udev->last_busy = jiffies;
        usb_pm_unlock(udev);
        status = usb_resume_both(udev, msg);
        udev->last_busy = jiffies;
        usb_pm_unlock(udev);
index 0d46bbec44b7183aed7695ae35b9d8442ba5665c..8751ec79a1595f3b8ed930c690451294f236b917 100644 (file)
@@ -1313,7 +1313,7 @@ static int option_suspend(struct usb_serial *serial, pm_message_t message)
 
        dbg("%s entered", __func__);
 
 
        dbg("%s entered", __func__);
 
-       if (serial->dev->auto_pm) {
+       if (message.event & PM_EVENT_AUTO) {
                spin_lock_irq(&intfdata->susp_lock);
                b = intfdata->in_flight;
                spin_unlock_irq(&intfdata->susp_lock);
                spin_lock_irq(&intfdata->susp_lock);
                b = intfdata->in_flight;
                spin_unlock_irq(&intfdata->susp_lock);
index c5c41aed106d9d89ecd5a62a469f9a87a57467c9..ac1b6449fb6abc779f6904cd4899508f466426de 100644 (file)
@@ -1005,7 +1005,7 @@ static int sierra_suspend(struct usb_serial *serial, pm_message_t message)
        struct sierra_intf_private *intfdata;
        int b;
 
        struct sierra_intf_private *intfdata;
        int b;
 
-       if (serial->dev->auto_pm) {
+       if (message.event & PM_EVENT_AUTO) {
                intfdata = serial->private;
                spin_lock_irq(&intfdata->susp_lock);
                b = intfdata->in_flight;
                intfdata = serial->private;
                spin_lock_irq(&intfdata->susp_lock);
                b = intfdata->in_flight;
index 6e91ee4f5b81ab686b9c60c4948b505f2f99d4e3..4b6f6db544ee8b0b48df5e866ed3bd3c2b58632e 100644 (file)
@@ -429,7 +429,6 @@ struct usb_tt;
  * @last_busy: time of last use
  * @autosuspend_delay: in jiffies
  * @connect_time: time device was first connected
  * @last_busy: time of last use
  * @autosuspend_delay: in jiffies
  * @connect_time: time device was first connected
- * @auto_pm: autosuspend/resume in progress
  * @do_remote_wakeup:  remote wakeup should be enabled
  * @reset_resume: needs reset instead of resume
  * @autosuspend_disabled: autosuspend disabled by the user
  * @do_remote_wakeup:  remote wakeup should be enabled
  * @reset_resume: needs reset instead of resume
  * @autosuspend_disabled: autosuspend disabled by the user
@@ -514,7 +513,6 @@ struct usb_device {
        int autosuspend_delay;
        unsigned long connect_time;
 
        int autosuspend_delay;
        unsigned long connect_time;
 
-       unsigned auto_pm:1;
        unsigned do_remote_wakeup:1;
        unsigned reset_resume:1;
        unsigned autosuspend_disabled:1;
        unsigned do_remote_wakeup:1;
        unsigned reset_resume:1;
        unsigned autosuspend_disabled:1;