cyclades: tiocm cleanup
[deliverable/linux.git] / drivers / char / cyclades.c
index 74627950f90199774bf51b3c684bfc31c566dcee..ed66c3ab230d72a8b7c146ac7298e45220742a8f 100644 (file)
@@ -831,6 +831,7 @@ static void cyy_change_rts_dtr(struct cyclades_port *info, unsigned int set,
        struct cyclades_card *card = info->card;
        void __iomem *base_addr;
        int chip, channel, index;
+       u32 rts, dtr, msvrr, msvrd;
 
        channel = info->line - card->first_line;
        chip = channel >> 2;
@@ -838,29 +839,28 @@ static void cyy_change_rts_dtr(struct cyclades_port *info, unsigned int set,
        index = card->bus_index;
        base_addr = card->base_addr + (cy_chip_offset[chip] << index);
 
+       if (info->rtsdtr_inv) {
+               msvrr = CyMSVR2;
+               msvrd = CyMSVR1;
+               rts = CyDTR;
+               dtr = CyRTS;
+       } else {
+               msvrr = CyMSVR1;
+               msvrd = CyMSVR2;
+               rts = CyRTS;
+               dtr = CyDTR;
+       }
        if (set & TIOCM_RTS) {
-               cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
-               if (info->rtsdtr_inv) {
-                       cy_writeb(base_addr + (CyMSVR2 << index), CyDTR);
-               } else {
-                       cy_writeb(base_addr + (CyMSVR1 << index), CyRTS);
-               }
+               cy_writeb(base_addr + (CyCAR << index), (u8)channel);
+               cy_writeb(base_addr + (msvrr << index), rts);
        }
        if (clear & TIOCM_RTS) {
-               cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
-               if (info->rtsdtr_inv) {
-                       cy_writeb(base_addr + (CyMSVR2 << index), ~CyDTR);
-               } else {
-                       cy_writeb(base_addr + (CyMSVR1 << index), ~CyRTS);
-               }
+               cy_writeb(base_addr + (CyCAR << index), (u8)channel);
+               cy_writeb(base_addr + (msvrr << index), ~rts);
        }
        if (set & TIOCM_DTR) {
-               cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
-               if (info->rtsdtr_inv) {
-                       cy_writeb(base_addr + (CyMSVR1 << index), CyRTS);
-               } else {
-                       cy_writeb(base_addr + (CyMSVR2 << index), CyDTR);
-               }
+               cy_writeb(base_addr + (CyCAR << index), (u8)channel);
+               cy_writeb(base_addr + (msvrd << index), dtr);
 #ifdef CY_DEBUG_DTR
                printk(KERN_DEBUG "cyc:set_modem_info raising DTR\n");
                printk(KERN_DEBUG "     status: 0x%x, 0x%x\n",
@@ -869,13 +869,8 @@ static void cyy_change_rts_dtr(struct cyclades_port *info, unsigned int set,
 #endif
        }
        if (clear & TIOCM_DTR) {
-               cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
-               if (info->rtsdtr_inv) {
-                       cy_writeb(base_addr + (CyMSVR1 << index), ~CyRTS);
-               } else {
-                       cy_writeb(base_addr + (CyMSVR2 << index), ~CyDTR);
-               }
-
+               cy_writeb(base_addr + (CyCAR << index), (u8)channel);
+               cy_writeb(base_addr + (msvrd << index), ~dtr);
 #ifdef CY_DEBUG_DTR
                printk(KERN_DEBUG "cyc:set_modem_info dropping DTR\n");
                printk(KERN_DEBUG "     status: 0x%x, 0x%x\n",
@@ -1296,7 +1291,7 @@ static int cy_startup(struct cyclades_port *info, struct tty_struct *tty)
        unsigned long flags;
        int retval = 0;
        void __iomem *base_addr;
-       int chip, channel, index;
+       int channel;
        unsigned long page;
 
        card = info->card;
@@ -1308,14 +1303,11 @@ static int cy_startup(struct cyclades_port *info, struct tty_struct *tty)
 
        spin_lock_irqsave(&card->card_lock, flags);
 
-       if (info->port.flags & ASYNC_INITIALIZED) {
-               free_page(page);
+       if (info->port.flags & ASYNC_INITIALIZED)
                goto errout;
-       }
 
        if (!info->type) {
                set_bit(TTY_IO_ERROR, &tty->flags);
-               free_page(page);
                goto errout;
        }
 
@@ -1329,9 +1321,9 @@ static int cy_startup(struct cyclades_port *info, struct tty_struct *tty)
        cy_set_line_char(info, tty);
 
        if (!cy_is_Z(card)) {
-               chip = channel >> 2;
+               int chip = channel >> 2;
+               int index = card->bus_index;
                channel &= 0x03;
-               index = card->bus_index;
                base_addr = card->base_addr + (cy_chip_offset[chip] << index);
 
 #ifdef CY_DEBUG_OPEN
@@ -1354,18 +1346,6 @@ static int cy_startup(struct cyclades_port *info, struct tty_struct *tty)
 
                cy_writeb(base_addr + (CySRER << index),
                        readb(base_addr + (CySRER << index)) | CyRxData);
-               info->port.flags |= ASYNC_INITIALIZED;
-
-               clear_bit(TTY_IO_ERROR, &tty->flags);
-               info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-               info->breakon = info->breakoff = 0;
-               memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
-               info->idle_stats.in_use =
-               info->idle_stats.recv_idle =
-               info->idle_stats.xmit_idle = jiffies;
-
-               spin_unlock_irqrestore(&card->card_lock, flags);
-
        } else {
                struct CH_CTRL __iomem *ch_ctrl = info->u.cyz.ch_ctrl;
 
@@ -1416,18 +1396,19 @@ static int cy_startup(struct cyclades_port *info, struct tty_struct *tty)
                tty_port_raise_dtr_rts(&info->port);
 
                /* enable send, recv, modem !!! */
+       }
 
-               info->port.flags |= ASYNC_INITIALIZED;
-               clear_bit(TTY_IO_ERROR, &tty->flags);
-               info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
-               info->breakon = info->breakoff = 0;
-               memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
-               info->idle_stats.in_use =
-               info->idle_stats.recv_idle =
-               info->idle_stats.xmit_idle = jiffies;
+       info->port.flags |= ASYNC_INITIALIZED;
 
-               spin_unlock_irqrestore(&card->card_lock, flags);
-       }
+       clear_bit(TTY_IO_ERROR, &tty->flags);
+       info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
+       info->breakon = info->breakoff = 0;
+       memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats));
+       info->idle_stats.in_use =
+       info->idle_stats.recv_idle =
+       info->idle_stats.xmit_idle = jiffies;
+
+       spin_unlock_irqrestore(&card->card_lock, flags);
 
 #ifdef CY_DEBUG_OPEN
        printk(KERN_DEBUG "cyc startup done\n");
@@ -1436,6 +1417,7 @@ static int cy_startup(struct cyclades_port *info, struct tty_struct *tty)
 
 errout:
        spin_unlock_irqrestore(&card->card_lock, flags);
+       free_page(page);
        return retval;
 }                              /* startup */
 
@@ -2424,29 +2406,25 @@ static void cy_set_line_char(struct cyclades_port *info, struct tty_struct *tty)
        }
 }                              /* set_line_char */
 
-static int
-get_serial_info(struct cyclades_port *info,
+static int cy_get_serial_info(struct cyclades_port *info,
                struct serial_struct __user *retinfo)
 {
-       struct serial_struct tmp;
        struct cyclades_card *cinfo = info->card;
-
-       if (!retinfo)
-               return -EFAULT;
-       memset(&tmp, 0, sizeof(tmp));
-       tmp.type = info->type;
-       tmp.line = info->line;
-       tmp.port = (info->card - cy_card) * 0x100 + info->line -
-               cinfo->first_line;
-       tmp.irq = cinfo->irq;
-       tmp.flags = info->port.flags;
-       tmp.close_delay = info->port.close_delay;
-       tmp.closing_wait = info->port.closing_wait;
-       tmp.baud_base = info->baud;
-       tmp.custom_divisor = info->custom_divisor;
-       tmp.hub6 = 0;           /*!!! */
+       struct serial_struct tmp = {
+               .type = info->type,
+               .line = info->line,
+               .port = (info->card - cy_card) * 0x100 + info->line -
+                       cinfo->first_line,
+               .irq = cinfo->irq,
+               .flags = info->port.flags,
+               .close_delay = info->port.close_delay,
+               .closing_wait = info->port.closing_wait,
+               .baud_base = info->baud,
+               .custom_divisor = info->custom_divisor,
+               .hub6 = 0,              /*!!! */
+       };
        return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
-}                              /* get_serial_info */
+}
 
 static int
 cy_set_serial_info(struct cyclades_port *info, struct tty_struct *tty,
@@ -2535,28 +2513,27 @@ static int cy_tiocmget(struct tty_struct *tty, struct file *file)
 {
        struct cyclades_port *info = tty->driver_data;
        struct cyclades_card *card;
-       int chip, channel, index;
        void __iomem *base_addr;
-       unsigned long flags;
-       unsigned char status;
-       unsigned long lstatus;
-       unsigned int result;
+       int result, channel;
 
        if (serial_paranoia_check(info, tty->name, __func__))
                return -ENODEV;
 
-       lock_kernel();
-
        card = info->card;
        channel = info->line - card->first_line;
+
+       lock_kernel();
        if (!cy_is_Z(card)) {
-               chip = channel >> 2;
+               unsigned long flags;
+               unsigned char status;
+               int chip = channel >> 2;
+               int index = card->bus_index;
+
                channel &= 0x03;
-               index = card->bus_index;
                base_addr = card->base_addr + (cy_chip_offset[chip] << index);
 
                spin_lock_irqsave(&card->card_lock, flags);
-               cy_writeb(base_addr + (CyCAR << index), (u_char) channel);
+               cy_writeb(base_addr + (CyCAR << index), (u8)channel);
                status = readb(base_addr + (CyMSVR1 << index));
                status |= readb(base_addr + (CyMSVR2 << index));
                spin_unlock_irqrestore(&card->card_lock, flags);
@@ -2573,21 +2550,22 @@ static int cy_tiocmget(struct tty_struct *tty, struct file *file)
                        ((status & CyDSR) ? TIOCM_DSR : 0) |
                        ((status & CyCTS) ? TIOCM_CTS : 0);
        } else {
-               if (cyz_is_loaded(card)) {
-                       lstatus = readl(&info->u.cyz.ch_ctrl->rs_status);
-                       result = ((lstatus & C_RS_RTS) ? TIOCM_RTS : 0) |
-                               ((lstatus & C_RS_DTR) ? TIOCM_DTR : 0) |
-                               ((lstatus & C_RS_DCD) ? TIOCM_CAR : 0) |
-                               ((lstatus & C_RS_RI) ? TIOCM_RNG : 0) |
-                               ((lstatus & C_RS_DSR) ? TIOCM_DSR : 0) |
-                               ((lstatus & C_RS_CTS) ? TIOCM_CTS : 0);
-               } else {
-                       result = 0;
-                       unlock_kernel();
-                       return -ENODEV;
+               u32 lstatus;
+
+               if (!cyz_is_loaded(card)) {
+                       result = -ENODEV;
+                       goto end;
                }
 
+               lstatus = readl(&info->u.cyz.ch_ctrl->rs_status);
+               result = ((lstatus & C_RS_RTS) ? TIOCM_RTS : 0) |
+                       ((lstatus & C_RS_DTR) ? TIOCM_DTR : 0) |
+                       ((lstatus & C_RS_DCD) ? TIOCM_CAR : 0) |
+                       ((lstatus & C_RS_RI) ? TIOCM_RNG : 0) |
+                       ((lstatus & C_RS_DSR) ? TIOCM_DSR : 0) |
+                       ((lstatus & C_RS_CTS) ? TIOCM_CTS : 0);
        }
+end:
        unlock_kernel();
        return result;
 }                              /* cy_tiomget */
@@ -2599,68 +2577,52 @@ cy_tiocmset(struct tty_struct *tty, struct file *file,
        struct cyclades_port *info = tty->driver_data;
        struct cyclades_card *card;
        unsigned long flags;
-       int channel, retval;
 
        if (serial_paranoia_check(info, tty->name, __func__))
                return -ENODEV;
 
        card = info->card;
-       channel = (info->line) - (card->first_line);
        if (!cy_is_Z(card)) {
                spin_lock_irqsave(&card->card_lock, flags);
                cyy_change_rts_dtr(info, set, clear);
                spin_unlock_irqrestore(&card->card_lock, flags);
        } else {
-               if (cyz_is_loaded(card)) {
-                       struct CH_CTRL __iomem *ch_ctrl = info->u.cyz.ch_ctrl;
-
-                       if (set & TIOCM_RTS) {
-                               spin_lock_irqsave(&card->card_lock, flags);
-                               cy_writel(&ch_ctrl->rs_control,
-                                       readl(&ch_ctrl->rs_control) | C_RS_RTS);
-                               spin_unlock_irqrestore(&card->card_lock, flags);
-                       }
-                       if (clear & TIOCM_RTS) {
-                               spin_lock_irqsave(&card->card_lock, flags);
-                               cy_writel(&ch_ctrl->rs_control,
-                                       readl(&ch_ctrl->rs_control) &
-                                       ~C_RS_RTS);
-                               spin_unlock_irqrestore(&card->card_lock, flags);
-                       }
-                       if (set & TIOCM_DTR) {
-                               spin_lock_irqsave(&card->card_lock, flags);
-                               cy_writel(&ch_ctrl->rs_control,
-                                       readl(&ch_ctrl->rs_control) | C_RS_DTR);
+               struct CH_CTRL __iomem *ch_ctrl = info->u.cyz.ch_ctrl;
+               int retval, channel = info->line - card->first_line;
+               u32 rs;
+
+               if (!cyz_is_loaded(card))
+                       return -ENODEV;
+
+               spin_lock_irqsave(&card->card_lock, flags);
+               rs = readl(&ch_ctrl->rs_control);
+               if (set & TIOCM_RTS)
+                       rs |= C_RS_RTS;
+               if (clear & TIOCM_RTS)
+                       rs &= ~C_RS_RTS;
+               if (set & TIOCM_DTR) {
+                       rs |= C_RS_DTR;
 #ifdef CY_DEBUG_DTR
-                               printk(KERN_DEBUG "cyc:set_modem_info raising "
-                                       "Z DTR\n");
+                       printk(KERN_DEBUG "cyc:set_modem_info raising Z DTR\n");
 #endif
-                               spin_unlock_irqrestore(&card->card_lock, flags);
-                       }
-                       if (clear & TIOCM_DTR) {
-                               spin_lock_irqsave(&card->card_lock, flags);
-                               cy_writel(&ch_ctrl->rs_control,
-                                       readl(&ch_ctrl->rs_control) &
-                                       ~C_RS_DTR);
+               }
+               if (clear & TIOCM_DTR) {
+                       rs &= ~C_RS_DTR;
 #ifdef CY_DEBUG_DTR
-                               printk(KERN_DEBUG "cyc:set_modem_info clearing "
-                                       "Z DTR\n");
+                       printk(KERN_DEBUG "cyc:set_modem_info clearing "
+                               "Z DTR\n");
 #endif
-                               spin_unlock_irqrestore(&card->card_lock, flags);
-                       }
-               } else {
-                       return -ENODEV;
                }
-               spin_lock_irqsave(&card->card_lock, flags);
+               cy_writel(&ch_ctrl->rs_control, rs);
                retval = cyz_issue_cmd(card, channel, C_CM_IOCTLM, 0L);
+               spin_unlock_irqrestore(&card->card_lock, flags);
                if (retval != 0) {
                        printk(KERN_ERR "cyc:set_modem_info retval on ttyC%d "
                                "was %x\n", info->line, retval);
                }
-               spin_unlock_irqrestore(&card->card_lock, flags);
        }
        return 0;
-}                              /* cy_tiocmset */
+}
 
 /*
  * cy_break() --- routine which turns the break handling on or off
@@ -2725,18 +2687,6 @@ static int cy_break(struct tty_struct *tty, int break_state)
        return retval;
 }                              /* cy_break */
 
-static int get_mon_info(struct cyclades_port *info,
-                               struct cyclades_monitor __user *mon)
-{
-       if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor)))
-               return -EFAULT;
-       info->mon.int_count = 0;
-       info->mon.char_count = 0;
-       info->mon.char_max = 0;
-       info->mon.char_last = 0;
-       return 0;
-}                              /* get_mon_info */
-
 static int set_threshold(struct cyclades_port *info, unsigned long value)
 {
        struct cyclades_card *card;
@@ -2786,19 +2736,6 @@ static int get_threshold(struct cyclades_port *info,
        return 0;
 }                              /* get_threshold */
 
-static int set_default_threshold(struct cyclades_port *info,
-                                                       unsigned long value)
-{
-       info->default_threshold = value & 0x0f;
-       return 0;
-}                              /* set_default_threshold */
-
-static int get_default_threshold(struct cyclades_port *info,
-                                               unsigned long __user *value)
-{
-       return put_user(info->default_threshold, value);
-}                              /* get_default_threshold */
-
 static int set_timeout(struct cyclades_port *info, unsigned long value)
 {
        struct cyclades_card *card;
@@ -2843,17 +2780,26 @@ static int get_timeout(struct cyclades_port *info,
        return 0;
 }                              /* get_timeout */
 
-static int set_default_timeout(struct cyclades_port *info, unsigned long value)
+static int cy_cflags_changed(struct cyclades_port *info, unsigned long arg,
+               struct cyclades_icount *cprev)
 {
-       info->default_timeout = value & 0xff;
-       return 0;
-}                              /* set_default_timeout */
+       struct cyclades_icount cnow;
+       unsigned long flags;
+       int ret;
 
-static int get_default_timeout(struct cyclades_port *info,
-                                       unsigned long __user *value)
-{
-       return put_user(info->default_timeout, value);
-}                              /* get_default_timeout */
+       spin_lock_irqsave(&info->card->card_lock, flags);
+       cnow = info->icount;    /* atomic copy */
+       spin_unlock_irqrestore(&info->card->card_lock, flags);
+
+       ret =   ((arg & TIOCM_RNG) && (cnow.rng != cprev->rng)) ||
+               ((arg & TIOCM_DSR) && (cnow.dsr != cprev->dsr)) ||
+               ((arg & TIOCM_CD)  && (cnow.dcd != cprev->dcd)) ||
+               ((arg & TIOCM_CTS) && (cnow.cts != cprev->cts));
+
+       *cprev = cnow;
+
+       return ret;
+}
 
 /*
  * This routine allows the tty driver to implement device-
@@ -2865,8 +2811,7 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
         unsigned int cmd, unsigned long arg)
 {
        struct cyclades_port *info = tty->driver_data;
-       struct cyclades_icount cprev, cnow;     /* kernel counter temps */
-       struct serial_icounter_struct __user *p_cuser;  /* user space */
+       struct cyclades_icount cnow;    /* kernel counter temps */
        int ret_val = 0;
        unsigned long flags;
        void __user *argp = (void __user *)arg;
@@ -2882,7 +2827,11 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
 
        switch (cmd) {
        case CYGETMON:
-               ret_val = get_mon_info(info, argp);
+               if (copy_to_user(argp, &info->mon, sizeof(info->mon))) {
+                       ret_val = -EFAULT;
+                       break;
+               }
+               memset(&info->mon, 0, sizeof(info->mon));
                break;
        case CYGETTHRESH:
                ret_val = get_threshold(info, argp);
@@ -2891,10 +2840,11 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
                ret_val = set_threshold(info, arg);
                break;
        case CYGETDEFTHRESH:
-               ret_val = get_default_threshold(info, argp);
+               ret_val = put_user(info->default_threshold,
+                               (unsigned long __user *)argp);
                break;
        case CYSETDEFTHRESH:
-               ret_val = set_default_threshold(info, arg);
+               info->default_threshold = arg & 0x0f;
                break;
        case CYGETTIMEOUT:
                ret_val = get_timeout(info, argp);
@@ -2903,21 +2853,20 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
                ret_val = set_timeout(info, arg);
                break;
        case CYGETDEFTIMEOUT:
-               ret_val = get_default_timeout(info, argp);
+               ret_val = put_user(info->default_timeout,
+                               (unsigned long __user *)argp);
                break;
        case CYSETDEFTIMEOUT:
-               ret_val = set_default_timeout(info, arg);
+               info->default_timeout = arg & 0xff;
                break;
        case CYSETRFLOW:
                info->rflow = (int)arg;
-               ret_val = 0;
                break;
        case CYGETRFLOW:
                ret_val = info->rflow;
                break;
        case CYSETRTSDTR_INV:
                info->rtsdtr_inv = (int)arg;
-               ret_val = 0;
                break;
        case CYGETRTSDTR_INV:
                ret_val = info->rtsdtr_inv;
@@ -2928,7 +2877,6 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
 #ifndef CONFIG_CYZ_INTR
        case CYZSETPOLLCYCLE:
                cyz_polling_cycle = (arg * HZ) / 1000;
-               ret_val = 0;
                break;
        case CYZGETPOLLCYCLE:
                ret_val = (cyz_polling_cycle * 1000) / HZ;
@@ -2936,13 +2884,12 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
 #endif                         /* CONFIG_CYZ_INTR */
        case CYSETWAIT:
                info->port.closing_wait = (unsigned short)arg * HZ / 100;
-               ret_val = 0;
                break;
        case CYGETWAIT:
                ret_val = info->port.closing_wait / (HZ / 100);
                break;
        case TIOCGSERIAL:
-               ret_val = get_serial_info(info, argp);
+               ret_val = cy_get_serial_info(info, argp);
                break;
        case TIOCSSERIAL:
                ret_val = cy_set_serial_info(info, tty, argp);
@@ -2961,17 +2908,8 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
                /* note the counters on entry */
                cnow = info->icount;
                spin_unlock_irqrestore(&info->card->card_lock, flags);
-               ret_val = wait_event_interruptible(info->delta_msr_wait, ({
-                       cprev = cnow;
-                       spin_lock_irqsave(&info->card->card_lock, flags);
-                       cnow = info->icount;    /* atomic copy */
-                       spin_unlock_irqrestore(&info->card->card_lock, flags);
-
-                       ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) ||
-                       ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) ||
-                       ((arg & TIOCM_CD)  && (cnow.dcd != cprev.dcd)) ||
-                       ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts));
-               }));
+               ret_val = wait_event_interruptible(info->delta_msr_wait,
+                               cy_cflags_changed(info, arg, &cnow));
                break;
 
                /*
@@ -2980,46 +2918,29 @@ cy_ioctl(struct tty_struct *tty, struct file *file,
                 * NB: both 1->0 and 0->1 transitions are counted except for
                 *     RI where only 0->1 is counted.
                 */
-       case TIOCGICOUNT:
+       case TIOCGICOUNT: {
+               struct serial_icounter_struct sic = { };
+
                spin_lock_irqsave(&info->card->card_lock, flags);
                cnow = info->icount;
                spin_unlock_irqrestore(&info->card->card_lock, flags);
-               p_cuser = argp;
-               ret_val = put_user(cnow.cts, &p_cuser->cts);
-               if (ret_val)
-                       break;
-               ret_val = put_user(cnow.dsr, &p_cuser->dsr);
-               if (ret_val)
-                       break;
-               ret_val = put_user(cnow.rng, &p_cuser->rng);
-               if (ret_val)
-                       break;
-               ret_val = put_user(cnow.dcd, &p_cuser->dcd);
-               if (ret_val)
-                       break;
-               ret_val = put_user(cnow.rx, &p_cuser->rx);
-               if (ret_val)
-                       break;
-               ret_val = put_user(cnow.tx, &p_cuser->tx);
-               if (ret_val)
-                       break;
-               ret_val = put_user(cnow.frame, &p_cuser->frame);
-               if (ret_val)
-                       break;
-               ret_val = put_user(cnow.overrun, &p_cuser->overrun);
-               if (ret_val)
-                       break;
-               ret_val = put_user(cnow.parity, &p_cuser->parity);
-               if (ret_val)
-                       break;
-               ret_val = put_user(cnow.brk, &p_cuser->brk);
-               if (ret_val)
-                       break;
-               ret_val = put_user(cnow.buf_overrun, &p_cuser->buf_overrun);
-               if (ret_val)
-                       break;
-               ret_val = 0;
+
+               sic.cts = cnow.cts;
+               sic.dsr = cnow.dsr;
+               sic.rng = cnow.rng;
+               sic.dcd = cnow.dcd;
+               sic.rx = cnow.rx;
+               sic.tx = cnow.tx;
+               sic.frame = cnow.frame;
+               sic.overrun = cnow.overrun;
+               sic.parity = cnow.parity;
+               sic.brk = cnow.brk;
+               sic.buf_overrun = cnow.buf_overrun;
+
+               if (copy_to_user(argp, &sic, sizeof(sic)))
+                       ret_val = -EFAULT;
                break;
+       }
        default:
                ret_val = -ENOIOCTLCMD;
        }
This page took 0.031033 seconds and 5 git commands to generate.