| @@ -300,47 +300,59 @@ struct dev_pm_ops { · 299 unmodified lines |
| 300 | int (*runtime_idle)(struct device *dev); | 300 | int (*runtime_idle)(struct device *dev); |
| 301 | }; | 301 | }; |
| 302 | | 302 | |
| | 303 | #define SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ |
| | 304 | .suspend = pm_sleep_ptr(suspend_fn), \ |
| | 305 | .resume = pm_sleep_ptr(resume_fn), \ |
| | 306 | .freeze = pm_sleep_ptr(suspend_fn), \ |
| | 307 | .thaw = pm_sleep_ptr(resume_fn), \ |
| | 308 | .poweroff = pm_sleep_ptr(suspend_fn), \ |
| | 309 | .restore = pm_sleep_ptr(resume_fn), |
| | 310 | |
| | 311 | #define LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ |
| | 312 | .suspend_late = pm_sleep_ptr(suspend_fn), \ |
| | 313 | .resume_early = pm_sleep_ptr(resume_fn), \ |
| | 314 | .freeze_late = pm_sleep_ptr(suspend_fn), \ |
| | 315 | .thaw_early = pm_sleep_ptr(resume_fn), \ |
| | 316 | .poweroff_late = pm_sleep_ptr(suspend_fn), \ |
| | 317 | .restore_early = pm_sleep_ptr(resume_fn), |
| | 318 | |
| | 319 | #define NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ |
| | 320 | .suspend_noirq = pm_sleep_ptr(suspend_fn), \ |
| | 321 | .resume_noirq = pm_sleep_ptr(resume_fn), \ |
| | 322 | .freeze_noirq = pm_sleep_ptr(suspend_fn), \ |
| | 323 | .thaw_noirq = pm_sleep_ptr(resume_fn), \ |
| | 324 | .poweroff_noirq = pm_sleep_ptr(suspend_fn), \ |
| | 325 | .restore_noirq = pm_sleep_ptr(resume_fn), |
| | 326 | |
| | 327 | #define RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ |
| | 328 | .runtime_suspend = suspend_fn, \ |
| | 329 | .runtime_resume = resume_fn, \ |
| | 330 | .runtime_idle = idle_fn, |
| | 331 | |
| 303 | #ifdef CONFIG_PM_SLEEP | 332 | #ifdef CONFIG_PM_SLEEP |
| 304 | #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ | 333 | #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ |
| 305 | .suspend = suspend_fn, \ | 334 | SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) |
| 306 | .resume = resume_fn, \ | | |
| 307 | .freeze = suspend_fn, \ | | |
| 308 | .thaw = resume_fn, \ | | |
| 309 | .poweroff = suspend_fn, \ | | |
| 310 | .restore = resume_fn, | | |
| 311 | #else | 335 | #else |
| 312 | #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) | 336 | #define SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) |
| 313 | #endif | 337 | #endif |
| 314 | | 338 | |
| 315 | #ifdef CONFIG_PM_SLEEP | 339 | #ifdef CONFIG_PM_SLEEP |
| 316 | #define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ | 340 | #define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ |
| 317 | .suspend_late = suspend_fn, \ | 341 | LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) |
| 318 | .resume_early = resume_fn, \ | | |
| 319 | .freeze_late = suspend_fn, \ | | |
| 320 | .thaw_early = resume_fn, \ | | |
| 321 | .poweroff_late = suspend_fn, \ | | |
| 322 | .restore_early = resume_fn, | | |
| 323 | #else | 342 | #else |
| 324 | #define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) | 343 | #define SET_LATE_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) |
| 325 | #endif | 344 | #endif |
| 326 | | 345 | |
| 327 | #ifdef CONFIG_PM_SLEEP | 346 | #ifdef CONFIG_PM_SLEEP |
| 328 | #define SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ | 347 | #define SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ |
| 329 | .suspend_noirq = suspend_fn, \ | 348 | NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) |
| 330 | .resume_noirq = resume_fn, \ | | |
| 331 | .freeze_noirq = suspend_fn, \ | | |
| 332 | .thaw_noirq = resume_fn, \ | | |
| 333 | .poweroff_noirq = suspend_fn, \ | | |
| 334 | .restore_noirq = resume_fn, | | |
| 335 | #else | 349 | #else |
| 336 | #define SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) | 350 | #define SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) |
| 337 | #endif | 351 | #endif |
| 338 | | 352 | |
| 339 | #ifdef CONFIG_PM | 353 | #ifdef CONFIG_PM |
| 340 | #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ | 354 | #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ |
| 341 | .runtime_suspend = suspend_fn, \ | 355 | RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) |
| 342 | .runtime_resume = resume_fn, \ | | |
| 343 | .runtime_idle = idle_fn, | | |
| 344 | #else | 356 | #else |
| 345 | #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) | 357 | #define SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) |
| 346 | #endif | 358 | #endif |
| @@ -349,9 +361,9 @@ struct dev_pm_ops { · 2 unmodified lines |
| 349 | * Use this if you want to use the same suspend and resume callbacks for suspend | 361 | * Use this if you want to use the same suspend and resume callbacks for suspend |
| 350 | * to RAM and hibernation. | 362 | * to RAM and hibernation. |
| 351 | */ | 363 | */ |
| 352 | #define SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ | 364 | #define DEFINE_SIMPLE_DEV_PM_OPS(name, suspend_fn, resume_fn) \ |
| 353 | const struct dev_pm_ops __maybe_unused name = { \ | 365 | static const struct dev_pm_ops name = { \ |
| 354 | SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ | 366 | SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ |
| 355 | } | 367 | } |
| 356 | | 368 | |
| 357 | /* | 369 | /* |
| @@ -367,17 +379,27 @@ const struct dev_pm_ops __maybe_unused name = { \ · 9 unmodified lines |
| 367 | * .resume_early(), to the same routines as .runtime_suspend() and | 379 | * .resume_early(), to the same routines as .runtime_suspend() and |
| 368 | * .runtime_resume(), respectively (and analogously for hibernation). | 380 | * .runtime_resume(), respectively (and analogously for hibernation). |
| 369 | */ | 381 | */ |
| | 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. */ |
| 370 | #define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \ | 395 | #define UNIVERSAL_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \ |
| 371 | const struct dev_pm_ops __maybe_unused name = { \ | 396 | const struct dev_pm_ops __maybe_unused name = { \ |
| 372 | SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ | 397 | SET_SYSTEM_SLEEP_PM_OPS(suspend_fn, resume_fn) \ |
| 373 | SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ | 398 | SET_RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \ |
| 374 | } | 399 | } |
| 375 | | 400 | |
| 376 | #ifdef CONFIG_PM | 401 | #define pm_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM), (_ptr)) |
| 377 | #define pm_ptr(_ptr) (_ptr) | 402 | #define pm_sleep_ptr(_ptr) PTR_IF(IS_ENABLED(CONFIG_PM_SLEEP), (_ptr)) |
| 378 | #else | | |
| 379 | #define pm_ptr(_ptr) NULL | | |
| 380 | #endif | | |
| 381 | | 403 | |
| 382 | /* | 404 | /* |
| 383 | * PM_EVENT_ messages | 405 | * PM_EVENT_ messages |
| @@ -499,6 +521,7 @@ const struct dev_pm_ops __maybe_unused name = { \ · 115 unmodified lines |
| 499 | */ | 521 | */ |
| 500 | | 522 | |
| 501 | enum rpm_status { | 523 | enum rpm_status { |
| | 524 | RPM_INVALID = -1, |
| 502 | RPM_ACTIVE = 0, | 525 | RPM_ACTIVE = 0, |
| 503 | RPM_RESUMING, | 526 | RPM_RESUMING, |
| 504 | RPM_SUSPENDED, | 527 | RPM_SUSPENDED, |
| @@ -612,6 +635,7 @@ struct dev_pm_info { · 107 unmodified lines |
| 612 | unsigned int links_count; | 635 | unsigned int links_count; |
| 613 | enum rpm_request request; | 636 | enum rpm_request request; |
| 614 | enum rpm_status runtime_status; | 637 | enum rpm_status runtime_status; |
| | 638 | enum rpm_status last_status; |
| 615 | int runtime_error; | 639 | int runtime_error; |
| 616 | int autosuspend_delay; | 640 | int autosuspend_delay; |
| 617 | u64 last_busy; | 641 | u64 last_busy; |