]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
PM: runtime: Relocate rpm_callback() right after __rpm_callback()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 2 Dec 2022 14:32:09 +0000 (15:32 +0100)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Mon, 5 Dec 2022 14:43:37 +0000 (15:43 +0100)
Because rpm_callback() is a wrapper around __rpm_callback(), and the
only caller of it after the change eliminating an invocation of it
from rpm_idle(), move the former next to the latter to make the code
a bit easier to follow.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
drivers/base/power/runtime.c

index 14088b5adb556525fcfeb0c8b77252c753086133..5a5cd1d8c4a9b7f1c5efd7c6d0c3da5c9b050812 100644 (file)
@@ -421,6 +421,38 @@ fail:
        return retval;
 }
 
+/**
+ * rpm_callback - Run a given runtime PM callback for a given device.
+ * @cb: Runtime PM callback to run.
+ * @dev: Device to run the callback for.
+ */
+static int rpm_callback(int (*cb)(struct device *), struct device *dev)
+{
+       int retval;
+
+       if (dev->power.memalloc_noio) {
+               unsigned int noio_flag;
+
+               /*
+                * Deadlock might be caused if memory allocation with
+                * GFP_KERNEL happens inside runtime_suspend and
+                * runtime_resume callbacks of one block device's
+                * ancestor or the block device itself. Network
+                * device might be thought as part of iSCSI block
+                * device, so network device and its ancestor should
+                * be marked as memalloc_noio too.
+                */
+               noio_flag = memalloc_noio_save();
+               retval = __rpm_callback(cb, dev);
+               memalloc_noio_restore(noio_flag);
+       } else {
+               retval = __rpm_callback(cb, dev);
+       }
+
+       dev->power.runtime_error = retval;
+       return retval != -EACCES ? retval : -EIO;
+}
+
 /**
  * rpm_idle - Notify device bus type if the device can be suspended.
  * @dev: Device to notify the bus type about.
@@ -504,38 +536,6 @@ static int rpm_idle(struct device *dev, int rpmflags)
        return retval ? retval : rpm_suspend(dev, rpmflags | RPM_AUTO);
 }
 
-/**
- * rpm_callback - Run a given runtime PM callback for a given device.
- * @cb: Runtime PM callback to run.
- * @dev: Device to run the callback for.
- */
-static int rpm_callback(int (*cb)(struct device *), struct device *dev)
-{
-       int retval;
-
-       if (dev->power.memalloc_noio) {
-               unsigned int noio_flag;
-
-               /*
-                * Deadlock might be caused if memory allocation with
-                * GFP_KERNEL happens inside runtime_suspend and
-                * runtime_resume callbacks of one block device's
-                * ancestor or the block device itself. Network
-                * device might be thought as part of iSCSI block
-                * device, so network device and its ancestor should
-                * be marked as memalloc_noio too.
-                */
-               noio_flag = memalloc_noio_save();
-               retval = __rpm_callback(cb, dev);
-               memalloc_noio_restore(noio_flag);
-       } else {
-               retval = __rpm_callback(cb, dev);
-       }
-
-       dev->power.runtime_error = retval;
-       return retval != -EACCES ? retval : -EIO;
-}
-
 /**
  * rpm_suspend - Carry out runtime suspend of given device.
  * @dev: Device to suspend.