diff options
Diffstat (limited to 'drivers/char/moxa.c')
-rw-r--r-- | drivers/char/moxa.c | 114 |
1 files changed, 30 insertions, 84 deletions
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index a369dd6877d8..f391a24a1b44 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -130,6 +130,7 @@ static moxa_isa_board_conf moxa_isa_boards[] = | |||
130 | typedef struct _moxa_pci_devinfo { | 130 | typedef struct _moxa_pci_devinfo { |
131 | ushort busNum; | 131 | ushort busNum; |
132 | ushort devNum; | 132 | ushort devNum; |
133 | struct pci_dev *pdev; | ||
133 | } moxa_pci_devinfo; | 134 | } moxa_pci_devinfo; |
134 | 135 | ||
135 | typedef struct _moxa_board_conf { | 136 | typedef struct _moxa_board_conf { |
@@ -221,7 +222,7 @@ static struct semaphore moxaBuffSem; | |||
221 | /* | 222 | /* |
222 | * static functions: | 223 | * static functions: |
223 | */ | 224 | */ |
224 | static void do_moxa_softint(void *); | 225 | static void do_moxa_softint(struct work_struct *); |
225 | static int moxa_open(struct tty_struct *, struct file *); | 226 | static int moxa_open(struct tty_struct *, struct file *); |
226 | static void moxa_close(struct tty_struct *, struct file *); | 227 | static void moxa_close(struct tty_struct *, struct file *); |
227 | static int moxa_write(struct tty_struct *, const unsigned char *, int); | 228 | static int moxa_write(struct tty_struct *, const unsigned char *, int); |
@@ -233,7 +234,7 @@ static void moxa_put_char(struct tty_struct *, unsigned char); | |||
233 | static int moxa_ioctl(struct tty_struct *, struct file *, unsigned int, unsigned long); | 234 | static int moxa_ioctl(struct tty_struct *, struct file *, unsigned int, unsigned long); |
234 | static void moxa_throttle(struct tty_struct *); | 235 | static void moxa_throttle(struct tty_struct *); |
235 | static void moxa_unthrottle(struct tty_struct *); | 236 | static void moxa_unthrottle(struct tty_struct *); |
236 | static void moxa_set_termios(struct tty_struct *, struct termios *); | 237 | static void moxa_set_termios(struct tty_struct *, struct ktermios *); |
237 | static void moxa_stop(struct tty_struct *); | 238 | static void moxa_stop(struct tty_struct *); |
238 | static void moxa_start(struct tty_struct *); | 239 | static void moxa_start(struct tty_struct *); |
239 | static void moxa_hangup(struct tty_struct *); | 240 | static void moxa_hangup(struct tty_struct *); |
@@ -260,7 +261,7 @@ static void MoxaPortEnable(int); | |||
260 | static void MoxaPortDisable(int); | 261 | static void MoxaPortDisable(int); |
261 | static long MoxaPortGetMaxBaud(int); | 262 | static long MoxaPortGetMaxBaud(int); |
262 | static long MoxaPortSetBaud(int, long); | 263 | static long MoxaPortSetBaud(int, long); |
263 | static int MoxaPortSetTermio(int, struct termios *); | 264 | static int MoxaPortSetTermio(int, struct ktermios *, speed_t); |
264 | static int MoxaPortGetLineOut(int, int *, int *); | 265 | static int MoxaPortGetLineOut(int, int *, int *); |
265 | static void MoxaPortLineCtrl(int, int, int); | 266 | static void MoxaPortLineCtrl(int, int, int); |
266 | static void MoxaPortFlowCtrl(int, int, int, int, int, int); | 267 | static void MoxaPortFlowCtrl(int, int, int, int, int, int); |
@@ -281,7 +282,7 @@ static int moxa_get_serial_info(struct moxa_str *, struct serial_struct __user * | |||
281 | static int moxa_set_serial_info(struct moxa_str *, struct serial_struct __user *); | 282 | static int moxa_set_serial_info(struct moxa_str *, struct serial_struct __user *); |
282 | static void MoxaSetFifo(int port, int enable); | 283 | static void MoxaSetFifo(int port, int enable); |
283 | 284 | ||
284 | static struct tty_operations moxa_ops = { | 285 | static const struct tty_operations moxa_ops = { |
285 | .open = moxa_open, | 286 | .open = moxa_open, |
286 | .close = moxa_close, | 287 | .close = moxa_close, |
287 | .write = moxa_write, | 288 | .write = moxa_write, |
@@ -324,6 +325,9 @@ static int moxa_get_PCI_conf(struct pci_dev *p, int board_type, moxa_board_conf | |||
324 | board->busType = MOXA_BUS_TYPE_PCI; | 325 | board->busType = MOXA_BUS_TYPE_PCI; |
325 | board->pciInfo.busNum = p->bus->number; | 326 | board->pciInfo.busNum = p->bus->number; |
326 | board->pciInfo.devNum = p->devfn >> 3; | 327 | board->pciInfo.devNum = p->devfn >> 3; |
328 | board->pciInfo.pdev = p; | ||
329 | /* don't lose the reference in the next pci_get_device iteration */ | ||
330 | pci_dev_get(p); | ||
327 | 331 | ||
328 | return (0); | 332 | return (0); |
329 | } | 333 | } |
@@ -351,6 +355,8 @@ static int __init moxa_init(void) | |||
351 | moxaDriver->init_termios.c_oflag = 0; | 355 | moxaDriver->init_termios.c_oflag = 0; |
352 | moxaDriver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL; | 356 | moxaDriver->init_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL; |
353 | moxaDriver->init_termios.c_lflag = 0; | 357 | moxaDriver->init_termios.c_lflag = 0; |
358 | moxaDriver->init_termios.c_ispeed = 9600; | ||
359 | moxaDriver->init_termios.c_ospeed = 9600; | ||
354 | moxaDriver->flags = TTY_DRIVER_REAL_RAW; | 360 | moxaDriver->flags = TTY_DRIVER_REAL_RAW; |
355 | tty_set_operations(moxaDriver, &moxa_ops); | 361 | tty_set_operations(moxaDriver, &moxa_ops); |
356 | 362 | ||
@@ -359,7 +365,7 @@ static int __init moxa_init(void) | |||
359 | for (i = 0, ch = moxaChannels; i < MAX_PORTS; i++, ch++) { | 365 | for (i = 0, ch = moxaChannels; i < MAX_PORTS; i++, ch++) { |
360 | ch->type = PORT_16550A; | 366 | ch->type = PORT_16550A; |
361 | ch->port = i; | 367 | ch->port = i; |
362 | INIT_WORK(&ch->tqueue, do_moxa_softint, ch); | 368 | INIT_WORK(&ch->tqueue, do_moxa_softint); |
363 | ch->tty = NULL; | 369 | ch->tty = NULL; |
364 | ch->close_delay = 5 * HZ / 10; | 370 | ch->close_delay = 5 * HZ / 10; |
365 | ch->closing_wait = 30 * HZ; | 371 | ch->closing_wait = 30 * HZ; |
@@ -493,6 +499,14 @@ static void __exit moxa_exit(void) | |||
493 | if (tty_unregister_driver(moxaDriver)) | 499 | if (tty_unregister_driver(moxaDriver)) |
494 | printk("Couldn't unregister MOXA Intellio family serial driver\n"); | 500 | printk("Couldn't unregister MOXA Intellio family serial driver\n"); |
495 | put_tty_driver(moxaDriver); | 501 | put_tty_driver(moxaDriver); |
502 | |||
503 | for (i = 0; i < MAX_BOARDS; i++) { | ||
504 | if (moxaBaseAddr[i]) | ||
505 | iounmap(moxaBaseAddr[i]); | ||
506 | if (moxa_boards[i].busType == MOXA_BUS_TYPE_PCI) | ||
507 | pci_dev_put(moxa_boards[i].pciInfo.pdev); | ||
508 | } | ||
509 | |||
496 | if (verbose) | 510 | if (verbose) |
497 | printk("Done\n"); | 511 | printk("Done\n"); |
498 | } | 512 | } |
@@ -500,9 +514,9 @@ static void __exit moxa_exit(void) | |||
500 | module_init(moxa_init); | 514 | module_init(moxa_init); |
501 | module_exit(moxa_exit); | 515 | module_exit(moxa_exit); |
502 | 516 | ||
503 | static void do_moxa_softint(void *private_) | 517 | static void do_moxa_softint(struct work_struct *work) |
504 | { | 518 | { |
505 | struct moxa_str *ch = (struct moxa_str *) private_; | 519 | struct moxa_str *ch = container_of(work, struct moxa_str, tqueue); |
506 | struct tty_struct *tty; | 520 | struct tty_struct *tty; |
507 | 521 | ||
508 | if (ch && (tty = ch->tty)) { | 522 | if (ch && (tty = ch->tty)) { |
@@ -852,7 +866,7 @@ static void moxa_unthrottle(struct tty_struct *tty) | |||
852 | } | 866 | } |
853 | 867 | ||
854 | static void moxa_set_termios(struct tty_struct *tty, | 868 | static void moxa_set_termios(struct tty_struct *tty, |
855 | struct termios *old_termios) | 869 | struct ktermios *old_termios) |
856 | { | 870 | { |
857 | struct moxa_str *ch = (struct moxa_str *) tty->driver_data; | 871 | struct moxa_str *ch = (struct moxa_str *) tty->driver_data; |
858 | 872 | ||
@@ -966,7 +980,7 @@ static void moxa_poll(unsigned long ignored) | |||
966 | 980 | ||
967 | static void set_tty_param(struct tty_struct *tty) | 981 | static void set_tty_param(struct tty_struct *tty) |
968 | { | 982 | { |
969 | register struct termios *ts; | 983 | register struct ktermios *ts; |
970 | struct moxa_str *ch; | 984 | struct moxa_str *ch; |
971 | int rts, cts, txflow, rxflow, xany; | 985 | int rts, cts, txflow, rxflow, xany; |
972 | 986 | ||
@@ -986,7 +1000,7 @@ static void set_tty_param(struct tty_struct *tty) | |||
986 | if (ts->c_iflag & IXANY) | 1000 | if (ts->c_iflag & IXANY) |
987 | xany = 1; | 1001 | xany = 1; |
988 | MoxaPortFlowCtrl(ch->port, rts, cts, txflow, rxflow, xany); | 1002 | MoxaPortFlowCtrl(ch->port, rts, cts, txflow, rxflow, xany); |
989 | MoxaPortSetTermio(ch->port, ts); | 1003 | MoxaPortSetTermio(ch->port, ts, tty_get_baud_rate(tty)); |
990 | } | 1004 | } |
991 | 1005 | ||
992 | static int block_till_ready(struct tty_struct *tty, struct file *filp, | 1006 | static int block_till_ready(struct tty_struct *tty, struct file *filp, |
@@ -1137,7 +1151,7 @@ static void shut_down(struct moxa_str *ch) | |||
1137 | static void receive_data(struct moxa_str *ch) | 1151 | static void receive_data(struct moxa_str *ch) |
1138 | { | 1152 | { |
1139 | struct tty_struct *tp; | 1153 | struct tty_struct *tp; |
1140 | struct termios *ts; | 1154 | struct ktermios *ts; |
1141 | unsigned long flags; | 1155 | unsigned long flags; |
1142 | 1156 | ||
1143 | ts = NULL; | 1157 | ts = NULL; |
@@ -1900,9 +1914,10 @@ int MoxaPortsOfCard(int cardno) | |||
1900 | * | 1914 | * |
1901 | * Function 12: Configure the port. | 1915 | * Function 12: Configure the port. |
1902 | * Syntax: | 1916 | * Syntax: |
1903 | * int MoxaPortSetTermio(int port, struct termios *termio); | 1917 | * int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud); |
1904 | * int port : port number (0 - 127) | 1918 | * int port : port number (0 - 127) |
1905 | * struct termios * termio : termio structure pointer | 1919 | * struct ktermios * termio : termio structure pointer |
1920 | * speed_t baud : baud rate | ||
1906 | * | 1921 | * |
1907 | * return: -1 : this port is invalid or termio == NULL | 1922 | * return: -1 : this port is invalid or termio == NULL |
1908 | * 0 : setting O.K. | 1923 | * 0 : setting O.K. |
@@ -2182,11 +2197,10 @@ long MoxaPortSetBaud(int port, long baud) | |||
2182 | return (baud); | 2197 | return (baud); |
2183 | } | 2198 | } |
2184 | 2199 | ||
2185 | int MoxaPortSetTermio(int port, struct termios *termio) | 2200 | int MoxaPortSetTermio(int port, struct ktermios *termio, speed_t baud) |
2186 | { | 2201 | { |
2187 | void __iomem *ofsAddr; | 2202 | void __iomem *ofsAddr; |
2188 | tcflag_t cflag; | 2203 | tcflag_t cflag; |
2189 | long baud; | ||
2190 | tcflag_t mode = 0; | 2204 | tcflag_t mode = 0; |
2191 | 2205 | ||
2192 | if (moxaChkPort[port] == 0 || termio == 0) | 2206 | if (moxaChkPort[port] == 0 || termio == 0) |
@@ -2222,77 +2236,9 @@ int MoxaPortSetTermio(int port, struct termios *termio) | |||
2222 | 2236 | ||
2223 | moxafunc(ofsAddr, FC_SetDataMode, (ushort) mode); | 2237 | moxafunc(ofsAddr, FC_SetDataMode, (ushort) mode); |
2224 | 2238 | ||
2225 | cflag &= (CBAUD | CBAUDEX); | ||
2226 | #ifndef B921600 | ||
2227 | #define B921600 (B460800+1) | ||
2228 | #endif | ||
2229 | switch (cflag) { | ||
2230 | case B921600: | ||
2231 | baud = 921600L; | ||
2232 | break; | ||
2233 | case B460800: | ||
2234 | baud = 460800L; | ||
2235 | break; | ||
2236 | case B230400: | ||
2237 | baud = 230400L; | ||
2238 | break; | ||
2239 | case B115200: | ||
2240 | baud = 115200L; | ||
2241 | break; | ||
2242 | case B57600: | ||
2243 | baud = 57600L; | ||
2244 | break; | ||
2245 | case B38400: | ||
2246 | baud = 38400L; | ||
2247 | break; | ||
2248 | case B19200: | ||
2249 | baud = 19200L; | ||
2250 | break; | ||
2251 | case B9600: | ||
2252 | baud = 9600L; | ||
2253 | break; | ||
2254 | case B4800: | ||
2255 | baud = 4800L; | ||
2256 | break; | ||
2257 | case B2400: | ||
2258 | baud = 2400L; | ||
2259 | break; | ||
2260 | case B1800: | ||
2261 | baud = 1800L; | ||
2262 | break; | ||
2263 | case B1200: | ||
2264 | baud = 1200L; | ||
2265 | break; | ||
2266 | case B600: | ||
2267 | baud = 600L; | ||
2268 | break; | ||
2269 | case B300: | ||
2270 | baud = 300L; | ||
2271 | break; | ||
2272 | case B200: | ||
2273 | baud = 200L; | ||
2274 | break; | ||
2275 | case B150: | ||
2276 | baud = 150L; | ||
2277 | break; | ||
2278 | case B134: | ||
2279 | baud = 134L; | ||
2280 | break; | ||
2281 | case B110: | ||
2282 | baud = 110L; | ||
2283 | break; | ||
2284 | case B75: | ||
2285 | baud = 75L; | ||
2286 | break; | ||
2287 | case B50: | ||
2288 | baud = 50L; | ||
2289 | break; | ||
2290 | default: | ||
2291 | baud = 0; | ||
2292 | } | ||
2293 | if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) || | 2239 | if ((moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_ISA) || |
2294 | (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) { | 2240 | (moxa_boards[port / MAX_PORTS_PER_BOARD].boardType == MOXA_BOARD_C320_PCI)) { |
2295 | if (baud == 921600L) | 2241 | if (baud >= 921600L) |
2296 | return (-1); | 2242 | return (-1); |
2297 | } | 2243 | } |
2298 | MoxaPortSetBaud(port, baud); | 2244 | MoxaPortSetBaud(port, baud); |