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

isicom: split the open method for the isicom device

Again moving towards being able to add a common open method

Signed-off-by: Alan Cox <alan@linux.intel.com>

authored by

Alan Cox and committed by
Live-CD User
11d85d7b a509a7e4

+24 -8
+24 -8
drivers/char/isicom.c
··· 846 846 return (ip->status & ISI_DCD)?1 : 0; 847 847 } 848 848 849 - static int isicom_open(struct tty_struct *tty, struct file *filp) 849 + static struct tty_port *isicom_find_port(struct tty_struct *tty) 850 850 { 851 851 struct isi_port *port; 852 852 struct isi_board *card; 853 853 unsigned int board; 854 - int error, line; 854 + int line = tty->index; 855 855 856 - line = tty->index; 857 856 if (line < 0 || line > PORT_COUNT-1) 858 - return -ENODEV; 857 + return NULL; 859 858 board = BOARD(line); 860 859 card = &isi_card[board]; 861 860 862 861 if (!(card->status & FIRMWARE_LOADED)) 863 - return -ENODEV; 862 + return NULL; 864 863 865 864 /* open on a port greater than the port count for the card !!! */ 866 865 if (line > ((board * 16) + card->port_count - 1)) 867 - return -ENODEV; 866 + return NULL; 868 867 869 868 port = &isi_ports[line]; 870 869 if (isicom_paranoia_check(port, tty->name, "isicom_open")) 871 - return -ENODEV; 870 + return NULL; 872 871 872 + return &port->port; 873 + } 874 + 875 + static 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 887 isicom_setup_board(card); 874 888 875 889 /* FIXME: locking on port.count etc */ 876 890 port->port.count++; 877 891 tty->driver_data = port; 878 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 896 if (error == 0) 881 897 error = tty_port_block_til_ready(&port->port, tty, filp); 882 898 return error;