Skip to content

Commit

Permalink
isicom: split the open method for the isicom device
Browse files Browse the repository at this point in the history
Again moving towards being able to add a common open method

Signed-off-by: Alan Cox <alan@linux.intel.com>
  • Loading branch information
Alan Cox authored and Live-CD User committed Sep 19, 2009
1 parent a509a7e commit 11d85d7
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions drivers/char/isicom.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 11d85d7

Please sign in to comment.