Skip to content

Commit 8357f6f

Browse files
committed
Merge tag 'pm-5.17-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull more power management updates from Rafael Wysocki: "This is a continuation of the rework of device power management macros used for declaring device power management callbacks (Paul Cercueil)" * tag 'pm-5.17-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: iio: pressure: bmp280: Use new PM macros PM: runtime: Add EXPORT[_GPL]_RUNTIME_DEV_PM_OPS macros PM: runtime: Add DEFINE_RUNTIME_DEV_PM_OPS() macro PM: core: Add EXPORT[_GPL]_SIMPLE_DEV_PM_OPS macros PM: core: Remove static qualifier in DEFINE_SIMPLE_DEV_PM_OPS macro PM: core: Remove DEFINE_UNIVERSAL_DEV_PM_OPS() macro
2 parents 6a8d7fb + 5865918 commit 8357f6f

File tree

7 files changed

+71
-29
lines changed

7 files changed

+71
-29
lines changed

drivers/iio/pressure/bmp280-core.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,6 @@ int bmp280_common_probe(struct device *dev,
11381138
}
11391139
EXPORT_SYMBOL(bmp280_common_probe);
11401140

1141-
#ifdef CONFIG_PM
11421141
static int bmp280_runtime_suspend(struct device *dev)
11431142
{
11441143
struct iio_dev *indio_dev = dev_get_drvdata(dev);
@@ -1159,15 +1158,9 @@ static int bmp280_runtime_resume(struct device *dev)
11591158
usleep_range(data->start_up_time, data->start_up_time + 100);
11601159
return data->chip_info->chip_config(data);
11611160
}
1162-
#endif /* CONFIG_PM */
11631161

1164-
const struct dev_pm_ops bmp280_dev_pm_ops = {
1165-
SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
1166-
pm_runtime_force_resume)
1167-
SET_RUNTIME_PM_OPS(bmp280_runtime_suspend,
1168-
bmp280_runtime_resume, NULL)
1169-
};
1170-
EXPORT_SYMBOL(bmp280_dev_pm_ops);
1162+
EXPORT_RUNTIME_DEV_PM_OPS(bmp280_dev_pm_ops, bmp280_runtime_suspend,
1163+
bmp280_runtime_resume, NULL);
11711164

11721165
MODULE_AUTHOR("Vlad Dogaru <[email protected]>");
11731166
MODULE_DESCRIPTION("Driver for Bosch Sensortec BMP180/BMP280 pressure and temperature sensor");

drivers/iio/pressure/bmp280-i2c.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static struct i2c_driver bmp280_i2c_driver = {
5858
.driver = {
5959
.name = "bmp280",
6060
.of_match_table = bmp280_of_i2c_match,
61-
.pm = &bmp280_dev_pm_ops,
61+
.pm = pm_ptr(&bmp280_dev_pm_ops),
6262
},
6363
.probe = bmp280_i2c_probe,
6464
.id_table = bmp280_i2c_id,

drivers/iio/pressure/bmp280-spi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static struct spi_driver bmp280_spi_driver = {
109109
.driver = {
110110
.name = "bmp280",
111111
.of_match_table = bmp280_of_spi_match,
112-
.pm = &bmp280_dev_pm_ops,
112+
.pm = pm_ptr(&bmp280_dev_pm_ops),
113113
},
114114
.id_table = bmp280_spi_id,
115115
.probe = bmp280_spi_probe,

drivers/mmc/host/jz4740_mmc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1128,8 +1128,8 @@ static int jz4740_mmc_resume(struct device *dev)
11281128
return pinctrl_select_default_state(dev);
11291129
}
11301130

1131-
DEFINE_SIMPLE_DEV_PM_OPS(jz4740_mmc_pm_ops, jz4740_mmc_suspend,
1132-
jz4740_mmc_resume);
1131+
static DEFINE_SIMPLE_DEV_PM_OPS(jz4740_mmc_pm_ops, jz4740_mmc_suspend,
1132+
jz4740_mmc_resume);
11331133

11341134
static struct platform_driver jz4740_mmc_driver = {
11351135
.probe = jz4740_mmc_probe,

drivers/mmc/host/mxcmmc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1210,7 +1210,7 @@ static int mxcmci_resume(struct device *dev)
12101210
return ret;
12111211
}
12121212

1213-
DEFINE_SIMPLE_DEV_PM_OPS(mxcmci_pm_ops, mxcmci_suspend, mxcmci_resume);
1213+
static DEFINE_SIMPLE_DEV_PM_OPS(mxcmci_pm_ops, mxcmci_suspend, mxcmci_resume);
12141214

12151215
static struct platform_driver mxcmci_driver = {
12161216
.probe = mxcmci_probe,

include/linux/pm.h

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#ifndef _LINUX_PM_H
99
#define _LINUX_PM_H
1010

11+
#include <linux/export.h>
1112
#include <linux/list.h>
1213
#include <linux/workqueue.h>
1314
#include <linux/spinlock.h>
@@ -357,13 +358,47 @@ struct dev_pm_ops {
357358
#define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
358359
#endif
359360

361+
#define _DEFINE_DEV_PM_OPS(name, \
362+
suspend_fn, resume_fn, \
363+
runtime_suspend_fn, runtime_resume_fn, idle_fn) \
364+
const struct dev_pm_ops name = { \
365+
SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
366+
RUNTIME_PM_OPS(runtime_suspend_fn, runtime_resume_fn, idle_fn) \
367+
}
368+
369+
#ifdef CONFIG_PM
370+
#define _EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn, \
371+
runtime_resume_fn, idle_fn, sec) \
372+
_DEFINE_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn, \
373+
runtime_resume_fn, idle_fn); \
374+
_EXPORT_SYMBOL(name, sec)
375+
#else
376+
#define _EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, runtime_suspend_fn, \
377+
runtime_resume_fn, idle_fn, sec) \
378+
static __maybe_unused _DEFINE_DEV_PM_OPS(__static_##name, suspend_fn, \
379+
resume_fn, runtime_suspend_fn, \
380+
runtime_resume_fn, idle_fn)
381+
#endif
382+
360383
/*
361384
* Use this if you want to use the same suspend and resume callbacks for suspend
362385
* to RAM and hibernation.
386+
*
387+
* If the underlying dev_pm_ops struct symbol has to be exported, use
388+
* EXPORT_SIMPLE_DEV_PM_OPS() or EXPORT_GPL_SIMPLE_DEV_PM_OPS() instead.
363389
*/
364390
#define DEFINE_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
365-
static const struct dev_pm_ops name = { \
366-
SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
391+
_DEFINE_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL)
392+
393+
#define EXPORT_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
394+
_EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL, "")
395+
#define EXPORT_GPL_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
396+
_EXPORT_DEV_PM_OPS(name, suspend_fn, resume_fn, NULL, NULL, NULL, "_gpl")
397+
398+
/* Deprecated. Use DEFINE_SIMPLE_DEV_PM_OPS() instead. */
399+
#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
400+
const struct dev_pm_ops __maybe_unused name = { \
401+
SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
367402
}
368403

