vserver 1.9.5.x5
[linux-2.6.git] / drivers / isdn / i4l / isdn_tty.c
index 3abc26e..e21007e 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <linux/config.h>
 #include <linux/isdn.h>
+#include <linux/delay.h>
 #include "isdn_common.h"
 #include "isdn_tty.h"
 #ifdef CONFIG_ISDN_AUDIO
@@ -26,8 +27,8 @@
 
 /* Prototypes */
 
-static int isdn_tty_edit_at(const char *, int, modem_info *, int);
-static void isdn_tty_check_esc(const u_char *, u_char, int, int *, u_long *, int);
+static int isdn_tty_edit_at(const char *, int, modem_info *);
+static void isdn_tty_check_esc(const u_char *, u_char, int, int *, u_long *);
 static void isdn_tty_modem_reset_regs(modem_info *, int);
 static void isdn_tty_cmd_ATA(modem_info *);
 static void isdn_tty_flush_buffer(struct tty_struct *);
@@ -134,7 +135,7 @@ isdn_tty_readmodem(void)
                                                if (c > 0) {
                                                        r = isdn_readbchan(info->isdn_driver, info->isdn_channel,
                                                                           tty->flip.char_buf_ptr,
-                                                                          tty->flip.flag_buf_ptr, c, 0);
+                                                                          tty->flip.flag_buf_ptr, c, NULL);
                                                        /* CISCO AsyncPPP Hack */
                                                        if (!(info->emu.mdmreg[REG_CPPP] & BIT_CPPP))
                                                                memset(tty->flip.flag_buf_ptr, 0, r);
@@ -296,10 +297,7 @@ isdn_tty_tint(modem_info * info)
                info->send_outstanding++;
                info->msr &= ~UART_MSR_CTS;
                info->lsr &= ~UART_LSR_TEMT;
-               if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-                   tty->ldisc.write_wakeup)
-                       (tty->ldisc.write_wakeup) (tty);
-               wake_up_interruptible(&tty->write_wait);
+               tty_wakeup(tty);
                return;
        }
        if (slen < 0) {
@@ -393,15 +391,12 @@ isdn_tty_handleDLEdown(modem_info * info, atemu * m, int len)
  * ^S or ^Q is sent.
  */
 static int
-isdn_tty_end_vrx(const char *buf, int c, int from_user)
+isdn_tty_end_vrx(const char *buf, int c)
 {
        char ch;
 
        while (c--) {
-               if (from_user)
-                       get_user(ch, buf);
-               else
-                       ch = *buf;
+               ch = *buf;
                if ((ch != 0x11) && (ch != 0x13))
                        return 1;
                buf++;
@@ -1129,7 +1124,7 @@ isdn_tty_shutdown(modem_info * info)
  *  - If dialing, abort dial.
  */
 static int
-isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int count)
+isdn_tty_write(struct tty_struct *tty, const u_char * buf, int count)
 {
        int c;
        int total = 0;
@@ -1138,8 +1133,6 @@ isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int co
 
        if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_write"))
                return 0;
-       if (from_user)
-               down(&info->write_sem);
        /* See isdn_tty_senddown() */
        atomic_inc(&info->xmit_lock);
        while (1) {
@@ -1160,12 +1153,8 @@ isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int co
 #endif
                                isdn_tty_check_esc(buf, m->mdmreg[REG_ESC], c,
                                                   &(m->pluscount),
-                                                  &(m->lastplus),
-                                                  from_user);
-                       if (from_user)
-                               copy_from_user(&(info->xmit_buf[info->xmit_count]), buf, c);
-                       else
-                               memcpy(&(info->xmit_buf[info->xmit_count]), buf, c);
+                                                  &(m->lastplus));
+                       memcpy(&(info->xmit_buf[info->xmit_count]), buf, c);
 #ifdef CONFIG_ISDN_AUDIO
                        if (info->vonline) {
                                int cc = isdn_tty_handleDLEdown(info, m, c);
@@ -1174,10 +1163,7 @@ isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int co
                                                /* If DLE decoding results in zero-transmit, but
                                                 * c originally was non-zero, do a wakeup.
                                                 */
-                                               if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-                                                tty->ldisc.write_wakeup)
-                                                       (tty->ldisc.write_wakeup) (tty);
-                                               wake_up_interruptible(&tty->write_wait);
+                                               tty_wakeup(tty);
                                                info->msr |= UART_MSR_CTS;
                                                info->lsr |= UART_LSR_TEMT;
                                        }
@@ -1187,7 +1173,7 @@ isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int co
                                        /* Do NOT handle Ctrl-Q or Ctrl-S
                                         * when in full-duplex audio mode.
                                         */
-                                       if (isdn_tty_end_vrx(buf, c, from_user)) {
+                                       if (isdn_tty_end_vrx(buf, c)) {
                                                info->vonline &= ~1;
 #ifdef ISDN_DEBUG_MODEM_VOICE
                                                printk(KERN_DEBUG
@@ -1230,7 +1216,7 @@ isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int co
                                isdn_tty_modem_result(RESULT_NO_CARRIER, info);
                                isdn_tty_modem_hup(info, 1);
                        } else
-                               c = isdn_tty_edit_at(buf, c, info, from_user);
+                               c = isdn_tty_edit_at(buf, c, info);
                }
                buf += c;
                count -= c;
@@ -1244,8 +1230,6 @@ isdn_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int co
                }
                isdn_timer_ctrl(ISDN_TIMER_MODEMXMIT, 1);
        }
-       if (from_user)
-               up(&info->write_sem);
        return total;
 }
 
