patch-2.2.0-pre6 linux/include/asm-arm/proc-armv/semaphore.h

Next file: linux/include/asm-arm/proc-armv/system.h
Previous file: linux/include/asm-arm/proc-armv/page.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.2.0-pre5/linux/include/asm-arm/proc-armv/semaphore.h linux/include/asm-arm/proc-armv/semaphore.h
@@ -10,20 +10,24 @@
  */
 extern inline void down(struct semaphore * sem)
 {
+	unsigned int cpsr, temp;
+
 	__asm__ __volatile__ ("
 	@ atomic down operation
-	mrs	r0, cpsr
-	orr	r1, r0, #128		@ disable IRQs
-	bic	r0, r0, #0x80000000	@ clear N
-	msr	cpsr, r1
-	ldr	r1, [%0]
-	subs	r1, r1, #1
-	str	r1, [%0]
-	orrmi	r0, r0, #0x80000000	@ set N
-	msr	cpsr, r0
-	movmi	r0, %0
-	blmi	" SYMBOL_NAME_STR(__down)
-		: : "r" (sem) : "r0", "r1", "r2", "r3", "ip", "lr", "cc");
+	mrs	%0, cpsr
+	orr	%1, %0, #128		@ disable IRQs
+	bic	%0, %0, #0x80000000	@ clear N
+	msr	cpsr, %1
+	ldr	%1, [%2]
+	subs	%1, %1, #1
+	orrmi	%0, %0, #0x80000000	@ set N
+	str	%1, [%2]
+	msr	cpsr, %0
+	movmi	r0, %2
+	blmi	" SYMBOL_NAME_STR(__down_failed)
+		: "=&r" (cpsr), "=&r" (temp)
+		: "r" (sem)
+		: "r0", "lr", "cc");
 }
 
 /*
@@ -32,26 +36,28 @@
  */
 extern inline int down_interruptible (struct semaphore * sem)
 {
-	int result;
+	unsigned int cpsr, temp;
+
 	__asm__ __volatile__ ("
-	@ atomic down operation
-	mrs	r0, cpsr
-	orr	r1, r0, #128		@ disable IRQs
-	bic	r0, r0, #0x80000000	@ clear N
-	msr	cpsr, r1
-	ldr	r1, [%1]
-	subs	r1, r1, #1
-	str	r1, [%1]
-	orrmi	r0, r0, #0x80000000	@ set N
-	msr	cpsr, r0
-	movmi	r0, %1
+	@ atomic down interruptible operation
+	mrs	%0, cpsr
+	orr	%1, %0, #128		@ disable IRQs
+	bic	%0, %0, #0x80000000	@ clear N
+	msr	cpsr, %1
+	ldr	%1, [%2]
+	subs	%1, %1, #1
+	orrmi	%0, %0, #0x80000000	@ set N
+	str	%1, [%2]
+	msr	cpsr, %0
+	movmi	r0, %2
 	movpl	r0, #0
-	blmi	" SYMBOL_NAME_STR(__down_interruptible) "
-	mov	%0, r0"
-		: "=r" (result)
+	blmi	" SYMBOL_NAME_STR(__down_interruptible_failed) "
+	mov	%1, r0"
+		: "=&r" (cpsr), "=&r" (temp)
 		: "r" (sem)
-		: "r0", "r1", "r2", "r3", "ip", "lr", "cc");
-	return result;
+		: "r0", "lr", "cc");
+
+	return temp;
 }
 
 /*
@@ -62,20 +68,24 @@
  */
 extern inline void up(struct semaphore * sem)
 {
+	unsigned int cpsr, temp;
+
 	__asm__ __volatile__ ("
 	@ atomic up operation
-	mrs	r0, cpsr
-	orr	r1, r0, #128		@ disable IRQs
-	bic	r0, r0, #0x80000000	@ clear N
-	msr	cpsr, r1
-	ldr	r1, [%0]
-	adds	r1, r1, #1
-	str	r1, [%0]
-	orrls	r0, r0, #0x80000000	@ set N
-	msr	cpsr, r0
-	movmi	r0, %0
-	blmi	" SYMBOL_NAME_STR(__up)
-		: : "r" (sem) : "r0", "r1", "r2", "r3", "ip", "lr", "cc");
+	mrs	%0, cpsr
+	orr	%1, %0, #128		@ disable IRQs
+	bic	%0, %0, #0x80000000	@ clear N
+	msr	cpsr, %1
+	ldr	%1, [%2]
+	adds	%1, %1, #1
+	orrls	%0, %0, #0x80000000	@ set N
+	str	%1, [%2]
+	msr	cpsr, %0
+	movmi	r0, %2
+	blmi	" SYMBOL_NAME_STR(__up_wakeup)
+		: "=&r" (cpsr), "=&r" (temp)
+		: "r" (sem)
+		: "r0", "lr", "cc");
 }
 
 #endif

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov