| .. | .. |
|---|
| 221 | 221 | static int MoxaPortTxFree(struct moxa_port *); |
|---|
| 222 | 222 | static void MoxaPortTxDisable(struct moxa_port *); |
|---|
| 223 | 223 | 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 *); |
|---|
| 226 | 226 | static void MoxaSetFifo(struct moxa_port *port, int enable); |
|---|
| 227 | 227 | |
|---|
| 228 | 228 | /* |
|---|
| .. | .. |
|---|
| 375 | 375 | } |
|---|
| 376 | 376 | break; |
|---|
| 377 | 377 | } |
|---|
| 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; |
|---|
| 388 | 378 | default: |
|---|
| 389 | 379 | ret = -ENOIOCTLCMD; |
|---|
| 390 | 380 | } |
|---|
| .. | .. |
|---|
| 415 | 405 | .break_ctl = moxa_break_ctl, |
|---|
| 416 | 406 | .tiocmget = moxa_tiocmget, |
|---|
| 417 | 407 | .tiocmset = moxa_tiocmset, |
|---|
| 408 | + .set_serial = moxa_set_serial_info, |
|---|
| 409 | + .get_serial = moxa_get_serial_info, |
|---|
| 418 | 410 | }; |
|---|
| 419 | 411 | |
|---|
| 420 | 412 | static const struct tty_port_operations moxa_port_ops = { |
|---|
| .. | .. |
|---|
| 969 | 961 | goto err; |
|---|
| 970 | 962 | } |
|---|
| 971 | 963 | |
|---|
| 972 | | - board->basemem = ioremap_nocache(pci_resource_start(pdev, 2), 0x4000); |
|---|
| 964 | + board->basemem = ioremap(pci_resource_start(pdev, 2), 0x4000); |
|---|
| 973 | 965 | if (board->basemem == NULL) { |
|---|
| 974 | 966 | dev_err(&pdev->dev, "can't remap io space 2\n"); |
|---|
| 975 | 967 | retval = -ENOMEM; |
|---|
| .. | .. |
|---|
| 1079 | 1071 | brd->numPorts = type[i] == MOXA_BOARD_C218_ISA ? 8 : |
|---|
| 1080 | 1072 | numports[i]; |
|---|
| 1081 | 1073 | brd->busType = MOXA_BUS_TYPE_ISA; |
|---|
| 1082 | | - brd->basemem = ioremap_nocache(baseaddr[i], 0x4000); |
|---|
| 1074 | + brd->basemem = ioremap(baseaddr[i], 0x4000); |
|---|
| 1083 | 1075 | if (!brd->basemem) { |
|---|
| 1084 | 1076 | printk(KERN_ERR "MOXA: can't remap %lx\n", |
|---|
| 1085 | 1077 | baseaddr[i]); |
|---|
| .. | .. |
|---|
| 1393 | 1385 | if (inited && !tty_throttled(tty) && |
|---|
| 1394 | 1386 | MoxaPortRxQueue(p) > 0) { /* RX */ |
|---|
| 1395 | 1387 | MoxaPortReadData(p); |
|---|
| 1396 | | - tty_schedule_flip(&p->port); |
|---|
| 1388 | + tty_flip_buffer_push(&p->port); |
|---|
| 1397 | 1389 | } |
|---|
| 1398 | 1390 | } else { |
|---|
| 1399 | 1391 | clear_bit(EMPTYWAIT, &p->statusflags); |
|---|
| .. | .. |
|---|
| 1418 | 1410 | |
|---|
| 1419 | 1411 | if (tty && (intr & IntrBreak) && !I_IGNBRK(tty)) { /* BREAK */ |
|---|
| 1420 | 1412 | tty_insert_flip_char(&p->port, 0, TTY_BREAK); |
|---|
| 1421 | | - tty_schedule_flip(&p->port); |
|---|
| 1413 | + tty_flip_buffer_push(&p->port); |
|---|
| 1422 | 1414 | } |
|---|
| 1423 | 1415 | |
|---|
| 1424 | 1416 | if (intr & IntrLine) |
|---|
| .. | .. |
|---|
| 2034 | 2026 | moxafunc(port->tableAddr, FC_SetXonState, Magic_code); |
|---|
| 2035 | 2027 | } |
|---|
| 2036 | 2028 | |
|---|
| 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) |
|---|
| 2039 | 2031 | { |
|---|
| 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; |
|---|
| 2048 | 2046 | } |
|---|
| 2049 | 2047 | |
|---|
| 2050 | 2048 | |
|---|
| 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) |
|---|
| 2053 | 2051 | { |
|---|
| 2054 | | - struct serial_struct new_serial; |
|---|
| 2052 | + struct moxa_port *info = tty->driver_data; |
|---|
| 2053 | + unsigned int close_delay; |
|---|
| 2055 | 2054 | |
|---|
| 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; |
|---|
| 2058 | 2059 | |
|---|
| 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) |
|---|
| 2062 | 2063 | return -EPERM; |
|---|
| 2063 | 2064 | |
|---|
| 2065 | + close_delay = msecs_to_jiffies(ss->close_delay * 10); |
|---|
| 2066 | + |
|---|
| 2067 | + mutex_lock(&info->port.mutex); |
|---|
| 2064 | 2068 | 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); |
|---|
| 2067 | 2074 | 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; |
|---|
| 2070 | 2078 | |
|---|
| 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); |
|---|
| 2073 | 2080 | |
|---|
| 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); |
|---|
| 2077 | 2084 | return 0; |
|---|
| 2078 | 2085 | } |
|---|
| 2079 | 2086 | |
|---|