@@ -1290,9 +1274,7 @@ isdn_tty_flush_buffer(struct tty_struct *tty)
        isdn_tty_cleanup_xmit(info);
        info->xmit_count = 0;
        wake_up_interruptible(&tty->write_wait);
-       if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
-           tty->ldisc.write_wakeup)
-               (tty->ldisc.write_wakeup) (tty);
+       tty_wakeup(tty);
 }
 
 static void
@@ -1359,14 +1341,14 @@ isdn_tty_unthrottle(struct tty_struct *tty)
  *          allows RS485 driver to be written in user space.
  */
 static int
-isdn_tty_get_lsr_info(modem_info * info, uint * value)
+isdn_tty_get_lsr_info(modem_info * info, uint __user * value)
 {
        u_char status;
        uint result;
 
        status = info->lsr;
        result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0);
-       return put_user(result, (uint *) value);
+       return put_user(result, value);
 }
 
 
@@ -1468,12 +1450,12 @@ isdn_tty_ioctl(struct tty_struct *tty, struct file *file,
 #ifdef ISDN_DEBUG_MODEM_IOCTL
                        printk(KERN_DEBUG "ttyI%d ioctl TIOCGSOFTCAR\n", info->line);
 #endif
-                       return put_user(C_CLOCAL(tty) ? 1 : 0, (ulong *) arg);
+                       return put_user(C_CLOCAL(tty) ? 1 : 0, (ulong __user *) arg);
                case TIOCSSOFTCAR:
 #ifdef ISDN_DEBUG_MODEM_IOCTL
                        printk(KERN_DEBUG "ttyI%d ioctl TIOCSSOFTCAR\n", info->line);
 #endif
-                       if (get_user(arg, (ulong *) arg))
+                       if (get_user(arg, (ulong __user *) arg))
                                return -EFAULT;
                        tty->termios->c_cflag =
                            ((tty->termios->c_cflag & ~CLOCAL) |
@@ -1483,7 +1465,7 @@ isdn_tty_ioctl(struct tty_struct *tty, struct file *file,
 #ifdef ISDN_DEBUG_MODEM_IOCTL
                        printk(KERN_DEBUG "ttyI%d ioctl TIOCSERGETLSR\n", info->line);
 #endif
-                       return isdn_tty_get_lsr_info(info, (uint *) arg);
+                       return isdn_tty_get_lsr_info(info, (uint __user *) arg);
                default:
 #ifdef ISDN_DEBUG_MODEM_IOCTL
                        printk(KERN_DEBUG "UNKNOWN ioctl 0x%08x on ttyi%d\n", cmd, info->line);
@@ -1747,17 +1729,16 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
        }
        dev->modempoll--;
        isdn_tty_shutdown(info);
+       
        if (tty->driver->flush_buffer)
                tty->driver->flush_buffer(tty);
-       if (tty->ldisc.flush_buffer)
-               tty->ldisc.flush_buffer(tty);
-       info->tty = 0;
+       tty_ldisc_flush(tty);
+       info->tty = NULL;
        info->ncarrier = 0;
        tty->closing = 0;
        module_put(info->owner);
        if (info->blocked_open) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(HZ/2);
+               msleep_interruptible(500);
                wake_up_interruptible(&info->open_wait);
        }
        info->flags &= ~(ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CLOSING);
@@ -1780,7 +1761,7 @@ isdn_tty_hangup(struct tty_struct *tty)
        isdn_tty_shutdown(info);
        info->count = 0;
        info->flags &= ~(ISDN_ASYNC_NORMAL_ACTIVE | ISDN_ASYNC_CALLOUT_ACTIVE);
-       info->tty = 0;
+       info->tty = NULL;
        wake_up_interruptible(&info->open_wait);
 }
 
