Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 25986
b: refs/heads/master
c: fa37281
h: refs/heads/master
v: v3
  • Loading branch information
Hirokazu Takata authored and Linus Torvalds committed Apr 19, 2006
1 parent c4e4ed3 commit 83f7061
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 61 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 8e8ff02c0b61d9b7c15c7996a2eddbedf51a105b
refs/heads/master: fa372810e51979c5044e036a34015845e9c6aedd
64 changes: 4 additions & 60 deletions trunk/include/asm-m32r/semaphore.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
* SMP- and interrupt-safe semaphores..
*
* Copyright (C) 1996 Linus Torvalds
* Copyright (C) 2004 Hirokazu Takata <takata at linux-m32r.org>
* Copyright (C) 2004, 2006 Hirokazu Takata <takata at linux-m32r.org>
*/

#include <linux/config.h>
Expand Down Expand Up @@ -77,27 +77,8 @@ asmlinkage void __up(struct semaphore * sem);
*/
static inline void down(struct semaphore * sem)
{
unsigned long flags;
long count;

might_sleep();
local_irq_save(flags);
__asm__ __volatile__ (
"# down \n\t"
DCACHE_CLEAR("%0", "r4", "%1")
M32R_LOCK" %0, @%1; \n\t"
"addi %0, #-1; \n\t"
M32R_UNLOCK" %0, @%1; \n\t"
: "=&r" (count)
: "r" (&sem->count)
: "memory"
#ifdef CONFIG_CHIP_M32700_TS1
, "r4"
#endif /* CONFIG_CHIP_M32700_TS1 */
);
local_irq_restore(flags);

if (unlikely(count < 0))
if (unlikely(atomic_dec_return(&sem->count) < 0))
__down(sem);
}

Expand All @@ -107,28 +88,10 @@ static inline void down(struct semaphore * sem)
*/
static inline int down_interruptible(struct semaphore * sem)
{
unsigned long flags;
long count;
int result = 0;

might_sleep();
local_irq_save(flags);
__asm__ __volatile__ (
"# down_interruptible \n\t"
DCACHE_CLEAR("%0", "r4", "%1")
M32R_LOCK" %0, @%1; \n\t"
"addi %0, #-1; \n\t"
M32R_UNLOCK" %0, @%1; \n\t"
: "=&r" (count)
: "r" (&sem->count)
: "memory"
#ifdef CONFIG_CHIP_M32700_TS1
, "r4"
#endif /* CONFIG_CHIP_M32700_TS1 */
);
local_irq_restore(flags);

if (unlikely(count < 0))
if (unlikely(atomic_dec_return(&sem->count) < 0))
result = __down_interruptible(sem);

return result;
Expand Down Expand Up @@ -174,26 +137,7 @@ static inline int down_trylock(struct semaphore * sem)
*/
static inline void up(struct semaphore * sem)
{
unsigned long flags;
long count;

local_irq_save(flags);
__asm__ __volatile__ (
"# up \n\t"
DCACHE_CLEAR("%0", "r4", "%1")
M32R_LOCK" %0, @%1; \n\t"
"addi %0, #1; \n\t"
M32R_UNLOCK" %0, @%1; \n\t"
: "=&r" (count)
: "r" (&sem->count)
: "memory"
#ifdef CONFIG_CHIP_M32700_TS1
, "r4"
#endif /* CONFIG_CHIP_M32700_TS1 */
);
local_irq_restore(flags);

if (unlikely(count <= 0))
if (unlikely(atomic_inc_return(&sem->count) <= 0))
__up(sem);
}

Expand Down

0 comments on commit 83f7061

Please sign in to comment.