mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 03:06:10 +00:00
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>
This commit is contained in:
parent
c46a7aec55
commit
254702568d
1 changed files with 12 additions and 12 deletions
|
@ -1809,10 +1809,10 @@ static int sx_tiocmset(struct tty_struct *tty, struct file *file,
|
|||
if (clear & TIOCM_DTR)
|
||||
port->MSVR &= ~MSVR_DTR;
|
||||
}
|
||||
spin_lock_irqsave(&bp->lock, flags);
|
||||
spin_lock(&bp->lock);
|
||||
sx_out(bp, CD186x_CAR, port_No(port));
|
||||
sx_out(bp, CD186x_MSVR, port->MSVR);
|
||||
spin_unlock_irqrestore(&bp->lock, flags);
|
||||
spin_unlock(&bp->lock);
|
||||
spin_unlock_irqrestore(&port->lock, flags);
|
||||
func_exit();
|
||||
return 0;
|
||||
|
@ -1833,11 +1833,11 @@ static int sx_send_break(struct tty_struct *tty, int length)
|
|||
port->break_length = SPECIALIX_TPS / HZ * length;
|
||||
port->COR2 |= COR2_ETC;
|
||||
port->IER |= IER_TXRDY;
|
||||
spin_lock_irqsave(&bp->lock, flags);
|
||||
spin_lock(&bp->lock);
|
||||
sx_out(bp, CD186x_CAR, port_No(port));
|
||||
sx_out(bp, CD186x_COR2, port->COR2);
|
||||
sx_out(bp, CD186x_IER, port->IER);
|
||||
spin_unlock_irqrestore(&bp->lock, flags);
|
||||
spin_unlock(&bp->lock);
|
||||
spin_unlock_irqrestore(&port->lock, flags);
|
||||
sx_wait_CCR(bp);
|
||||
spin_lock_irqsave(&bp->lock, flags);
|
||||
|
@ -2023,9 +2023,9 @@ static void sx_unthrottle(struct tty_struct *tty)
|
|||
if (sx_crtscts(tty))
|
||||
port->MSVR |= MSVR_DTR;
|
||||
/* Else clause: see remark in "sx_throttle"... */
|
||||
spin_lock_irqsave(&bp->lock, flags);
|
||||
spin_lock(&bp->lock);
|
||||
sx_out(bp, CD186x_CAR, port_No(port));
|
||||
spin_unlock_irqrestore(&bp->lock, flags);
|
||||
spin_unlock(&bp->lock);
|
||||
if (I_IXOFF(tty)) {
|
||||
spin_unlock_irqrestore(&port->lock, flags);
|
||||
sx_wait_CCR(bp);
|
||||
|
@ -2035,9 +2035,9 @@ static void sx_unthrottle(struct tty_struct *tty)
|
|||
sx_wait_CCR(bp);
|
||||
spin_lock_irqsave(&port->lock, flags);
|
||||
}
|
||||
spin_lock_irqsave(&bp->lock, flags);
|
||||
spin_lock(&bp->lock);
|
||||
sx_out(bp, CD186x_MSVR, port->MSVR);
|
||||
spin_unlock_irqrestore(&bp->lock, flags);
|
||||
spin_unlock(&bp->lock);
|
||||
spin_unlock_irqrestore(&port->lock, flags);
|
||||
|
||||
func_exit();
|
||||
|
@ -2061,10 +2061,10 @@ static void sx_stop(struct tty_struct *tty)
|
|||
|
||||
spin_lock_irqsave(&port->lock, flags);
|
||||
port->IER &= ~IER_TXRDY;
|
||||
spin_lock_irqsave(&bp->lock, flags);
|
||||
spin_lock(&bp->lock);
|
||||
sx_out(bp, CD186x_CAR, port_No(port));
|
||||
sx_out(bp, CD186x_IER, port->IER);
|
||||
spin_unlock_irqrestore(&bp->lock, flags);
|
||||
spin_unlock(&bp->lock);
|
||||
spin_unlock_irqrestore(&port->lock, flags);
|
||||
|
||||
func_exit();
|
||||
|
@ -2089,10 +2089,10 @@ static void sx_start(struct tty_struct *tty)
|
|||
spin_lock_irqsave(&port->lock, flags);
|
||||
if (port->xmit_cnt && port->xmit_buf && !(port->IER & IER_TXRDY)) {
|
||||
port->IER |= IER_TXRDY;
|
||||
spin_lock_irqsave(&bp->lock, flags);
|
||||
spin_lock(&bp->lock);
|
||||
sx_out(bp, CD186x_CAR, port_No(port));
|
||||
sx_out(bp, CD186x_IER, port->IER);
|
||||
spin_unlock_irqrestore(&bp->lock, flags);
|
||||
spin_unlock(&bp->lock);
|
||||
}
|
||||
spin_unlock_irqrestore(&port->lock, flags);
|
||||
|
||||
|
|
Loading…
Reference in a new issue