Commit 727dda800f5076ce6f4653393fab651706959c93
Committed by
Linus Torvalds
1 parent
9a9bb6fb34
Exists in
master
and in
20 other branches
[PATCH] m68knommu: fix compilation problems with 68328serial driver
Clean out the 68328serial driver: . remove use of cli/sti . fix usage of tty_* calls . remove unused variables Signed-off-by: Greg Ungerer <gerg@uclinux.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 44 additions and 58 deletions Side-by-side Diff
drivers/serial/68328serial.c
... | ... | @@ -131,17 +131,6 @@ |
131 | 131 | static int m68328_console_cbaud = DEFAULT_CBAUD; |
132 | 132 | |
133 | 133 | |
134 | -/* | |
135 | - * tmp_buf is used as a temporary buffer by serial_write. We need to | |
136 | - * lock it in case the memcpy_fromfs blocks while swapping in a page, | |
137 | - * and some other program tries to do a serial write at the same time. | |
138 | - * Since the lock will only come under contention when the system is | |
139 | - * swapping and available memory is low, it makes sense to share one | |
140 | - * buffer across all the serial ports, since it significantly saves | |
141 | - * memory if large numbers of serial ports are open. | |
142 | - */ | |
143 | -static unsigned char tmp_buf[SERIAL_XMIT_SIZE]; /* This is cheating */ | |
144 | - | |
145 | 134 | static inline int serial_paranoia_check(struct m68k_serial *info, |
146 | 135 | char *name, const char *routine) |
147 | 136 | { |
148 | 137 | |
149 | 138 | |
... | ... | @@ -211,16 +200,16 @@ |
211 | 200 | if (serial_paranoia_check(info, tty->name, "rs_stop")) |
212 | 201 | return; |
213 | 202 | |
214 | - save_flags(flags); cli(); | |
203 | + local_irq_save(flags); | |
215 | 204 | uart->ustcnt &= ~USTCNT_TXEN; |
216 | - restore_flags(flags); | |
205 | + local_irq_restore(flags); | |
217 | 206 | } |
218 | 207 | |
219 | 208 | static void rs_put_char(char ch) |
220 | 209 | { |
221 | 210 | int flags, loops = 0; |
222 | 211 | |
223 | - save_flags(flags); cli(); | |
212 | + local_irq_save(flags); | |
224 | 213 | |
225 | 214 | while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) { |
226 | 215 | loops++; |
... | ... | @@ -229,7 +218,7 @@ |
229 | 218 | |
230 | 219 | UTX_TXDATA = ch; |
231 | 220 | udelay(5); |
232 | - restore_flags(flags); | |
221 | + local_irq_restore(flags); | |
233 | 222 | } |
234 | 223 | |
235 | 224 | static void rs_start(struct tty_struct *tty) |
... | ... | @@ -241,7 +230,7 @@ |
241 | 230 | if (serial_paranoia_check(info, tty->name, "rs_start")) |
242 | 231 | return; |
243 | 232 | |
244 | - save_flags(flags); cli(); | |
233 | + local_irq_save(flags); | |
245 | 234 | if (info->xmit_cnt && info->xmit_buf && !(uart->ustcnt & USTCNT_TXEN)) { |
246 | 235 | #ifdef USE_INTS |
247 | 236 | uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK; |
... | ... | @@ -249,7 +238,7 @@ |
249 | 238 | uart->ustcnt |= USTCNT_TXEN; |
250 | 239 | #endif |
251 | 240 | } |
252 | - restore_flags(flags); | |
241 | + local_irq_restore(flags); | |
253 | 242 | } |
254 | 243 | |
255 | 244 | /* Drop into either the boot monitor or kadb upon receiving a break |
... | ... | @@ -327,14 +316,6 @@ |
327 | 316 | if(!tty) |
328 | 317 | goto clear_and_exit; |
329 | 318 | |
330 | - /* | |
331 | - * Make sure that we do not overflow the buffer | |
332 | - */ | |
333 | - if (tty_request_buffer_room(tty, 1) == 0) { | |
334 | - tty_schedule_flip(tty); | |
335 | - return; | |
336 | - } | |
337 | - | |
338 | 319 | flag = TTY_NORMAL; |
339 | 320 | |
340 | 321 | if(rx & URX_PARITY_ERROR) { |
... | ... | @@ -473,7 +454,7 @@ |
473 | 454 | return -ENOMEM; |
474 | 455 | } |
475 | 456 | |
476 | - save_flags(flags); cli(); | |
457 | + local_irq_save(flags); | |
477 | 458 | |
478 | 459 | /* |
479 | 460 | * Clear the FIFO buffers and disable them |
... | ... | @@ -506,7 +487,7 @@ |
506 | 487 | change_speed(info); |
507 | 488 | |
508 | 489 | info->flags |= S_INITIALIZED; |
509 | - restore_flags(flags); | |
490 | + local_irq_restore(flags); | |
510 | 491 | return 0; |
511 | 492 | } |
512 | 493 | |
... | ... | @@ -523,7 +504,7 @@ |
523 | 504 | if (!(info->flags & S_INITIALIZED)) |
524 | 505 | return; |
525 | 506 | |
526 | - save_flags(flags); cli(); /* Disable interrupts */ | |
507 | + local_irq_save(flags); | |
527 | 508 | |
528 | 509 | if (info->xmit_buf) { |
529 | 510 | free_page((unsigned long) info->xmit_buf); |
... | ... | @@ -534,7 +515,7 @@ |
534 | 515 | set_bit(TTY_IO_ERROR, &info->tty->flags); |
535 | 516 | |
536 | 517 | info->flags &= ~S_INITIALIZED; |
537 | - restore_flags(flags); | |
518 | + local_irq_restore(flags); | |
538 | 519 | } |
539 | 520 | |
540 | 521 | struct { |
541 | 522 | |
542 | 523 | |
543 | 524 | |
... | ... | @@ -655,24 +636,24 @@ |
655 | 636 | if (info == 0) return; |
656 | 637 | if (info->xmit_buf == 0) return; |
657 | 638 | |
658 | - save_flags(flags); cli(); | |
639 | + local_irq_save(flags); | |
659 | 640 | left = info->xmit_cnt; |
660 | 641 | while (left != 0) { |
661 | 642 | c = info->xmit_buf[info->xmit_tail]; |
662 | 643 | info->xmit_tail = (info->xmit_tail+1) & (SERIAL_XMIT_SIZE-1); |
663 | 644 | info->xmit_cnt--; |
664 | - restore_flags(flags); | |
645 | + local_irq_restore(flags); | |
665 | 646 | |
666 | 647 | rs_put_char(c); |
667 | 648 | |
668 | - save_flags(flags); cli(); | |
649 | + local_irq_save(flags); | |
669 | 650 | left = min(info->xmit_cnt, left-1); |
670 | 651 | } |
671 | 652 | |
672 | 653 | /* Last character is being transmitted now (hopefully). */ |
673 | 654 | udelay(5); |
674 | 655 | |
675 | - restore_flags(flags); | |
656 | + local_irq_restore(flags); | |
676 | 657 | return; |
677 | 658 | } |
678 | 659 | |
679 | 660 | |
... | ... | @@ -720,11 +701,11 @@ |
720 | 701 | #endif |
721 | 702 | |
722 | 703 | /* Enable transmitter */ |
723 | - save_flags(flags); cli(); | |
704 | + local_irq_save(flags); | |
724 | 705 | |
725 | 706 | if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || |
726 | 707 | !info->xmit_buf) { |
727 | - restore_flags(flags); | |
708 | + local_irq_restore(flags); | |
728 | 709 | return; |
729 | 710 | } |
730 | 711 | |
... | ... | @@ -749,7 +730,7 @@ |
749 | 730 | while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5); |
750 | 731 | } |
751 | 732 | #endif |
752 | - restore_flags(flags); | |
733 | + local_irq_restore(flags); | |
753 | 734 | } |
754 | 735 | |
755 | 736 | extern void console_printn(const char * b, int count); |
756 | 737 | |
757 | 738 | |
758 | 739 | |
759 | 740 | |
... | ... | @@ -768,18 +749,22 @@ |
768 | 749 | if (!tty || !info->xmit_buf) |
769 | 750 | return 0; |
770 | 751 | |
771 | - save_flags(flags); | |
752 | + local_save_flags(flags); | |
772 | 753 | while (1) { |
773 | - cli(); | |
754 | + local_irq_disable(); | |
774 | 755 | c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1, |
775 | 756 | SERIAL_XMIT_SIZE - info->xmit_head)); |
757 | + local_irq_restore(flags); | |
758 | + | |
776 | 759 | if (c <= 0) |
777 | 760 | break; |
778 | 761 | |
779 | 762 | memcpy(info->xmit_buf + info->xmit_head, buf, c); |
763 | + | |
764 | + local_irq_disable(); | |
780 | 765 | info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1); |
781 | 766 | info->xmit_cnt += c; |
782 | - restore_flags(flags); | |
767 | + local_irq_restore(flags); | |
783 | 768 | buf += c; |
784 | 769 | count -= c; |
785 | 770 | total += c; |
... | ... | @@ -787,7 +772,7 @@ |
787 | 772 | |
788 | 773 | if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) { |
789 | 774 | /* Enable transmitter */ |
790 | - cli(); | |
775 | + local_irq_disable(); | |
791 | 776 | #ifndef USE_INTS |
792 | 777 | while(info->xmit_cnt) { |
793 | 778 | #endif |
794 | 779 | |
... | ... | @@ -807,9 +792,9 @@ |
807 | 792 | #ifndef USE_INTS |
808 | 793 | } |
809 | 794 | #endif |
810 | - restore_flags(flags); | |
795 | + local_irq_restore(flags); | |
811 | 796 | } |
812 | - restore_flags(flags); | |
797 | + | |
813 | 798 | return total; |
814 | 799 | } |
815 | 800 | |
816 | 801 | |
817 | 802 | |
... | ... | @@ -838,12 +823,13 @@ |
838 | 823 | static void rs_flush_buffer(struct tty_struct *tty) |
839 | 824 | { |
840 | 825 | struct m68k_serial *info = (struct m68k_serial *)tty->driver_data; |
826 | + unsigned long flags; | |
841 | 827 | |
842 | 828 | if (serial_paranoia_check(info, tty->name, "rs_flush_buffer")) |
843 | 829 | return; |
844 | - cli(); | |
830 | + local_irq_save(flags); | |
845 | 831 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; |
846 | - sti(); | |
832 | + local_irq_restore(flags); | |
847 | 833 | tty_wakeup(tty); |
848 | 834 | } |
849 | 835 | |
850 | 836 | |
851 | 837 | |
... | ... | @@ -973,14 +959,15 @@ |
973 | 959 | m68328_uart *uart = &uart_addr[info->line]; |
974 | 960 | #endif |
975 | 961 | unsigned char status; |
962 | + unsigned long flags; | |
976 | 963 | |
977 | - cli(); | |
964 | + local_irq_save(flags); | |
978 | 965 | #ifdef CONFIG_SERIAL_68328_RTS_CTS |
979 | 966 | status = (uart->utx.w & UTX_CTS_STAT) ? 1 : 0; |
980 | 967 | #else |
981 | 968 | status = 0; |
982 | 969 | #endif |
983 | - sti(); | |
970 | + local_irq_restore(flags); | |
984 | 971 | put_user(status,value); |
985 | 972 | return 0; |
986 | 973 | } |
987 | 974 | |
... | ... | @@ -994,14 +981,13 @@ |
994 | 981 | unsigned long flags; |
995 | 982 | if (!info->port) |
996 | 983 | return; |
997 | - save_flags(flags); | |
998 | - cli(); | |
984 | + local_irq_save(flags); | |
999 | 985 | #ifdef USE_INTS |
1000 | 986 | uart->utx.w |= UTX_SEND_BREAK; |
1001 | 987 | msleep_interruptible(duration); |
1002 | 988 | uart->utx.w &= ~UTX_SEND_BREAK; |
1003 | 989 | #endif |
1004 | - restore_flags(flags); | |
990 | + local_irq_restore(flags); | |
1005 | 991 | } |
1006 | 992 | |
1007 | 993 | static int rs_ioctl(struct tty_struct *tty, struct file * file, |
... | ... | @@ -1060,7 +1046,7 @@ |
1060 | 1046 | (struct serial_struct *) arg); |
1061 | 1047 | case TIOCSERGETLSR: /* Get line status register */ |
1062 | 1048 | if (access_ok(VERIFY_WRITE, (void *) arg, |
1063 | - sizeof(unsigned int)); | |
1049 | + sizeof(unsigned int))) | |
1064 | 1050 | return get_lsr_info(info, (unsigned int *) arg); |
1065 | 1051 | return -EFAULT; |
1066 | 1052 | case TIOCSERGSTRUCT: |
1067 | 1053 | |
... | ... | @@ -1113,10 +1099,10 @@ |
1113 | 1099 | if (!info || serial_paranoia_check(info, tty->name, "rs_close")) |
1114 | 1100 | return; |
1115 | 1101 | |
1116 | - save_flags(flags); cli(); | |
1102 | + local_irq_save(flags); | |
1117 | 1103 | |
1118 | 1104 | if (tty_hung_up_p(filp)) { |
1119 | - restore_flags(flags); | |
1105 | + local_irq_restore(flags); | |
1120 | 1106 | return; |
1121 | 1107 | } |
1122 | 1108 | |
... | ... | @@ -1138,7 +1124,7 @@ |
1138 | 1124 | info->count = 0; |
1139 | 1125 | } |
1140 | 1126 | if (info->count) { |
1141 | - restore_flags(flags); | |
1127 | + local_irq_restore(flags); | |
1142 | 1128 | return; |
1143 | 1129 | } |
1144 | 1130 | info->flags |= S_CLOSING; |
... | ... | @@ -1186,7 +1172,7 @@ |
1186 | 1172 | } |
1187 | 1173 | info->flags &= ~(S_NORMAL_ACTIVE|S_CLOSING); |
1188 | 1174 | wake_up_interruptible(&info->close_wait); |
1189 | - restore_flags(flags); | |
1175 | + local_irq_restore(flags); | |
1190 | 1176 | } |
1191 | 1177 | |
1192 | 1178 | /* |
1193 | 1179 | |
... | ... | @@ -1262,9 +1248,9 @@ |
1262 | 1248 | info->count--; |
1263 | 1249 | info->blocked_open++; |
1264 | 1250 | while (1) { |
1265 | - cli(); | |
1251 | + local_irq_disable(); | |
1266 | 1252 | m68k_rtsdtr(info, 1); |
1267 | - sti(); | |
1253 | + local_irq_enable(); | |
1268 | 1254 | current->state = TASK_INTERRUPTIBLE; |
1269 | 1255 | if (tty_hung_up_p(filp) || |
1270 | 1256 | !(info->flags & S_INITIALIZED)) { |
... | ... | @@ -1444,7 +1430,7 @@ |
1444 | 1430 | return -ENOMEM; |
1445 | 1431 | } |
1446 | 1432 | |
1447 | - save_flags(flags); cli(); | |
1433 | + local_irq_save(flags); | |
1448 | 1434 | |
1449 | 1435 | for(i=0;i<NR_PORTS;i++) { |
1450 | 1436 | |
... | ... | @@ -1489,7 +1475,7 @@ |
1489 | 1475 | serial_pm[i]->data = info; |
1490 | 1476 | #endif |
1491 | 1477 | } |
1492 | - restore_flags(flags); | |
1478 | + local_irq_restore(flags); | |
1493 | 1479 | return 0; |
1494 | 1480 | } |
1495 | 1481 |