This commit was generated by cvs2svn to compensate for changes in r1129,
[linux-2.6.git] / drivers / s390 / net / ctctty.c
index 2806b2d..5cdcdbf 100644 (file)
@@ -1,6 +1,4 @@
 /*
- * $Id: ctctty.c,v 1.26 2004/08/04 11:06:55 mschwide Exp $
- *
  * CTC / ESCON network driver, tty interface.
  *
  * Copyright (C) 2001 IBM Deutschland Entwicklung GmbH, IBM Corporation
@@ -25,6 +23,7 @@
 #include <linux/config.h>
 #include <linux/module.h>
 #include <linux/tty.h>
+#include <linux/tty_flip.h>
 #include <linux/serial_reg.h>
 #include <linux/interrupt.h>
 #include <linux/delay.h>
@@ -101,25 +100,17 @@ static spinlock_t ctc_tty_lock;
 static int
 ctc_tty_try_read(ctc_tty_info * info, struct sk_buff *skb)
 {
-       int c;
        int len;
        struct tty_struct *tty;
 
        DBF_TEXT(trace, 5, __FUNCTION__);
        if ((tty = info->tty)) {
                if (info->mcr & UART_MCR_RTS) {
-                       c = TTY_FLIPBUF_SIZE - tty->flip.count;
                        len = skb->len;
-                       if (c >= len) {
-                               memcpy(tty->flip.char_buf_ptr, skb->data, len);
-                               memset(tty->flip.flag_buf_ptr, 0, len);
-                               tty->flip.count += len;
-                               tty->flip.char_buf_ptr += len;
-                               tty->flip.flag_buf_ptr += len;
-                               tty_flip_buffer_push(tty);
-                               kfree_skb(skb);
-                               return 1;
-                       }
+                       tty_insert_flip_string(tty, skb->data, len);
+                       tty_flip_buffer_push(tty);
+                       kfree_skb(skb);
+                       return 1;
                }
        }
        return 0;
@@ -138,25 +129,18 @@ ctc_tty_readmodem(ctc_tty_info *info)
        DBF_TEXT(trace, 5, __FUNCTION__);
        if ((tty = info->tty)) {
                if (info->mcr & UART_MCR_RTS) {
-                       int c = TTY_FLIPBUF_SIZE - tty->flip.count;
                        struct sk_buff *skb;
                        
-                       if ((c > 0) && (skb = skb_dequeue(&info->rx_queue))) {
+                       if ((skb = skb_dequeue(&info->rx_queue))) {
                                int len = skb->len;
-                               if (len > c)
-                                       len = c;
-                               memcpy(tty->flip.char_buf_ptr, skb->data, len);
+                               tty_insert_flip_string(tty, skb->data, len);
                                skb_pull(skb, len);
-                               memset(tty->flip.flag_buf_ptr, 0, len);
-                               tty->flip.count += len;
-                               tty->flip.char_buf_ptr += len;
-                               tty->flip.flag_buf_ptr += len;
                                tty_flip_buffer_push(tty);
                                if (skb->len > 0)
                                        skb_queue_head(&info->rx_queue, skb);
                                else {
                                        kfree_skb(skb);
-                                       ret = skb_queue_len(&info->rx_queue);
+                                       ret = !skb_queue_empty(&info->rx_queue);
                                }
                        }
                }
@@ -489,7 +473,7 @@ ctc_tty_shutdown(ctc_tty_info * info)
  *  - If dialing, abort dial.
  */
 static int
-ctc_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int count)
+ctc_tty_write(struct tty_struct *tty, const u_char * buf, int count)
 {
        int c;
        int total = 0;
@@ -506,8 +490,6 @@ ctc_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int cou
                total = -ENODEV;
                goto ex;
        }
-       if (from_user)
-               down(&info->write_sem);
        while (1) {
                struct sk_buff *skb;
                int skb_res;
@@ -526,22 +508,16 @@ ctc_tty_write(struct tty_struct *tty, int from_user, const u_char * buf, int cou
                        break;
                }
                skb_reserve(skb, skb_res);
-               if (from_user)
-                       copy_from_user(skb_put(skb, c),
-                                       (const u_char __user *)buf, c);
-               else
-                       memcpy(skb_put(skb, c), buf, c);
+               memcpy(skb_put(skb, c), buf, c);
                skb_queue_tail(&info->tx_queue, skb);
                buf += c;
                total += c;
                count -= c;
        }
-       if (skb_queue_len(&info->tx_queue)) {
+       if (!skb_queue_empty(&info->tx_queue)) {
                info->lsr &= ~UART_LSR_TEMT;
                tasklet_schedule(&info->tasklet);
        }
-       if (from_user)
-               up(&info->write_sem);
 ex:
        DBF_TEXT(trace, 6, __FUNCTION__);
        return total;
@@ -602,7 +578,7 @@ ctc_tty_flush_chars(struct tty_struct *tty)
                return;
        if (ctc_tty_paranoia_check(info, tty->name, "ctc_tty_flush_chars"))
                return;
-       if (tty->stopped || tty->hw_stopped || (!skb_queue_len(&info->tx_queue)))
+       if (tty->stopped || tty->hw_stopped || skb_queue_empty(&info->tx_queue))
                return;
        tasklet_schedule(&info->tasklet);
 }
@@ -786,11 +762,10 @@ ctc_tty_ioctl(struct tty_struct *tty, struct file *file,
                        printk(KERN_DEBUG "%s%d ioctl TIOCSERGETLSR\n", CTC_TTY_NAME,
                               info->line);
 #endif
-                       error = verify_area(VERIFY_WRITE, (void __user *) arg, sizeof(uint));
-                       if (error)
-                               return error;
-                       else
+                       if (access_ok(VERIFY_WRITE, (void __user *) arg, sizeof(uint)))
                                return ctc_tty_get_lsr_info(info, (uint __user *) arg);
+                       else
+                               return -EFAULT;
                default:
 #ifdef CTC_DEBUG_MODEM_IOCTL
                        printk(KERN_DEBUG "UNKNOWN ioctl 0x%08x on %s%d\n", cmd,
@@ -1065,8 +1040,7 @@ ctc_tty_close(struct tty_struct *tty, struct file *filp)
        info->tty = 0;
        tty->closing = 0;
        if (info->blocked_open) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               schedule_timeout(HZ/2);
+               msleep_interruptible(500);
                wake_up_interruptible(&info->open_wait);
        }
        info->flags &= ~(CTC_ASYNC_NORMAL_ACTIVE | CTC_ASYNC_CLOSING);