[PATCH 4/7] ark3116: (3rd try) Add atomic set-and-clear function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Bart Hartgers <bart.hartgers@xxxxxxxxx>
---
Index: linux-2.6.32-rc4/drivers/usb/serial/ark3116.c
===================================================================
--- linux-2.6.32-rc4.orig/drivers/usb/serial/ark3116.c	2009-10-18 16:20:13.000000000 +0200
+++ linux-2.6.32-rc4/drivers/usb/serial/ark3116.c	2009-10-18 16:20:17.000000000 +0200
@@ -151,6 +151,33 @@ static inline void ARK3116_RCV_QUIET(str
 			buf, 0x0000001, 1000);
 }
 
+static inline void ark3116_atomic_set_clear(unsigned set,
+					    unsigned clear, atomic_t *at)
+{
+	if ((clear == 0) && (set == 0))
+		return;
+#if defined(atomic_set_mask)
+	if (clear == 0) {
+		atomic_set_mask(set, at);
+		return;
+	}
+#endif
+#if defined(atomic_clear_mask)
+	if (set == 0) {
+		atomic_clear_mask(clear, at);
+		return;
+	}
+#endif
+	/* operation needs to be atomic */
+	for (;;) {
+		register unsigned old = atomic_read(at);
+		register unsigned prev = atomic_cmpxchg(at, old,
+							(old|set)&(~clear));
+		if (likely(prev == old))
+			break;
+	}
+}
+
 static inline int calc_divisor(int bps)
 {
 	/* Original ark3116 made some exceptions in rounding here

-- 
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux