aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/moxa.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2013-03-07 07:12:30 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-03-18 19:24:29 -0400
commitaa27a094e2c2e0cc59914e56113b860f524f4479 (patch)
treeb3cfef8d8023741107e3d3bed934f2bd4d8bf189 /drivers/tty/moxa.c
parente4408ce3c23f8451eff7a2954694598fb8fce833 (diff)
TTY: add tty_port_tty_hangup helper
It allows for cleaning up on a considerable amount of places. They did port_get, hangup, kref_put. Now the only thing needed is to call tty_port_tty_hangup which does exactly that. And they can also decide whether to consider CLOCAL or completely ignore that. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/moxa.c')
-rw-r--r--drivers/tty/moxa.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
index adeac255e526..1deaca4674e4 100644
--- a/drivers/tty/moxa.c
+++ b/drivers/tty/moxa.c
@@ -913,16 +913,12 @@ static void moxa_board_deinit(struct moxa_board_conf *brd)
913 913
914 /* pci hot-un-plug support */ 914 /* pci hot-un-plug support */
915 for (a = 0; a < brd->numPorts; a++) 915 for (a = 0; a < brd->numPorts; a++)
916 if (brd->ports[a].port.flags & ASYNC_INITIALIZED) { 916 if (brd->ports[a].port.flags & ASYNC_INITIALIZED)
917 struct tty_struct *tty = tty_port_tty_get( 917 tty_port_tty_hangup(&brd->ports[a].port, false);
918 &brd->ports[a].port); 918
919 if (tty) {
920 tty_hangup(tty);
921 tty_kref_put(tty);
922 }
923 }
924 for (a = 0; a < MAX_PORTS_PER_BOARD; a++) 919 for (a = 0; a < MAX_PORTS_PER_BOARD; a++)
925 tty_port_destroy(&brd->ports[a].port); 920 tty_port_destroy(&brd->ports[a].port);
921
926 while (1) { 922 while (1) {
927 opened = 0; 923 opened = 0;
928 for (a = 0; a < brd->numPorts; a++) 924 for (a = 0; a < brd->numPorts; a++)
@@ -1365,7 +1361,6 @@ static void moxa_hangup(struct tty_struct *tty)
1365 1361
1366static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd) 1362static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd)
1367{ 1363{
1368 struct tty_struct *tty;
1369 unsigned long flags; 1364 unsigned long flags;
1370 dcd = !!dcd; 1365 dcd = !!dcd;
1371 1366
@@ -1373,10 +1368,8 @@ static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd)
1373 if (dcd != p->DCDState) { 1368 if (dcd != p->DCDState) {
1374 p->DCDState = dcd; 1369 p->DCDState = dcd;
1375 spin_unlock_irqrestore(&p->port.lock, flags); 1370 spin_unlock_irqrestore(&p->port.lock, flags);
1376 tty = tty_port_tty_get(&p->port); 1371 if (!dcd)
1377 if (tty && !C_CLOCAL(tty) && !dcd) 1372 tty_port_tty_hangup(&p->port, true);
1378 tty_hangup(tty);
1379 tty_kref_put(tty);
1380 } 1373 }
1381 else 1374 else
1382 spin_unlock_irqrestore(&p->port.lock, flags); 1375 spin_unlock_irqrestore(&p->port.lock, flags);