aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-10-13 05:39:58 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-10-13 12:51:41 -0400
commitd450b5a0196b6442cf3f29fc611d9c8daa56b559 (patch)
tree2a6b641b033bfbe16b194897ddbc988544dcefc2
parent4a90f09b20f4622dcbff1f0e1e6bae1704f8ad8c (diff)
tty: kref usage for isicom and moxa
Rather than blindly keep taking krefs we reorder the code in a few places to pass the tty down to the right place (which is important as from the user side it is not the case that tty == port->tty in all situations). For the irq and related paths use the krefs to stop the tty being freed under us. Signed-off-by: Alan Cox <alan@redhat.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--drivers/char/isicom.c61
-rw-r--r--drivers/char/moxa.c61
2 files changed, 69 insertions, 53 deletions
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index 8f7cc190b62d..7d30ee1d3fca 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -421,17 +421,16 @@ static void isicom_tx(unsigned long _data)
421 if (retries >= 100) 421 if (retries >= 100)
422 goto unlock; 422 goto unlock;
423 423
424 tty = tty_port_tty_get(&port->port);
425 if (tty == NULL)
426 goto put_unlock;
427
424 for (; count > 0; count--, port++) { 428 for (; count > 0; count--, port++) {
425 /* port not active or tx disabled to force flow control */ 429 /* port not active or tx disabled to force flow control */
426 if (!(port->port.flags & ASYNC_INITIALIZED) || 430 if (!(port->port.flags & ASYNC_INITIALIZED) ||
427 !(port->status & ISI_TXOK)) 431 !(port->status & ISI_TXOK))
428 continue; 432 continue;
429 433
430 tty = port->port.tty;
431
432 if (tty == NULL)
433 continue;
434
435 txcount = min_t(short, TX_SIZE, port->xmit_cnt); 434 txcount = min_t(short, TX_SIZE, port->xmit_cnt);
436 if (txcount <= 0 || tty->stopped || tty->hw_stopped) 435 if (txcount <= 0 || tty->stopped || tty->hw_stopped)
437 continue; 436 continue;
@@ -489,6 +488,8 @@ static void isicom_tx(unsigned long _data)
489 tty_wakeup(tty); 488 tty_wakeup(tty);
490 } 489 }
491 490
491put_unlock:
492 tty_kref_put(tty);
492unlock: 493unlock:
493 spin_unlock_irqrestore(&isi_card[card].card_lock, flags); 494 spin_unlock_irqrestore(&isi_card[card].card_lock, flags);
494 /* schedule another tx for hopefully in about 10ms */ 495 /* schedule another tx for hopefully in about 10ms */
@@ -547,7 +548,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
547 return IRQ_HANDLED; 548 return IRQ_HANDLED;
548 } 549 }
549 550
550 tty = port->port.tty; 551 tty = tty_port_tty_get(&port->port);
551 if (tty == NULL) { 552 if (tty == NULL) {
552 word_count = byte_count >> 1; 553 word_count = byte_count >> 1;
553 while (byte_count > 1) { 554 while (byte_count > 1) {
@@ -588,7 +589,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
588 } 589 }
589 590
590 if (port->port.flags & ASYNC_CTS_FLOW) { 591 if (port->port.flags & ASYNC_CTS_FLOW) {
591 if (port->port.tty->hw_stopped) { 592 if (tty->hw_stopped) {
592 if (header & ISI_CTS) { 593 if (header & ISI_CTS) {
593 port->port.tty->hw_stopped = 0; 594 port->port.tty->hw_stopped = 0;
594 /* start tx ing */ 595 /* start tx ing */
@@ -597,7 +598,7 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
597 tty_wakeup(tty); 598 tty_wakeup(tty);
598 } 599 }
599 } else if (!(header & ISI_CTS)) { 600 } else if (!(header & ISI_CTS)) {
600 port->port.tty->hw_stopped = 1; 601 tty->hw_stopped = 1;
601 /* stop tx ing */ 602 /* stop tx ing */
602 port->status &= ~(ISI_TXOK | ISI_CTS); 603 port->status &= ~(ISI_TXOK | ISI_CTS);
603 } 604 }
@@ -660,24 +661,21 @@ static irqreturn_t isicom_interrupt(int irq, void *dev_id)
660 } 661 }
661 outw(0x0000, base+0x04); /* enable interrupts */ 662 outw(0x0000, base+0x04); /* enable interrupts */
662 spin_unlock(&card->card_lock); 663 spin_unlock(&card->card_lock);
664 tty_kref_put(tty);
663 665
664 return IRQ_HANDLED; 666 return IRQ_HANDLED;
665} 667}
666 668
667static void isicom_config_port(struct isi_port *port) 669static void isicom_config_port(struct tty_struct *tty)
668{ 670{
671 struct isi_port *port = tty->driver_data;
669 struct isi_board *card = port->card; 672 struct isi_board *card = port->card;
670 struct tty_struct *tty;
671 unsigned long baud; 673 unsigned long baud;
672 unsigned long base = card->base; 674 unsigned long base = card->base;
673 u16 channel_setup, channel = port->channel, 675 u16 channel_setup, channel = port->channel,
674 shift_count = card->shift_count; 676 shift_count = card->shift_count;
675 unsigned char flow_ctrl; 677 unsigned char flow_ctrl;
676 678
677 tty = port->port.tty;
678
679 if (tty == NULL)
680 return;
681 /* FIXME: Switch to new tty baud API */ 679 /* FIXME: Switch to new tty baud API */
682 baud = C_BAUD(tty); 680 baud = C_BAUD(tty);
683 if (baud & CBAUDEX) { 681 if (baud & CBAUDEX) {
@@ -690,7 +688,7 @@ static void isicom_config_port(struct isi_port *port)
690 688
691 /* 1,2,3,4 => 57.6, 115.2, 230, 460 kbps resp. */ 689 /* 1,2,3,4 => 57.6, 115.2, 230, 460 kbps resp. */
692 if (baud < 1 || baud > 4) 690 if (baud < 1 || baud > 4)
693 port->port.tty->termios->c_cflag &= ~CBAUDEX; 691 tty->termios->c_cflag &= ~CBAUDEX;
694 else 692 else
695 baud += 15; 693 baud += 15;
696 } 694 }
@@ -797,8 +795,9 @@ static inline void isicom_setup_board(struct isi_board *bp)
797 spin_unlock_irqrestore(&bp->card_lock, flags); 795 spin_unlock_irqrestore(&bp->card_lock, flags);
798} 796}
799 797
800static int isicom_setup_port(struct isi_port *port) 798static int isicom_setup_port(struct tty_struct *tty)
801{ 799{
800 struct isi_port *port = tty->driver_data;
802 struct isi_board *card = port->card; 801 struct isi_board *card = port->card;
803 unsigned long flags; 802 unsigned long flags;
804 803
@@ -808,8 +807,7 @@ static int isicom_setup_port(struct isi_port *port)
808 return -ENOMEM; 807 return -ENOMEM;
809 808
810 spin_lock_irqsave(&card->card_lock, flags); 809 spin_lock_irqsave(&card->card_lock, flags);
811 if (port->port.tty) 810 clear_bit(TTY_IO_ERROR, &tty->flags);
812 clear_bit(TTY_IO_ERROR, &port->port.tty->flags);
813 if (port->port.count == 1) 811 if (port->port.count == 1)
814 card->count++; 812 card->count++;
815 813
@@ -823,7 +821,7 @@ static int isicom_setup_port(struct isi_port *port)
823 InterruptTheCard(card->base); 821 InterruptTheCard(card->base);
824 } 822 }
825 823
826 isicom_config_port(port); 824 isicom_config_port(tty);
827 port->port.flags |= ASYNC_INITIALIZED; 825 port->port.flags |= ASYNC_INITIALIZED;
828 spin_unlock_irqrestore(&card->card_lock, flags); 826 spin_unlock_irqrestore(&card->card_lock, flags);
829 827
@@ -934,8 +932,8 @@ static int isicom_open(struct tty_struct *tty, struct file *filp)
934 932
935 port->port.count++; 933 port->port.count++;
936 tty->driver_data = port; 934 tty->driver_data = port;
937 port->port.tty = tty; 935 tty_port_tty_set(&port->port, tty);
938 error = isicom_setup_port(port); 936 error = isicom_setup_port(tty);
939 if (error == 0) 937 if (error == 0)
940 error = block_til_ready(tty, filp, port); 938 error = block_til_ready(tty, filp, port);
941 return error; 939 return error;
@@ -955,15 +953,17 @@ static void isicom_shutdown_port(struct isi_port *port)
955 struct isi_board *card = port->card; 953 struct isi_board *card = port->card;
956 struct tty_struct *tty; 954 struct tty_struct *tty;
957 955
958 tty = port->port.tty; 956 tty = tty_port_tty_get(&port->port);
959 957
960 if (!(port->port.flags & ASYNC_INITIALIZED)) 958 if (!(port->port.flags & ASYNC_INITIALIZED)) {
959 tty_kref_put(tty);
961 return; 960 return;
961 }
962 962
963 tty_port_free_xmit_buf(&port->port); 963 tty_port_free_xmit_buf(&port->port);
964 port->port.flags &= ~ASYNC_INITIALIZED; 964 port->port.flags &= ~ASYNC_INITIALIZED;
965 /* 3rd October 2000 : Vinayak P Risbud */ 965 /* 3rd October 2000 : Vinayak P Risbud */
966 port->port.tty = NULL; 966 tty_port_tty_set(&port->port, NULL);
967 967
968 /*Fix done by Anil .S on 30-04-2001 968 /*Fix done by Anil .S on 30-04-2001
969 remote login through isi port has dtr toggle problem 969 remote login through isi port has dtr toggle problem
@@ -1243,9 +1243,10 @@ static int isicom_tiocmset(struct tty_struct *tty, struct file *file,
1243 return 0; 1243 return 0;
1244} 1244}
1245 1245
1246static int isicom_set_serial_info(struct isi_port *port, 1246static int isicom_set_serial_info(struct tty_struct *tty,
1247 struct serial_struct __user *info) 1247 struct serial_struct __user *info)
1248{ 1248{
1249 struct isi_port *port = tty->driver_data;
1249 struct serial_struct newinfo; 1250 struct serial_struct newinfo;
1250 int reconfig_port; 1251 int reconfig_port;
1251 1252
@@ -1276,7 +1277,7 @@ static int isicom_set_serial_info(struct isi_port *port,
1276 if (reconfig_port) { 1277 if (reconfig_port) {
1277 unsigned long flags; 1278 unsigned long flags;
1278 spin_lock_irqsave(&port->card->card_lock, flags); 1279 spin_lock_irqsave(&port->card->card_lock, flags);
1279 isicom_config_port(port); 1280 isicom_config_port(tty);
1280 spin_unlock_irqrestore(&port->card->card_lock, flags); 1281 spin_unlock_irqrestore(&port->card->card_lock, flags);
1281 } 1282 }
1282 unlock_kernel(); 1283 unlock_kernel();
@@ -1318,7 +1319,7 @@ static int isicom_ioctl(struct tty_struct *tty, struct file *filp,
1318 return isicom_get_serial_info(port, argp); 1319 return isicom_get_serial_info(port, argp);
1319 1320
1320 case TIOCSSERIAL: 1321 case TIOCSSERIAL:
1321 return isicom_set_serial_info(port, argp); 1322 return isicom_set_serial_info(tty, argp);
1322 1323
1323 default: 1324 default:
1324 return -ENOIOCTLCMD; 1325 return -ENOIOCTLCMD;
@@ -1341,7 +1342,7 @@ static void isicom_set_termios(struct tty_struct *tty,
1341 return; 1342 return;
1342 1343
1343 spin_lock_irqsave(&port->card->card_lock, flags); 1344 spin_lock_irqsave(&port->card->card_lock, flags);
1344 isicom_config_port(port); 1345 isicom_config_port(tty);
1345 spin_unlock_irqrestore(&port->card->card_lock, flags); 1346 spin_unlock_irqrestore(&port->card->card_lock, flags);
1346 1347
1347 if ((old_termios->c_cflag & CRTSCTS) && 1348 if ((old_termios->c_cflag & CRTSCTS) &&
@@ -1419,7 +1420,7 @@ static void isicom_hangup(struct tty_struct *tty)
1419 1420
1420 port->port.count = 0; 1421 port->port.count = 0;
1421 port->port.flags &= ~ASYNC_NORMAL_ACTIVE; 1422 port->port.flags &= ~ASYNC_NORMAL_ACTIVE;
1422 port->port.tty = NULL; 1423 tty_port_tty_set(&port->port, NULL);
1423 wake_up_interruptible(&port->port.open_wait); 1424 wake_up_interruptible(&port->port.open_wait);
1424} 1425}
1425 1426
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c
index d3d7864e0c1e..5df4003ad873 100644
--- a/drivers/char/moxa.c
+++ b/drivers/char/moxa.c
@@ -205,7 +205,7 @@ static int moxa_tiocmset(struct tty_struct *tty, struct file *file,
205static void moxa_poll(unsigned long); 205static void moxa_poll(unsigned long);
206static void moxa_set_tty_param(struct tty_struct *, struct ktermios *); 206static void moxa_set_tty_param(struct tty_struct *, struct ktermios *);
207static void moxa_setup_empty_event(struct tty_struct *); 207static void moxa_setup_empty_event(struct tty_struct *);
208static void moxa_shut_down(struct moxa_port *); 208static void moxa_shut_down(struct tty_struct *);
209/* 209/*
210 * moxa board interface functions: 210 * moxa board interface functions:
211 */ 211 */
@@ -217,7 +217,7 @@ static void MoxaPortLineCtrl(struct moxa_port *, int, int);
217static void MoxaPortFlowCtrl(struct moxa_port *, int, int, int, int, int); 217static void MoxaPortFlowCtrl(struct moxa_port *, int, int, int, int, int);
218static int MoxaPortLineStatus(struct moxa_port *); 218static int MoxaPortLineStatus(struct moxa_port *);
219static void MoxaPortFlushData(struct moxa_port *, int); 219static void MoxaPortFlushData(struct moxa_port *, int);
220static int MoxaPortWriteData(struct moxa_port *, const unsigned char *, int); 220static int MoxaPortWriteData(struct tty_struct *, const unsigned char *, int);
221static int MoxaPortReadData(struct moxa_port *); 221static int MoxaPortReadData(struct moxa_port *);
222static int MoxaPortTxQueue(struct moxa_port *); 222static int MoxaPortTxQueue(struct moxa_port *);
223static int MoxaPortRxQueue(struct moxa_port *); 223static int MoxaPortRxQueue(struct moxa_port *);
@@ -332,6 +332,7 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file,
332 for (i = 0; i < MAX_BOARDS; i++) { 332 for (i = 0; i < MAX_BOARDS; i++) {
333 p = moxa_boards[i].ports; 333 p = moxa_boards[i].ports;
334 for (j = 0; j < MAX_PORTS_PER_BOARD; j++, p++, argm++) { 334 for (j = 0; j < MAX_PORTS_PER_BOARD; j++, p++, argm++) {
335 struct tty_struct *ttyp;
335 memset(&tmp, 0, sizeof(tmp)); 336 memset(&tmp, 0, sizeof(tmp));
336 if (!moxa_boards[i].ready) 337 if (!moxa_boards[i].ready)
337 goto copy; 338 goto copy;
@@ -344,10 +345,12 @@ static int moxa_ioctl(struct tty_struct *tty, struct file *file,
344 if (status & 4) 345 if (status & 4)
345 tmp.dcd = 1; 346 tmp.dcd = 1;
346 347
347 if (!p->port.tty || !p->port.tty->termios) 348 ttyp = tty_port_tty_get(&p->port);
349 if (!ttyp || !ttyp->termios)
348 tmp.cflag = p->cflag; 350 tmp.cflag = p->cflag;
349 else 351 else
350 tmp.cflag = p->port.tty->termios->c_cflag; 352 tmp.cflag = ttyp->termios->c_cflag;
353 tty_kref_put(tty);
351copy: 354copy:
352 if (copy_to_user(argm, &tmp, sizeof(tmp))) { 355 if (copy_to_user(argm, &tmp, sizeof(tmp))) {
353 mutex_unlock(&moxa_openlock); 356 mutex_unlock(&moxa_openlock);
@@ -880,8 +883,14 @@ static void moxa_board_deinit(struct moxa_board_conf *brd)
880 883
881 /* pci hot-un-plug support */ 884 /* pci hot-un-plug support */
882 for (a = 0; a < brd->numPorts; a++) 885 for (a = 0; a < brd->numPorts; a++)
883 if (brd->ports[a].port.flags & ASYNC_INITIALIZED) 886 if (brd->ports[a].port.flags & ASYNC_INITIALIZED) {
884 tty_hangup(brd->ports[a].port.tty); 887 struct tty_struct *tty = tty_port_tty_get(
888 &brd->ports[a].port);
889 if (tty) {
890 tty_hangup(tty);
891 tty_kref_put(tty);
892 }
893 }
885 while (1) { 894 while (1) {
886 opened = 0; 895 opened = 0;
887 for (a = 0; a < brd->numPorts; a++) 896 for (a = 0; a < brd->numPorts; a++)
@@ -1096,13 +1105,14 @@ static void __exit moxa_exit(void)
1096module_init(moxa_init); 1105module_init(moxa_init);
1097module_exit(moxa_exit); 1106module_exit(moxa_exit);
1098 1107
1099static void moxa_close_port(struct moxa_port *ch) 1108static void moxa_close_port(struct tty_struct *tty)
1100{ 1109{
1101 moxa_shut_down(ch); 1110 struct moxa_port *ch = tty->driver_data;
1111 moxa_shut_down(tty);
1102 MoxaPortFlushData(ch, 2); 1112 MoxaPortFlushData(ch, 2);
1103 ch->port.flags &= ~ASYNC_NORMAL_ACTIVE; 1113 ch->port.flags &= ~ASYNC_NORMAL_ACTIVE;
1104 ch->port.tty->driver_data = NULL; 1114 tty->driver_data = NULL;
1105 ch->port.tty = NULL; 1115 tty_port_tty_set(&ch->port, NULL);
1106} 1116}
1107 1117
1108static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp, 1118static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp,
@@ -1161,7 +1171,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
1161 ch = &brd->ports[port % MAX_PORTS_PER_BOARD]; 1171 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
1162 ch->port.count++; 1172 ch->port.count++;
1163 tty->driver_data = ch; 1173 tty->driver_data = ch;
1164 ch->port.tty = tty; 1174 tty_port_tty_set(&ch->port, tty);
1165 if (!(ch->port.flags & ASYNC_INITIALIZED)) { 1175 if (!(ch->port.flags & ASYNC_INITIALIZED)) {
1166 ch->statusflags = 0; 1176 ch->statusflags = 0;
1167 moxa_set_tty_param(tty, tty->termios); 1177 moxa_set_tty_param(tty, tty->termios);
@@ -1179,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
1179 if (retval) { 1189 if (retval) {
1180 if (ch->port.count) /* 0 means already hung up... */ 1190 if (ch->port.count) /* 0 means already hung up... */
1181 if (--ch->port.count == 0) 1191 if (--ch->port.count == 0)
1182 moxa_close_port(ch); 1192 moxa_close_port(tty);
1183 } else 1193 } else
1184 ch->port.flags |= ASYNC_NORMAL_ACTIVE; 1194 ch->port.flags |= ASYNC_NORMAL_ACTIVE;
1185 mutex_unlock(&moxa_openlock); 1195 mutex_unlock(&moxa_openlock);
@@ -1219,7 +1229,7 @@ static void moxa_close(struct tty_struct *tty, struct file *filp)
1219 tty_wait_until_sent(tty, 30 * HZ); /* 30 seconds timeout */ 1229 tty_wait_until_sent(tty, 30 * HZ); /* 30 seconds timeout */
1220 } 1230 }
1221 1231
1222 moxa_close_port(ch); 1232 moxa_close_port(tty);
1223unlock: 1233unlock:
1224 mutex_unlock(&moxa_openlock); 1234 mutex_unlock(&moxa_openlock);
1225} 1235}
@@ -1234,7 +1244,7 @@ static int moxa_write(struct tty_struct *tty,
1234 return 0; 1244 return 0;
1235 1245
1236 spin_lock_bh(&moxa_lock); 1246 spin_lock_bh(&moxa_lock);
1237 len = MoxaPortWriteData(ch, buf, count); 1247 len = MoxaPortWriteData(tty, buf, count);
1238 spin_unlock_bh(&moxa_lock); 1248 spin_unlock_bh(&moxa_lock);
1239 1249
1240 ch->statusflags |= LOWWAIT; 1250 ch->statusflags |= LOWWAIT;
@@ -1409,7 +1419,7 @@ static void moxa_hangup(struct tty_struct *tty)
1409 return; 1419 return;
1410 } 1420 }
1411 ch->port.count = 0; 1421 ch->port.count = 0;
1412 moxa_close_port(ch); 1422 moxa_close_port(tty);
1413 mutex_unlock(&moxa_openlock); 1423 mutex_unlock(&moxa_openlock);
1414 1424
1415 wake_up_interruptible(&ch->port.open_wait); 1425 wake_up_interruptible(&ch->port.open_wait);
@@ -1417,11 +1427,14 @@ static void moxa_hangup(struct tty_struct *tty)
1417 1427
1418static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd) 1428static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd)
1419{ 1429{
1430 struct tty_struct *tty;
1420 dcd = !!dcd; 1431 dcd = !!dcd;
1421 1432
1422 if (dcd != p->DCDState && p->port.tty && C_CLOCAL(p->port.tty)) { 1433 if (dcd != p->DCDState) {
1423 if (!dcd) 1434 tty = tty_port_tty_get(&p->port);
1424 tty_hangup(p->port.tty); 1435 if (tty && C_CLOCAL(tty) && !dcd)
1436 tty_hangup(tty);
1437 tty_kref_put(tty);
1425 } 1438 }
1426 p->DCDState = dcd; 1439 p->DCDState = dcd;
1427} 1440}
@@ -1429,7 +1442,7 @@ static void moxa_new_dcdstate(struct moxa_port *p, u8 dcd)
1429static int moxa_poll_port(struct moxa_port *p, unsigned int handle, 1442static int moxa_poll_port(struct moxa_port *p, unsigned int handle,
1430 u16 __iomem *ip) 1443 u16 __iomem *ip)
1431{ 1444{
1432 struct tty_struct *tty = p->port.tty; 1445 struct tty_struct *tty = tty_port_tty_get(&p->port);
1433 void __iomem *ofsAddr; 1446 void __iomem *ofsAddr;
1434 unsigned int inited = p->port.flags & ASYNC_INITIALIZED; 1447 unsigned int inited = p->port.flags & ASYNC_INITIALIZED;
1435 u16 intr; 1448 u16 intr;
@@ -1476,6 +1489,7 @@ static int moxa_poll_port(struct moxa_port *p, unsigned int handle,
1476 tty_insert_flip_char(tty, 0, TTY_BREAK); 1489 tty_insert_flip_char(tty, 0, TTY_BREAK);
1477 tty_schedule_flip(tty); 1490 tty_schedule_flip(tty);
1478 } 1491 }
1492 tty_kref_put(tty);
1479 1493
1480 if (intr & IntrLine) 1494 if (intr & IntrLine)
1481 moxa_new_dcdstate(p, readb(ofsAddr + FlagStat) & DCD_state); 1495 moxa_new_dcdstate(p, readb(ofsAddr + FlagStat) & DCD_state);
@@ -1560,9 +1574,9 @@ static void moxa_setup_empty_event(struct tty_struct *tty)
1560 spin_unlock_bh(&moxa_lock); 1574 spin_unlock_bh(&moxa_lock);
1561} 1575}
1562 1576
1563static void moxa_shut_down(struct moxa_port *ch) 1577static void moxa_shut_down(struct tty_struct *tty)
1564{ 1578{
1565 struct tty_struct *tp = ch->port.tty; 1579 struct moxa_port *ch = tty->driver_data;
1566 1580
1567 if (!(ch->port.flags & ASYNC_INITIALIZED)) 1581 if (!(ch->port.flags & ASYNC_INITIALIZED))
1568 return; 1582 return;
@@ -1572,7 +1586,7 @@ static void moxa_shut_down(struct moxa_port *ch)
1572 /* 1586 /*
1573 * If we're a modem control device and HUPCL is on, drop RTS & DTR. 1587 * If we're a modem control device and HUPCL is on, drop RTS & DTR.
1574 */ 1588 */
1575 if (C_HUPCL(tp)) 1589 if (C_HUPCL(tty))
1576 MoxaPortLineCtrl(ch, 0, 0); 1590 MoxaPortLineCtrl(ch, 0, 0);
1577 1591
1578 spin_lock_bh(&moxa_lock); 1592 spin_lock_bh(&moxa_lock);
@@ -1953,9 +1967,10 @@ static int MoxaPortLineStatus(struct moxa_port *port)
1953 return val; 1967 return val;
1954} 1968}
1955 1969
1956static int MoxaPortWriteData(struct moxa_port *port, 1970static int MoxaPortWriteData(struct tty_struct *tty,
1957 const unsigned char *buffer, int len) 1971 const unsigned char *buffer, int len)
1958{ 1972{
1973 struct moxa_port *port = tty->driver_data;
1959 void __iomem *baseAddr, *ofsAddr, *ofs; 1974 void __iomem *baseAddr, *ofsAddr, *ofs;
1960 unsigned int c, total; 1975 unsigned int c, total;
1961 u16 head, tail, tx_mask, spage, epage; 1976 u16 head, tail, tx_mask, spage, epage;