mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
locking/arch, alpha: Add __down_read_killable()
Similar to __down_write_killable(), and read killable primitive. Signed-off-by: Kirill Tkhai <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Cc: [email protected] Link: http://lkml.kernel.org/r/150670115677.23930.5711263025537758463.stgit@localhost.localdomain Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
e6fd28eb35
commit
8c74392a8d
1 changed files with 18 additions and 3 deletions
|
|
@ -21,7 +21,7 @@
|
|||
#define RWSEM_ACTIVE_READ_BIAS RWSEM_ACTIVE_BIAS
|
||||
#define RWSEM_ACTIVE_WRITE_BIAS (RWSEM_WAITING_BIAS + RWSEM_ACTIVE_BIAS)
|
||||
|
||||
static inline void __down_read(struct rw_semaphore *sem)
|
||||
static inline int ___down_read(struct rw_semaphore *sem)
|
||||
{
|
||||
long oldcount;
|
||||
#ifndef CONFIG_SMP
|
||||
|
|
@ -41,10 +41,24 @@ static inline void __down_read(struct rw_semaphore *sem)
|
|||
:"=&r" (oldcount), "=m" (sem->count), "=&r" (temp)
|
||||
:"Ir" (RWSEM_ACTIVE_READ_BIAS), "m" (sem->count) : "memory");
|
||||
#endif
|
||||
if (unlikely(oldcount < 0))
|
||||
return (oldcount < 0);
|
||||
}
|
||||
|
||||
static inline void __down_read(struct rw_semaphore *sem)
|
||||
{
|
||||
if (unlikely(___down_read(sem)))
|
||||
rwsem_down_read_failed(sem);
|
||||
}
|
||||
|
||||
static inline int __down_read_killable(struct rw_semaphore *sem)
|
||||
{
|
||||
if (unlikely(___down_read(sem)))
|
||||
if (IS_ERR(rwsem_down_read_failed_killable(sem)))
|
||||
return -EINTR;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* trylock for reading -- returns 1 if successful, 0 if contention
|
||||
*/
|
||||
|
|
@ -94,9 +108,10 @@ static inline void __down_write(struct rw_semaphore *sem)
|
|||
|
||||
static inline int __down_write_killable(struct rw_semaphore *sem)
|
||||
{
|
||||
if (unlikely(___down_write(sem)))
|
||||
if (unlikely(___down_write(sem))) {
|
||||
if (IS_ERR(rwsem_down_write_failed_killable(sem)))
|
||||
return -EINTR;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue