Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / serial / 68328serial.c
index db92a0c..b88a7c1 100644 (file)
 #include <linux/keyboard.h>
 #include <linux/init.h>
 #include <linux/pm.h>
+#include <linux/pm_legacy.h>
 #include <linux/bitops.h>
 #include <linux/delay.h>
 
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/system.h>
-#include <asm/segment.h>
 #include <asm/delay.h>
 #include <asm/uaccess.h>
 
@@ -101,8 +101,6 @@ struct tty_driver *serial_driver;
 
 #define RS_ISR_PASS_LIMIT 256
 
-#define _INLINE_ inline
-
 static void change_speed(struct m68k_serial *info);
 
 /*
@@ -143,7 +141,6 @@ static int m68328_console_cbaud   = DEFAULT_CBAUD;
  * memory if large numbers of serial ports are open.
  */
 static unsigned char tmp_buf[SERIAL_XMIT_SIZE]; /* This is cheating */
-DECLARE_MUTEX(tmp_buf_sem);
 
 static inline int serial_paranoia_check(struct m68k_serial *info,
                                        char *name, const char *routine)
@@ -263,7 +260,7 @@ static void batten_down_hatches(void)
        /* Drop into the debugger */
 }
 
-static _INLINE_ void status_handle(struct m68k_serial *info, unsigned short status)
+static void status_handle(struct m68k_serial *info, unsigned short status)
 {
 #if 0
        if(status & DCD) {
@@ -290,11 +287,12 @@ static _INLINE_ void status_handle(struct m68k_serial *info, unsigned short stat
        return;
 }
 
-static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *regs, unsigned short rx)
+static void receive_chars(struct m68k_serial *info, struct pt_regs *regs,
+                         unsigned short rx)
 {
        struct tty_struct *tty = info->tty;
        m68328_uart *uart = &uart_addr[info->line];
-       unsigned char ch;
+       unsigned char ch, flag;
 
        /*
         * This do { } while() loop will get ALL chars out of Rx FIFO 
@@ -316,7 +314,7 @@ static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *reg
 /*                             show_net_buffers(); */
                                return;
                        } else if (ch == 0x12) { /* ^R */
-                               machine_restart(NULL);
+                               emergency_restart();
                                return;
 #endif /* CONFIG_MAGIC_SYSRQ */
                        }
@@ -332,37 +330,35 @@ static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *reg
                /*
                 * Make sure that we do not overflow the buffer
                 */
-               if (tty->flip.count >= TTY_FLIPBUF_SIZE) {
-                       schedule_work(&tty->flip.work);
+               if (tty_request_buffer_room(tty, 1) == 0) {
+                       tty_schedule_flip(tty);
                        return;
                }
 
+               flag = TTY_NORMAL;
+
                if(rx & URX_PARITY_ERROR) {
-                       *tty->flip.flag_buf_ptr++ = TTY_PARITY;
+                       flag = TTY_PARITY;
                        status_handle(info, rx);
                } else if(rx & URX_OVRUN) {
-                       *tty->flip.flag_buf_ptr++ = TTY_OVERRUN;
+                       flag = TTY_OVERRUN;
                        status_handle(info, rx);
                } else if(rx & URX_FRAME_ERROR) {
-                       *tty->flip.flag_buf_ptr++ = TTY_FRAME;
+                       flag = TTY_FRAME;
                        status_handle(info, rx);
-               } else {
-                       *tty->flip.flag_buf_ptr++ = 0; /* XXX */
                }
-                *tty->flip.char_buf_ptr++ = ch;
-               tty->flip.count++;
-
+               tty_insert_flip_char(tty, ch, flag);
 #ifndef CONFIG_XCOPILOT_BUGS
        } while((rx = uart->urx.w) & URX_DATA_READY);
 #endif
 
-       schedule_work(&tty->flip.work);
+       tty_schedule_flip(tty);
 
 clear_and_exit:
        return;
 }
 
-static _INLINE_ void transmit_chars(struct m68k_serial *info)
+static void transmit_chars(struct m68k_serial *info)
 {
        m68328_uart *uart = &uart_addr[info->line];
 
@@ -992,18 +988,17 @@ static int get_lsr_info(struct m68k_serial * info, unsigned int *value)
 /*
  * This routine sends a break character out the serial port.
  */
-static void send_break(        struct m68k_serial * info, int duration)
+static void send_break(struct m68k_serial * info, unsigned int duration)
 {
        m68328_uart *uart = &uart_addr[info->line];
         unsigned long flags;
         if (!info->port)
                 return;
-        set_current_state(TASK_INTERRUPTIBLE);
         save_flags(flags);
         cli();
 #ifdef USE_INTS        
        uart->utx.w |= UTX_SEND_BREAK;
-        schedule_timeout(duration);
+       msleep_interruptible(duration);
        uart->utx.w &= ~UTX_SEND_BREAK;
 #endif         
         restore_flags(flags);
@@ -1033,14 +1028,14 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file,
                                return retval;
                        tty_wait_until_sent(tty, 0);
                        if (!arg)
-                               send_break(info, HZ/4); /* 1/4 second */
+                               send_break(info, 250);  /* 1/4 second */
                        return 0;
                case TCSBRKP:   /* support for POSIX tcsendbreak() */
                        retval = tty_check_change(tty);
                        if (retval)
                                return retval;
                        tty_wait_until_sent(tty, 0);
-                       send_break(info, arg ? arg*(HZ/10) : HZ/4);
+                       send_break(info, arg ? arg*(100) : 250);
                        return 0;
                case TIOCGSOFTCAR:
                        error = put_user(C_CLOCAL(tty) ? 1 : 0,
@@ -1345,7 +1340,7 @@ static void show_serial_version(void)
        printk("MC68328 serial driver version 1.00\n");
 }
 
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
 /* Serial Power management
  *  The console (currently fixed at line 0) is a special case for power
  *  management because the kernel is so chatty. The console will be 
@@ -1395,7 +1390,7 @@ void startup_console(void)
        struct m68k_serial *info = &m68k_soft[0];
        startup(info);
 }
-#endif
+#endif /* CONFIG_PM_LEGACY */
 
 
 static struct tty_operations rs_ops = {
@@ -1488,7 +1483,7 @@ rs68328_init(void)
                            IRQ_FLG_STD,
                            "M68328_UART", NULL))
                 panic("Unable to attach 68328 serial interrupt\n");
-#ifdef CONFIG_PM
+#ifdef CONFIG_PM_LEGACY
            serial_pm[i] = pm_register(PM_SYS_DEV, PM_SYS_COM, serial_pm_callback);
            if (serial_pm[i])
                    serial_pm[i]->data = info;
@@ -1498,23 +1493,6 @@ rs68328_init(void)
        return 0;
 }
 
-
-
-/*
- * register_serial and unregister_serial allows for serial ports to be
- * configured at run-time, to support PCMCIA modems.
- */
-/* SPARC: Unused at this time, just here to make things link. */
-int register_serial(struct serial_struct *req)
-{
-       return -1;
-}
-
-void unregister_serial(int line)
-{
-       return;
-}
-       
 module_init(rs68328_init);