diff options
Diffstat (limited to 'include/linux/spinlock.h')
| -rw-r--r-- | include/linux/spinlock.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h index 61fef376ed2e..a946176db638 100644 --- a/include/linux/spinlock.h +++ b/include/linux/spinlock.h | |||
| @@ -283,6 +283,43 @@ do { \ | |||
| 283 | }) | 283 | }) |
| 284 | 284 | ||
| 285 | /* | 285 | /* |
| 286 | * Locks two spinlocks l1 and l2. | ||
| 287 | * l1_first indicates if spinlock l1 should be taken first. | ||
| 288 | */ | ||
| 289 | static inline void double_spin_lock(spinlock_t *l1, spinlock_t *l2, | ||
| 290 | bool l1_first) | ||
| 291 | __acquires(l1) | ||
| 292 | __acquires(l2) | ||
| 293 | { | ||
| 294 | if (l1_first) { | ||
| 295 | spin_lock(l1); | ||
| 296 | spin_lock(l2); | ||
| 297 | } else { | ||
| 298 | spin_lock(l2); | ||
| 299 | spin_lock(l1); | ||
| 300 | } | ||
| 301 | } | ||
| 302 | |||
| 303 | /* | ||
| 304 | * Unlocks two spinlocks l1 and l2. | ||
| 305 | * l1_taken_first indicates if spinlock l1 was taken first and therefore | ||
| 306 | * should be released after spinlock l2. | ||
| 307 | */ | ||
| 308 | static inline void double_spin_unlock(spinlock_t *l1, spinlock_t *l2, | ||
| 309 | bool l1_taken_first) | ||
| 310 | __releases(l1) | ||
| 311 | __releases(l2) | ||
| 312 | { | ||
| 313 | if (l1_taken_first) { | ||
| 314 | spin_unlock(l2); | ||
| 315 | spin_unlock(l1); | ||
| 316 | } else { | ||
| 317 | spin_unlock(l1); | ||
| 318 | spin_unlock(l2); | ||
| 319 | } | ||
| 320 | } | ||
| 321 | |||
| 322 | /* | ||
| 286 | * Pull the atomic_t declaration: | 323 | * Pull the atomic_t declaration: |
| 287 | * (asm-mips/atomic.h needs above definitions) | 324 | * (asm-mips/atomic.h needs above definitions) |
| 288 | */ | 325 | */ |
