V4L/DVB (4914): Saa7146: Protect access to the IER register by a spinlock
authorHartmut Birr <e9hack@googlemail.com>
Wed, 1 Nov 2006 15:46:32 +0000 (12:46 -0300)
committerMauro Carvalho Chehab <mchehab@infradead.org>
Sun, 10 Dec 2006 11:05:33 +0000 (09:05 -0200)
Protect the access to the IER register of the SAA7146 by the device
spinlock. I2C transfers may use interrupt mode now.

Signed-off-by: Oliver Endriss <o.endriss@gmx.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
include/media/saa7146.h

index fee579f..afa5ff6 100644 (file)
@@ -42,10 +42,20 @@ extern unsigned int saa7146_debug;
 #define DEB_INT(x)  if (0!=(DEBUG_VARIABLE&0x20)) { DEBUG_PROLOG; printk x; } /* interrupt debug messages */
 #define DEB_CAP(x)  if (0!=(DEBUG_VARIABLE&0x40)) { DEBUG_PROLOG; printk x; } /* capture debug messages */
 
-#define SAA7146_IER_DISABLE(x,y) \
-       saa7146_write(x, IER, saa7146_read(x, IER) & ~(y));
-#define SAA7146_IER_ENABLE(x,y) \
-       saa7146_write(x, IER, saa7146_read(x, IER) | (y));
+#define SAA7146_IER_DISABLE(x,y)                                       \
+       do {                                                            \
+               unsigned int flags;                                     \
+               spin_lock_irqsave(&x->int_slock, flags);                \
+               saa7146_write(x, IER, saa7146_read(x, IER) & ~(y));     \
+               spin_unlock_irqrestore(&x->int_slock, flags);           \
+       } while(0)
+#define SAA7146_IER_ENABLE(x,y)                                                \
+       do {                                                            \
+               unsigned int flags;                                     \
+               spin_lock_irqsave(&x->int_slock, flags);                \
+               saa7146_write(x, IER, saa7146_read(x, IER) | (y));      \
+               spin_unlock_irqrestore(&x->int_slock, flags);           \
+       } while(0)
 #define SAA7146_ISR_CLEAR(x,y) \
        saa7146_write(x, ISR, (y));