Skip to content

Commit 9ec17c7

Browse files
committed
PM: Move two sleep-related functions under CONFIG_PM_SLEEP
JIRA: https://issues.redhat.com/browse/RHEL-109251 commit c021c1b Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Date: Thu, 03 Jul 2025 17:10:40 +0000 Since pm_runtime_force_resume() and pm_runtime_need_not_resume() are only needed for handling system-wide PM transitions, there is no reason to compile them in if CONFIG_PM_SLEEP is unset. Accordingly, move them under CONFIG_PM_SLEEP and make the static inline stub for pm_runtime_force_resume() return an error to indicate that it should not be used outside CONFIG_PM_SLEEP. Putting pm_runtime_force_resume() also allows subsequent changes to be more straightforward because this function is going to access a device PM flag that is only defined when CONFIG_PM_SLEEP is set. Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Link: https://patch.msgid.link/3384523.aeNJFYEL58@rjwysocki.net Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
1 parent 0d56f9a commit 9ec17c7

File tree

2 files changed

+23
-11
lines changed

2 files changed

+23
-11
lines changed

drivers/base/power/runtime.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,13 +1941,6 @@ void pm_runtime_drop_link(struct device_link *link)
19411941
pm_request_idle(link->supplier);
19421942
}
19431943

1944-
bool pm_runtime_need_not_resume(struct device *dev)
1945-
{
1946-
return atomic_read(&dev->power.usage_count) <= 1 &&
1947-
(atomic_read(&dev->power.child_count) == 0 ||
1948-
dev->power.ignore_children);
1949-
}
1950-
19511944
/**
19521945
* pm_runtime_force_suspend - Force a device into suspend state if needed.
19531946
* @dev: Device to suspend.
@@ -2009,6 +2002,8 @@ int pm_runtime_force_suspend(struct device *dev)
20092002
}
20102003
EXPORT_SYMBOL_GPL(pm_runtime_force_suspend);
20112004

2005+
#ifdef CONFIG_PM_SLEEP
2006+
20122007
/**
20132008
* pm_runtime_force_resume - Force a device into resume state if needed.
20142009
* @dev: Device to resume.
@@ -2052,3 +2047,12 @@ int pm_runtime_force_resume(struct device *dev)
20522047
return ret;
20532048
}
20542049
EXPORT_SYMBOL_GPL(pm_runtime_force_resume);
2050+
2051+
bool pm_runtime_need_not_resume(struct device *dev)
2052+
{
2053+
return atomic_read(&dev->power.usage_count) <= 1 &&
2054+
(atomic_read(&dev->power.child_count) == 0 ||
2055+
dev->power.ignore_children);
2056+
}
2057+
2058+
#endif /* CONFIG_PM_SLEEP */

include/linux/pm_runtime.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,7 @@ static inline bool queue_pm_work(struct work_struct *work)
6666

6767
extern int pm_generic_runtime_suspend(struct device *dev);
6868
extern int pm_generic_runtime_resume(struct device *dev);
69-
extern bool pm_runtime_need_not_resume(struct device *dev);
7069
extern int pm_runtime_force_suspend(struct device *dev);
71-
extern int pm_runtime_force_resume(struct device *dev);
7270

7371
extern int __pm_runtime_idle(struct device *dev, int rpmflags);
7472
extern int __pm_runtime_suspend(struct device *dev, int rpmflags);
@@ -259,9 +257,7 @@ static inline bool queue_pm_work(struct work_struct *work) { return false; }
259257

260258
static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
261259
static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
262-
static inline bool pm_runtime_need_not_resume(struct device *dev) {return true; }
263260
static inline int pm_runtime_force_suspend(struct device *dev) { return 0; }
264-
static inline int pm_runtime_force_resume(struct device *dev) { return 0; }
265261

266262
static inline int __pm_runtime_idle(struct device *dev, int rpmflags)
267263
{
@@ -332,6 +328,18 @@ static inline void pm_runtime_release_supplier(struct device_link *link) {}
332328

333329
#endif /* !CONFIG_PM */
334330

331+
#ifdef CONFIG_PM_SLEEP
332+
333+
bool pm_runtime_need_not_resume(struct device *dev);
334+
int pm_runtime_force_resume(struct device *dev);
335+
336+
#else /* !CONFIG_PM_SLEEP */
337+
338+
static inline bool pm_runtime_need_not_resume(struct device *dev) {return true; }
339+
static inline int pm_runtime_force_resume(struct device *dev) { return -ENXIO; }
340+
341+
#endif /* CONFIG_PM_SLEEP */
342+
335343
/**
336344
* pm_runtime_idle - Conditionally set up autosuspend of a device or suspend it.
337345
* @dev: Target device.

0 commit comments

Comments
 (0)