aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/isicom.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/isicom.c')
-rw-r--r--drivers/char/isicom.c57
1 files changed, 38 insertions, 19 deletions
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c
index 4f1f4cd670da..426bfdd7f3e0 100644
--- a/drivers/char/isicom.c
+++ b/drivers/char/isicom.c
@@ -846,37 +846,53 @@ static int isicom_carrier_raised(struct tty_port *port)
846 return (ip->status & ISI_DCD)?1 : 0; 846 return (ip->status & ISI_DCD)?1 : 0;
847} 847}
848 848
849static int isicom_open(struct tty_struct *tty, struct file *filp) 849static struct tty_port *isicom_find_port(struct tty_struct *tty)
850{ 850{
851 struct isi_port *port; 851 struct isi_port *port;
852 struct isi_board *card; 852 struct isi_board *card;
853 unsigned int board; 853 unsigned int board;
854 int error, line; 854 int line = tty->index;
855 855
856 line = tty->index;
857 if (line < 0 || line > PORT_COUNT-1) 856 if (line < 0 || line > PORT_COUNT-1)
858 return -ENODEV; 857 return NULL;
859 board = BOARD(line); 858 board = BOARD(line);
860 card = &isi_card[board]; 859 card = &isi_card[board];
861 860
862 if (!(card->status & FIRMWARE_LOADED)) 861 if (!(card->status & FIRMWARE_LOADED))
863 return -ENODEV; 862 return NULL;
864 863
865 /* open on a port greater than the port count for the card !!! */ 864 /* open on a port greater than the port count for the card !!! */
866 if (line > ((board * 16) + card->port_count - 1)) 865 if (line > ((board * 16) + card->port_count - 1))
867 return -ENODEV; 866 return NULL;
868 867
869 port = &isi_ports[line]; 868 port = &isi_ports[line];
870 if (isicom_paranoia_check(port, tty->name, "isicom_open")) 869 if (isicom_paranoia_check(port, tty->name, "isicom_open"))
871 return -ENODEV; 870 return NULL;
872 871
872 return &port->port;
873}
874
875static int isicom_open(struct tty_struct *tty, struct file *filp)
876{
877 struct isi_port *port;
878 struct isi_board *card;
879 struct tty_port *tport;
880 int error = 0;
881
882 tport = isicom_find_port(tty);
883 if (tport == NULL)
884 return -ENODEV;
885 port = container_of(tport, struct isi_port, port);
886 card = &isi_card[BOARD(tty->index)];
873 isicom_setup_board(card); 887 isicom_setup_board(card);
874 888
875 /* FIXME: locking on port.count etc */ 889 /* FIXME: locking on port.count etc */
876 port->port.count++; 890 port->port.count++;
877 tty->driver_data = port; 891 tty->driver_data = port;
878 tty_port_tty_set(&port->port, tty); 892 tty_port_tty_set(&port->port, tty);
879 error = isicom_setup_port(tty); 893 /* FIXME: Locking on Initialized flag */
894 if (!test_bit(ASYNCB_INITIALIZED, &tport->flags))
895 error = isicom_setup_port(tty);
880 if (error == 0) 896 if (error == 0)
881 error = tty_port_block_til_ready(&port->port, tty, filp); 897 error = tty_port_block_til_ready(&port->port, tty, filp);
882 return error; 898 return error;
@@ -952,19 +968,12 @@ static void isicom_flush_buffer(struct tty_struct *tty)
952 tty_wakeup(tty); 968 tty_wakeup(tty);
953} 969}
954 970
955static void isicom_close(struct tty_struct *tty, struct file *filp) 971static void isicom_close_port(struct tty_port *port)
956{ 972{
957 struct isi_port *ip = tty->driver_data; 973 struct isi_port *ip = container_of(port, struct isi_port, port);
958 struct tty_port *port = &ip->port; 974 struct isi_board *card = ip->card;
959 struct isi_board *card;
960 unsigned long flags; 975 unsigned long flags;
961 976
962 BUG_ON(!ip);
963
964 card = ip->card;
965 if (isicom_paranoia_check(ip, tty->name, "isicom_close"))
966 return;
967
968 /* indicate to the card that no more data can be received 977 /* indicate to the card that no more data can be received
969 on this port */ 978 on this port */
970 spin_lock_irqsave(&card->card_lock, flags); 979 spin_lock_irqsave(&card->card_lock, flags);
@@ -974,9 +983,19 @@ static void isicom_close(struct tty_struct *tty, struct file *filp)
974 } 983 }
975 isicom_shutdown_port(ip); 984 isicom_shutdown_port(ip);
976 spin_unlock_irqrestore(&card->card_lock, flags); 985 spin_unlock_irqrestore(&card->card_lock, flags);
986}
987
988static void isicom_close(struct tty_struct *tty, struct file *filp)
989{
990 struct isi_port *ip = tty->driver_data;
991 struct tty_port *port = &ip->port;
992 if (isicom_paranoia_check(ip, tty->name, "isicom_close"))
993 return;
977 994
995 if (tty_port_close_start(port, tty, filp) == 0)
996 return;
997 isicom_close_port(port);
978 isicom_flush_buffer(tty); 998 isicom_flush_buffer(tty);
979
980 tty_port_close_end(port, tty); 999 tty_port_close_end(port, tty);
981} 1000}
982 1001