hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/tty/moxa.c
....@@ -221,8 +221,8 @@
221221 static int MoxaPortTxFree(struct moxa_port *);
222222 static void MoxaPortTxDisable(struct moxa_port *);
223223 static void MoxaPortTxEnable(struct moxa_port *);
224
-static int moxa_get_serial_info(struct moxa_port *, struct serial_struct __user *);
225
-static int moxa_set_serial_info(struct moxa_port *, struct serial_struct __user *);
224
+static int moxa_get_serial_info(struct tty_struct *, struct serial_struct *);
225
+static int moxa_set_serial_info(struct tty_struct *, struct serial_struct *);
226226 static void MoxaSetFifo(struct moxa_port *port, int enable);
227227
228228 /*
....@@ -375,16 +375,6 @@
375375 }
376376 break;
377377 }
378
- case TIOCGSERIAL:
379
- mutex_lock(&ch->port.mutex);
380
- ret = moxa_get_serial_info(ch, argp);
381
- mutex_unlock(&ch->port.mutex);
382
- break;
383
- case TIOCSSERIAL:
384
- mutex_lock(&ch->port.mutex);
385
- ret = moxa_set_serial_info(ch, argp);
386
- mutex_unlock(&ch->port.mutex);
387
- break;
388378 default:
389379 ret = -ENOIOCTLCMD;
390380 }
....@@ -415,6 +405,8 @@
415405 .break_ctl = moxa_break_ctl,
416406 .tiocmget = moxa_tiocmget,
417407 .tiocmset = moxa_tiocmset,
408
+ .set_serial = moxa_set_serial_info,
409
+ .get_serial = moxa_get_serial_info,
418410 };
419411
420412 static const struct tty_port_operations moxa_port_ops = {
....@@ -969,7 +961,7 @@
969961 goto err;
970962 }
971963
972
- board->basemem = ioremap_nocache(pci_resource_start(pdev, 2), 0x4000);
964
+ board->basemem = ioremap(pci_resource_start(pdev, 2), 0x4000);
973965 if (board->basemem == NULL) {
974966 dev_err(&pdev->dev, "can't remap io space 2\n");
975967 retval = -ENOMEM;
....@@ -1079,7 +1071,7 @@
10791071 brd->numPorts = type[i] == MOXA_BOARD_C218_ISA ? 8 :
10801072 numports[i];
10811073 brd->busType = MOXA_BUS_TYPE_ISA;
1082
- brd->basemem = ioremap_nocache(baseaddr[i], 0x4000);
1074
+ brd->basemem = ioremap(baseaddr[i], 0x4000);
10831075 if (!brd->basemem) {
10841076 printk(KERN_ERR "MOXA: can't remap %lx\n",
10851077 baseaddr[i]);
....@@ -1393,7 +1385,7 @@
13931385 if (inited && !tty_throttled(tty) &&
13941386 MoxaPortRxQueue(p) > 0) { /* RX */
13951387 MoxaPortReadData(p);
1396
- tty_schedule_flip(&p->port);
1388
+ tty_flip_buffer_push(&p->port);
13971389 }
13981390 } else {
13991391 clear_bit(EMPTYWAIT, &p->statusflags);
....@@ -1418,7 +1410,7 @@
14181410
14191411 if (tty && (intr & IntrBreak) && !I_IGNBRK(tty)) { /* BREAK */
14201412 tty_insert_flip_char(&p->port, 0, TTY_BREAK);
1421
- tty_schedule_flip(&p->port);
1413
+ tty_flip_buffer_push(&p->port);
14221414 }
14231415
14241416 if (intr & IntrLine)
....@@ -2034,46 +2026,61 @@
20342026 moxafunc(port->tableAddr, FC_SetXonState, Magic_code);
20352027 }
20362028
2037
-static int moxa_get_serial_info(struct moxa_port *info,
2038
- struct serial_struct __user *retinfo)
2029
+static int moxa_get_serial_info(struct tty_struct *tty,
2030
+ struct serial_struct *ss)
20392031 {
2040
- struct serial_struct tmp = {
2041
- .type = info->type,
2042
- .line = info->port.tty->index,
2043
- .flags = info->port.flags,
2044
- .baud_base = 921600,
2045
- .close_delay = info->port.close_delay
2046
- };
2047
- return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0;
2032
+ struct moxa_port *info = tty->driver_data;
2033
+
2034
+ if (tty->index == MAX_PORTS)
2035
+ return -EINVAL;
2036
+ if (!info)
2037
+ return -ENODEV;
2038
+ mutex_lock(&info->port.mutex);
2039
+ ss->type = info->type,
2040
+ ss->line = info->port.tty->index,
2041
+ ss->flags = info->port.flags,
2042
+ ss->baud_base = 921600,
2043
+ ss->close_delay = jiffies_to_msecs(info->port.close_delay) / 10;
2044
+ mutex_unlock(&info->port.mutex);
2045
+ return 0;
20482046 }
20492047
20502048
2051
-static int moxa_set_serial_info(struct moxa_port *info,
2052
- struct serial_struct __user *new_info)
2049
+static int moxa_set_serial_info(struct tty_struct *tty,
2050
+ struct serial_struct *ss)
20532051 {
2054
- struct serial_struct new_serial;
2052
+ struct moxa_port *info = tty->driver_data;
2053
+ unsigned int close_delay;
20552054
2056
- if (copy_from_user(&new_serial, new_info, sizeof(new_serial)))
2057
- return -EFAULT;
2055
+ if (tty->index == MAX_PORTS)
2056
+ return -EINVAL;
2057
+ if (!info)
2058
+ return -ENODEV;
20582059
2059
- if (new_serial.irq != 0 || new_serial.port != 0 ||
2060
- new_serial.custom_divisor != 0 ||
2061
- new_serial.baud_base != 921600)
2060
+ if (ss->irq != 0 || ss->port != 0 ||
2061
+ ss->custom_divisor != 0 ||
2062
+ ss->baud_base != 921600)
20622063 return -EPERM;
20632064
2065
+ close_delay = msecs_to_jiffies(ss->close_delay * 10);
2066
+
2067
+ mutex_lock(&info->port.mutex);
20642068 if (!capable(CAP_SYS_ADMIN)) {
2065
- if (((new_serial.flags & ~ASYNC_USR_MASK) !=
2066
- (info->port.flags & ~ASYNC_USR_MASK)))
2069
+ if (close_delay != info->port.close_delay ||
2070
+ ss->type != info->type ||
2071
+ ((ss->flags & ~ASYNC_USR_MASK) !=
2072
+ (info->port.flags & ~ASYNC_USR_MASK))) {
2073
+ mutex_unlock(&info->port.mutex);
20672074 return -EPERM;
2068
- } else
2069
- info->port.close_delay = new_serial.close_delay * HZ / 100;
2075
+ }
2076
+ } else {
2077
+ info->port.close_delay = close_delay;
20702078
2071
- new_serial.flags = (new_serial.flags & ~ASYNC_FLAGS);
2072
- new_serial.flags |= (info->port.flags & ASYNC_FLAGS);
2079
+ MoxaSetFifo(info, ss->type == PORT_16550A);
20732080
2074
- MoxaSetFifo(info, new_serial.type == PORT_16550A);
2075
-
2076
- info->type = new_serial.type;
2081
+ info->type = ss->type;
2082
+ }
2083
+ mutex_unlock(&info->port.mutex);
20772084 return 0;
20782085 }
20792086