aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/specialix.c
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2009-07-20 11:05:07 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-07-20 19:38:43 -0400
commit254702568da63ce6f5ad68e77d83b427da693654 (patch)
tree750ec8042d629b48cb04e869d3b97496f51c717a /drivers/char/specialix.c
parentc46a7aec556ffdbdb7357db0b05904b176cb3375 (diff)
specialix.c: convert nested spin_lock_irqsave to spin_lock
If spin_lock_irqsave is called twice in a row with the same second argument, the interrupt state at the point of the second call overwrites the value saved by the first call. Indeed, the second call does not need to save the interrupt state, so it is changed to a simple spin_lock. The semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @@ expression lock1,lock2; expression flags; @@ *spin_lock_irqsave(lock1,flags) ... when != flags *spin_lock_irqsave(lock2,flags) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/specialix.c')
-rw-r--r--drivers/char/specialix.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c
index bfe4cdb2febb..268e17f9ec3f 100644
--- a/drivers/char/specialix.c
+++ b/drivers/char/specialix.c
@@ -1809,10 +1809,10 @@ static int sx_tiocmset(struct tty_struct *tty, struct file *file,
1809 if (clear & TIOCM_DTR) 1809 if (clear & TIOCM_DTR)
1810 port->MSVR &= ~MSVR_DTR; 1810 port->MSVR &= ~MSVR_DTR;
1811 } 1811 }
1812 spin_lock_irqsave(&bp->lock, flags); 1812 spin_lock(&bp->lock);
1813 sx_out(bp, CD186x_CAR, port_No(port)); 1813 sx_out(bp, CD186x_CAR, port_No(port));
1814 sx_out(bp, CD186x_MSVR, port->MSVR); 1814 sx_out(bp, CD186x_MSVR, port->MSVR);
1815 spin_unlock_irqrestore(&bp->lock, flags); 1815 spin_unlock(&bp->lock);
1816 spin_unlock_irqrestore(&port->lock, flags); 1816 spin_unlock_irqrestore(&port->lock, flags);
1817 func_exit(); 1817 func_exit();
1818 return 0; 1818 return 0;
@@ -1833,11 +1833,11 @@ static int sx_send_break(struct tty_struct *tty, int length)
1833 port->break_length = SPECIALIX_TPS / HZ * length; 1833 port->break_length = SPECIALIX_TPS / HZ * length;
1834 port->COR2 |= COR2_ETC; 1834 port->COR2 |= COR2_ETC;
1835 port->IER |= IER_TXRDY; 1835 port->IER |= IER_TXRDY;
1836 spin_lock_irqsave(&bp->lock, flags); 1836 spin_lock(&bp->lock);
1837 sx_out(bp, CD186x_CAR, port_No(port)); 1837 sx_out(bp, CD186x_CAR, port_No(port));
1838 sx_out(bp, CD186x_COR2, port->COR2); 1838 sx_out(bp, CD186x_COR2, port->COR2);
1839 sx_out(bp, CD186x_IER, port->IER); 1839 sx_out(bp, CD186x_IER, port->IER);
1840 spin_unlock_irqrestore(&bp->lock, flags); 1840 spin_unlock(&bp->lock);
1841 spin_unlock_irqrestore(&port->lock, flags); 1841 spin_unlock_irqrestore(&port->lock, flags);
1842 sx_wait_CCR(bp); 1842 sx_wait_CCR(bp);
1843 spin_lock_irqsave(&bp->lock, flags); 1843 spin_lock_irqsave(&bp->lock, flags);
@@ -2023,9 +2023,9 @@ static void sx_unthrottle(struct tty_struct *tty)
2023 if (sx_crtscts(tty)) 2023 if (sx_crtscts(tty))
2024 port->MSVR |= MSVR_DTR; 2024 port->MSVR |= MSVR_DTR;
2025 /* Else clause: see remark in "sx_throttle"... */ 2025 /* Else clause: see remark in "sx_throttle"... */
2026 spin_lock_irqsave(&bp->lock, flags); 2026 spin_lock(&bp->lock);
2027 sx_out(bp, CD186x_CAR, port_No(port)); 2027 sx_out(bp, CD186x_CAR, port_No(port));
2028 spin_unlock_irqrestore(&bp->lock, flags); 2028 spin_unlock(&bp->lock);
2029 if (I_IXOFF(tty)) { 2029 if (I_IXOFF(tty)) {
2030 spin_unlock_irqrestore(&port->lock, flags); 2030 spin_unlock_irqrestore(&port->lock, flags);
2031 sx_wait_CCR(bp); 2031 sx_wait_CCR(bp);
@@ -2035,9 +2035,9 @@ static void sx_unthrottle(struct tty_struct *tty)
2035 sx_wait_CCR(bp); 2035 sx_wait_CCR(bp);
2036 spin_lock_irqsave(&port->lock, flags); 2036 spin_lock_irqsave(&port->lock, flags);
2037 } 2037 }
2038 spin_lock_irqsave(&bp->lock, flags); 2038 spin_lock(&bp->lock);
2039 sx_out(bp, CD186x_MSVR, port->MSVR); 2039 sx_out(bp, CD186x_MSVR, port->MSVR);
2040 spin_unlock_irqrestore(&bp->lock, flags); 2040 spin_unlock(&bp->lock);
2041 spin_unlock_irqrestore(&port->lock, flags); 2041 spin_unlock_irqrestore(&port->lock, flags);
2042 2042
2043 func_exit(); 2043 func_exit();
@@ -2061,10 +2061,10 @@ static void sx_stop(struct tty_struct *tty)
2061 2061
2062 spin_lock_irqsave(&port->lock, flags); 2062 spin_lock_irqsave(&port->lock, flags);
2063 port->IER &= ~IER_TXRDY; 2063 port->IER &= ~IER_TXRDY;
2064 spin_lock_irqsave(&bp->lock, flags); 2064 spin_lock(&bp->lock);
2065 sx_out(bp, CD186x_CAR, port_No(port)); 2065 sx_out(bp, CD186x_CAR, port_No(port));
2066 sx_out(bp, CD186x_IER, port->IER); 2066 sx_out(bp, CD186x_IER, port->IER);
2067 spin_unlock_irqrestore(&bp->lock, flags); 2067 spin_unlock(&bp->lock);
2068 spin_unlock_irqrestore(&port->lock, flags); 2068 spin_unlock_irqrestore(&port->lock, flags);
2069 2069
2070 func_exit(); 2070 func_exit();
@@ -2089,10 +2089,10 @@ static void sx_start(struct tty_struct *tty)
2089 spin_lock_irqsave(&port->lock, flags); 2089 spin_lock_irqsave(&port->lock, flags);
2090 if (port->xmit_cnt && port->xmit_buf && !(port->IER & IER_TXRDY)) { 2090 if (port->xmit_cnt && port->xmit_buf && !(port->IER & IER_TXRDY)) {
2091 port->IER |= IER_TXRDY; 2091 port->IER |= IER_TXRDY;
2092 spin_lock_irqsave(&bp->lock, flags); 2092 spin_lock(&bp->lock);
2093 sx_out(bp, CD186x_CAR, port_No(port)); 2093 sx_out(bp, CD186x_CAR, port_No(port));
2094 sx_out(bp, CD186x_IER, port->IER); 2094 sx_out(bp, CD186x_IER, port->IER);
2095 spin_unlock_irqrestore(&bp->lock, flags); 2095 spin_unlock(&bp->lock);
2096 } 2096 }
2097 spin_unlock_irqrestore(&port->lock, flags); 2097 spin_unlock_irqrestore(&port->lock, flags);
2098 2098