@@ -1959,7 +1940,7 @@ isdn_tty_modem_init(void)
                isdn_tty_modem_reset_regs(info, 1);
                info->magic = ISDN_ASYNC_MAGIC;
                info->line = i;
-               info->tty = 0;
+               info->tty = NULL;
                info->x_char = 0;
                info->count = 0;
                info->blocked_open = 0;
@@ -2373,8 +2354,8 @@ isdn_tty_at_cout(char *msg, modem_info * info)
        char *p;
        char c;
        u_long flags;
-       struct sk_buff *skb = 0;
-       char *sp = 0;
+       struct sk_buff *skb = NULL;
+       char *sp = NULL;
 
        if (!msg) {
                printk(KERN_WARNING "isdn_tty: Null-Message in isdn_tty_at_cout\n");
@@ -2475,10 +2456,8 @@ isdn_tty_off_hook(void)
  */
 static void
 isdn_tty_check_esc(const u_char * p, u_char plus, int count, int *pluscount,
-                  u_long *lastplus, int from_user)
+                  u_long *lastplus)
 {
-       char cbuf[3];
-
        if (plus > 127)
                return;
        if (count > 3) {
@@ -2486,10 +2465,6 @@ isdn_tty_check_esc(const u_char * p, u_char plus, int count, int *pluscount,
                count = 3;
                *pluscount = 0;
        }
-       if (from_user) {
-               copy_from_user(cbuf, p, count);
-               p = cbuf;
-       }
        while (count > 0) {
                if (*(p++) == plus) {
                        if ((*pluscount)++) {
@@ -2681,8 +2656,7 @@ isdn_tty_modem_result(int code, modem_info * info)
                if ((info->flags & ISDN_ASYNC_CLOSING) || (!info->tty)) {
                        return;
                }
-               if (info->tty->ldisc.flush_buffer)
-                       info->tty->ldisc.flush_buffer(info->tty);
+               tty_ldisc_flush(info->tty);
                if ((info->flags & ISDN_ASYNC_CHECK_CD) &&
                    (!((info->flags & ISDN_ASYNC_CALLOUT_ACTIVE) &&
                       (info->flags & ISDN_ASYNC_CALLOUT_NOHUP)))) {
@@ -3770,10 +3744,9 @@ isdn_tty_parse_at(modem_info * info)
  *   p        inputbuffer
  *   count    length of buffer
  *   channel  index to line (minor-device)
- *   user     flag: buffer is in userspace
  */
 static int
-isdn_tty_edit_at(const char *p, int count, modem_info * info, int user)
+isdn_tty_edit_at(const char *p, int count, modem_info * info)
 {
        atemu *m = &info->emu;
        int total = 0;
@@ -3782,10 +3755,7 @@ isdn_tty_edit_at(const char *p, int count, modem_info * info, int user)
        int cnt;
 
        for (cnt = count; cnt > 0; p++, cnt--) {
-               if (user)
-                       get_user(c, p);
-               else
-                       c = *p;
+               c = *p;
                total++;
                if (c == m->mdmreg[REG_CR] || c == m->mdmreg[REG_LF]) {
                        /* Separator (CR or LF) */