From 7710179abdd52d403f2636c9ec3ca97d851ecc54 Mon Sep 17 00:00:00 2001 From: Alan Cox Date: Sat, 19 Sep 2009 13:13:27 -0700 Subject: [PATCH] --- yaml --- r: 163843 b: refs/heads/master c: 11d85d7b2ecc72fe752bba55389e7d11907528af h: refs/heads/master i: 163841: 0a600ee647490c993753478ef557c46e8601bab0 163839: 820908f85d8f79136026e16e4e366ec7895ebcf6 v: v3 --- [refs] | 2 +- trunk/drivers/char/isicom.c | 32 ++++++++++++++++++++++++-------- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/[refs] b/[refs] index 86e857d50c30..a79c5e602fd4 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: a509a7e478e4766114d69f12d19d644ac63e9765 +refs/heads/master: 11d85d7b2ecc72fe752bba55389e7d11907528af diff --git a/trunk/drivers/char/isicom.c b/trunk/drivers/char/isicom.c index 08f574333a57..426bfdd7f3e0 100644 --- a/trunk/drivers/char/isicom.c +++ b/trunk/drivers/char/isicom.c @@ -846,37 +846,53 @@ static int isicom_carrier_raised(struct tty_port *port) return (ip->status & ISI_DCD)?1 : 0; } -static int isicom_open(struct tty_struct *tty, struct file *filp) +static struct tty_port *isicom_find_port(struct tty_struct *tty) { struct isi_port *port; struct isi_board *card; unsigned int board; - int error, line; + int line = tty->index; - line = tty->index; if (line < 0 || line > PORT_COUNT-1) - return -ENODEV; + return NULL; board = BOARD(line); card = &isi_card[board]; if (!(card->status & FIRMWARE_LOADED)) - return -ENODEV; + return NULL; /* open on a port greater than the port count for the card !!! */ if (line > ((board * 16) + card->port_count - 1)) - return -ENODEV; + return NULL; port = &isi_ports[line]; if (isicom_paranoia_check(port, tty->name, "isicom_open")) - return -ENODEV; + return NULL; + + return &port->port; +} + +static int isicom_open(struct tty_struct *tty, struct file *filp) +{ + struct isi_port *port; + struct isi_board *card; + struct tty_port *tport; + int error = 0; + tport = isicom_find_port(tty); + if (tport == NULL) + return -ENODEV; + port = container_of(tport, struct isi_port, port); + card = &isi_card[BOARD(tty->index)]; isicom_setup_board(card); /* FIXME: locking on port.count etc */ port->port.count++; tty->driver_data = port; tty_port_tty_set(&port->port, tty); - error = isicom_setup_port(tty); + /* FIXME: Locking on Initialized flag */ + if (!test_bit(ASYNCB_INITIALIZED, &tport->flags)) + error = isicom_setup_port(tty); if (error == 0) error = tty_port_block_til_ready(&port->port, tty, filp); return error;