]> Pileus Git - ~andy/linux/blobdiff - net/irda/ircomm/ircomm_tty.c
net, TTY: initialize tty->driver_data before usage
[~andy/linux] / net / irda / ircomm / ircomm_tty.c
index 4e35b45c1c73a6d40c093b5fb9bf4de4d791950d..496ce2cebcd7316f7a1eab1051758e2f90b22263 100644 (file)
@@ -52,6 +52,8 @@
 #include <net/irda/ircomm_tty_attach.h>
 #include <net/irda/ircomm_tty.h>
 
+static int ircomm_tty_install(struct tty_driver *driver,
+               struct tty_struct *tty);
 static int  ircomm_tty_open(struct tty_struct *tty, struct file *filp);
 static void ircomm_tty_close(struct tty_struct * tty, struct file *filp);
 static int  ircomm_tty_write(struct tty_struct * tty,
@@ -82,6 +84,7 @@ static struct tty_driver *driver;
 static hashbin_t *ircomm_tty = NULL;
 
 static const struct tty_operations ops = {
+       .install         = ircomm_tty_install,
        .open            = ircomm_tty_open,
        .close           = ircomm_tty_close,
        .write           = ircomm_tty_write,
@@ -292,7 +295,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
                return 0;
        }
 
-       if (tty->termios->c_cflag & CLOCAL) {
+       if (tty->termios.c_cflag & CLOCAL) {
                IRDA_DEBUG(1, "%s(), doing CLOCAL!\n", __func__ );
                do_clocal = 1;
        }
@@ -319,7 +322,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
        port->blocked_open++;
 
        while (1) {
-               if (tty->termios->c_cflag & CBAUD)
+               if (tty->termios.c_cflag & CBAUD)
                        tty_port_raise_dtr_rts(port);
 
                current->state = TASK_INTERRUPTIBLE;
@@ -374,21 +377,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
        return retval;
 }
 
-/*
- * Function ircomm_tty_open (tty, filp)
- *
- *    This routine is called when a particular tty device is opened. This
- *    routine is mandatory; if this routine is not filled in, the attempted
- *    open will fail with ENODEV.
- */
-static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
+
+static int ircomm_tty_install(struct tty_driver *driver, struct tty_struct *tty)
 {
        struct ircomm_tty_cb *self;
        unsigned int line = tty->index;
-       unsigned long   flags;
-       int ret;
-
-       IRDA_DEBUG(2, "%s()\n", __func__ );
 
        /* Check if instance already exists */
        self = hashbin_lock_find(ircomm_tty, line, NULL);
@@ -421,18 +414,36 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
                 *
                 * Note this is completely usafe and doesn't work properly
                 */
-               tty->termios->c_iflag = 0;
-               tty->termios->c_oflag = 0;
+               tty->termios.c_iflag = 0;
+               tty->termios.c_oflag = 0;
 
                /* Insert into hash */
-               /* FIXME there is a window from find to here */
                hashbin_insert(ircomm_tty, (irda_queue_t *) self, line, NULL);
        }
+
+       tty->driver_data = self;
+
+       return tty_port_install(&self->port, driver, tty);
+}
+
+/*
+ * Function ircomm_tty_open (tty, filp)
+ *
+ *    This routine is called when a particular tty device is opened. This
+ *    routine is mandatory; if this routine is not filled in, the attempted
+ *    open will fail with ENODEV.
+ */
+static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
+{
+       struct ircomm_tty_cb *self = tty->driver_data;
+       unsigned long   flags;
+       int ret;
+
+       IRDA_DEBUG(2, "%s()\n", __func__ );
+
        /* ++ is not atomic, so this should be protected - Jean II */
        spin_lock_irqsave(&self->port.lock, flags);
        self->port.count++;
-
-       tty->driver_data = self;
        spin_unlock_irqrestore(&self->port.lock, flags);
        tty_port_tty_set(&self->port, tty);
 
@@ -472,7 +483,7 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
        }
 
        /* Check if this is a "normal" ircomm device, or an irlpt device */
-       if (line < 0x10) {
+       if (self->line < 0x10) {
                self->service_type = IRCOMM_3_WIRE | IRCOMM_9_WIRE;
                self->settings.service_type = IRCOMM_9_WIRE; /* 9 wire as default */
                /* Jan Kiszka -> add DSR/RI -> Conform to IrCOMM spec */
@@ -842,7 +853,7 @@ static void ircomm_tty_throttle(struct tty_struct *tty)
                ircomm_tty_send_xchar(tty, STOP_CHAR(tty));
 
        /* Hardware flow control? */
-       if (tty->termios->c_cflag & CRTSCTS) {
+       if (tty->termios.c_cflag & CRTSCTS) {
                self->settings.dte &= ~IRCOMM_RTS;
                self->settings.dte |= IRCOMM_DELTA_RTS;
 
@@ -874,7 +885,7 @@ static void ircomm_tty_unthrottle(struct tty_struct *tty)
        }
 
        /* Using hardware flow control? */
-       if (tty->termios->c_cflag & CRTSCTS) {
+       if (tty->termios.c_cflag & CRTSCTS) {
                self->settings.dte |= (IRCOMM_RTS|IRCOMM_DELTA_RTS);
 
                ircomm_param_request(self, IRCOMM_DTE, TRUE);
@@ -1061,7 +1072,7 @@ void ircomm_tty_check_modem_status(struct ircomm_tty_cb *self)
                        goto put;
                }
        }
-       if (tty && self->port.flags & ASYNC_CTS_FLOW) {
+       if (tty && tty_port_cts_enabled(&self->port)) {
                if (tty->hw_stopped) {
                        if (status & IRCOMM_CTS) {
                                IRDA_DEBUG(2,
@@ -1304,7 +1315,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
 
        seq_puts(m, "Flags:");
        sep = ' ';
-       if (self->port.flags & ASYNC_CTS_FLOW) {
+       if (tty_port_cts_enabled(&self->port)) {
                seq_printf(m, "%cASYNC_CTS_FLOW", sep);
                sep = '|';
        }