tty/serial: lay the foundations for the next set of reworks
[linux-2.6-block.git] / drivers / serial / mcfserial.c
index 3db206d29b338b36df60bd6920872fcdb6d4702b..aafa1704e1ab034d318807d6dff9530e0cae1459 100644 (file)
@@ -40,7 +40,6 @@
 #include <asm/io.h>
 #include <asm/irq.h>
 #include <asm/system.h>
-#include <asm/semaphore.h>
 #include <asm/delay.h>
 #include <asm/coldfire.h>
 #include <asm/mcfsim.h>
@@ -425,15 +424,13 @@ irqreturn_t mcfrs_interrupt(int irq, void *dev_id)
  * -------------------------------------------------------------------
  */
 
-static void mcfrs_offintr(void *private)
+static void mcfrs_offintr(struct work_struct *work)
 {
-       struct mcf_serial       *info = (struct mcf_serial *) private;
-       struct tty_struct       *tty;
+       struct mcf_serial *info = container_of(work, struct mcf_serial, tqueue);
+       struct tty_struct *tty = info->tty;
        
-       tty = info->tty;
-       if (!tty)
-               return;
-       tty_wakeup(tty);
+       if (tty)
+               tty_wakeup(tty);
 }
 
 
@@ -497,16 +494,13 @@ static void mcfrs_timer(void)
  *     do_serial_hangup() -> tty->hangup() -> mcfrs_hangup()
  * 
  */
-static void do_serial_hangup(void *private)
+static void do_serial_hangup(struct work_struct *work)
 {
-       struct mcf_serial       *info = (struct mcf_serial *) private;
-       struct tty_struct       *tty;
+       struct mcf_serial *info = container_of(work, struct mcf_serial, tqueue_hangup);
+       struct tty_struct *tty = info->tty;
        
-       tty = info->tty;
-       if (!tty)
-               return;
-
-       tty_hangup(tty);
+       if (tty)
+               tty_hangup(tty);
 }
 
 static int startup(struct mcf_serial * info)
@@ -857,7 +851,7 @@ static void mcfrs_throttle(struct tty_struct * tty)
 #ifdef SERIAL_DEBUG_THROTTLE
        char    buf[64];
        
-       printk("throttle %s: %d....\n", _tty_name(tty, buf),
+       printk("throttle %s: %d....\n", tty_name(tty, buf),
               tty->ldisc.chars_in_buffer(tty));
 #endif
 
@@ -876,7 +870,7 @@ static void mcfrs_unthrottle(struct tty_struct * tty)
 #ifdef SERIAL_DEBUG_THROTTLE
        char    buf[64];
        
-       printk("unthrottle %s: %d....\n", _tty_name(tty, buf),
+       printk("unthrottle %s: %d....\n", tty_name(tty, buf),
               tty->ldisc.chars_in_buffer(tty));
 #endif
 
@@ -1078,18 +1072,6 @@ static int mcfrs_ioctl(struct tty_struct *tty, struct file * file,
                        tty_wait_until_sent(tty, 0);
                        send_break(info, arg ? arg*(HZ/10) : HZ/4);
                        return 0;
-               case TIOCGSOFTCAR:
-                       error = put_user(C_CLOCAL(tty) ? 1 : 0,
-                                   (unsigned long *) arg);
-                       if (error)
-                               return error;
-                       return 0;
-               case TIOCSSOFTCAR:
-                       get_user(arg, (unsigned long *) arg);
-                       tty->termios->c_cflag =
-                               ((tty->termios->c_cflag & ~CLOCAL) |
-                                (arg ? CLOCAL : 0));
-                       return 0;
                case TIOCGSERIAL:
                        if (access_ok(VERIFY_WRITE, (void *) arg,
                                                sizeof(struct serial_struct)))
@@ -1132,7 +1114,7 @@ static int mcfrs_ioctl(struct tty_struct *tty, struct file * file,
        return 0;
 }
 
-static void mcfrs_set_termios(struct tty_struct *tty, struct termios *old_termios)
+static void mcfrs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
 {
        struct mcf_serial *info = (struct mcf_serial *)tty->driver_data;
 
@@ -1228,8 +1210,7 @@ static void mcfrs_close(struct tty_struct *tty, struct file * filp)
        } else
 #endif
        shutdown(info);
-       if (tty->driver->flush_buffer)
-               tty->driver->flush_buffer(tty);
+       mcfrs_flush_buffer(tty);
        tty_ldisc_flush(tty);
        
        tty->closing = 0;
@@ -1282,6 +1263,8 @@ mcfrs_wait_until_sent(struct tty_struct *tty, int timeout)
         * Note: we have to use pretty tight timings here to satisfy
         * the NIST-PCTS.
         */
+       lock_kernel();
+
        fifo_time = (MCF5272_FIFO_SIZE * HZ * 10) / info->baud;
        char_time = fifo_time / 5;
        if (char_time == 0)
@@ -1318,6 +1301,7 @@ mcfrs_wait_until_sent(struct tty_struct *tty, int timeout)
                if (timeout && time_after(jiffies, orig_jiffies + timeout))
                        break;
        }
+       unlock_kernel();
 #else
        /*
         * For the other coldfire models, assume all data has been sent
@@ -1541,8 +1525,8 @@ static void mcfrs_irqinit(struct mcf_serial *info)
                 * External Pin Mask Setting & Enable External Pin for Interface
                 * mrcbis@aliceposta.it
                 */
-               unsigned short *serpin_enable_mask;
-               serpin_enable_mask = (MCF_IPSBAR + MCF_GPIO_PAR_UART);
+               u16 *serpin_enable_mask;
+               serpin_enable_mask = (u16 *) (MCF_IPSBAR + MCF_GPIO_PAR_UART);
                if (info->line == 0)
                        *serpin_enable_mask |= UART0_ENABLE_MASK;
                else if (info->line == 1)
@@ -1551,6 +1535,13 @@ static void mcfrs_irqinit(struct mcf_serial *info)
                        *serpin_enable_mask |= UART2_ENABLE_MASK;
        }
 #endif
+#if defined(CONFIG_M528x)
+       /* make sure PUAPAR is set for UART0 and UART1 */
+       if (info->line < 2) {
+               volatile unsigned char *portp = (volatile unsigned char *) (MCF_MBAR + MCF5282_GPIO_PUAPAR);
+               *portp |= (0x03 << (info->line * 2));
+       }
+#endif
 #elif defined(CONFIG_M520x)
        volatile unsigned char *icrp, *uartp;
        volatile unsigned long *imrp;
@@ -1783,8 +1774,8 @@ mcfrs_init(void)
                info->event = 0;
                info->count = 0;
                info->blocked_open = 0;
-               INIT_WORK(&info->tqueue, mcfrs_offintr, info);
-               INIT_WORK(&info->tqueue_hangup, do_serial_hangup, info);
+               INIT_WORK(&info->tqueue, mcfrs_offintr);
+               INIT_WORK(&info->tqueue_hangup, do_serial_hangup);
                init_waitqueue_head(&info->open_wait);
                init_waitqueue_head(&info->close_wait);