summaryrefslogtreecommitdiffstats
path: root/drivers/serial/dz.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@linux-mips.org>2008-02-07 00:15:11 -0800
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-07 08:42:24 -0800
commit43d46ab1cdeb12b8d072cfdf84956073a1fa8866 (patch)
tree00e55a9babe058feef7065621f12c63dd493ff07 /drivers/serial/dz.c
parent6d83c067ebd11d375b34c53192c10826947e8568 (diff)
downloadop-kernel-dev-43d46ab1cdeb12b8d072cfdf84956073a1fa8866.zip
op-kernel-dev-43d46ab1cdeb12b8d072cfdf84956073a1fa8866.tar.gz
dz: fix locking issues
The ->start_tx(), ->stop_tx() and ->stop_rx() backends are called with the port's lock already taken. Remove locking from within them and wrap around calls as necessary. Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org> Cc: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/serial/dz.c')
-rw-r--r--drivers/serial/dz.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/serial/dz.c b/drivers/serial/dz.c
index c2f8677..656c342 100644
--- a/drivers/serial/dz.c
+++ b/drivers/serial/dz.c
@@ -108,37 +108,28 @@ static void dz_stop_tx(struct uart_port *uport)
{
struct dz_port *dport = (struct dz_port *)uport;
unsigned short tmp, mask = 1 << dport->port.line;
- unsigned long flags;
- spin_lock_irqsave(&dport->port.lock, flags);
tmp = dz_in(dport, DZ_TCR); /* read the TX flag */
tmp &= ~mask; /* clear the TX flag */
dz_out(dport, DZ_TCR, tmp);
- spin_unlock_irqrestore(&dport->port.lock, flags);
}
static void dz_start_tx(struct uart_port *uport)
{
struct dz_port *dport = (struct dz_port *)uport;
unsigned short tmp, mask = 1 << dport->port.line;
- unsigned long flags;
- spin_lock_irqsave(&dport->port.lock, flags);
tmp = dz_in(dport, DZ_TCR); /* read the TX flag */
tmp |= mask; /* set the TX flag */
dz_out(dport, DZ_TCR, tmp);
- spin_unlock_irqrestore(&dport->port.lock, flags);
}
static void dz_stop_rx(struct uart_port *uport)
{
struct dz_port *dport = (struct dz_port *)uport;
- unsigned long flags;
- spin_lock_irqsave(&dport->port.lock, flags);
dport->cflag &= ~DZ_CREAD;
dz_out(dport, DZ_LPR, dport->cflag | dport->port.line);
- spin_unlock_irqrestore(&dport->port.lock, flags);
}
static void dz_enable_ms(struct uart_port *port)
@@ -268,7 +259,9 @@ static inline void dz_transmit_chars(struct dz_port *dport_in)
}
/* If nothing to do or stopped or hardware stopped. */
if (uart_circ_empty(xmit) || uart_tx_stopped(&dport->port)) {
+ spin_lock(&dport->port.lock);
dz_stop_tx(&dport->port);
+ spin_unlock(&dport->port.lock);
return;
}
@@ -285,8 +278,11 @@ static inline void dz_transmit_chars(struct dz_port *dport_in)
uart_write_wakeup(&dport->port);
/* Are we are done. */
- if (uart_circ_empty(xmit))
+ if (uart_circ_empty(xmit)) {
+ spin_lock(&dport->port.lock);
dz_stop_tx(&dport->port);
+ spin_unlock(&dport->port.lock);
+ }
}
/*
@@ -417,7 +413,12 @@ static int dz_startup(struct uart_port *uport)
*/
static void dz_shutdown(struct uart_port *uport)
{
- dz_stop_tx(uport);
+ struct dz_port *dport = (struct dz_port *)uport;
+ unsigned long flags;
+
+ spin_lock_irqsave(&dport->port.lock, flags);
+ dz_stop_tx(&dport->port);
+ spin_unlock_irqrestore(&dport->port.lock, flags);
}
/*
OpenPOWER on IntegriCloud