]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/esp.c
Char: moxa, remove port->port
[linux-2.6-omap-h63xx.git] / drivers / char / esp.c
index 2e7ae42a5503be7b3120ee91acc2e9fb50e00cde..5ad11a6716c7878edbd862f825d79244fbe30107 100644 (file)
@@ -19,7 +19,7 @@
  *
  *  rs_set_termios fixed to look also for changes of the input
  *      flags INPCK, BRKINT, PARMRK, IGNPAR and IGNBRK.
- *                                            Bernd Anhpl 05/17/96.
+ *                                            Bernd Anhäupl 05/17/96.
  *
  * --- End of notices from serial.c ---
  *
 #include <linux/mm.h>
 #include <linux/init.h>
 #include <linux/delay.h>
+#include <linux/bitops.h>
 
 #include <asm/system.h>
 #include <asm/io.h>
-#include <asm/bitops.h>
 
 #include <asm/dma.h>
 #include <linux/slab.h>
@@ -111,9 +111,6 @@ static char serial_version[] __initdata = "2.2";
 
 static struct tty_driver *esp_driver;
 
-/* serial subtype definitions */
-#define SERIAL_TYPE_NORMAL     1
-
 /*
  * Serial driver configuration section.  Here are the various options:
  *
@@ -245,17 +242,6 @@ static void rs_start(struct tty_struct *tty)
  * -----------------------------------------------------------------------
  */
 
-/*
- * This routine is used by the interrupt handler to schedule
- * processing in the software interrupt portion of the driver.
- */
-static inline void rs_sched_event(struct esp_struct *info,
-                                 int event)
-{
-       info->event |= 1 << event;
-       schedule_work(&info->tqueue);
-}
-
 static DEFINE_SPINLOCK(pio_lock);
 
 static inline struct esp_pio_buffer *get_pio_buffer(void)
@@ -477,7 +463,8 @@ static inline void transmit_chars_pio(struct esp_struct *info,
        }
 
        if (info->xmit_cnt < WAKEUP_CHARS) {
-               rs_sched_event(info, ESP_EVENT_WRITE_WAKEUP);
+               if (info->tty)
+                       tty_wakeup(info->tty);
 
 #ifdef SERIAL_DEBUG_INTR
                printk("THRE...");
@@ -515,7 +502,8 @@ static inline void transmit_chars_dma(struct esp_struct *info, int num_bytes)
        info->xmit_tail = (info->xmit_tail + dma_bytes) & (ESP_XMIT_SIZE - 1);
 
        if (info->xmit_cnt < WAKEUP_CHARS) {
-               rs_sched_event(info, ESP_EVENT_WRITE_WAKEUP);
+               if (info->tty)
+                       tty_wakeup(info->tty);
 
 #ifdef SERIAL_DEBUG_INTR
                printk("THRE...");
@@ -607,7 +595,7 @@ static inline void check_modem_status(struct esp_struct *info)
 #ifdef SERIAL_DEBUG_OPEN
                        printk("scheduling hangup...");
 #endif
-                       schedule_work(&info->tqueue_hangup);
+                       tty_hangup(info->tty);
                }
        }
 }
@@ -723,41 +711,6 @@ static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
  * -------------------------------------------------------------------
  */
 
