Add test_and_clear and test_and_set.
Showing the changes to include/linux/blkdev.h (1 of 2 files). Show all
Unified · Split
| @@ -428,6 +428,32 @@ static inline void queue_flag_set_unlocked(unsigned int flag, · 427 unmodified lines | |||
| 428 | __set_bit(flag, &q->queue_flags); | 428 | __set_bit(flag, &q->queue_flags); |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | static inline int queue_flag_test_and_clear(unsigned int flag, | ||
| 432 | struct request_queue *q) | ||
| 433 | { | ||
| 434 | WARN_ON_ONCE(!queue_is_locked(q)); | ||
| 435 | |||
| 436 | if (test_bit(flag, &q->queue_flags)) { | ||
| 437 | __clear_bit(flag, &q->queue_flags); | ||
| 438 | return 1; | ||
| 439 | } | ||
| 440 | |||
| 441 | return 0; | ||
| 442 | } | ||
| 443 | |||
| 444 | static inline int queue_flag_test_and_set(unsigned int flag, | ||
| 445 | struct request_queue *q) | ||
| 446 | { | ||
| 447 | WARN_ON_ONCE(!queue_is_locked(q)); | ||
| 448 | |||
| 449 | if (!test_bit(flag, &q->queue_flags)) { | ||
| 450 | __set_bit(flag, &q->queue_flags); | ||
| 451 | return 0; | ||
| 452 | } | ||
| 453 | |||
| 454 | return 1; | ||
| 455 | } | ||
| 456 | |||
| 431 | static inline void queue_flag_set(unsigned int flag, struct request_queue *q) | 457 | static inline void queue_flag_set(unsigned int flag, struct request_queue *q) |
| 432 | { | 458 | { |
| 433 | WARN_ON_ONCE(!queue_is_locked(q)); | 459 | WARN_ON_ONCE(!queue_is_locked(q)); |