Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b1b0b81 authored by Alan Stern's avatar Alan Stern Committed by Rafael J. Wysocki
Browse files

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: default avatarAlan Stern <stern@rowland.harvard.edu>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarRafael J. Wysocki <rjw@sisk.pl>
parent 311aab73
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -439,10 +439,10 @@ cause autosuspends to fail with -EBUSY if the driver needs to use the
device.

External suspend calls should never be allowed to fail in this way,
only autosuspend calls.  The driver can tell them apart by checking
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.
only autosuspend calls.  The driver can tell them apart by applying
the PMSG_IS_AUTO() macro to the message argument to the suspend
method; it will return True for internal PM events (autosuspend) and
False for external PM events.


	Mutual exclusion
+1 −1
Original line number Diff line number Diff line
@@ -1103,7 +1103,7 @@ static int btusb_suspend(struct usb_interface *intf, pm_message_t message)
		return 0;

	spin_lock_irq(&data->txlock);
	if (!((message.event & PM_EVENT_AUTO) && data->tx_in_flight)) {
	if (!(PMSG_IS_AUTO(message) && data->tx_in_flight)) {
		set_bit(BTUSB_SUSPENDING, &data->flags);
		spin_unlock_irq(&data->txlock);
	} else {
+1 −1
Original line number Diff line number Diff line
@@ -2409,7 +2409,7 @@ static int picolcd_raw_event(struct hid_device *hdev,
#ifdef CONFIG_PM
static int picolcd_suspend(struct hid_device *hdev, pm_message_t message)
{
	if (message.event & PM_EVENT_AUTO)
	if (PMSG_IS_AUTO(message))
		return 0;

	picolcd_suspend_backlight(hid_get_drvdata(hdev));
+3 −4
Original line number Diff line number Diff line
@@ -1332,7 +1332,7 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
	struct usbhid_device *usbhid = hid->driver_data;
	int status;

	if (message.event & PM_EVENT_AUTO) {
	if (PMSG_IS_AUTO(message)) {
		spin_lock_irq(&usbhid->lock);	/* Sync with error handler */
		if (!test_bit(HID_RESET_PENDING, &usbhid->iofl)
		    && !test_bit(HID_CLEAR_HALT, &usbhid->iofl)
@@ -1367,7 +1367,7 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
			return -EIO;
	}

	if (!ignoreled && (message.event & PM_EVENT_AUTO)) {
	if (!ignoreled && PMSG_IS_AUTO(message)) {
		spin_lock_irq(&usbhid->lock);
		if (test_bit(HID_LED_ON, &usbhid->iofl)) {
			spin_unlock_irq(&usbhid->lock);
@@ -1380,8 +1380,7 @@ static int hid_suspend(struct usb_interface *intf, pm_message_t message)
	hid_cancel_delayed_stuff(usbhid);
	hid_cease_io(usbhid);

	if ((message.event & PM_EVENT_AUTO) &&
			test_bit(HID_KEYS_PRESSED, &usbhid->iofl)) {
	if (PMSG_IS_AUTO(message) && test_bit(HID_KEYS_PRESSED, &usbhid->iofl)) {
		/* lost race against keypresses */
		status = hid_start_in(hid);
		if (status < 0)
+1 −1
Original line number Diff line number Diff line
@@ -1470,7 +1470,7 @@ int usbnet_suspend (struct usb_interface *intf, pm_message_t message)
	if (!dev->suspend_count++) {
		spin_lock_irq(&dev->txq.lock);
		/* don't autosuspend while transmitting */
		if (dev->txq.qlen && (message.event & PM_EVENT_AUTO)) {
		if (dev->txq.qlen && PMSG_IS_AUTO(message)) {
			spin_unlock_irq(&dev->txq.lock);
			return -EBUSY;
		} else {
Loading