]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/char/riscom8.c
riscom/rocket: switch to int put_char method
[linux-2.6-omap-h63xx.git] / drivers / char / riscom8.c
index 3f9d0a9ac36d5988408f29a133e5a9c8fa1763ae..221b5a29207638605dbf59da209165b0ed17dcbd 100644 (file)
@@ -1015,6 +1015,24 @@ static int rc_open(struct tty_struct * tty, struct file * filp)
        return 0;
 }
 
+static void rc_flush_buffer(struct tty_struct *tty)
+{
+       struct riscom_port *port = (struct riscom_port *)tty->driver_data;
+       unsigned long flags;
+
+       if (rc_paranoia_check(port, tty->name, "rc_flush_buffer"))
+               return;
+
+       spin_lock_irqsave(&riscom_lock, flags);
+
+       port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
+
+       spin_unlock_irqrestore(&riscom_lock, flags);
+
+       tty_wakeup(tty);
+}
+
+
 static void rc_close(struct tty_struct * tty, struct file * filp)
 {
        struct riscom_port *port = (struct riscom_port *) tty->driver_data;
@@ -1078,8 +1096,7 @@ static void rc_close(struct tty_struct * tty, struct file * filp)
                }
        }
        rc_shutdown_port(bp, port);
-       if (tty->driver->flush_buffer)
-               tty->driver->flush_buffer(tty);
+       rc_flush_buffer(tty);
        tty_ldisc_flush(tty);
 
        tty->closing = 0;
@@ -1144,16 +1161,17 @@ static int rc_write(struct tty_struct * tty,
        return total;
 }
 
-static void rc_put_char(struct tty_struct * tty, unsigned char ch)
+static int rc_put_char(struct tty_struct * tty, unsigned char ch)
 {
        struct riscom_port *port = (struct riscom_port *)tty->driver_data;
        unsigned long flags;
+       int ret = 0;
 
        if (rc_paranoia_check(port, tty->name, "rc_put_char"))
-               return;
+               return 0;
 
        if (!tty || !port->xmit_buf)
-               return;
+               return 0;
 
        spin_lock_irqsave(&riscom_lock, flags);
        
@@ -1163,9 +1181,11 @@ static void rc_put_char(struct tty_struct * tty, unsigned char ch)
        port->xmit_buf[port->xmit_head++] = ch;
        port->xmit_head &= SERIAL_XMIT_SIZE - 1;
        port->xmit_cnt++;
+       ret = 1;
 
 out:
        spin_unlock_irqrestore(&riscom_lock, flags);
+       return ret;
 }
 
 static void rc_flush_chars(struct tty_struct * tty)
@@ -1213,23 +1233,6 @@ static int rc_chars_in_buffer(struct tty_struct *tty)
        return port->xmit_cnt;
 }
 
-static void rc_flush_buffer(struct tty_struct *tty)
-{
-       struct riscom_port *port = (struct riscom_port *)tty->driver_data;
-       unsigned long flags;
-                               
-       if (rc_paranoia_check(port, tty->name, "rc_flush_buffer"))
-               return;
-
-       spin_lock_irqsave(&riscom_lock, flags);
-
-       port->xmit_cnt = port->xmit_head = port->xmit_tail = 0;
-
-       spin_unlock_irqrestore(&riscom_lock, flags);
-       
-       tty_wakeup(tty);
-}
-
 static int rc_tiocmget(struct tty_struct *tty, struct file *file)
 {
        struct riscom_port *port = (struct riscom_port *)tty->driver_data;
@@ -1385,7 +1388,7 @@ static int rc_ioctl(struct tty_struct * tty, struct file * filp,
 {
        struct riscom_port *port = (struct riscom_port *)tty->driver_data;
        void __user *argp = (void __user *)arg;
-       int retval;
+       int retval = 0;
                                
        if (rc_paranoia_check(port, tty->name, "rc_ioctl"))
                return -ENODEV;
@@ -1406,23 +1409,20 @@ static int rc_ioctl(struct tty_struct * tty, struct file * filp,
                tty_wait_until_sent(tty, 0);
                rc_send_break(port, arg ? arg*(HZ/10) : HZ/4);
                break;
-        case TIOCGSOFTCAR:
-               return put_user(C_CLOCAL(tty) ? 1 : 0, (unsigned __user *)argp);
-        case TIOCSSOFTCAR:
-               if (get_user(arg,(unsigned __user *) argp))
-                       return -EFAULT;
-               tty->termios->c_cflag =
-                       ((tty->termios->c_cflag & ~CLOCAL) |
-                       (arg ? CLOCAL : 0));
+        case TIOCGSERIAL:
+               lock_kernel();
+               retval = rc_get_serial_info(port, argp);
+               unlock_kernel();
                break;
-        case TIOCGSERIAL:      
-               return rc_get_serial_info(port, argp);
         case TIOCSSERIAL:      
-               return rc_set_serial_info(port, argp);
+               lock_kernel();
+               retval = rc_set_serial_info(port, argp);
+               unlock_kernel();
+               break;
         default:
-               return -ENOIOCTLCMD;
+               retval = -ENOIOCTLCMD;
        }
-       return 0;
+       return retval;
 }
 
 static void rc_throttle(struct tty_struct * tty)