diff options
-rw-r--r-- | drivers/char/moxa.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index 0c34bc5b04e1..8849d662295e 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -146,8 +146,6 @@ struct moxa_port { | |||
146 | wait_queue_head_t close_wait; | 146 | wait_queue_head_t close_wait; |
147 | 147 | ||
148 | struct timer_list emptyTimer; | 148 | struct timer_list emptyTimer; |
149 | struct mxser_mstatus GMStatus; | ||
150 | struct moxaq_str temp_queue; | ||
151 | 149 | ||
152 | char chkPort; | 150 | char chkPort; |
153 | char lineCtrl; | 151 | char lineCtrl; |
@@ -1487,17 +1485,15 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port) | |||
1487 | return (0); | 1485 | return (0); |
1488 | case MOXA_GET_IOQUEUE: { | 1486 | case MOXA_GET_IOQUEUE: { |
1489 | struct moxaq_str __user *argm = argp; | 1487 | struct moxaq_str __user *argm = argp; |
1490 | struct moxa_port *p; | 1488 | struct moxaq_str tmp; |
1491 | 1489 | ||
1492 | for (i = 0; i < MAX_PORTS; i++, argm++) { | 1490 | for (i = 0; i < MAX_PORTS; i++, argm++) { |
1493 | p = &moxa_ports[i]; | 1491 | memset(&tmp, 0, sizeof(tmp)); |
1494 | memset(&p->temp_queue, 0, sizeof(p->temp_queue)); | 1492 | if (moxa_ports[i].chkPort) { |
1495 | if (p->chkPort) { | 1493 | tmp.inq = MoxaPortRxQueue(i); |
1496 | p->temp_queue.inq = MoxaPortRxQueue(i); | 1494 | tmp.outq = MoxaPortTxQueue(i); |
1497 | p->temp_queue.outq = MoxaPortTxQueue(i); | ||
1498 | } | 1495 | } |
1499 | if (copy_to_user(argm, &p->temp_queue, | 1496 | if (copy_to_user(argm, &tmp, sizeof(tmp))) |
1500 | sizeof(p->temp_queue))) | ||
1501 | return -EFAULT; | 1497 | return -EFAULT; |
1502 | } | 1498 | } |
1503 | return (0); | 1499 | return (0); |
@@ -1518,33 +1514,30 @@ int MoxaDriverIoctl(unsigned int cmd, unsigned long arg, int port) | |||
1518 | return 0; | 1514 | return 0; |
1519 | case MOXA_GETMSTATUS: { | 1515 | case MOXA_GETMSTATUS: { |
1520 | struct mxser_mstatus __user *argm = argp; | 1516 | struct mxser_mstatus __user *argm = argp; |
1517 | struct mxser_mstatus tmp; | ||
1521 | struct moxa_port *p; | 1518 | struct moxa_port *p; |
1522 | 1519 | ||
1523 | for (i = 0; i < MAX_PORTS; i++, argm++) { | 1520 | for (i = 0; i < MAX_PORTS; i++, argm++) { |
1524 | p = &moxa_ports[i]; | 1521 | p = &moxa_ports[i]; |
1525 | p->GMStatus.ri = 0; | 1522 | memset(&tmp, 0, sizeof(tmp)); |
1526 | p->GMStatus.dcd = 0; | ||
1527 | p->GMStatus.dsr = 0; | ||
1528 | p->GMStatus.cts = 0; | ||
1529 | if (!p->chkPort) { | 1523 | if (!p->chkPort) { |
1530 | goto copy; | 1524 | goto copy; |
1531 | } else { | 1525 | } else { |
1532 | status = MoxaPortLineStatus(p->port); | 1526 | status = MoxaPortLineStatus(p->port); |
1533 | if (status & 1) | 1527 | if (status & 1) |
1534 | p->GMStatus.cts = 1; | 1528 | tmp.cts = 1; |
1535 | if (status & 2) | 1529 | if (status & 2) |
1536 | p->GMStatus.dsr = 1; | 1530 | tmp.dsr = 1; |
1537 | if (status & 4) | 1531 | if (status & 4) |
1538 | p->GMStatus.dcd = 1; | 1532 | tmp.dcd = 1; |
1539 | } | 1533 | } |
1540 | 1534 | ||
1541 | if (!p->tty || !p->tty->termios) | 1535 | if (!p->tty || !p->tty->termios) |
1542 | p->GMStatus.cflag = p->cflag; | 1536 | tmp.cflag = p->cflag; |
1543 | else | 1537 | else |
1544 | p->GMStatus.cflag = p->tty->termios->c_cflag; | 1538 | tmp.cflag = p->tty->termios->c_cflag; |
1545 | copy: | 1539 | copy: |
1546 | if (copy_to_user(argm, &p->GMStatus, | 1540 | if (copy_to_user(argm, &tmp, sizeof(tmp))) |
1547 | sizeof(p->GMStatus))) | ||
1548 | return -EFAULT; | 1541 | return -EFAULT; |
1549 | } | 1542 | } |
1550 | return 0; | 1543 | return 0; |