Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (4914): Saa7146: Protect access to the IER register by a spinlock

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>

authored by

Hartmut Birr and committed by
Mauro Carvalho Chehab
88bbdf74 122b5dbe

+14 -4
+14 -4
include/media/saa7146.h
··· 42 42 #define DEB_INT(x) if (0!=(DEBUG_VARIABLE&0x20)) { DEBUG_PROLOG; printk x; } /* interrupt debug messages */ 43 43 #define DEB_CAP(x) if (0!=(DEBUG_VARIABLE&0x40)) { DEBUG_PROLOG; printk x; } /* capture debug messages */ 44 44 45 - #define SAA7146_IER_DISABLE(x,y) \ 46 - saa7146_write(x, IER, saa7146_read(x, IER) & ~(y)); 47 - #define SAA7146_IER_ENABLE(x,y) \ 48 - saa7146_write(x, IER, saa7146_read(x, IER) | (y)); 45 + #define SAA7146_IER_DISABLE(x,y) \ 46 + do { \ 47 + unsigned int flags; \ 48 + spin_lock_irqsave(&x->int_slock, flags); \ 49 + saa7146_write(x, IER, saa7146_read(x, IER) & ~(y)); \ 50 + spin_unlock_irqrestore(&x->int_slock, flags); \ 51 + } while(0) 52 + #define SAA7146_IER_ENABLE(x,y) \ 53 + do { \ 54 + unsigned int flags; \ 55 + spin_lock_irqsave(&x->int_slock, flags); \ 56 + saa7146_write(x, IER, saa7146_read(x, IER) | (y)); \ 57 + spin_unlock_irqrestore(&x->int_slock, flags); \ 58 + } while(0) 49 59 #define SAA7146_ISR_CLEAR(x,y) \ 50 60 saa7146_write(x, ISR, (y)); 51 61