-static void do_softint(struct work_struct *work)
-{
-       struct esp_struct       *info =
-               container_of(work, struct esp_struct, tqueue);
-       struct tty_struct       *tty;
-       
-       tty = info->tty;
-       if (!tty)
-               return;
-
-       if (test_and_clear_bit(ESP_EVENT_WRITE_WAKEUP, &info->event)) {
-               tty_wakeup(tty);
-       }
-}
-
-/*
- * This routine is called from the scheduler tqueue when the interrupt
- * routine has signalled that a hangup has occurred.  The path of
- * hangup processing is:
- *
- *     serial interrupt routine -> (scheduler tqueue) ->
- *     do_serial_hangup() -> tty->hangup() -> esp_hangup()
- * 
- */
-static void do_serial_hangup(struct work_struct *work)
-{
-       struct esp_struct       *info =
-               container_of(work, struct esp_struct, tqueue_hangup);
-       struct tty_struct       *tty;
-       
-       tty = info->tty;
-       if (tty)
-               tty_hangup(tty);
-}
-
 /*
  * ---------------------------------------------------------------
  * Low level utility subroutines for the serial driver:  routines to
@@ -1402,6 +1355,7 @@ static int get_serial_info(struct esp_struct * info,
 {
        struct serial_struct tmp;
   
+       lock_kernel();
        memset(&tmp, 0, sizeof(tmp));
        tmp.type = PORT_16550A;
        tmp.line = info->line;
@@ -1414,6 +1368,7 @@ static int get_serial_info(struct esp_struct * info,
        tmp.closing_wait = info->closing_wait;
        tmp.custom_divisor = info->custom_divisor;
        tmp.hub6 = 0;
+       unlock_kernel();
        if (copy_to_user(retinfo,&tmp,sizeof(*retinfo)))
                return -EFAULT;
        return 0;
@@ -1428,6 +1383,7 @@ static int get_esp_config(struct esp_struct * info,
                return -EFAULT;
 
        memset(&tmp, 0, sizeof(tmp));
+       lock_kernel();
        tmp.rx_timeout = info->config.rx_timeout;
        tmp.rx_trigger = info->config.rx_trigger;
        tmp.tx_trigger = info->config.tx_trigger;
@@ -1435,6 +1391,7 @@ static int get_esp_config(struct esp_struct * info,
        tmp.flow_on = info->config.flow_on;
        tmp.pio_threshold = info->config.pio_threshold;
        tmp.dma_channel = (info->stat_flags & ESP_STAT_NEVER_DMA ? 0 : dma);
+       unlock_kernel();
 
        return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
 }
@@ -1813,6 +1770,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
        struct serial_icounter_struct __user *p_cuser;  /* user space */
        void __user *argp = (void __user *)arg;
        unsigned long flags;
+       int ret;
 
        if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
                return -ENODEV;
@@ -1830,7 +1788,10 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
                case TIOCGSERIAL:
                        return get_serial_info(info, argp);
                case TIOCSSERIAL:
-                       return set_serial_info(info, argp);
+                       lock_kernel();
+                       ret = set_serial_info(info, argp);
+                       unlock_kernel();
+                       return ret;
                case TIOCSERCONFIG:
                        /* do not reconfigure after initial configuration */
                        return 0;
@@ -1902,11 +1863,13 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
                                return -EFAULT;
 
                        return 0;
-       case TIOCGHAYESESP:
-               return get_esp_config(info, argp);
-       case TIOCSHAYESESP:
-               return set_esp_config(info, argp);
-
+               case TIOCGHAYESESP:
+                       return get_esp_config(info, argp);
+               case TIOCSHAYESESP:
+                       lock_kernel();
+                       ret = set_esp_config(info, argp);
+                       unlock_kernel();
+                       return ret;
                default:
                        return -ENOIOCTLCMD;
                }
@@ -2041,7 +2004,6 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
                tty->driver->flush_buffer(tty);
        tty_ldisc_flush(tty);
        tty->closing = 0;
-       info->event = 0;
        info->tty = NULL;
 
        if (info->blocked_open) {
@@ -2109,7 +2071,6 @@ static void esp_hangup(struct tty_struct *tty)
        
        rs_flush_buffer(tty);
        shutdown(info);
-       info->event = 0;
        info->count = 0;
        info->flags &= ~ASYNC_NORMAL_ACTIVE;
        info->tty = NULL;
@@ -2495,8 +2456,6 @@ static int __init espserial_init(void)
                info->magic = ESP_MAGIC;
                info->close_delay = 5*HZ/10;
                info->closing_wait = 30*HZ;
-               INIT_WORK(&info->tqueue, do_softint);
-               INIT_WORK(&info->tqueue_hangup, do_serial_hangup);
                info->config.rx_timeout = rx_timeout;
                info->config.flow_on = flow_on;
                info->config.flow_off = flow_off;
@@ -2535,6 +2494,7 @@ static int __init espserial_init(void)
                        return 0;
                }
 
+               spin_lock_init(&info->lock);
                /* rx_trigger, tx_trigger are needed by autoconfig */
                info->config.rx_trigger = rx_trigger;
                info->config.tx_trigger = tx_trigger;