diff options
author | Alan Cox <alan@linux.intel.com> | 2009-11-30 08:18:13 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-11 18:18:08 -0500 |
commit | 8482bcd58530ad5857d7187854132f2b846db681 (patch) | |
tree | 7fce3340156ab74e2f6f199994147bf290926ee1 /drivers/char | |
parent | f9b412a8c9adb17d50922f91962e8b1e48789430 (diff) |
tty: moxa: Fix modem op locking
This is overkill and mostly not needed
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/moxa.c | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index d180aa965a5a..ac06d0131db5 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -139,7 +139,7 @@ struct moxa_port { | |||
139 | int cflag; | 139 | int cflag; |
140 | unsigned long statusflags; | 140 | unsigned long statusflags; |
141 | 141 | ||
142 | u8 DCDState; | 142 | u8 DCDState; /* Protected by the port lock */ |
143 | u8 lineCtrl; | 143 | u8 lineCtrl; |
144 | u8 lowChkFlag; | 144 | u8 lowChkFlag; |
145 | }; | 145 | }; |
@@ -1141,9 +1141,9 @@ static int moxa_carrier_raised(struct tty_port *port) | |||
1141 | struct moxa_port *ch = container_of(port, struct moxa_port, port); | 1141 | struct moxa_port *ch = container_of(port, struct moxa_port, port); |
1142 | int dcd; | 1142 | int dcd; |
1143 | 1143 | ||
1144 | spin_lock_bh(&moxa_lock); | 1144 | spin_lock_irq(&port->lock); |
1145 | dcd = ch->DCDState; | 1145 | dcd = ch->DCDState; |
1146 | spin_unlock_bh(&moxa_lock); | 1146 | spin_unlock_irq(&port->lock); |
1147 | return dcd; | 1147 | return dcd; |
1148 | } | 1148 | } |
1149 | 1149 | ||
@@ -1267,16 +1267,9 @@ static int moxa_chars_in_buffer(struct tty_struct *tty) | |||
1267 | 1267 | ||
1268 | static int moxa_tiocmget(struct tty_struct *tty, struct file *file) | 1268 | static int moxa_tiocmget(struct tty_struct *tty, struct file *file) |
1269 | { | 1269 | { |
1270 | struct moxa_port *ch; | 1270 | struct moxa_port *ch = tty->driver_data; |
1271 | int flag = 0, dtr, rts; | 1271 | int flag = 0, dtr, rts; |
1272 | 1272 | ||
1273 | mutex_lock(&moxa_openlock); | ||
1274 | ch = tty->driver_data; | ||
1275 | if (!ch) { | ||
1276 | mutex_unlock(&moxa_openlock); | ||
1277 | return -EINVAL; | ||
1278 | } | ||
1279 | |||
1280 | MoxaPortGetLineOut(ch, &dtr, &rts); | 1273 | MoxaPortGetLineOut(ch, &dtr, &rts); |
1281 | if (dtr) | 1274 | if (dtr) |
1282 | flag |= TIOCM_DTR; | 1275 | flag |= TIOCM_DTR; |
@@ -1289,7 +1282,6 @@ static int moxa_tiocmget(struct tty_struct *tty, struct file *file) | |||
1289 | flag |= TIOCM_DSR; | 1282 | flag |= TIOCM_DSR; |
1290 | if (dtr & 4) | 1283 | if (dtr & 4) |
1291 | flag |= TIOCM_CD; | 1284 | flag |= TIOCM_CD; |
1292 | mutex_unlock(&moxa_openlock); | ||
1293 | return flag; | 1285 | return flag; |
1294 | } | 1286 | } |
1295 | 1287 | ||
@@ -1368,15 +1360,20 @@ static void moxa_hangup(struct tty_struct *tty) | |||
1368 | static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd) | 1360 | static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd) |
1369 | { | 1361 | { |
1370 | struct tty_struct *tty; | 1362 | struct tty_struct *tty; |
1363 | unsigned long flags; | ||
1371 | dcd = !!dcd; | 1364 | dcd = !!dcd; |
1372 | 1365 | ||
1366 | spin_lock_irqsave(&p->port.lock, flags); | ||
1373 | if (dcd != p->DCDState) { | 1367 | if (dcd != p->DCDState) { |
1368 | p->DCDState = dcd; | ||
1369 | spin_unlock_irqrestore(&p->port.lock, flags); | ||
1374 | tty = tty_port_tty_get(&p->port); | 1370 | tty = tty_port_tty_get(&p->port); |
1375 | if (tty && C_CLOCAL(tty) && !dcd) | 1371 | if (tty && C_CLOCAL(tty) && !dcd) |
1376 | tty_hangup(tty); | 1372 | tty_hangup(tty); |
1377 | tty_kref_put(tty); | 1373 | tty_kref_put(tty); |
1378 | } | 1374 | } |
1379 | p->DCDState = dcd; | 1375 | else |
1376 | spin_unlock_irqrestore(&p->port.lock, flags); | ||
1380 | } | 1377 | } |
1381 | 1378 | ||
1382 | static int moxa_poll_port(struct moxa_port *p, unsigned int handle, | 1379 | static int moxa_poll_port(struct moxa_port *p, unsigned int handle, |
@@ -1878,9 +1875,7 @@ static int MoxaPortLineStatus(struct moxa_port *port) | |||
1878 | val &= 0x0B; | 1875 | val &= 0x0B; |
1879 | if (val & 8) | 1876 | if (val & 8) |
1880 | val |= 4; | 1877 | val |= 4; |
1881 | spin_lock_bh(&moxa_lock); | ||
1882 | moxa_new_dcdstate(port, val & 8); | 1878 | moxa_new_dcdstate(port, val & 8); |
1883 | spin_unlock_bh(&moxa_lock); | ||
1884 | val &= 7; | 1879 | val &= 7; |
1885 | return val; | 1880 | return val; |
1886 | } | 1881 | } |