Skip to content

Commit 5a2bd1b

Browse files
storulfrafaeljw
authored andcommitted
PM: runtime: Improve path in rpm_idle() when no callback
When pm_runtime_no_callbacks() has been called for a struct device to set the dev->power.no_callbacks flag for it, it enables rpm_idle() to take a slightly quicker path by assuming that a ->runtime_idle() callback would have returned 0 to indicate success. A device that does not have the dev->power.no_callbacks flag set for it, may still be missing a corresponding ->runtime_idle() callback, in which case the slower path in rpm_idle() is taken. Let's improve the behaviour for this case, by aligning code to the quicker path. Signed-off-by: Ulf Hansson <[email protected]> Acked-by: Alan Stern <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent c58e7ed commit 5a2bd1b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

drivers/base/power/runtime.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,10 @@ static int rpm_idle(struct device *dev, int rpmflags)
446446
/* Pending requests need to be canceled. */
447447
dev->power.request = RPM_REQ_NONE;
448448

449-
if (dev->power.no_callbacks)
449+
callback = RPM_GET_CALLBACK(dev, runtime_idle);
450+
451+
/* If no callback assume success. */
452+
if (!callback || dev->power.no_callbacks)
450453
goto out;
451454

452455
/* Carry out an asynchronous or a synchronous idle notification. */
@@ -462,10 +465,7 @@ static int rpm_idle(struct device *dev, int rpmflags)
462465

463466
dev->power.idle_notification = true;
464467

465-
callback = RPM_GET_CALLBACK(dev, runtime_idle);
466-
467-
if (callback)
468-
retval = __rpm_callback(callback, dev);
468+
retval = __rpm_callback(callback, dev);
469469

470470
dev->power.idle_notification = false;
471471
wake_up_all(&dev->power.wait_queue);

0 commit comments

Comments
 (0)