Skip to contentSkip to conversation

: Implement change_bit with immediate operand as "lock xorb"

PATCH In review Uros Bizjak 2 participants 4 messages Oct 24, 2008 – Oct 25, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Implement change_bit with immediate operand as "lock xorb"

Hello!

Implement change_bit with immediate bit count as "lock xorb". This is similar to "lock orb" and "lock andb" for set_bit and clear_bit functions.

Uros.

bitops.h renamed from bitops.h~ +9 -1
@@ -168,7 +168,15 @@
  */
 static inline void change_bit(int nr, volatile unsigned long *addr)
 {
-	asm volatile(LOCK_PREFIX "btc %1,%0" : ADDR : "Ir" (nr));
+	if (IS_IMMEDIATE(nr)) {
+		asm volatile(LOCK_PREFIX "xorb %1,%0"
+			: CONST_MASK_ADDR(nr, addr)
+			: "iq" ((u8)CONST_MASK(nr)));
+	} else {
+		asm volatile(LOCK_PREFIX "btc %1,%0"
+			: BITOP_ADDR(addr)
+			: "Ir" (nr));
+	}
 }
 
 /**
#1 lore raw
Quoted 3 lines · Uros Bizjak

Implement change_bit with immediate bit count as "lock xorb". This is similar to "lock orb" and "lock andb" for set_bit and clear_bit functions.

Forgot Signed-off-by line.

Uros.

bitops.h renamed from bitops.h~ +9 -1
@@ -168,7 +168,15 @@
  */
 static inline void change_bit(int nr, volatile unsigned long *addr)
 {
-	asm volatile(LOCK_PREFIX "btc %1,%0" : ADDR : "Ir" (nr));
+	if (IS_IMMEDIATE(nr)) {
+		asm volatile(LOCK_PREFIX "xorb %1,%0"
+			: CONST_MASK_ADDR(nr, addr)
+			: "iq" ((u8)CONST_MASK(nr)));
+	} else {
+		asm volatile(LOCK_PREFIX "btc %1,%0"
+			: BITOP_ADDR(addr)
+			: "Ir" (nr));
+	}
 }
 
 /**
#2 lore raw

PATCH 1/1 : Implement change_bit with immediate operand as "lock xorb"

Quoted 3 lines · Uros Bizjak

Implement change_bit with immediate bit count as "lock xorb". This is similar to "lock orb" and "lock andb" for set_bit and clear_bit functions.

Forgot Signed-off-by line and added CC.

Uros.

bitops.h renamed from bitops.h~ +9 -1
@@ -168,7 +168,15 @@
  */
 static inline void change_bit(int nr, volatile unsigned long *addr)
 {
-	asm volatile(LOCK_PREFIX "btc %1,%0" : ADDR : "Ir" (nr));
+	if (IS_IMMEDIATE(nr)) {
+		asm volatile(LOCK_PREFIX "xorb %1,%0"
+			: CONST_MASK_ADDR(nr, addr)
+			: "iq" ((u8)CONST_MASK(nr)));
+	} else {
+		asm volatile(LOCK_PREFIX "btc %1,%0"
+			: BITOP_ADDR(addr)
+			: "Ir" (nr));
+	}
 }
 
 /**
#3 lore raw
In reply to Uros Bizjak
Quoted 6 lines · Uros Bizjak

Hello!

Implement change_bit with immediate bit count as "lock xorb". This is similar to "lock orb" and "lock andb" for set_bit and clear_bit functions.

Looks good, but please resubmit your patch with a Signed-off-by: line and Cc: [email protected] on the submission.

Thanks!

-hpa