Bart Van Assche | bca6b06 | 2018-09-26 14:01:03 -0700 | [diff] [blame^] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
| 2 | |
| 3 | #ifndef _BLOCK_BLK_PM_H_ |
| 4 | #define _BLOCK_BLK_PM_H_ |
| 5 | |
| 6 | #include <linux/pm_runtime.h> |
| 7 | |
| 8 | #ifdef CONFIG_PM |
| 9 | static inline void blk_pm_requeue_request(struct request *rq) |
| 10 | { |
| 11 | if (rq->q->dev && !(rq->rq_flags & RQF_PM)) |
| 12 | rq->q->nr_pending--; |
| 13 | } |
| 14 | |
| 15 | static inline void blk_pm_add_request(struct request_queue *q, |
| 16 | struct request *rq) |
| 17 | { |
| 18 | if (q->dev && !(rq->rq_flags & RQF_PM) && q->nr_pending++ == 0 && |
| 19 | (q->rpm_status == RPM_SUSPENDED || q->rpm_status == RPM_SUSPENDING)) |
| 20 | pm_request_resume(q->dev); |
| 21 | } |
| 22 | |
| 23 | static inline void blk_pm_put_request(struct request *rq) |
| 24 | { |
| 25 | if (rq->q->dev && !(rq->rq_flags & RQF_PM) && !--rq->q->nr_pending) |
| 26 | pm_runtime_mark_last_busy(rq->q->dev); |
| 27 | } |
| 28 | #else |
| 29 | static inline void blk_pm_requeue_request(struct request *rq) |
| 30 | { |
| 31 | } |
| 32 | |
| 33 | static inline void blk_pm_add_request(struct request_queue *q, |
| 34 | struct request *rq) |
| 35 | { |
| 36 | } |
| 37 | |
| 38 | static inline void blk_pm_put_request(struct request *rq) |
| 39 | { |
| 40 | } |
| 41 | #endif |
| 42 | |
| 43 | #endif /* _BLOCK_BLK_PM_H_ */ |