369404
/*
@@ -378,20 +413,10 @@ static const struct dev_pm_ops name = { \
378413
* suspend and "early" resume callback pointers, .suspend_late() and
379414
* .resume_early(), to the same routines as .runtime_suspend() and
380415
* .runtime_resume(), respectively (and analogously for hibernation).
416+
*
417+
* Deprecated. You most likely don't want this macro. Use
418+
* DEFINE_RUNTIME_DEV_PM_OPS() instead.
381419
*/
382-
#define DEFINE_UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
383-
static const struct dev_pm_ops name = { \
384-
SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
385-
RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
386-
}
387-
388-
/* Deprecated. Use DEFINE_SIMPLE_DEV_PM_OPS() instead. */
389-
#define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
390-
const struct dev_pm_ops __maybe_unused name = { \
391-
SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \
392-
}
393-
394-
/* Deprecated. Use DEFINE_UNIVERSAL_DEV_PM_OPS() instead. */
395420
#define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
396421
const struct dev_pm_ops __maybe_unused name = { \
397422
SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \

include/linux/pm_runtime.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,30 @@
2222
usage_count */
2323
#define RPM_AUTO 0x08 /* Use autosuspend_delay */
2424

25+
/*
26+
* Use this for defining a set of PM operations to be used in all situations
27+
* (system suspend, hibernation or runtime PM).
28+
*
29+
* Note that the behaviour differs from the deprecated UNIVERSAL_DEV_PM_OPS()
30+
* macro, which uses the provided callbacks for both runtime PM and system
31+
* sleep, while DEFINE_RUNTIME_DEV_PM_OPS() uses pm_runtime_force_suspend()
32+
* and pm_runtime_force_resume() for its system sleep callbacks.
33+
*
34+
* If the underlying dev_pm_ops struct symbol has to be exported, use
35+
* EXPORT_RUNTIME_DEV_PM_OPS() or EXPORT_GPL_RUNTIME_DEV_PM_OPS() instead.
36+
*/
37+
#define DEFINE_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
38+
_DEFINE_DEV_PM_OPS(name, pm_runtime_force_suspend, \
39+
pm_runtime_force_resume, suspend_fn, \
40+
resume_fn, idle_fn)
41+
42+
#define EXPORT_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
43+
_EXPORT_DEV_PM_OPS(name, pm_runtime_force_suspend, pm_runtime_force_resume, \
44+
suspend_fn, resume_fn, idle_fn, "")
45+
#define EXPORT_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
46+
_EXPORT_DEV_PM_OPS(name, pm_runtime_force_suspend, pm_runtime_force_resume, \
47+
suspend_fn, resume_fn, idle_fn, "_gpl")
48+
2549
#ifdef CONFIG_PM
2650
extern struct workqueue_struct *pm_wq;
2751

0 commit comments

Comments
 (0)