Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Alan Cox and committed by
Greg Kroah-Hartman
baaa08ac 568aafc6

+21 -67
+21 -67
drivers/char/isicom.c
··· 804 804 bp->status |= BOARD_ACTIVE; 805 805 for (channel = 0; channel < bp->port_count; channel++, port++) 806 806 drop_dtr_rts(port); 807 + bp->count++; 807 808 spin_unlock_irqrestore(&bp->card_lock, flags); 808 809 } 809 810 810 - static int isicom_setup_port(struct tty_struct *tty) 811 + static 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 814 struct isi_board *card = port->card; 814 815 unsigned long flags; 815 816 816 - if (port->port.flags & ASYNC_INITIALIZED) 817 - return 0; 818 - if (tty_port_alloc_xmit_buf(&port->port) < 0) 817 + if (tty_port_alloc_xmit_buf(tport) < 0) 819 818 return -ENOMEM; 820 819 821 820 spin_lock_irqsave(&card->card_lock, flags); 822 - clear_bit(TTY_IO_ERROR, &tty->flags); 823 - if (port->port.count == 1) 824 - card->count++; 821 + isicom_setup_board(card); 825 822 826 823 port->xmit_cnt = port->xmit_head = port->xmit_tail = 0; 827 824 ··· 829 832 outw(((ISICOM_KILLTX | ISICOM_KILLRX) << 8) | 0x06, card->base); 830 833 InterruptTheCard(card->base); 831 834 } 832 - 833 835 isicom_config_port(tty); 834 - port->port.flags |= ASYNC_INITIALIZED; 835 836 spin_unlock_irqrestore(&card->card_lock, flags); 836 837 837 838 return 0; ··· 866 871 867 872 return &port->port; 868 873 } 869 - 874 + 870 875 static int isicom_open(struct tty_struct *tty, struct file *filp) 871 876 { 872 877 struct isi_port *port; 873 878 struct isi_board *card; 874 879 struct tty_port *tport; 875 - int error = 0; 876 880 877 881 tport = isicom_find_port(tty); 878 882 if (tport == NULL) 879 883 return -ENODEV; 880 884 port = container_of(tport, struct isi_port, port); 881 885 card = &isi_card[BOARD(tty->index)]; 882 - isicom_setup_board(card); 883 886 884 - /* FIXME: locking on port.count etc */ 885 - port->port.count++; 886 - tty->driver_data = port; 887 - tty_port_tty_set(&port->port, tty); 888 - /* FIXME: Locking on Initialized flag */ 889 - if (!test_bit(ASYNCB_INITIALIZED, &tport->flags)) 890 - error = isicom_setup_port(tty); 891 - if (error == 0) 892 - error = tty_port_block_til_ready(&port->port, tty, filp); 893 - return error; 887 + return tty_port_open(tport, tty, filp); 894 888 } 895 889 896 890 /* close et all */ ··· 898 914 899 915 tty = tty_port_tty_get(&port->port); 900 916 901 - if (!(port->port.flags & ASYNC_INITIALIZED)) { 902 - tty_kref_put(tty); 903 - return; 904 - } 905 - 906 917 tty_port_free_xmit_buf(&port->port); 907 - port->port.flags &= ~ASYNC_INITIALIZED; 908 - /* 3rd October 2000 : Vinayak P Risbud */ 909 - tty_port_tty_set(&port->port, NULL); 910 - 911 - /*Fix done by Anil .S on 30-04-2001 912 - remote login through isi port has dtr toggle problem 913 - due to which the carrier drops before the password prompt 914 - appears on the remote end. Now we drop the dtr only if the 915 - HUPCL(Hangup on close) flag is set for the tty*/ 916 - 917 - if (C_HUPCL(tty)) 918 - /* drop dtr on this port */ 919 - drop_dtr(port); 920 - 921 - /* any other port uninits */ 922 - if (tty) 923 - set_bit(TTY_IO_ERROR, &tty->flags); 924 - 925 918 if (--card->count < 0) { 926 919 pr_dbg("isicom_shutdown_port: bad board(0x%lx) count %d.\n", 927 920 card->base, card->count); 928 921 card->count = 0; 929 922 } 930 923 931 - /* last port was closed, shutdown that boad too */ 932 - if (C_HUPCL(tty)) { 933 - if (!card->count) 934 - isicom_shutdown_board(card); 924 + /* last port was closed, shutdown that board too */ 925 + if (tty && C_HUPCL(tty)) { 926 + /* FIXME: this logic is bogus - it's the old logic that was 927 + bogus before but it still wants fixing */ 928 + if (!card->count) { 929 + if (card->status & BOARD_ACTIVE) 930 + card->status &= ~BOARD_ACTIVE; 931 + } 935 932 } 936 933 tty_kref_put(tty); 937 934 } ··· 933 968 tty_wakeup(tty); 934 969 } 935 970 936 - static void isicom_close_port(struct tty_port *port) 971 + static void isicom_shutdown(struct tty_port *port) 937 972 { 938 973 struct isi_port *ip = container_of(port, struct isi_port, port); 939 974 struct isi_board *card = ip->card; ··· 942 977 /* indicate to the card that no more data can be received 943 978 on this port */ 944 979 spin_lock_irqsave(&card->card_lock, flags); 945 - if (port->flags & ASYNC_INITIALIZED) { 946 - card->port_status &= ~(1 << ip->channel); 947 - outw(card->port_status, card->base + 0x02); 948 - } 980 + card->port_status &= ~(1 << ip->channel); 981 + outw(card->port_status, card->base + 0x02); 949 982 isicom_shutdown_port(ip); 950 983 spin_unlock_irqrestore(&card->card_lock, flags); 951 984 } ··· 954 991 struct tty_port *port = &ip->port; 955 992 if (isicom_paranoia_check(ip, tty->name, "isicom_close")) 956 993 return; 957 - 958 - if (tty_port_close_start(port, tty, filp) == 0) 959 - return; 960 - isicom_close_port(port); 961 - isicom_flush_buffer(tty); 962 - tty_port_close_end(port, tty); 994 + tty_port_close(port, tty, filp); 963 995 } 964 996 965 997 /* write et all */ ··· 1284 1326 static void isicom_hangup(struct tty_struct *tty) 1285 1327 { 1286 1328 struct isi_port *port = tty->driver_data; 1287 - unsigned long flags; 1288 1329 1289 1330 if (isicom_paranoia_check(port, tty->name, "isicom_hangup")) 1290 1331 return; 1291 - 1292 - spin_lock_irqsave(&port->card->card_lock, flags); 1293 - isicom_shutdown_port(port); 1294 - spin_unlock_irqrestore(&port->card->card_lock, flags); 1295 - 1296 1332 tty_port_hangup(&port->port); 1297 1333 } 1298 1334 ··· 1319 1367 static const struct tty_port_operations isicom_port_ops = { 1320 1368 .carrier_raised = isicom_carrier_raised, 1321 1369 .dtr_rts = isicom_dtr_rts, 1370 + .activate = isicom_activate, 1371 + .shutdown = isicom_shutdown, 1322 1372 }; 1323 1373 1324 1374 static int __devinit reset_card(struct pci_dev *pdev,