aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/isicom.c
diff options
context:
space:
mode:
authorAlan Cox <alan@linux.intel.com>2009-11-30 08:17:24 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-12-11 18:18:07 -0500
commitbaaa08acb0ca2df47830b58b5df8b9059cf9ddd2 (patch)
tree5d1d362e3e4006697fe87560c833f7425be8b992 /drivers/char/isicom.c
parent568aafc627e2978509e8a80c640ba534d1e843cc (diff)
tty: isicom: switch to the new tty_port_open helper
Trivial conversion in this case so might as well do it while testing the port_open design is right Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/char/isicom.c')
-rw-r--r--drivers/char/isicom.c88
1 files changed, 21 insertions, 67 deletions
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index 426bfdd7f3e0..e7be3ec6d21c 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -804,24 +804,21 @@ static inline void isicom_setup_board(struct isi_board *bp)
804 bp->status |= BOARD_ACTIVE; 804 bp->status |= BOARD_ACTIVE;
805 for (channel = 0; channel < bp->port_count; channel++, port++) 805 for (channel = 0; channel < bp->port_count; channel++, port++)
806 drop_dtr_rts(port); 806 drop_dtr_rts(port);
807 bp->count++;
807 spin_unlock_irqrestore(&bp->card_lock, flags); 808 spin_unlock_irqrestore(&bp->card_lock, flags);
808} 809}
809 810
810static int isicom_setup_port(struct tty_struct *tty) 811static int isicom_activate(struct tty_port *tport, struct tty_struct *tty)
811{ 812{
812 struct isi_port *port = tty->driver_data; 813 struct isi_port *port = container_of(tport, struct isi_port, port);
813 struct isi_board *card = port->card; 814 struct isi_board *card = port->card;
814 unsigned long flags; 815 unsigned long flags;
815 816
816 if (port->port.flags & ASYNC_INITIALIZED) 817 if (tty_port_alloc_xmit_buf(tport) < 0)
817 return 0;
818 if (tty_port_alloc_xmit_buf(&port->port) < 0)
819 return -ENOMEM; 818 return -ENOMEM;
820 819
821 spin_lock_irqsave(&card->card_lock, flags); 820 spin_lock_irqsave(&card->card_lock, flags);
822 clear_bit(TTY_IO_ERROR, &tty->flags); 821 isicom_setup_board(card);
823 if (port->port.count == 1)
824 card->count++;
825 822
826 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 823 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
827 824
@@ -832,9 +829,7 @@ static int isicom_setup_port(struct tty_struct *tty)
832 outw(((ISICOM_KILLTX | ISICOM_KILLRX) << 8) | 0x06, card->base); 829 outw(((ISICOM_KILLTX | ISICOM_KILLRX) << 8) | 0x06, card->base);
833 InterruptTheCard(card->base); 830 InterruptTheCard(card->base);
834 } 831 }
835
836 isicom_config_port(tty); 832 isicom_config_port(tty);
837 port->port.flags |= ASYNC_INITIALIZED;
838 spin_unlock_irqrestore(&card->card_lock, flags); 833 spin_unlock_irqrestore(&card->card_lock, flags);
839 834
840 return 0; 835 return 0;
@@ -871,31 +866,20 @@ static struct tty_port *isicom_find_port(struct tty_struct *tty)
871 866
872 return &port->port; 867 return &port->port;
873} 868}
874 869
875static int isicom_open(struct tty_struct *tty, struct file *filp) 870static int isicom_open(struct tty_struct *tty, struct file *filp)
876{ 871{
877 struct isi_port *port; 872 struct isi_port *port;
878 struct isi_board *card; 873 struct isi_board *card;
879 struct tty_port *tport; 874 struct tty_port *tport;
880 int error = 0;
881 875
882 tport = isicom_find_port(tty); 876 tport = isicom_find_port(tty);
883 if (tport == NULL) 877 if (tport == NULL)
884 return -ENODEV; 878 return -ENODEV;
885 port = container_of(tport, struct isi_port, port); 879 port = container_of(tport, struct isi_port, port);
886 card = &isi_card[BOARD(tty->index)]; 880 card = &isi_card[BOARD(tty->index)];
887 isicom_setup_board(card);
888 881
889 /* FIXME: locking on port.count etc */ 882 return tty_port_open(tport, tty, filp);
890 port->port.count++;
891 tty->driver_data = port;
892 tty_port_tty_set(&port->port, tty);
893 /* FIXME: Locking on Initialized flag */
894 if (!test_bit(ASYNCB_INITIALIZED, &tport->flags))
895 error = isicom_setup_port(tty);
896 if (error == 0)
897 error = tty_port_block_til_ready(&port->port, tty, filp);
898 return error;
899} 883}
900 884
901/* close et all */ 885/* close et all */
@@ -914,40 +898,21 @@ static void isicom_shutdown_port(struct isi_port *port)
914 898
915 tty = tty_port_tty_get(&port->port); 899 tty = tty_port_tty_get(&port->port);
916 900
917 if (!(port->port.flags & ASYNC_INITIALIZED)) {
918 tty_kref_put(tty);
919 return;
920 }
921
922 tty_port_free_xmit_buf(&port->port); 901 tty_port_free_xmit_buf(&port->port);
923 port->port.flags &= ~ASYNC_INITIALIZED;
924 /* 3rd October 2000 : Vinayak P Risbud */
925 tty_port_tty_set(&port->port, NULL);
926
927 /*Fix done by Anil .S on 30-04-2001
928 remote login through isi port has dtr toggle problem
929 due to which the carrier drops before the password prompt
930 appears on the remote end. Now we drop the dtr only if the
931 HUPCL(Hangup on close) flag is set for the tty*/
932
933 if (C_HUPCL(tty))
934 /* drop dtr on this port */
935 drop_dtr(port);
936
937 /* any other port uninits */
938 if (tty)
939 set_bit(TTY_IO_ERROR, &tty->flags);
940
941 if (--card->count < 0) { 902 if (--card->count < 0) {
942 pr_dbg("isicom_shutdown_port: bad board(0x%lx) count %d.\n", 903 pr_dbg("isicom_shutdown_port: bad board(0x%lx) count %d.\n",
943 card->base, card->count); 904 card->base, card->count);
944 card->count = 0; 905 card->count = 0;
945 } 906 }
946 907
947 /* last port was closed, shutdown that boad too */ 908 /* last port was closed, shutdown that board too */
948 if (C_HUPCL(tty)) { 909 if (tty && C_HUPCL(tty)) {
949 if (!card->count) 910 /* FIXME: this logic is bogus - it's the old logic that was
950 isicom_shutdown_board(card); 911 bogus before but it still wants fixing */
912 if (!card->count) {
913 if (card->status & BOARD_ACTIVE)
914 card->status &= ~BOARD_ACTIVE;
915 }
951 } 916 }
952 tty_kref_put(tty); 917 tty_kref_put(tty);
953} 918}
@@ -968,7 +933,7 @@ static void isicom_flush_buffer(struct tty_struct *tty)
968 tty_wakeup(tty); 933 tty_wakeup(tty);
969} 934}
970 935
971static void isicom_close_port(struct tty_port *port) 936static void isicom_shutdown(struct tty_port *port)
972{ 937{
973 struct isi_port *ip = container_of(port, struct isi_port, port); 938 struct isi_port *ip = container_of(port, struct isi_port, port);
974 struct isi_board *card = ip->card; 939 struct isi_board *card = ip->card;
@@ -977,10 +942,8 @@ static void isicom_close_port(struct tty_port *port)
977 /* indicate to the card that no more data can be received 942 /* indicate to the card that no more data can be received
978 on this port */ 943 on this port */
979 spin_lock_irqsave(&card->card_lock, flags); 944 spin_lock_irqsave(&card->card_lock, flags);
980 if (port->flags & ASYNC_INITIALIZED) { 945 card->port_status &= ~(1 << ip->channel);
981 card->port_status &= ~(1 << ip->channel); 946 outw(card->port_status, card->base + 0x02);
982 outw(card->port_status, card->base + 0x02);
983 }
984 isicom_shutdown_port(ip); 947 isicom_shutdown_port(ip);
985 spin_unlock_irqrestore(&card->card_lock, flags); 948 spin_unlock_irqrestore(&card->card_lock, flags);
986} 949}
@@ -991,12 +954,7 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
991 struct tty_port *port = &ip->port; 954 struct tty_port *port = &ip->port;
992 if (isicom_paranoia_check(ip, tty->name, "isicom_close")) 955 if (isicom_paranoia_check(ip, tty->name, "isicom_close"))
993 return; 956 return;
994 957 tty_port_close(port, tty, filp);
995 if (tty_port_close_start(port, tty, filp) == 0)
996 return;
997 isicom_close_port(port);
998 isicom_flush_buffer(tty);
999 tty_port_close_end(port, tty);
1000} 958}
1001 959
1002/* write et all */ 960/* write et all */
@@ -1326,15 +1284,9 @@ static void isicom_start(struct tty_struct *tty)
1326static void isicom_hangup(struct tty_struct *tty) 1284static void isicom_hangup(struct tty_struct *tty)
1327{ 1285{
1328 struct isi_port *port = tty->driver_data; 1286 struct isi_port *port = tty->driver_data;
1329 unsigned long flags;
1330 1287
1331 if (isicom_paranoia_check(port, tty->name, "isicom_hangup")) 1288 if (isicom_paranoia_check(port, tty->name, "isicom_hangup"))
1332 return; 1289 return;
1333
1334 spin_lock_irqsave(&port->card->card_lock, flags);
1335 isicom_shutdown_port(port);
1336 spin_unlock_irqrestore(&port->card->card_lock, flags);
1337
1338 tty_port_hangup(&port->port); 1290 tty_port_hangup(&port->port);
1339} 1291}
1340 1292
@@ -1367,6 +1319,8 @@ static const struct tty_operations isicom_ops = {
1367static const struct tty_port_operations isicom_port_ops = { 1319static const struct tty_port_operations isicom_port_ops = {
1368 .carrier_raised = isicom_carrier_raised, 1320 .carrier_raised = isicom_carrier_raised,
1369 .dtr_rts = isicom_dtr_rts, 1321 .dtr_rts = isicom_dtr_rts,
1322 .activate = isicom_activate,
1323 .shutdown = isicom_shutdown,
1370}; 1324};
1371 1325
1372static int __devinit reset_card(struct pci_dev *pdev, 1326static int __devinit reset_card(struct pci_dev *pdev,