aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2011-08-19 17:49:48 -0400
committerRafael J. Wysocki <rjw@sisk.pl>2011-08-19 17:49:48 -0400
commit5b1b0b812a7b1a5b968c5d06d90d1cb88621b941 (patch)
treedd57943592e4152147d1a5667b082e5f30faaf83 /drivers
parent311aab73d273eb22be976055f6cab224f7279d5e (diff)
PM / Runtime: Add macro to test for runtime PM events
This patch (as1482) adds a macro for testing whether or not a pm_message value represents an autosuspend or autoresume (i.e., a runtime PM) event. Encapsulating this notion seems preferable to open-coding the test all over the place. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/bluetooth/btusb.c2
-rw-r--r--drivers/hid/hid-picolcd.c2
-rw-r--r--drivers/hid/usbhid/hid-core.c7
-rw-r--r--drivers/net/usb/usbnet.c2
-rw-r--r--drivers/net/wimax/i2400m/usb.c4
-rw-r--r--drivers/usb/class/cdc-acm.c2
-rw-r--r--drivers/usb/class/cdc-wdm.c6
-rw-r--r--drivers/usb/core/driver.c9
-rw-r--r--drivers/usb/core/hcd.c4
-rw-r--r--drivers/usb/core/hub.c10
-rw-r--r--drivers/usb/serial/sierra.c2
-rw-r--r--drivers/usb/serial/usb_wwan.c2
12 files changed, 25 insertions, 27 deletions
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 91d13a9e8c65..91b190c40497 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1103,7 +1103,7 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
1103 return 0; 1103 return 0;
1104 1104
1105 spin_lock_irq(&data->txlock); 1105 spin_lock_irq(&data->txlock);
1106 if (!((message.event & PM_EVENT_AUTO) && data->tx_in_flight)) { 1106 if (!(PMSG_IS_AUTO(message) && data->tx_in_flight)) {
1107 set_bit(BTUSB_SUSPENDING, &data->flags); 1107 set_bit(BTUSB_SUSPENDING, &data->flags);
1108 spin_unlock_irq(&data->txlock); 1108 spin_unlock_irq(&data->txlock);
1109 } else { 1109 } else {
diff --git a/drivers/hid/hid-picolcd.c b/drivers/hid/hid-picolcd.c
index 9d8710f8bc79..1782693819f3 100644
--- a/drivers/hid/hid-picolcd.c
+++ b/drivers/hid/hid-picolcd.c
@@ -2409,7 +2409,7 @@ static int picolcd_raw_event(struct hid_device *hdev,
2409#ifdef CONFIG_PM 2409#ifdef CONFIG_PM
2410static int picolcd_suspend(struct hid_device *hdev, pm_message_t message) 2410static int picolcd_suspend(struct hid_device *hdev, pm_message_t message)
2411{ 2411{
2412 if (message.event & PM_EVENT_AUTO) 2412 if (PMSG_IS_AUTO(message))
2413 return 0; 2413 return 0;
2414 2414
2415 picolcd_suspend_backlight(hid_get_drvdata(hdev)); 2415 picolcd_suspend_backlight(hid_get_drvdata(hdev));
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index ad978f5748d3..a9fa294ee7d3 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1332,7 +1332,7 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
1332 struct usbhid_device *usbhid = hid->driver_data; 1332 struct usbhid_device *usbhid = hid->driver_data;
1333 int status; 1333 int status;
1334 1334
1335 if (message.event & PM_EVENT_AUTO) { 1335 if (PMSG_IS_AUTO(message)) {
1336 spin_lock_irq(&usbhid->lock); /* Sync with error handler */ 1336 spin_lock_irq(&usbhid->lock); /* Sync with error handler */
1337 if (!test_bit(HID_RESET_PENDING, &usbhid->iofl) 1337 if (!test_bit(HID_RESET_PENDING, &usbhid->iofl)
1338 && !test_bit(HID_CLEAR_HALT, &usbhid->iofl) 1338 && !test_bit(HID_CLEAR_HALT, &usbhid->iofl)
@@ -1367,7 +1367,7 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
1367 return -EIO; 1367 return -EIO;
1368 } 1368 }
1369 1369
1370 if (!ignoreled && (message.event & PM_EVENT_AUTO)) { 1370 if (!ignoreled && PMSG_IS_AUTO(message)) {
1371 spin_lock_irq(&usbhid->lock); 1371 spin_lock_irq(&usbhid->lock);
1372 if (test_bit(HID_LED_ON, &usbhid->iofl)) { 1372 if (test_bit(HID_LED_ON, &usbhid->iofl)) {
1373 spin_unlock_irq(&usbhid->lock); 1373 spin_unlock_irq(&usbhid->lock);
@@ -1380,8 +1380,7 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
1380 hid_cancel_delayed_stuff(usbhid); 1380 hid_cancel_delayed_stuff(usbhid);
1381 hid_cease_io(usbhid); 1381 hid_cease_io(usbhid);
1382 1382
1383 if ((message.event & PM_EVENT_AUTO) && 1383 if (PMSG_IS_AUTO(message) && test_bit(HID_KEYS_PRESSED, &usbhid->iofl)) {
1384 test_bit(HID_KEYS_PRESSED, &usbhid->iofl)) {
1385 /* lost race against keypresses */ 1384 /* lost race against keypresses */
1386 status = hid_start_in(hid); 1385 status = hid_start_in(hid);
1387 if (status < 0) 1386 if (status < 0)
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c
index ce395fe5de26..f1c435ba5284 100644
--- a/drivers/net/usb/usbnet.c
+++ b/drivers/net/usb/usbnet.c
@@ -1470,7 +1470,7 @@ int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
1470 if (!dev->suspend_count++) { 1470 if (!dev->suspend_count++) {
1471 spin_lock_irq(&dev->txq.lock); 1471 spin_lock_irq(&dev->txq.lock);
1472 /* don't autosuspend while transmitting */ 1472 /* don't autosuspend while transmitting */
1473 if (dev->txq.qlen && (message.event & PM_EVENT_AUTO)) { 1473 if (dev->txq.qlen && PMSG_IS_AUTO(message)) {
1474 spin_unlock_irq(&dev->txq.lock); 1474 spin_unlock_irq(&dev->txq.lock);
1475 return -EBUSY; 1475 return -EBUSY;
1476 } else { 1476 } else {
diff --git a/drivers/net/wimax/i2400m/usb.c b/drivers/net/wimax/i2400m/usb.c
index 298f2b0b6311..9a644d052f1e 100644
--- a/drivers/net/wimax/i2400m/usb.c
+++ b/drivers/net/wimax/i2400m/usb.c
@@ -599,7 +599,7 @@ void i2400mu_disconnect(struct usb_interface *iface)
599 * 599 *
600 * As well, the device might refuse going to sleep for whichever 600 * As well, the device might refuse going to sleep for whichever
601 * reason. In this case we just fail. For system suspend/hibernate, 601 * reason. In this case we just fail. For system suspend/hibernate,
602 * we *can't* fail. We check PM_EVENT_AUTO to see if the 602 * we *can't* fail. We check PMSG_IS_AUTO to see if the
603 * suspend call comes from the USB stack or from the system and act 603 * suspend call comes from the USB stack or from the system and act
604 * in consequence. 604 * in consequence.
605 * 605 *
@@ -615,7 +615,7 @@ int i2400mu_suspend(struct usb_interface *iface, pm_message_t pm_msg)
615 struct i2400m *i2400m = &i2400mu->i2400m; 615 struct i2400m *i2400m = &i2400mu->i2400m;
616 616
617#ifdef CONFIG_PM 617#ifdef CONFIG_PM
618 if (pm_msg.event & PM_EVENT_AUTO) 618 if (PMSG_IS_AUTO(pm_msg))
619 is_autosuspend = 1; 619 is_autosuspend = 1;
620#endif 620#endif
621 621
diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c
index dac7676ce21b..94e6c5c09dd8 100644
--- a/drivers/usb/class/cdc-acm.c
+++ b/drivers/usb/class/cdc-acm.c
@@ -1305,7 +1305,7 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message)
1305 struct acm *acm = usb_get_intfdata(intf); 1305 struct acm *acm = usb_get_intfdata(intf);
1306 int cnt; 1306 int cnt;
1307 1307
1308 if (message.event & PM_EVENT_AUTO) { 1308 if (PMSG_IS_AUTO(message)) {
1309 int b; 1309 int b;
1310 1310
1311 spin_lock_irq(&acm->write_lock); 1311 spin_lock_irq(&acm->write_lock);
diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 2b9ff518b509..42f180aca3fb 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -798,11 +798,11 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
798 dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor); 798 dev_dbg(&desc->intf->dev, "wdm%d_suspend\n", intf->minor);
799 799
800 /* if this is an autosuspend the caller does the locking */ 800 /* if this is an autosuspend the caller does the locking */
801 if (!(message.event & PM_EVENT_AUTO)) 801 if (!PMSG_IS_AUTO(message))
802 mutex_lock(&desc->lock); 802 mutex_lock(&desc->lock);
803 spin_lock_irq(&desc->iuspin); 803 spin_lock_irq(&desc->iuspin);
804 804
805 if ((message.event & PM_EVENT_AUTO) && 805 if (PMSG_IS_AUTO(message) &&
806 (test_bit(WDM_IN_USE, &desc->flags) 806 (test_bit(WDM_IN_USE, &desc->flags)
807 || test_bit(WDM_RESPONDING, &desc->flags))) { 807 || test_bit(WDM_RESPONDING, &desc->flags))) {
808 spin_unlock_irq(&desc->iuspin); 808 spin_unlock_irq(&desc->iuspin);
@@ -815,7 +815,7 @@ static int wdm_suspend(struct usb_interface *intf, pm_message_t message)
815 kill_urbs(desc); 815 kill_urbs(desc);
816 cancel_work_sync(&desc->rxwork); 816 cancel_work_sync(&desc->rxwork);
817 } 817 }
818 if (!(message.event & PM_EVENT_AUTO)) 818 if (!PMSG_IS_AUTO(message))
819 mutex_unlock(&desc->lock); 819 mutex_unlock(&desc->lock);
820 820
821 return rv; 821 return rv;
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 34e3da5aa72a..e03042883c68 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -1046,8 +1046,7 @@ static int usb_resume_device(struct usb_device *udev, pm_message_t msg)
1046 /* Non-root devices on a full/low-speed bus must wait for their 1046 /* Non-root devices on a full/low-speed bus must wait for their
1047 * companion high-speed root hub, in case a handoff is needed. 1047 * companion high-speed root hub, in case a handoff is needed.
1048 */ 1048 */
1049 if (!(msg.event & PM_EVENT_AUTO) && udev->parent && 1049 if (!PMSG_IS_AUTO(msg) && udev->parent && udev->bus->hs_companion)
1050 udev->bus->hs_companion)
1051 device_pm_wait_for_dev(&udev->dev, 1050 device_pm_wait_for_dev(&udev->dev,
1052 &udev->bus->hs_companion->root_hub->dev); 1051 &udev->bus->hs_companion->root_hub->dev);
1053 1052
@@ -1075,7 +1074,7 @@ static int usb_suspend_interface(struct usb_device *udev,
1075 1074
1076 if (driver->suspend) { 1075 if (driver->suspend) {
1077 status = driver->suspend(intf, msg); 1076 status = driver->suspend(intf, msg);
1078 if (status && !(msg.event & PM_EVENT_AUTO)) 1077 if (status && !PMSG_IS_AUTO(msg))
1079 dev_err(&intf->dev, "%s error %d\n", 1078 dev_err(&intf->dev, "%s error %d\n",
1080 "suspend", status); 1079 "suspend", status);
1081 } else { 1080 } else {
@@ -1189,7 +1188,7 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1189 status = usb_suspend_interface(udev, intf, msg); 1188 status = usb_suspend_interface(udev, intf, msg);
1190 1189
1191 /* Ignore errors during system sleep transitions */ 1190 /* Ignore errors during system sleep transitions */
1192 if (!(msg.event & PM_EVENT_AUTO)) 1191 if (!PMSG_IS_AUTO(msg))
1193 status = 0; 1192 status = 0;
1194 if (status != 0) 1193 if (status != 0)
1195 break; 1194 break;
@@ -1199,7 +1198,7 @@ static int usb_suspend_both(struct usb_device *udev, pm_message_t msg)
1199 status = usb_suspend_device(udev, msg); 1198 status = usb_suspend_device(udev, msg);
1200 1199
1201 /* Again, ignore errors during system sleep transitions */ 1200 /* Again, ignore errors during system sleep transitions */
1202 if (!(msg.event & PM_EVENT_AUTO)) 1201 if (!PMSG_IS_AUTO(msg))
1203 status = 0; 1202 status = 0;
1204 } 1203 }
1205 1204
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 8669ba3fe794..da582f4e486b 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1960,7 +1960,7 @@ int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
1960 int old_state = hcd->state; 1960 int old_state = hcd->state;
1961 1961
1962 dev_dbg(&rhdev->dev, "bus %s%s\n", 1962 dev_dbg(&rhdev->dev, "bus %s%s\n",
1963 (msg.event & PM_EVENT_AUTO ? "auto-" : ""), "suspend"); 1963 (PMSG_IS_AUTO(msg) ? "auto-" : ""), "suspend");
1964 if (HCD_DEAD(hcd)) { 1964 if (HCD_DEAD(hcd)) {
1965 dev_dbg(&rhdev->dev, "skipped %s of dead bus\n", "suspend"); 1965 dev_dbg(&rhdev->dev, "skipped %s of dead bus\n", "suspend");
1966 return 0; 1966 return 0;
@@ -1996,7 +1996,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
1996 int old_state = hcd->state; 1996 int old_state = hcd->state;
1997 1997
1998 dev_dbg(&rhdev->dev, "usb %s%s\n", 1998 dev_dbg(&rhdev->dev, "usb %s%s\n",
1999 (msg.event & PM_EVENT_AUTO ? "auto-" : ""), "resume"); 1999 (PMSG_IS_AUTO(msg) ? "auto-" : ""), "resume");
2000 if (HCD_DEAD(hcd)) { 2000 if (HCD_DEAD(hcd)) {
2001 dev_dbg(&rhdev->dev, "skipped %s of dead bus\n", "resume"); 2001 dev_dbg(&rhdev->dev, "skipped %s of dead bus\n", "resume");
2002 return 0; 2002 return 0;
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a428aa080a36..ee50e0bf84e8 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2342,7 +2342,7 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
2342 dev_dbg(&udev->dev, "won't remote wakeup, status %d\n", 2342 dev_dbg(&udev->dev, "won't remote wakeup, status %d\n",
2343 status); 2343 status);
2344 /* bail if autosuspend is requested */ 2344 /* bail if autosuspend is requested */
2345 if (msg.event & PM_EVENT_AUTO) 2345 if (PMSG_IS_AUTO(msg))
2346 return status; 2346 return status;
2347 } 2347 }
2348 } 2348 }
@@ -2367,12 +2367,12 @@ int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
2367 USB_CTRL_SET_TIMEOUT); 2367 USB_CTRL_SET_TIMEOUT);
2368 2368
2369 /* System sleep transitions should never fail */ 2369 /* System sleep transitions should never fail */
2370 if (!(msg.event & PM_EVENT_AUTO)) 2370 if (!PMSG_IS_AUTO(msg))
2371 status = 0; 2371 status = 0;
2372 } else { 2372 } else {
2373 /* device has up to 10 msec to fully suspend */ 2373 /* device has up to 10 msec to fully suspend */
2374 dev_dbg(&udev->dev, "usb %ssuspend\n", 2374 dev_dbg(&udev->dev, "usb %ssuspend\n",
2375 (msg.event & PM_EVENT_AUTO ? "auto-" : "")); 2375 (PMSG_IS_AUTO(msg) ? "auto-" : ""));
2376 usb_set_device_state(udev, USB_STATE_SUSPENDED); 2376 usb_set_device_state(udev, USB_STATE_SUSPENDED);
2377 msleep(10); 2377 msleep(10);
2378 } 2378 }
@@ -2523,7 +2523,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
2523 } else { 2523 } else {
2524 /* drive resume for at least 20 msec */ 2524 /* drive resume for at least 20 msec */
2525 dev_dbg(&udev->dev, "usb %sresume\n", 2525 dev_dbg(&udev->dev, "usb %sresume\n",
2526 (msg.event & PM_EVENT_AUTO ? "auto-" : "")); 2526 (PMSG_IS_AUTO(msg) ? "auto-" : ""));
2527 msleep(25); 2527 msleep(25);
2528 2528
2529 /* Virtual root hubs can trigger on GET_PORT_STATUS to 2529 /* Virtual root hubs can trigger on GET_PORT_STATUS to
@@ -2625,7 +2625,7 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
2625 udev = hdev->children [port1-1]; 2625 udev = hdev->children [port1-1];
2626 if (udev && udev->can_submit) { 2626 if (udev && udev->can_submit) {
2627 dev_warn(&intf->dev, "port %d nyet suspended\n", port1); 2627 dev_warn(&intf->dev, "port %d nyet suspended\n", port1);
2628 if (msg.event & PM_EVENT_AUTO) 2628 if (PMSG_IS_AUTO(msg))
2629 return -EBUSY; 2629 return -EBUSY;
2630 } 2630 }
2631 } 2631 }
diff --git a/drivers/usb/serial/sierra.c b/drivers/usb/serial/sierra.c
index d5d136a53b61..b18179bda0d8 100644
--- a/drivers/usb/serial/sierra.c
+++ b/drivers/usb/serial/sierra.c
@@ -1009,7 +1009,7 @@ static int sierra_suspend(struct usb_serial *serial, pm_message_t message)
1009 struct sierra_intf_private *intfdata; 1009 struct sierra_intf_private *intfdata;
1010 int b; 1010 int b;
1011 1011
1012 if (message.event & PM_EVENT_AUTO) { 1012 if (PMSG_IS_AUTO(message)) {
1013 intfdata = serial->private; 1013 intfdata = serial->private;
1014 spin_lock_irq(&intfdata->susp_lock); 1014 spin_lock_irq(&intfdata->susp_lock);
1015 b = intfdata->in_flight; 1015 b = intfdata->in_flight;
diff --git a/drivers/usb/serial/usb_wwan.c b/drivers/usb/serial/usb_wwan.c
index e4fad5e643d7..d555ca9567b8 100644
--- a/drivers/usb/serial/usb_wwan.c
+++ b/drivers/usb/serial/usb_wwan.c
@@ -651,7 +651,7 @@ int usb_wwan_suspend(struct usb_serial *serial, pm_message_t message)
651 651
652 dbg("%s entered", __func__); 652 dbg("%s entered", __func__);
653 653
654 if (message.event & PM_EVENT_AUTO) { 654 if (PMSG_IS_AUTO(message)) {
655 spin_lock_irq(&intfdata->susp_lock); 655 spin_lock_irq(&intfdata->susp_lock);
656 b = intfdata->in_flight; 656 b = intfdata->in_flight;
657 spin_unlock_irq(&intfdata->susp_lock); 657 spin_unlock_irq(&intfdata->susp_lock);