tty/serial: lay the foundations for the next set of reworks
[linux-2.6-block.git] / drivers / char / epca.c
index ffd747c5dff00dc7e69a1835d078003dd7ffc3d7..39c6a36e395bbee0586822d98f1072047c740e24 100644 (file)
@@ -157,7 +157,6 @@ static void epca_error(int, char *);
 static void pc_close(struct tty_struct *, struct file *);
 static void shutdown(struct channel *);
 static void pc_hangup(struct tty_struct *);
-static void pc_put_char(struct tty_struct *, unsigned char);
 static int pc_write_room(struct tty_struct *);
 static int pc_chars_in_buffer(struct tty_struct *);
 static void pc_flush_buffer(struct tty_struct *);
@@ -459,8 +458,7 @@ static void pc_close(struct tty_struct *tty, struct file *filp)
                        setup_empty_event(tty, ch);
                        tty_wait_until_sent(tty, 3000); /* 30 seconds timeout */
                }
-               if (tty->driver->flush_buffer)
-                       tty->driver->flush_buffer(tty);
+               pc_flush_buffer(tty);
 
                tty_ldisc_flush(tty);
                shutdown(ch);
@@ -532,8 +530,7 @@ static void pc_hangup(struct tty_struct *tty)
        if ((ch = verifyChannel(tty)) != NULL) {
                unsigned long flags;
 
-               if (tty->driver->flush_buffer)
-                       tty->driver->flush_buffer(tty);
+               pc_flush_buffer(tty);
                tty_ldisc_flush(tty);
                shutdown(ch);
 
@@ -645,11 +642,6 @@ static int pc_write(struct tty_struct *tty,
        return amountCopied;
 }
 
-static void pc_put_char(struct tty_struct *tty, unsigned char c)
-{
-       pc_write(tty, &c, 1);
-}
-
 static int pc_write_room(struct tty_struct *tty)
 {
        int remain;
@@ -923,7 +915,8 @@ static int pc_open(struct tty_struct *tty, struct file * filp)
                return(-ENODEV);
        }
 
-       if ((bc = ch->brdchan) == 0) {
+       bc = ch->brdchan;
+       if (bc == NULL) {
                tty->driver_data = NULL;
                return -ENODEV;
        }
@@ -1034,7 +1027,6 @@ static const struct tty_operations pc_ops = {
        .flush_buffer = pc_flush_buffer,
        .chars_in_buffer = pc_chars_in_buffer,
        .flush_chars = pc_flush_chars,
-       .put_char = pc_put_char,
        .ioctl = pc_ioctl,
        .set_termios = pc_set_termios,
        .stop = pc_stop,
@@ -1838,7 +1830,7 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch)
        unsigned mval, hflow, cflag, iflag;
 
        bc = ch->brdchan;
-       epcaassert(bc !=0, "bc out of range");
+       epcaassert(bc != NULL, "bc out of range");
 
        assertgwinon(ch);
        ts = tty->termios;
@@ -2206,21 +2198,6 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
                tty_wait_until_sent(tty, 0);
                digi_send_break(ch, arg ? arg*(HZ/10) : HZ/4);
                return 0;
-       case TIOCGSOFTCAR:
-               if (put_user(C_CLOCAL(tty)?1:0, (unsigned long __user *)arg))
-                       return -EFAULT;
-               return 0;
-       case TIOCSSOFTCAR:
-               {
-                       unsigned int value;
-
-                       if (get_user(value, (unsigned __user *)argp))
-                               return -EFAULT;
-                       tty->termios->c_cflag =
-                               ((tty->termios->c_cflag & ~CLOCAL) |
-                                (value ? CLOCAL : 0));
-                       return 0;
-               }
        case TIOCMODG:
                mflag = pc_tiocmget(tty, file);
                if (put_user(mflag, (unsigned long __user *)argp))
@@ -2253,6 +2230,7 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
                break;
        case DIGI_SETAW:
        case DIGI_SETAF:
+               lock_kernel();
                if (cmd == DIGI_SETAW) {
                        /* Setup an event to indicate when the transmit buffer empties */
                        spin_lock_irqsave(&epca_lock, flags);
@@ -2264,6 +2242,7 @@ static int pc_ioctl(struct tty_struct *tty, struct file * file,
                        if (tty->ldisc.flush_buffer)
                                tty->ldisc.flush_buffer(tty);
                }
+               unlock_kernel();
                /* Fall Thru */
        case DIGI_SETA:
                if (copy_from_user(&ch->digiext, argp, sizeof(digi_t)))
@@ -2490,7 +2469,7 @@ static void pc_unthrottle(struct tty_struct *tty)
        }
 }
 
-void digi_send_break(struct channel *ch, int msec)
+static void digi_send_break(struct channel *ch, int msec)
 {
        unsigned long flags;
 
@@ -2878,7 +2857,7 @@ static struct pci_device_id epca_pci_tbl[] = {
 
 MODULE_DEVICE_TABLE(pci, epca_pci_tbl);
 
-int __init init_PCI (void)
+static int __init init_PCI(void)
 {
        memset (&epca_driver, 0, sizeof (epca_driver));
        epca_driver.name = "epca";