ixgbe: Disable Flow Control for certain devices
[safe/jmp/linux-2.6] / drivers / char / esp.c
index 2eaf09f..b19d43c 100644 (file)
@@ -572,7 +572,7 @@ static void check_modem_status(struct esp_struct *info)
                        info->icount.dcd++;
                if (status & UART_MSR_DCTS)
                        info->icount.cts++;
-               wake_up_interruptible(&info->delta_msr_wait);
+               wake_up_interruptible(&info->port.delta_msr_wait);
        }
 
        if ((info->port.flags & ASYNC_CHECK_CD) && (status & UART_MSR_DDCD)) {
@@ -927,7 +927,7 @@ static void shutdown(struct esp_struct *info)
         * clear delta_msr_wait queue to avoid mem leaks: we may free the irq
         * here so the queue might never be waken up
         */
-       wake_up_interruptible(&info->delta_msr_wait);
+       wake_up_interruptible(&info->port.delta_msr_wait);
        wake_up_interruptible(&info->break_wait);
 
        /* stop a DMA transfer on the port being closed */
@@ -1725,13 +1725,13 @@ static int esp_tiocmset(struct tty_struct *tty, struct file *file,
 /*
  * rs_break() --- routine which turns the break handling on or off
  */
-static void esp_break(struct tty_struct *tty, int break_state)
+static int esp_break(struct tty_struct *tty, int break_state)
 {
        struct esp_struct *info = tty->driver_data;
        unsigned long flags;
 
        if (serial_paranoia_check(info, tty->name, "esp_break"))
-               return;
+               return -EINVAL;
 
        if (break_state == -1) {
                spin_lock_irqsave(&info->lock, flags);
@@ -1747,6 +1747,7 @@ static void esp_break(struct tty_struct *tty, int break_state)
                serial_out(info, UART_ESI_CMD2, 0x00);
                spin_unlock_irqrestore(&info->lock, flags);
        }
+       return 0;
 }
 
 static int rs_ioctl(struct tty_struct *tty, struct file *file,
@@ -1799,7 +1800,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file *file,
                spin_unlock_irqrestore(&info->lock, flags);
                while (1) {
                        /* FIXME: convert to new style wakeup */
-                       interruptible_sleep_on(&info->delta_msr_wait);
+                       interruptible_sleep_on(&info->port.delta_msr_wait);
                        /* see if a signal did it */
                        if (signal_pending(current))
                                return -ERESTARTSYS;
@@ -2053,6 +2054,15 @@ static void esp_hangup(struct tty_struct *tty)
        wake_up_interruptible(&info->port.open_wait);
 }
 
+static int esp_carrier_raised(struct tty_port *port)
+{
+       struct esp_struct *info = container_of(port, struct esp_struct, port);
+       serial_out(info, UART_ESI_CMD1, ESI_GET_UART_STAT);
+       if (serial_in(info, UART_ESI_STAT2) & UART_MSR_DCD)
+               return 1;
+       return 0;
+}
+
 /*
  * ------------------------------------------------------------
  * esp_open() and friends
@@ -2065,17 +2075,19 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
        int             retval;
        int             do_clocal = 0;
        unsigned long   flags;
+       int             cd;
+       struct tty_port *port = &info->port;
 
        /*
         * If the device is in the middle of being closed, then block
         * until it's done, and then try again.
         */
        if (tty_hung_up_p(filp) ||
-           (info->port.flags & ASYNC_CLOSING)) {
-               if (info->port.flags & ASYNC_CLOSING)
-                       interruptible_sleep_on(&info->port.close_wait);
+           (port->flags & ASYNC_CLOSING)) {
+               if (port->flags & ASYNC_CLOSING)
+                       interruptible_sleep_on(&port->close_wait);
 #ifdef SERIAL_DO_RESTART
-               if (info->port.flags & ASYNC_HUP_NOTIFY)
+               if (port->flags & ASYNC_HUP_NOTIFY)
                        return -EAGAIN;
                else
                        return -ERESTARTSYS;
@@ -2090,7 +2102,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
         */
        if ((filp->f_flags & O_NONBLOCK) ||
            (tty->flags & (1 << TTY_IO_ERROR))) {
-               info->port.flags |= ASYNC_NORMAL_ACTIVE;
+               port->flags |= ASYNC_NORMAL_ACTIVE;
                return 0;
        }
 
@@ -2100,20 +2112,20 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
        /*
         * Block waiting for the carrier detect and the line to become
         * free (i.e., not in use by the callout).  While we are in
-        * this loop, info->port.count is dropped by one, so that
+        * this loop, port->count is dropped by one, so that
         * rs_close() knows when to free things.  We restore it upon
         * exit, either normal or abnormal.
         */
        retval = 0;
-       add_wait_queue(&info->port.open_wait, &wait);
+       add_wait_queue(&port->open_wait, &wait);
 #ifdef SERIAL_DEBUG_OPEN
        printk(KERN_DEBUG "block_til_ready before block: ttys%d, count = %d\n",
-              info->line, info->port.count);
+              info->line, port->count);
 #endif
        spin_lock_irqsave(&info->lock, flags);
        if (!tty_hung_up_p(filp))
-               info->port.count--;
-       info->port.blocked_open++;
+               port->count--;
+       port->blocked_open++;
        while (1) {
                if ((tty->termios->c_cflag & CBAUD)) {
                        unsigned int scratch;
@@ -2128,9 +2140,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
                }
                set_current_state(TASK_INTERRUPTIBLE);
                if (tty_hung_up_p(filp) ||
-                   !(info->port.flags & ASYNC_INITIALIZED)) {
+                   !(port->flags & ASYNC_INITIALIZED)) {
 #ifdef SERIAL_DO_RESTART
-                       if (info->port.flags & ASYNC_HUP_NOTIFY)
+                       if (port->flags & ASYNC_HUP_NOTIFY)
                                retval = -EAGAIN;
                        else
                                retval = -ERESTARTSYS;
@@ -2140,11 +2152,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
                        break;
                }
 
-               serial_out(info, UART_ESI_CMD1, ESI_GET_UART_STAT);
-               if (serial_in(info, UART_ESI_STAT2) & UART_MSR_DCD)
-                       do_clocal = 1;
+               cd = tty_port_carrier_raised(port);
 
-               if (!(info->port.flags & ASYNC_CLOSING) &&
+               if (!(port->flags & ASYNC_CLOSING) &&
                    (do_clocal))
                        break;
                if (signal_pending(current)) {
@@ -2153,25 +2163,25 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
                }
 #ifdef SERIAL_DEBUG_OPEN
                printk(KERN_DEBUG "block_til_ready blocking: ttys%d, count = %d\n",
-                      info->line, info->port.count);
+                      info->line, port->count);
 #endif
                spin_unlock_irqrestore(&info->lock, flags);
                schedule();
                spin_lock_irqsave(&info->lock, flags);
        }
        set_current_state(TASK_RUNNING);
-       remove_wait_queue(&info->port.open_wait, &wait);
+       remove_wait_queue(&port->open_wait, &wait);
        if (!tty_hung_up_p(filp))
-               info->port.count++;
-       info->port.blocked_open--;
+               port->count++;
+       port->blocked_open--;
        spin_unlock_irqrestore(&info->lock, flags);
 #ifdef SERIAL_DEBUG_OPEN
        printk(KERN_DEBUG "block_til_ready after blocking: ttys%d, count = %d\n",
-              info->line, info->port.count);
+              info->line, port->count);
 #endif
        if (retval)
                return retval;
-       info->port.flags |= ASYNC_NORMAL_ACTIVE;
+       port->flags |= ASYNC_NORMAL_ACTIVE;
        return 0;
 }
 
@@ -2248,7 +2258,7 @@ static int esp_open(struct tty_struct *tty, struct file *filp)
  * driver.
  */
 
-static void show_serial_version(void)
+static void __init show_serial_version(void)
 {
        printk(KERN_INFO "%s version %s (DMA %u)\n",
                serial_name, serial_version, dma);
@@ -2328,6 +2338,10 @@ static const struct tty_operations esp_ops = {
        .tiocmset = esp_tiocmset,
 };
 
+static const struct tty_port_operations esp_port_ops = {
+       .esp_carrier_raised,
+};
+
 /*
  * The serial driver boot-time initialization code!
  */
@@ -2414,6 +2428,8 @@ static int __init espserial_init(void)
        offset = 0;
 
        do {
+               tty_port_init(&info->port);
+               info->port.ops = &esp_port_ops;
                info->io_port = esp[i] + offset;
                info->irq = irq[i];
                info->line = (i * 8) + (offset / 8);
@@ -2436,9 +2452,6 @@ static int __init espserial_init(void)
                info->config.flow_off = flow_off;
                info->config.pio_threshold = pio_threshold;
                info->next_port = ports;
-               init_waitqueue_head(&info->port.open_wait);
-               init_waitqueue_head(&info->port.close_wait);
-               init_waitqueue_head(&info->delta_msr_wait);
                init_waitqueue_head(&info->break_wait);
                ports = info;
                printk(KERN_INFO "ttyP%d at 0x%04x (irq = %d) is an ESP ",