Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

esp: clean up to modern coding style

Signed-off-by: Alan Cox <alan@redhat.com>
Cc: Jiri Slaby <jirislaby@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Alan Cox and committed by
Linus Torvalds
fb100b6e 191260a0

+283 -308
+283 -308
drivers/char/esp.c
··· 8 8 * Extensively rewritten by Theodore Ts'o, 8/16/92 -- 9/14/92. Now 9 9 * much more extensible to support other serial cards based on the 10 10 * 16450/16550A UART's. Added support for the AST FourPort and the 11 - * Accent Async board. 11 + * Accent Async board. 12 12 * 13 13 * set_serial_info fixed to set the flags, custom divisor, and uart 14 14 * type fields. Fix suggested by Michael K. Johnson 12/12/92. ··· 61 61 #include <linux/bitops.h> 62 62 63 63 #include <asm/system.h> 64 - #include <asm/io.h> 64 + #include <linux/io.h> 65 65 66 66 #include <asm/dma.h> 67 67 #include <linux/slab.h> 68 - #include <asm/uaccess.h> 68 + #include <linux/uaccess.h> 69 69 70 70 #include <linux/hayesesp.h> 71 71 ··· 127 127 #undef SERIAL_DEBUG_FLOW 128 128 129 129 #if defined(MODULE) && defined(SERIAL_DEBUG_MCOUNT) 130 - #define DBG_CNT(s) printk("(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ 131 - tty->name, (info->flags), serial_driver.refcount,info->count,tty->count,s) 130 + #define DBG_CNT(s) printk(KERN_DEBUG "(%s): [%x] refc=%d, serc=%d, ttyc=%d -> %s\n", \ 131 + tty->name, info->flags, \ 132 + serial_driver.refcount, \ 133 + info->count, tty->count, s) 132 134 #else 133 135 #define DBG_CNT(s) 134 136 #endif ··· 191 189 */ 192 190 static void rs_stop(struct tty_struct *tty) 193 191 { 194 - struct esp_struct *info = (struct esp_struct *)tty->driver_data; 192 + struct esp_struct *info = tty->driver_data; 195 193 unsigned long flags; 196 194 197 195 if (serial_paranoia_check(info, tty->name, "rs_stop")) ··· 208 206 209 207 static void rs_start(struct tty_struct *tty) 210 208 { 211 - struct esp_struct *info = (struct esp_struct *)tty->driver_data; 209 + struct esp_struct *info = tty->driver_data; 212 210 unsigned long flags; 213 - 211 + 214 212 if (serial_paranoia_check(info, tty->name, "rs_start")) 215 213 return; 216 - 214 + 217 215 spin_lock_irqsave(&info->lock, flags); 218 216 if (info->xmit_cnt && info->xmit_buf && !(info->IER & UART_IER_THRI)) { 219 217 info->IER |= UART_IER_THRI; ··· 235 233 * rs_interrupt() should try to keep the interrupt handler as fast as 236 234 * possible. After you are done making modifications, it is not a bad 237 235 * idea to do: 238 - * 236 + * 239 237 * gcc -S -DKERNEL -Wall -Wstrict-prototypes -O6 -fomit-frame-pointer serial.c 240 238 * 241 239 * and look at the resulting assemble code in serial.s. ··· 292 290 } 293 291 294 292 status_mask = (info->read_status_mask >> 2) & 0x07; 295 - 293 + 296 294 for (i = 0; i < num_bytes - 1; i += 2) { 297 295 *((unsigned short *)(pio_buf->data + i)) = 298 296 inw(info->port + UART_ESI_RX); ··· 327 325 flag = TTY_BREAK; 328 326 if (info->flags & ASYNC_SAK) 329 327 do_SAK(tty); 330 - } 331 - else if (err_buf->data[i] & 0x02) 328 + } else if (err_buf->data[i] & 0x02) 332 329 flag = TTY_FRAME; 333 330 else if (err_buf->data[i] & 0x01) 334 331 flag = TTY_PARITY; ··· 342 341 release_pio_buffer(err_buf); 343 342 } 344 343 345 - static inline void receive_chars_dma(struct esp_struct *info, int num_bytes) 344 + static void program_isa_dma(int dma, int dir, unsigned long addr, int len) 346 345 { 347 346 unsigned long flags; 347 + 348 + flags = claim_dma_lock(); 349 + disable_dma(dma); 350 + clear_dma_ff(dma); 351 + set_dma_mode(dma, dir); 352 + set_dma_addr(dma, addr); 353 + set_dma_count(dma, len); 354 + enable_dma(dma); 355 + release_dma_lock(flags); 356 + } 357 + 358 + static void receive_chars_dma(struct esp_struct *info, int num_bytes) 359 + { 348 360 info->stat_flags &= ~ESP_STAT_RX_TIMEOUT; 349 361 dma_bytes = num_bytes; 350 362 info->stat_flags |= ESP_STAT_DMA_RX; 351 - 352 - flags=claim_dma_lock(); 353 - disable_dma(dma); 354 - clear_dma_ff(dma); 355 - set_dma_mode(dma, DMA_MODE_READ); 356 - set_dma_addr(dma, isa_virt_to_bus(dma_buffer)); 357 - set_dma_count(dma, dma_bytes); 358 - enable_dma(dma); 359 - release_dma_lock(flags); 360 - 361 - serial_out(info, UART_ESI_CMD1, ESI_START_DMA_RX); 363 + 364 + program_isa_dma(dma, DMA_MODE_READ, isa_virt_to_bus(dma_buffer), 365 + dma_bytes); 366 + serial_out(info, UART_ESI_CMD1, ESI_START_DMA_RX); 362 367 } 363 368 364 369 static inline void receive_chars_dma_done(struct esp_struct *info, ··· 373 366 struct tty_struct *tty = info->tty; 374 367 int num_bytes; 375 368 unsigned long flags; 376 - 377 - flags=claim_dma_lock(); 369 + 370 + flags = claim_dma_lock(); 378 371 disable_dma(dma); 379 372 clear_dma_ff(dma); 380 373 381 374 info->stat_flags &= ~ESP_STAT_DMA_RX; 382 375 num_bytes = dma_bytes - get_dma_residue(dma); 383 376 release_dma_lock(flags); 384 - 377 + 385 378 info->icount.rx += num_bytes; 386 379 387 380 if (num_bytes > 0) { 388 381 tty_insert_flip_string(tty, dma_buffer, num_bytes - 1); 389 382 390 383 status &= (0x1c & info->read_status_mask); 391 - 384 + 392 385 /* Is the status significant or do we throw the last byte ? */ 393 386 if (!(status & info->ignore_status_mask)) { 394 387 int statflag = 0; ··· 400 393 do_SAK(tty); 401 394 } else if (status & 0x08) { 402 395 statflag = TTY_FRAME; 403 - (info->icount.frame)++; 404 - } 405 - else if (status & 0x04) { 396 + info->icount.frame++; 397 + } else if (status & 0x04) { 406 398 statflag = TTY_PARITY; 407 - (info->icount.parity)++; 399 + info->icount.parity++; 408 400 } 409 - tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], statflag); 401 + tty_insert_flip_char(tty, dma_buffer[num_bytes - 1], 402 + statflag); 410 403 } 411 404 tty_schedule_flip(tty); 412 405 } ··· 491 484 /* Caller must hold info->lock */ 492 485 static inline void transmit_chars_dma(struct esp_struct *info, int num_bytes) 493 486 { 494 - unsigned long flags; 495 - 496 487 dma_bytes = num_bytes; 497 488 498 489 if (info->xmit_tail + dma_bytes <= ESP_XMIT_SIZE) { ··· 522 517 } 523 518 524 519 info->stat_flags |= ESP_STAT_DMA_TX; 525 - 526 - flags=claim_dma_lock(); 527 - disable_dma(dma); 528 - clear_dma_ff(dma); 529 - set_dma_mode(dma, DMA_MODE_WRITE); 530 - set_dma_addr(dma, isa_virt_to_bus(dma_buffer)); 531 - set_dma_count(dma, dma_bytes); 532 - enable_dma(dma); 533 - release_dma_lock(flags); 534 - 535 - serial_out(info, UART_ESI_CMD1, ESI_START_DMA_TX); 520 + 521 + program_isa_dma(dma, DMA_MODE_WRITE, isa_virt_to_bus(dma_buffer), 522 + dma_bytes); 523 + serial_out(info, UART_ESI_CMD1, ESI_START_DMA_TX); 536 524 } 537 525 538 526 static inline void transmit_chars_dma_done(struct esp_struct *info) 539 527 { 540 528 int num_bytes; 541 529 unsigned long flags; 542 - 543 530 544 - flags=claim_dma_lock(); 531 + flags = claim_dma_lock(); 545 532 disable_dma(dma); 546 533 clear_dma_ff(dma); 547 534 ··· 544 547 if (dma_bytes != num_bytes) { 545 548 dma_bytes -= num_bytes; 546 549 memmove(dma_buffer, dma_buffer + num_bytes, dma_bytes); 547 - 548 - flags=claim_dma_lock(); 549 - disable_dma(dma); 550 - clear_dma_ff(dma); 551 - set_dma_mode(dma, DMA_MODE_WRITE); 552 - set_dma_addr(dma, isa_virt_to_bus(dma_buffer)); 553 - set_dma_count(dma, dma_bytes); 554 - enable_dma(dma); 555 - release_dma_lock(flags); 556 - 557 - serial_out(info, UART_ESI_CMD1, ESI_START_DMA_TX); 550 + 551 + program_isa_dma(dma, DMA_MODE_WRITE, 552 + isa_virt_to_bus(dma_buffer), dma_bytes); 553 + 554 + serial_out(info, UART_ESI_CMD1, ESI_START_DMA_TX); 558 555 } else { 559 556 dma_bytes = 0; 560 557 info->stat_flags &= ~ESP_STAT_DMA_TX; 561 558 } 562 559 } 563 560 564 - static inline void check_modem_status(struct esp_struct *info) 561 + static void check_modem_status(struct esp_struct *info) 565 562 { 566 563 int status; 567 - 564 + 568 565 serial_out(info, UART_ESI_CMD1, ESI_GET_UART_STAT); 569 566 status = serial_in(info, UART_ESI_STAT2); 570 567 ··· 579 588 #if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR)) 580 589 printk("ttys%d CD now %s...", info->line, 581 590 (status & UART_MSR_DCD) ? "on" : "off"); 582 - #endif 591 + #endif 583 592 if (status & UART_MSR_DCD) 584 593 wake_up_interruptible(&info->open_wait); 585 594 else { ··· 596 605 */ 597 606 static irqreturn_t rs_interrupt_single(int irq, void *dev_id) 598 607 { 599 - struct esp_struct * info; 608 + struct esp_struct *info; 600 609 unsigned err_status; 601 610 unsigned int scratch; 602 611 ··· 608 617 scratch = serial_in(info, UART_ESI_SID); 609 618 610 619 spin_lock(&info->lock); 611 - 620 + 612 621 if (!info->tty) { 613 622 spin_unlock(&info->lock); 614 623 return IRQ_NONE; ··· 628 637 if (err_status & 0x80) /* Start break */ 629 638 wake_up_interruptible(&info->break_wait); 630 639 } 631 - 640 + 632 641 if ((scratch & 0x88) || /* DMA completed or timed out */ 633 642 (err_status & 0x1c) /* receive error */) { 634 643 if (info->stat_flags & ESP_STAT_DMA_RX) ··· 658 667 receive_chars_dma(info, num_bytes); 659 668 } 660 669 } 661 - 670 + 662 671 if (!(info->stat_flags & (ESP_STAT_DMA_RX | ESP_STAT_DMA_TX)) && 663 672 (scratch & 0x02) && (info->IER & UART_IER_THRI)) { 664 673 if ((info->xmit_cnt <= 0) || info->tty->stopped) { ··· 713 722 * --------------------------------------------------------------- 714 723 */ 715 724 716 - static inline void esp_basic_init(struct esp_struct * info) 725 + static void esp_basic_init(struct esp_struct *info) 717 726 { 718 727 /* put ESPC in enhanced mode */ 719 728 serial_out(info, UART_ESI_CMD1, ESI_SET_MODE); 720 - 729 + 721 730 if (info->stat_flags & ESP_STAT_NEVER_DMA) 722 731 serial_out(info, UART_ESI_CMD2, 0x01); 723 732 else ··· 774 783 serial_out(info, UART_ESI_CMD2, 0xff); 775 784 } 776 785 777 - static int startup(struct esp_struct * info) 786 + static int startup(struct esp_struct *info) 778 787 { 779 788 unsigned long flags; 780 - int retval=0; 781 - unsigned int num_chars; 789 + int retval = 0; 790 + unsigned int num_chars; 782 791 783 - spin_lock_irqsave(&info->lock, flags); 792 + spin_lock_irqsave(&info->lock, flags); 784 793 785 794 if (info->flags & ASYNC_INITIALIZED) 786 795 goto out; ··· 793 802 } 794 803 795 804 #ifdef SERIAL_DEBUG_OPEN 796 - printk("starting up ttys%d (irq %d)...", info->line, info->irq); 805 + printk(KERN_DEBUG "starting up ttys%d (irq %d)...", 806 + info->line, info->irq); 797 807 #endif 798 808 799 809 /* Flush the RX buffer. Using the ESI flush command may cause */ ··· 855 863 dma_buffer = NULL; 856 864 info->stat_flags |= ESP_STAT_USE_PIO; 857 865 } 858 - 866 + 859 867 } 860 868 861 869 info->MCR = UART_MCR_DTR | UART_MCR_RTS | UART_MCR_OUT2; ··· 864 872 serial_out(info, UART_ESI_CMD1, ESI_WRITE_UART); 865 873 serial_out(info, UART_ESI_CMD2, UART_MCR); 866 874 serial_out(info, UART_ESI_CMD2, info->MCR); 867 - 875 + 868 876 /* 869 877 * Finally, enable interrupts 870 878 */ ··· 873 881 UART_IER_DMA_TC; 874 882 serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK); 875 883 serial_out(info, UART_ESI_CMD2, info->IER); 876 - 884 + 877 885 if (info->tty) 878 886 clear_bit(TTY_IO_ERROR, &info->tty->flags); 879 887 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; ··· 892 900 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) 893 901 info->tty->alt_speed = 460800; 894 902 } 895 - 903 + 896 904 /* 897 905 * set the speed of the serial port 898 906 */ ··· 910 918 * This routine will shutdown a serial port; interrupts are disabled, and 911 919 * DTR is dropped if the hangup on close termio flag is on. 912 920 */ 913 - static void shutdown(struct esp_struct * info) 921 + static void shutdown(struct esp_struct *info) 914 922 { 915 923 unsigned long flags, f; 916 924 ··· 921 929 printk("Shutting down serial port %d (irq %d)....", info->line, 922 930 info->irq); 923 931 #endif 924 - 932 + 925 933 spin_lock_irqsave(&info->lock, flags); 926 934 /* 927 935 * clear delta_msr_wait queue to avoid mem leaks: we may free the irq ··· 933 941 /* stop a DMA transfer on the port being closed */ 934 942 /* DMA lock is higher priority always */ 935 943 if (info->stat_flags & (ESP_STAT_DMA_RX | ESP_STAT_DMA_TX)) { 936 - f=claim_dma_lock(); 944 + f = claim_dma_lock(); 937 945 disable_dma(dma); 938 946 clear_dma_ff(dma); 939 947 release_dma_lock(f); 940 - 948 + 941 949 dma_bytes = 0; 942 950 } 943 - 951 + 944 952 /* 945 953 * Free the IRQ 946 954 */ ··· 962 970 free_pages((unsigned long)dma_buffer, 963 971 get_order(DMA_BUFFER_SZ)); 964 972 dma_buffer = NULL; 965 - } 973 + } 966 974 } 967 975 968 976 if (info->xmit_buf) { ··· 984 992 985 993 if (info->tty) 986 994 set_bit(TTY_IO_ERROR, &info->tty->flags); 987 - 995 + 988 996 info->flags &= ~ASYNC_INITIALIZED; 989 997 spin_unlock_irqrestore(&info->lock, flags); 990 998 } ··· 997 1005 { 998 1006 unsigned short port; 999 1007 int quot = 0; 1000 - unsigned cflag,cval; 1008 + unsigned cflag, cval; 1001 1009 int baud, bits; 1002 1010 unsigned char flow1 = 0, flow2 = 0; 1003 1011 unsigned long flags; ··· 1006 1014 return; 1007 1015 cflag = info->tty->termios->c_cflag; 1008 1016 port = info->port; 1009 - 1017 + 1010 1018 /* byte size and parity */ 1011 1019 switch (cflag & CSIZE) { 1012 - case CS5: cval = 0x00; bits = 7; break; 1013 - case CS6: cval = 0x01; bits = 8; break; 1014 - case CS7: cval = 0x02; bits = 9; break; 1015 - case CS8: cval = 0x03; bits = 10; break; 1016 - default: cval = 0x00; bits = 7; break; 1020 + case CS5: cval = 0x00; bits = 7; break; 1021 + case CS6: cval = 0x01; bits = 8; break; 1022 + case CS7: cval = 0x02; bits = 9; break; 1023 + case CS8: cval = 0x03; bits = 10; break; 1024 + default: cval = 0x00; bits = 7; break; 1017 1025 } 1018 1026 if (cflag & CSTOPB) { 1019 1027 cval |= 0x04; ··· 1029 1037 if (cflag & CMSPAR) 1030 1038 cval |= UART_LCR_SPAR; 1031 1039 #endif 1032 - 1033 1040 baud = tty_get_baud_rate(info->tty); 1034 1041 if (baud == 38400 && 1035 - ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) 1042 + ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) 1036 1043 quot = info->custom_divisor; 1037 1044 else { 1038 - if (baud == 134) 1039 - /* Special case since 134 is really 134.5 */ 1045 + if (baud == 134) /* Special case since 134 is really 134.5 */ 1040 1046 quot = (2*BASE_BAUD / 269); 1041 1047 else if (baud) 1042 1048 quot = BASE_BAUD / baud; ··· 1042 1052 /* If the quotient is ever zero, default to 9600 bps */ 1043 1053 if (!quot) 1044 1054 quot = BASE_BAUD / 9600; 1045 - 1055 + 1056 + if (baud) { 1057 + /* Actual rate */ 1058 + baud = BASE_BAUD/quot; 1059 + tty_encode_baud_rate(info->tty, baud, baud); 1060 + } 1046 1061 info->timeout = ((1024 * HZ * bits * quot) / BASE_BAUD) + (HZ / 50); 1047 1062 1048 1063 /* CTS flow control flag and modem status interrupts */ ··· 1061 1066 info->flags &= ~ASYNC_CTS_FLOW; 1062 1067 if (cflag & CLOCAL) 1063 1068 info->flags &= ~ASYNC_CHECK_CD; 1064 - else { 1069 + else 1065 1070 info->flags |= ASYNC_CHECK_CD; 1066 - /* info->IER |= UART_IER_MSI; */ 1067 - } 1068 1071 1069 1072 /* 1070 1073 * Set up parity check flag ··· 1072 1079 info->read_status_mask |= UART_LSR_FE | UART_LSR_PE; 1073 1080 if (I_BRKINT(info->tty) || I_PARMRK(info->tty)) 1074 1081 info->read_status_mask |= UART_LSR_BI; 1075 - 1082 + 1076 1083 info->ignore_status_mask = 0; 1077 1084 #if 0 1078 1085 /* This should be safe, but for some broken bits of hardware... */ ··· 1085 1092 info->ignore_status_mask |= UART_LSR_BI; 1086 1093 info->read_status_mask |= UART_LSR_BI; 1087 1094 /* 1088 - * If we're ignore parity and break indicators, ignore 1095 + * If we're ignore parity and break indicators, ignore 1089 1096 * overruns too. (For real raw support). 1090 1097 */ 1091 1098 if (I_IGNPAR(info->tty)) { ··· 1123 1130 serial_out(info, UART_ESI_CMD2, 0x10); 1124 1131 serial_out(info, UART_ESI_CMD2, 0x21); 1125 1132 switch (cflag & CSIZE) { 1126 - case CS5: 1127 - serial_out(info, UART_ESI_CMD2, 0x1f); 1128 - break; 1129 - case CS6: 1130 - serial_out(info, UART_ESI_CMD2, 0x3f); 1131 - break; 1132 - case CS7: 1133 - case CS8: 1134 - serial_out(info, UART_ESI_CMD2, 0x7f); 1135 - break; 1136 - default: 1137 - serial_out(info, UART_ESI_CMD2, 0xff); 1138 - break; 1133 + case CS5: 1134 + serial_out(info, UART_ESI_CMD2, 0x1f); 1135 + break; 1136 + case CS6: 1137 + serial_out(info, UART_ESI_CMD2, 0x3f); 1138 + break; 1139 + case CS7: 1140 + case CS8: 1141 + serial_out(info, UART_ESI_CMD2, 0x7f); 1142 + break; 1143 + default: 1144 + serial_out(info, UART_ESI_CMD2, 0xff); 1145 + break; 1139 1146 } 1140 1147 } 1141 1148 ··· 1151 1158 1152 1159 static int rs_put_char(struct tty_struct *tty, unsigned char ch) 1153 1160 { 1154 - struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1161 + struct esp_struct *info = tty->driver_data; 1155 1162 unsigned long flags; 1156 1163 int ret = 0; 1157 1164 ··· 1174 1181 1175 1182 static void rs_flush_chars(struct tty_struct *tty) 1176 1183 { 1177 - struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1184 + struct esp_struct *info = tty->driver_data; 1178 1185 unsigned long flags; 1179 - 1186 + 1180 1187 if (serial_paranoia_check(info, tty->name, "rs_flush_chars")) 1181 1188 return; 1182 1189 ··· 1194 1201 spin_unlock_irqrestore(&info->lock, flags); 1195 1202 } 1196 1203 1197 - static int rs_write(struct tty_struct * tty, 1204 + static int rs_write(struct tty_struct *tty, 1198 1205 const unsigned char *buf, int count) 1199 1206 { 1200 1207 int c, t, ret = 0; 1201 - struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1208 + struct esp_struct *info = tty->driver_data; 1202 1209 unsigned long flags; 1203 1210 1204 1211 if (serial_paranoia_check(info, tty->name, "rs_write")) ··· 1206 1213 1207 1214 if (!info->xmit_buf) 1208 1215 return 0; 1209 - 1216 + 1210 1217 while (1) { 1211 1218 /* Thanks to R. Wolff for suggesting how to do this with */ 1212 1219 /* interrupts enabled */ 1213 1220 1214 1221 c = count; 1215 1222 t = ESP_XMIT_SIZE - info->xmit_cnt - 1; 1216 - 1223 + 1217 1224 if (t < c) 1218 1225 c = t; 1219 1226 1220 1227 t = ESP_XMIT_SIZE - info->xmit_head; 1221 - 1228 + 1222 1229 if (t < c) 1223 1230 c = t; 1224 1231 ··· 1248 1255 1249 1256 static int rs_write_room(struct tty_struct *tty) 1250 1257 { 1251 - struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1258 + struct esp_struct *info = tty->driver_data; 1252 1259 int ret; 1253 1260 unsigned long flags; 1254 - 1261 + 1255 1262 if (serial_paranoia_check(info, tty->name, "rs_write_room")) 1256 1263 return 0; 1257 1264 ··· 1266 1273 1267 1274 static int rs_chars_in_buffer(struct tty_struct *tty) 1268 1275 { 1269 - struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1270 - 1276 + struct esp_struct *info = tty->driver_data; 1277 + 1271 1278 if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer")) 1272 1279 return 0; 1273 1280 return info->xmit_cnt; ··· 1275 1282 1276 1283 static void rs_flush_buffer(struct tty_struct *tty) 1277 1284 { 1278 - struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1285 + struct esp_struct *info = tty->driver_data; 1279 1286 unsigned long flags; 1280 - 1287 + 1281 1288 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer")) 1282 1289 return; 1283 1290 spin_lock_irqsave(&info->lock, flags); ··· 1289 1296 /* 1290 1297 * ------------------------------------------------------------ 1291 1298 * rs_throttle() 1292 - * 1299 + * 1293 1300 * This routine is called by the upper-layer tty layer to signal that 1294 1301 * incoming characters should be throttled. 1295 1302 * ------------------------------------------------------------ 1296 1303 */ 1297 - static void rs_throttle(struct tty_struct * tty) 1304 + static void rs_throttle(struct tty_struct *tty) 1298 1305 { 1299 - struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1306 + struct esp_struct *info = tty->driver_data; 1300 1307 unsigned long flags; 1301 1308 #ifdef SERIAL_DEBUG_THROTTLE 1302 1309 char buf[64]; 1303 - 1310 + 1304 1311 printk("throttle %s: %d....\n", tty_name(tty, buf), 1305 - tty->ldisc.chars_in_buffer(tty)); 1312 + tty_chars_in_buffer(tty)); 1306 1313 #endif 1307 1314 1308 1315 if (serial_paranoia_check(info, tty->name, "rs_throttle")) ··· 1317 1324 spin_unlock_irqrestore(&info->lock, flags); 1318 1325 } 1319 1326 1320 - static void rs_unthrottle(struct tty_struct * tty) 1327 + static void rs_unthrottle(struct tty_struct *tty) 1321 1328 { 1322 - struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1329 + struct esp_struct *info = tty->driver_data; 1323 1330 unsigned long flags; 1324 1331 #ifdef SERIAL_DEBUG_THROTTLE 1325 1332 char buf[64]; 1326 - 1327 - printk("unthrottle %s: %d....\n", tty_name(tty, buf), 1328 - tty->ldisc.chars_in_buffer(tty)); 1333 + 1334 + printk(KERN_DEBUG "unthrottle %s: %d....\n", tty_name(tty, buf), 1335 + tty_chars_in_buffer(tty)); 1329 1336 #endif 1330 1337 1331 1338 if (serial_paranoia_check(info, tty->name, "rs_unthrottle")) 1332 1339 return; 1333 - 1340 + 1334 1341 spin_lock_irqsave(&info->lock, flags); 1335 1342 info->IER |= UART_IER_RDI; 1336 1343 serial_out(info, UART_ESI_CMD1, ESI_SET_SRV_MASK); ··· 1346 1353 * ------------------------------------------------------------ 1347 1354 */ 1348 1355 1349 - static int get_serial_info(struct esp_struct * info, 1356 + static int get_serial_info(struct esp_struct *info, 1350 1357 struct serial_struct __user *retinfo) 1351 1358 { 1352 1359 struct serial_struct tmp; 1353 - 1360 + 1354 1361 lock_kernel(); 1355 1362 memset(&tmp, 0, sizeof(tmp)); 1356 1363 tmp.type = PORT_16550A; ··· 1365 1372 tmp.custom_divisor = info->custom_divisor; 1366 1373 tmp.hub6 = 0; 1367 1374 unlock_kernel(); 1368 - if (copy_to_user(retinfo,&tmp,sizeof(*retinfo))) 1375 + if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) 1369 1376 return -EFAULT; 1370 1377 return 0; 1371 1378 } 1372 1379 1373 - static int get_esp_config(struct esp_struct * info, 1380 + static int get_esp_config(struct esp_struct *info, 1374 1381 struct hayes_esp_config __user *retinfo) 1375 1382 { 1376 1383 struct hayes_esp_config tmp; 1377 - 1384 + 1378 1385 if (!retinfo) 1379 1386 return -EFAULT; 1380 1387 ··· 1392 1399 return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0; 1393 1400 } 1394 1401 1395 - static int set_serial_info(struct esp_struct * info, 1402 + static int set_serial_info(struct esp_struct *info, 1396 1403 struct serial_struct __user *new_info) 1397 1404 { 1398 1405 struct serial_struct new_serial; ··· 1401 1408 int retval = 0; 1402 1409 struct esp_struct *current_async; 1403 1410 1404 - if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) 1411 + if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) 1405 1412 return -EFAULT; 1406 1413 old_info = *info; 1407 1414 ··· 1422 1429 return -EINVAL; 1423 1430 1424 1431 if (!capable(CAP_SYS_ADMIN)) { 1425 - if (change_irq || 1432 + if (change_irq || 1426 1433 (new_serial.close_delay != info->close_delay) || 1427 1434 ((new_serial.flags & ~ASYNC_USR_MASK) != 1428 1435 (info->flags & ~ASYNC_USR_MASK))) ··· 1507 1514 return retval; 1508 1515 } 1509 1516 1510 - static int set_esp_config(struct esp_struct * info, 1511 - struct hayes_esp_config __user * new_info) 1517 + static int set_esp_config(struct esp_struct *info, 1518 + struct hayes_esp_config __user *new_info) 1512 1519 { 1513 1520 struct hayes_esp_config new_config; 1514 1521 unsigned int change_dma; ··· 1550 1557 if (new_config.dma_channel) { 1551 1558 /* PIO mode to DMA mode transition OR */ 1552 1559 /* change current DMA channel */ 1553 - 1554 1560 current_async = ports; 1555 1561 1556 1562 while (current_async) { ··· 1558 1566 return -EBUSY; 1559 1567 } else if (current_async->count) 1560 1568 return -EBUSY; 1561 - 1562 - current_async = 1563 - current_async->next_port; 1569 + 1570 + current_async = current_async->next_port; 1564 1571 } 1565 1572 1566 1573 shutdown(info); 1567 1574 dma = new_config.dma_channel; 1568 1575 info->stat_flags &= ~ESP_STAT_NEVER_DMA; 1569 - 1570 - /* all ports must use the same DMA channel */ 1576 + 1577 + /* all ports must use the same DMA channel */ 1571 1578 1572 1579 spin_lock_irqsave(&info->lock, flags); 1573 1580 current_async = ports; ··· 1578 1587 spin_unlock_irqrestore(&info->lock, flags); 1579 1588 } else { 1580 1589 /* DMA mode to PIO mode only */ 1581 - 1582 1590 if (info->count > 1) 1583 1591 return -EBUSY; 1584 1592 ··· 1648 1658 * release the bus after transmitting. This must be done when 1649 1659 * the transmit shift register is empty, not be done when the 1650 1660 * transmit holding register is empty. This functionality 1651 - * allows an RS485 driver to be written in user space. 1661 + * allows an RS485 driver to be written in user space. 1652 1662 */ 1653 - static int get_lsr_info(struct esp_struct * info, unsigned int __user *value) 1663 + static int get_lsr_info(struct esp_struct *info, unsigned int __user *value) 1654 1664 { 1655 1665 unsigned char status; 1656 1666 unsigned int result; ··· 1661 1671 status = serial_in(info, UART_ESI_STAT1); 1662 1672 spin_unlock_irqrestore(&info->lock, flags); 1663 1673 result = ((status & UART_LSR_TEMT) ? TIOCSER_TEMT : 0); 1664 - return put_user(result,value); 1674 + return put_user(result, value); 1665 1675 } 1666 1676 1667 1677 1668 1678 static int esp_tiocmget(struct tty_struct *tty, struct file *file) 1669 1679 { 1670 - struct esp_struct * info = (struct esp_struct *)tty->driver_data; 1680 + struct esp_struct *info = tty->driver_data; 1671 1681 unsigned char control, status; 1672 1682 unsigned long flags; 1673 1683 ··· 1694 1704 static int esp_tiocmset(struct tty_struct *tty, struct file *file, 1695 1705 unsigned int set, unsigned int clear) 1696 1706 { 1697 - struct esp_struct * info = (struct esp_struct *)tty->driver_data; 1707 + struct esp_struct *info = tty->driver_data; 1698 1708 unsigned long flags; 1699 1709 1700 1710 if (serial_paranoia_check(info, tty->name, __FUNCTION__)) ··· 1727 1737 */ 1728 1738 static void esp_break(struct tty_struct *tty, int break_state) 1729 1739 { 1730 - struct esp_struct * info = (struct esp_struct *)tty->driver_data; 1740 + struct esp_struct *info = tty->driver_data; 1731 1741 unsigned long flags; 1732 - 1742 + 1733 1743 if (serial_paranoia_check(info, tty->name, "esp_break")) 1734 1744 return; 1735 1745 ··· 1749 1759 } 1750 1760 } 1751 1761 1752 - static int rs_ioctl(struct tty_struct *tty, struct file * file, 1762 + static int rs_ioctl(struct tty_struct *tty, struct file *file, 1753 1763 unsigned int cmd, unsigned long arg) 1754 1764 { 1755 - struct esp_struct * info = (struct esp_struct *)tty->driver_data; 1765 + struct esp_struct *info = tty->driver_data; 1756 1766 struct async_icount cprev, cnow; /* kernel counter temps */ 1757 1767 struct serial_icounter_struct __user *p_cuser; /* user space */ 1758 1768 void __user *argp = (void __user *)arg; ··· 1770 1780 if (tty->flags & (1 << TTY_IO_ERROR)) 1771 1781 return -EIO; 1772 1782 } 1773 - 1783 + 1774 1784 switch (cmd) { 1775 - case TIOCGSERIAL: 1776 - return get_serial_info(info, argp); 1777 - case TIOCSSERIAL: 1778 - lock_kernel(); 1779 - ret = set_serial_info(info, argp); 1780 - unlock_kernel(); 1781 - return ret; 1782 - case TIOCSERCONFIG: 1783 - /* do not reconfigure after initial configuration */ 1784 - return 0; 1785 - 1786 - case TIOCSERGWILD: 1787 - return put_user(0L, (unsigned long __user *)argp); 1788 - 1789 - case TIOCSERGETLSR: /* Get line status register */ 1790 - return get_lsr_info(info, argp); 1791 - 1792 - case TIOCSERSWILD: 1793 - if (!capable(CAP_SYS_ADMIN)) 1794 - return -EPERM; 1795 - return 0; 1796 - 1797 - /* 1798 - * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change 1799 - * - mask passed in arg for lines of interest 1800 - * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) 1801 - * Caller should use TIOCGICOUNT to see which one it was 1802 - */ 1803 - case TIOCMIWAIT: 1785 + case TIOCGSERIAL: 1786 + return get_serial_info(info, argp); 1787 + case TIOCSSERIAL: 1788 + lock_kernel(); 1789 + ret = set_serial_info(info, argp); 1790 + unlock_kernel(); 1791 + return ret; 1792 + case TIOCSERGWILD: 1793 + return put_user(0L, (unsigned long __user *)argp); 1794 + case TIOCSERGETLSR: /* Get line status register */ 1795 + return get_lsr_info(info, argp); 1796 + case TIOCSERSWILD: 1797 + if (!capable(CAP_SYS_ADMIN)) 1798 + return -EPERM; 1799 + return 0; 1800 + /* 1801 + * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change 1802 + * - mask passed in arg for lines of interest 1803 + * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) 1804 + * Caller should use TIOCGICOUNT to see which one it was 1805 + */ 1806 + case TIOCMIWAIT: 1807 + spin_lock_irqsave(&info->lock, flags); 1808 + cprev = info->icount; /* note the counters on entry */ 1809 + spin_unlock_irqrestore(&info->lock, flags); 1810 + while (1) { 1811 + /* FIXME: convert to new style wakeup */ 1812 + interruptible_sleep_on(&info->delta_msr_wait); 1813 + /* see if a signal did it */ 1814 + if (signal_pending(current)) 1815 + return -ERESTARTSYS; 1804 1816 spin_lock_irqsave(&info->lock, flags); 1805 - cprev = info->icount; /* note the counters on entry */ 1817 + cnow = info->icount; /* atomic copy */ 1806 1818 spin_unlock_irqrestore(&info->lock, flags); 1807 - while (1) { 1808 - /* FIXME: convert to new style wakeup */ 1809 - interruptible_sleep_on(&info->delta_msr_wait); 1810 - /* see if a signal did it */ 1811 - if (signal_pending(current)) 1812 - return -ERESTARTSYS; 1813 - spin_lock_irqsave(&info->lock, flags); 1814 - cnow = info->icount; /* atomic copy */ 1815 - spin_unlock_irqrestore(&info->lock, flags); 1816 - if (cnow.rng == cprev.rng && 1817 - cnow.dsr == cprev.dsr && 1818 - cnow.dcd == cprev.dcd && 1819 - cnow.cts == cprev.cts) 1820 - return -EIO; /* no change => error */ 1821 - if (((arg & TIOCM_RNG) && 1822 - (cnow.rng != cprev.rng)) || 1823 - ((arg & TIOCM_DSR) && 1824 - (cnow.dsr != cprev.dsr)) || 1825 - ((arg & TIOCM_CD) && 1826 - (cnow.dcd != cprev.dcd)) || 1827 - ((arg & TIOCM_CTS) && 1828 - (cnow.cts != cprev.cts)) ) { 1829 - return 0; 1830 - } 1831 - cprev = cnow; 1819 + if (cnow.rng == cprev.rng && 1820 + cnow.dsr == cprev.dsr && 1821 + cnow.dcd == cprev.dcd && 1822 + cnow.cts == cprev.cts) 1823 + return -EIO; /* no change => error */ 1824 + if (((arg & TIOCM_RNG) && 1825 + (cnow.rng != cprev.rng)) || 1826 + ((arg & TIOCM_DSR) && 1827 + (cnow.dsr != cprev.dsr)) || 1828 + ((arg & TIOCM_CD) && 1829 + (cnow.dcd != cprev.dcd)) || 1830 + ((arg & TIOCM_CTS) && 1831 + (cnow.cts != cprev.cts))) { 1832 + return 0; 1832 1833 } 1833 - /* NOTREACHED */ 1834 - 1835 - /* 1836 - * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 1837 - * Return: write counters to the user passed counter struct 1838 - * NB: both 1->0 and 0->1 transitions are counted except for 1839 - * RI where only 0->1 is counted. 1840 - */ 1841 - case TIOCGICOUNT: 1842 - spin_lock_irqsave(&info->lock, flags); 1843 - cnow = info->icount; 1844 - spin_unlock_irqrestore(&info->lock, flags); 1845 - p_cuser = argp; 1846 - if (put_user(cnow.cts, &p_cuser->cts) || 1847 - put_user(cnow.dsr, &p_cuser->dsr) || 1848 - put_user(cnow.rng, &p_cuser->rng) || 1849 - put_user(cnow.dcd, &p_cuser->dcd)) 1850 - return -EFAULT; 1851 - 1852 - return 0; 1853 - case TIOCGHAYESESP: 1854 - return get_esp_config(info, argp); 1855 - case TIOCSHAYESESP: 1856 - lock_kernel(); 1857 - ret = set_esp_config(info, argp); 1858 - unlock_kernel(); 1859 - return ret; 1860 - default: 1861 - return -ENOIOCTLCMD; 1834 + cprev = cnow; 1862 1835 } 1836 + /* NOTREACHED */ 1837 + /* 1838 + * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 1839 + * Return: write counters to the user passed counter struct 1840 + * NB: both 1->0 and 0->1 transitions are counted except for 1841 + * RI where only 0->1 is counted. 1842 + */ 1843 + case TIOCGICOUNT: 1844 + spin_lock_irqsave(&info->lock, flags); 1845 + cnow = info->icount; 1846 + spin_unlock_irqrestore(&info->lock, flags); 1847 + p_cuser = argp; 1848 + if (put_user(cnow.cts, &p_cuser->cts) || 1849 + put_user(cnow.dsr, &p_cuser->dsr) || 1850 + put_user(cnow.rng, &p_cuser->rng) || 1851 + put_user(cnow.dcd, &p_cuser->dcd)) 1852 + return -EFAULT; 1853 + return 0; 1854 + case TIOCGHAYESESP: 1855 + return get_esp_config(info, argp); 1856 + case TIOCSHAYESESP: 1857 + lock_kernel(); 1858 + ret = set_esp_config(info, argp); 1859 + unlock_kernel(); 1860 + return ret; 1861 + default: 1862 + return -ENOIOCTLCMD; 1863 + } 1863 1864 return 0; 1864 1865 } 1865 1866 1866 1867 static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) 1867 1868 { 1868 - struct esp_struct *info = (struct esp_struct *)tty->driver_data; 1869 + struct esp_struct *info = tty->driver_data; 1869 1870 unsigned long flags; 1870 1871 1871 1872 change_speed(info); ··· 1893 1912 /* 1894 1913 * ------------------------------------------------------------ 1895 1914 * rs_close() 1896 - * 1915 + * 1897 1916 * This routine is called when the serial port gets closed. First, we 1898 1917 * wait for the last remaining data to be sent. Then, we unlink its 1899 1918 * async structure from the interrupt chain if necessary, and we free 1900 1919 * that IRQ if nothing is left in the chain. 1901 1920 * ------------------------------------------------------------ 1902 1921 */ 1903 - static void rs_close(struct tty_struct *tty, struct file * filp) 1922 + static void rs_close(struct tty_struct *tty, struct file *filp) 1904 1923 { 1905 - struct esp_struct * info = (struct esp_struct *)tty->driver_data; 1924 + struct esp_struct *info = tty->driver_data; 1906 1925 unsigned long flags; 1907 1926 1908 1927 if (!info || serial_paranoia_check(info, tty->name, "rs_close")) 1909 1928 return; 1910 - 1929 + 1911 1930 spin_lock_irqsave(&info->lock, flags); 1912 - 1931 + 1913 1932 if (tty_hung_up_p(filp)) { 1914 1933 DBG_CNT("before DEC-hung"); 1915 1934 goto out; 1916 1935 } 1917 - 1936 + 1918 1937 #ifdef SERIAL_DEBUG_OPEN 1919 - printk("rs_close ttys%d, count = %d\n", info->line, info->count); 1938 + printk(KERN_DEBUG "rs_close ttys%d, count = %d\n", 1939 + info->line, info->count); 1920 1940 #endif 1921 - if ((tty->count == 1) && (info->count != 1)) { 1941 + if (tty->count == 1 && info->count != 1) { 1922 1942 /* 1923 1943 * Uh, oh. tty->count is 1, which means that the tty 1924 1944 * structure will be freed. Info->count should always ··· 1927 1945 * one, we've got real problems, since it means the 1928 1946 * serial port won't be shutdown. 1929 1947 */ 1930 - printk("rs_close: bad serial port count; tty->count is 1, " 1931 - "info->count is %d\n", info->count); 1948 + printk(KERN_DEBUG "rs_close: bad serial port count; tty->count is 1, info->count is %d\n", info->count); 1932 1949 info->count = 1; 1933 1950 } 1934 1951 if (--info->count < 0) { 1935 - printk("rs_close: bad serial port count for ttys%d: %d\n", 1952 + printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n", 1936 1953 info->line, info->count); 1937 1954 info->count = 0; 1938 1955 } ··· 1943 1962 1944 1963 spin_unlock_irqrestore(&info->lock, flags); 1945 1964 /* 1946 - * Now we wait for the transmit buffer to clear; and we notify 1965 + * Now we wait for the transmit buffer to clear; and we notify 1947 1966 * the line discipline to only process XON/XOFF characters. 1948 1967 */ 1949 1968 tty->closing = 1; ··· 1984 2003 info->tty = NULL; 1985 2004 1986 2005 if (info->blocked_open) { 1987 - if (info->close_delay) { 2006 + if (info->close_delay) 1988 2007 msleep_interruptible(jiffies_to_msecs(info->close_delay)); 1989 - } 1990 2008 wake_up_interruptible(&info->open_wait); 1991 2009 } 1992 2010 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); ··· 1998 2018 1999 2019 static void rs_wait_until_sent(struct tty_struct *tty, int timeout) 2000 2020 { 2001 - struct esp_struct *info = (struct esp_struct *)tty->driver_data; 2021 + struct esp_struct *info = tty->driver_data; 2002 2022 unsigned long orig_jiffies, char_time; 2003 2023 unsigned long flags; 2004 2024 ··· 2040 2060 */ 2041 2061 static void esp_hangup(struct tty_struct *tty) 2042 2062 { 2043 - struct esp_struct * info = (struct esp_struct *)tty->driver_data; 2044 - 2063 + struct esp_struct *info = tty->driver_data; 2064 + 2045 2065 if (serial_paranoia_check(info, tty->name, "esp_hangup")) 2046 2066 return; 2047 - 2067 + 2048 2068 rs_flush_buffer(tty); 2049 2069 shutdown(info); 2050 2070 info->count = 0; ··· 2058 2078 * esp_open() and friends 2059 2079 * ------------------------------------------------------------ 2060 2080 */ 2061 - static int block_til_ready(struct tty_struct *tty, struct file * filp, 2081 + static int block_til_ready(struct tty_struct *tty, struct file *filp, 2062 2082 struct esp_struct *info) 2063 2083 { 2064 2084 DECLARE_WAITQUEUE(wait, current); ··· 2107 2127 retval = 0; 2108 2128 add_wait_queue(&info->open_wait, &wait); 2109 2129 #ifdef SERIAL_DEBUG_OPEN 2110 - printk("block_til_ready before block: ttys%d, count = %d\n", 2130 + printk(KERN_DEBUG "block_til_ready before block: ttys%d, count = %d\n", 2111 2131 info->line, info->count); 2112 2132 #endif 2113 2133 spin_lock_irqsave(&info->lock, flags); 2114 - if (!tty_hung_up_p(filp)) 2134 + if (!tty_hung_up_p(filp)) 2115 2135 info->count--; 2116 2136 info->blocked_open++; 2117 2137 while (1) { ··· 2133 2153 if (info->flags & ASYNC_HUP_NOTIFY) 2134 2154 retval = -EAGAIN; 2135 2155 else 2136 - retval = -ERESTARTSYS; 2156 + retval = -ERESTARTSYS; 2137 2157 #else 2138 2158 retval = -EAGAIN; 2139 2159 #endif ··· 2152 2172 break; 2153 2173 } 2154 2174 #ifdef SERIAL_DEBUG_OPEN 2155 - printk("block_til_ready blocking: ttys%d, count = %d\n", 2175 + printk(KERN_DEBUG "block_til_ready blocking: ttys%d, count = %d\n", 2156 2176 info->line, info->count); 2157 2177 #endif 2158 2178 spin_unlock_irqrestore(&info->lock, flags); ··· 2166 2186 info->blocked_open--; 2167 2187 spin_unlock_irqrestore(&info->lock, flags); 2168 2188 #ifdef SERIAL_DEBUG_OPEN 2169 - printk("block_til_ready after blocking: ttys%d, count = %d\n", 2189 + printk(KERN_DEBUG "block_til_ready after blocking: ttys%d, count = %d\n", 2170 2190 info->line, info->count); 2171 2191 #endif 2172 2192 if (retval) 2173 2193 return retval; 2174 2194 info->flags |= ASYNC_NORMAL_ACTIVE; 2175 2195 return 0; 2176 - } 2196 + } 2177 2197 2178 2198 /* 2179 2199 * This routine is called whenever a serial port is opened. It ··· 2181 2201 * the IRQ chain. It also performs the serial-specific 2182 2202 * initialization for the tty structure. 2183 2203 */ 2184 - static int esp_open(struct tty_struct *tty, struct file * filp) 2204 + static int esp_open(struct tty_struct *tty, struct file *filp) 2185 2205 { 2186 2206 struct esp_struct *info; 2187 2207 int retval, line; ··· 2204 2224 } 2205 2225 2206 2226 #ifdef SERIAL_DEBUG_OPEN 2207 - printk("esp_open %s, count = %d\n", tty->name, info->count); 2227 + printk(KERN_DEBUG "esp_open %s, count = %d\n", tty->name, info->count); 2208 2228 #endif 2209 2229 spin_lock_irqsave(&info->lock, flags); 2210 2230 info->count++; ··· 2212 2232 info->tty = tty; 2213 2233 2214 2234 spin_unlock_irqrestore(&info->lock, flags); 2215 - 2235 + 2216 2236 /* 2217 2237 * Start up serial port 2218 2238 */ ··· 2223 2243 retval = block_til_ready(tty, filp, info); 2224 2244 if (retval) { 2225 2245 #ifdef SERIAL_DEBUG_OPEN 2226 - printk("esp_open returning after block_til_ready with %d\n", 2246 + printk(KERN_DEBUG "esp_open returning after block_til_ready with %d\n", 2227 2247 retval); 2228 2248 #endif 2229 2249 return retval; 2230 2250 } 2231 - 2232 2251 #ifdef SERIAL_DEBUG_OPEN 2233 - printk("esp_open %s successful...", tty->name); 2252 + printk(KERN_DEBUG "esp_open %s successful...", tty->name); 2234 2253 #endif 2235 2254 return 0; 2236 2255 } ··· 2247 2268 * number, and identifies which options were configured into this 2248 2269 * driver. 2249 2270 */ 2250 - 2251 - static inline void show_serial_version(void) 2271 + 2272 + static void show_serial_version(void) 2252 2273 { 2253 - printk(KERN_INFO "%s version %s (DMA %u)\n", 2274 + printk(KERN_INFO "%s version %s (DMA %u)\n", 2254 2275 serial_name, serial_version, dma); 2255 2276 } 2256 2277 ··· 2258 2279 * This routine is called by espserial_init() to initialize a specific serial 2259 2280 * port. 2260 2281 */ 2261 - static inline int autoconfig(struct esp_struct * info) 2282 + static int autoconfig(struct esp_struct *info) 2262 2283 { 2263 2284 int port_detected = 0; 2264 2285 unsigned long flags; ··· 2334 2355 static int __init espserial_init(void) 2335 2356 { 2336 2357 int i, offset; 2337 - struct esp_struct * info; 2358 + struct esp_struct *info; 2338 2359 struct esp_struct *last_primary = NULL; 2339 - int esp[] = {0x100,0x140,0x180,0x200,0x240,0x280,0x300,0x380}; 2360 + int esp[] = { 0x100, 0x140, 0x180, 0x200, 0x240, 0x280, 0x300, 0x380 }; 2340 2361 2341 2362 esp_driver = alloc_tty_driver(NR_PORTS); 2342 2363 if (!esp_driver) 2343 2364 return -ENOMEM; 2344 - 2365 + 2345 2366 for (i = 0; i < NR_PRIMARY; i++) { 2346 2367 if (irq[i] != 0) { 2347 2368 if ((irq[i] < 2) || (irq[i] > 15) || (irq[i] == 6) || ··· 2363 2384 2364 2385 if ((flow_off < 1) || (flow_off > 1023)) 2365 2386 flow_off = 1016; 2366 - 2387 + 2367 2388 if ((flow_on < 1) || (flow_on > 1023)) 2368 2389 flow_on = 944; 2369 2390 2370 2391 if ((rx_timeout < 0) || (rx_timeout > 255)) 2371 2392 rx_timeout = 128; 2372 - 2393 + 2373 2394 if (flow_on >= flow_off) 2374 2395 flow_on = flow_off - 1; 2375 2396 2376 2397 show_serial_version(); 2377 2398 2378 2399 /* Initialize the tty_driver structure */ 2379 - 2400 + 2380 2401 esp_driver->owner = THIS_MODULE; 2381 2402 esp_driver->name = "ttyP"; 2382 2403 esp_driver->major = ESP_IN_MAJOR; ··· 2386 2407 esp_driver->init_termios = tty_std_termios; 2387 2408 esp_driver->init_termios.c_cflag = 2388 2409 B9600 | CS8 | CREAD | HUPCL | CLOCAL; 2410 + esp_driver->init_termios.c_ispeed = 9600; 2411 + esp_driver->init_termios.c_ospeed = 9600; 2389 2412 esp_driver->flags = TTY_DRIVER_REAL_RAW; 2390 2413 tty_set_operations(esp_driver, &esp_ops); 2391 - if (tty_register_driver(esp_driver)) 2392 - { 2414 + if (tty_register_driver(esp_driver)) { 2393 2415 printk(KERN_ERR "Couldn't register esp serial driver"); 2394 2416 put_tty_driver(esp_driver); 2395 2417 return 1; ··· 2398 2418 2399 2419 info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL); 2400 2420 2401 - if (!info) 2402 - { 2421 + if (!info) { 2403 2422 printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n"); 2404 2423 tty_unregister_driver(esp_driver); 2405 2424 put_tty_driver(esp_driver); ··· 2461 2482 info->stat_flags |= ESP_STAT_NEVER_DMA; 2462 2483 2463 2484 info = kzalloc(sizeof(struct esp_struct), GFP_KERNEL); 2464 - if (!info) 2465 - { 2466 - printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n"); 2467 - 2485 + if (!info) { 2486 + printk(KERN_ERR "Couldn't allocate memory for esp serial device information\n"); 2468 2487 /* allow use of the already detected ports */ 2469 2488 return 0; 2470 2489 } ··· 2486 2509 return 0; 2487 2510 } 2488 2511 2489 - static void __exit espserial_exit(void) 2512 + static void __exit espserial_exit(void) 2490 2513 { 2491 2514 int e1; 2492 2515 struct esp_struct *temp_async; 2493 2516 struct esp_pio_buffer *pio_buf; 2494 2517 2495 - /* printk("Unloading %s: version %s\n", serial_name, serial_version); */ 2496 - if ((e1 = tty_unregister_driver(esp_driver))) 2497 - printk("SERIAL: failed to unregister serial driver (%d)\n", 2498 - e1); 2518 + e1 = tty_unregister_driver(esp_driver); 2519 + if (e1) 2520 + printk(KERN_ERR "esp: failed to unregister driver (%d)\n", e1); 2499 2521 put_tty_driver(esp_driver); 2500 2522 2501 2523 while (ports) { 2502 - if (ports->port) { 2524 + if (ports->port) 2503 2525 release_region(ports->port, REGION_SIZE); 2504 - } 2505 2526 temp_async = ports->next_port; 2506 2527 kfree(ports); 2507 2528 ports = temp_async;