|
8 | 8 | #ifndef _LINUX_PM_H
|
9 | 9 | #define _LINUX_PM_H
|
10 | 10 |
|
| 11 | +#include <linux/export.h> |
11 | 12 | #include <linux/list.h>
|
12 | 13 | #include <linux/workqueue.h>
|
13 | 14 | #include <linux/spinlock.h>
|
@@ -357,14 +358,42 @@ struct dev_pm_ops {
|
357 | 358 | #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn)
|
358 | 359 | #endif
|
359 | 360 |
|
| 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 | + |
360 | 383 | /*
|
361 | 384 | * Use this if you want to use the same suspend and resume callbacks for suspend
|
362 | 385 | * 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. |
363 | 389 | */
|
364 | 390 | #define DEFINE_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
|
365 |
| -const struct dev_pm_ops name = { \ |
366 |
| - SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ |
367 |
| -} |
| 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") |
368 | 397 |
|
369 | 398 | /* Deprecated. Use DEFINE_SIMPLE_DEV_PM_OPS() instead. */
|
370 | 399 | #define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \
|
|
0 commit comments