diff options
Diffstat (limited to 'drivers/char')
61 files changed, 3374 insertions, 2377 deletions
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 43d6ba83a191..f5be8081cd81 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -190,7 +190,7 @@ config DIGIEPCA | |||
190 | 190 | ||
191 | config ESPSERIAL | 191 | config ESPSERIAL |
192 | tristate "Hayes ESP serial port support" | 192 | tristate "Hayes ESP serial port support" |
193 | depends on SERIAL_NONSTANDARD && ISA && ISA_DMA_API | 193 | depends on SERIAL_NONSTANDARD && ISA && ISA_DMA_API && BROKEN |
194 | help | 194 | help |
195 | This is a driver which supports Hayes ESP serial ports. Both single | 195 | This is a driver which supports Hayes ESP serial ports. Both single |
196 | port cards and multiport cards are supported. Make sure to read | 196 | port cards and multiport cards are supported. Make sure to read |
@@ -443,6 +443,17 @@ config UNIX98_PTYS | |||
443 | All modern Linux systems use the Unix98 ptys. Say Y unless | 443 | All modern Linux systems use the Unix98 ptys. Say Y unless |
444 | you're on an embedded system and want to conserve memory. | 444 | you're on an embedded system and want to conserve memory. |
445 | 445 | ||
446 | config DEVPTS_MULTIPLE_INSTANCES | ||
447 | bool "Support multiple instances of devpts" | ||
448 | depends on UNIX98_PTYS | ||
449 | default n | ||
450 | ---help--- | ||
451 | Enable support for multiple instances of devpts filesystem. | ||
452 | If you want to have isolated PTY namespaces (eg: in containers), | ||
453 | say Y here. Otherwise, say N. If enabled, each mount of devpts | ||
454 | filesystem with the '-o newinstance' option will create an | ||
455 | independent PTY namespace. | ||
456 | |||
446 | config LEGACY_PTYS | 457 | config LEGACY_PTYS |
447 | bool "Legacy (BSD) PTY support" | 458 | bool "Legacy (BSD) PTY support" |
448 | default y | 459 | default y |
@@ -605,6 +616,7 @@ config HVC_ISERIES | |||
605 | default y | 616 | default y |
606 | select HVC_DRIVER | 617 | select HVC_DRIVER |
607 | select HVC_IRQ | 618 | select HVC_IRQ |
619 | select VIOPATH | ||
608 | help | 620 | help |
609 | iSeries machines support a hypervisor virtual console. | 621 | iSeries machines support a hypervisor virtual console. |
610 | 622 | ||
@@ -622,6 +634,16 @@ config HVC_BEAT | |||
622 | help | 634 | help |
623 | Toshiba's Cell Reference Set Beat Console device driver | 635 | Toshiba's Cell Reference Set Beat Console device driver |
624 | 636 | ||
637 | config HVC_IUCV | ||
638 | bool "z/VM IUCV Hypervisor console support (VM only)" | ||
639 | depends on S390 | ||
640 | select HVC_DRIVER | ||
641 | select IUCV | ||
642 | default y | ||
643 | help | ||
644 | This driver provides a Hypervisor console (HVC) back-end to access | ||
645 | a Linux (console) terminal via a z/VM IUCV communication path. | ||
646 | |||
625 | config HVC_XEN | 647 | config HVC_XEN |
626 | bool "Xen Hypervisor Console support" | 648 | bool "Xen Hypervisor Console support" |
627 | depends on XEN | 649 | depends on XEN |
@@ -631,6 +653,12 @@ config HVC_XEN | |||
631 | help | 653 | help |
632 | Xen virtual console device driver | 654 | Xen virtual console device driver |
633 | 655 | ||
656 | config HVC_UDBG | ||
657 | bool "udbg based fake hypervisor console" | ||
658 | depends on PPC && EXPERIMENTAL | ||
659 | select HVC_DRIVER | ||
660 | default n | ||
661 | |||
634 | config VIRTIO_CONSOLE | 662 | config VIRTIO_CONSOLE |
635 | tristate "Virtio console" | 663 | tristate "Virtio console" |
636 | depends on VIRTIO | 664 | depends on VIRTIO |
@@ -814,7 +842,7 @@ config JS_RTC | |||
814 | 842 | ||
815 | config GEN_RTC | 843 | config GEN_RTC |
816 | tristate "Generic /dev/rtc emulation" | 844 | tristate "Generic /dev/rtc emulation" |
817 | depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH && !AVR32 | 845 | depends on RTC!=y && !IA64 && !ARM && !M32R && !MIPS && !SPARC && !FRV && !S390 && !SUPERH && !AVR32 && !BLACKFIN |
818 | ---help--- | 846 | ---help--- |
819 | If you say Y here and create a character special file /dev/rtc with | 847 | If you say Y here and create a character special file /dev/rtc with |
820 | major number 10 and minor number 135 using mknod ("man mknod"), you | 848 | major number 10 and minor number 135 using mknod ("man mknod"), you |
diff --git a/drivers/char/Makefile b/drivers/char/Makefile index 438f71317c5c..9caf5b5ad1c0 100644 --- a/drivers/char/Makefile +++ b/drivers/char/Makefile | |||
@@ -50,6 +50,8 @@ obj-$(CONFIG_HVC_BEAT) += hvc_beat.o | |||
50 | obj-$(CONFIG_HVC_DRIVER) += hvc_console.o | 50 | obj-$(CONFIG_HVC_DRIVER) += hvc_console.o |
51 | obj-$(CONFIG_HVC_IRQ) += hvc_irq.o | 51 | obj-$(CONFIG_HVC_IRQ) += hvc_irq.o |
52 | obj-$(CONFIG_HVC_XEN) += hvc_xen.o | 52 | obj-$(CONFIG_HVC_XEN) += hvc_xen.o |
53 | obj-$(CONFIG_HVC_IUCV) += hvc_iucv.o | ||
54 | obj-$(CONFIG_HVC_UDBG) += hvc_udbg.o | ||
53 | obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o | 55 | obj-$(CONFIG_VIRTIO_CONSOLE) += virtio_console.o |
54 | obj-$(CONFIG_RAW_DRIVER) += raw.o | 56 | obj-$(CONFIG_RAW_DRIVER) += raw.o |
55 | obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o | 57 | obj-$(CONFIG_SGI_SNSC) += snsc.o snsc_event.o |
diff --git a/drivers/char/agp/intel-agp.c b/drivers/char/agp/intel-agp.c index 9cf6e9bb017e..c7714185f831 100644 --- a/drivers/char/agp/intel-agp.c +++ b/drivers/char/agp/intel-agp.c | |||
@@ -40,6 +40,8 @@ | |||
40 | #define PCI_DEVICE_ID_INTEL_Q45_IG 0x2E12 | 40 | #define PCI_DEVICE_ID_INTEL_Q45_IG 0x2E12 |
41 | #define PCI_DEVICE_ID_INTEL_G45_HB 0x2E20 | 41 | #define PCI_DEVICE_ID_INTEL_G45_HB 0x2E20 |
42 | #define PCI_DEVICE_ID_INTEL_G45_IG 0x2E22 | 42 | #define PCI_DEVICE_ID_INTEL_G45_IG 0x2E22 |
43 | #define PCI_DEVICE_ID_INTEL_G41_HB 0x2E30 | ||
44 | #define PCI_DEVICE_ID_INTEL_G41_IG 0x2E32 | ||
43 | 45 | ||
44 | /* cover 915 and 945 variants */ | 46 | /* cover 915 and 945 variants */ |
45 | #define IS_I915 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB || \ | 47 | #define IS_I915 (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_E7221_HB || \ |
@@ -63,7 +65,8 @@ | |||
63 | #define IS_G4X (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGD_E_HB || \ | 65 | #define IS_G4X (agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_IGD_E_HB || \ |
64 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q45_HB || \ | 66 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_Q45_HB || \ |
65 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G45_HB || \ | 67 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G45_HB || \ |
66 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_GM45_HB) | 68 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_GM45_HB || \ |
69 | agp_bridge->dev->device == PCI_DEVICE_ID_INTEL_G41_HB) | ||
67 | 70 | ||
68 | extern int agp_memory_reserved; | 71 | extern int agp_memory_reserved; |
69 | 72 | ||
@@ -1196,6 +1199,7 @@ static void intel_i965_get_gtt_range(int *gtt_offset, int *gtt_size) | |||
1196 | case PCI_DEVICE_ID_INTEL_IGD_E_HB: | 1199 | case PCI_DEVICE_ID_INTEL_IGD_E_HB: |
1197 | case PCI_DEVICE_ID_INTEL_Q45_HB: | 1200 | case PCI_DEVICE_ID_INTEL_Q45_HB: |
1198 | case PCI_DEVICE_ID_INTEL_G45_HB: | 1201 | case PCI_DEVICE_ID_INTEL_G45_HB: |
1202 | case PCI_DEVICE_ID_INTEL_G41_HB: | ||
1199 | *gtt_offset = *gtt_size = MB(2); | 1203 | *gtt_offset = *gtt_size = MB(2); |
1200 | break; | 1204 | break; |
1201 | default: | 1205 | default: |
@@ -2156,13 +2160,15 @@ static const struct intel_driver_description { | |||
2156 | { PCI_DEVICE_ID_INTEL_Q33_HB, PCI_DEVICE_ID_INTEL_Q33_IG, 0, "Q33", | 2160 | { PCI_DEVICE_ID_INTEL_Q33_HB, PCI_DEVICE_ID_INTEL_Q33_IG, 0, "Q33", |
2157 | NULL, &intel_g33_driver }, | 2161 | NULL, &intel_g33_driver }, |
2158 | { PCI_DEVICE_ID_INTEL_GM45_HB, PCI_DEVICE_ID_INTEL_GM45_IG, 0, | 2162 | { PCI_DEVICE_ID_INTEL_GM45_HB, PCI_DEVICE_ID_INTEL_GM45_IG, 0, |
2159 | "Mobile Intel? GM45 Express", NULL, &intel_i965_driver }, | 2163 | "Mobile Intel® GM45 Express", NULL, &intel_i965_driver }, |
2160 | { PCI_DEVICE_ID_INTEL_IGD_E_HB, PCI_DEVICE_ID_INTEL_IGD_E_IG, 0, | 2164 | { PCI_DEVICE_ID_INTEL_IGD_E_HB, PCI_DEVICE_ID_INTEL_IGD_E_IG, 0, |
2161 | "Intel Integrated Graphics Device", NULL, &intel_i965_driver }, | 2165 | "Intel Integrated Graphics Device", NULL, &intel_i965_driver }, |
2162 | { PCI_DEVICE_ID_INTEL_Q45_HB, PCI_DEVICE_ID_INTEL_Q45_IG, 0, | 2166 | { PCI_DEVICE_ID_INTEL_Q45_HB, PCI_DEVICE_ID_INTEL_Q45_IG, 0, |
2163 | "Q45/Q43", NULL, &intel_i965_driver }, | 2167 | "Q45/Q43", NULL, &intel_i965_driver }, |
2164 | { PCI_DEVICE_ID_INTEL_G45_HB, PCI_DEVICE_ID_INTEL_G45_IG, 0, | 2168 | { PCI_DEVICE_ID_INTEL_G45_HB, PCI_DEVICE_ID_INTEL_G45_IG, 0, |
2165 | "G45/G43", NULL, &intel_i965_driver }, | 2169 | "G45/G43", NULL, &intel_i965_driver }, |
2170 | { PCI_DEVICE_ID_INTEL_G41_HB, PCI_DEVICE_ID_INTEL_G41_IG, 0, | ||
2171 | "G41", NULL, &intel_i965_driver }, | ||
2166 | { 0, 0, 0, NULL, NULL, NULL } | 2172 | { 0, 0, 0, NULL, NULL, NULL } |
2167 | }; | 2173 | }; |
2168 | 2174 | ||
@@ -2360,6 +2366,7 @@ static struct pci_device_id agp_intel_pci_table[] = { | |||
2360 | ID(PCI_DEVICE_ID_INTEL_IGD_E_HB), | 2366 | ID(PCI_DEVICE_ID_INTEL_IGD_E_HB), |
2361 | ID(PCI_DEVICE_ID_INTEL_Q45_HB), | 2367 | ID(PCI_DEVICE_ID_INTEL_Q45_HB), |
2362 | ID(PCI_DEVICE_ID_INTEL_G45_HB), | 2368 | ID(PCI_DEVICE_ID_INTEL_G45_HB), |
2369 | ID(PCI_DEVICE_ID_INTEL_G41_HB), | ||
2363 | { } | 2370 | { } |
2364 | }; | 2371 | }; |
2365 | 2372 | ||
diff --git a/drivers/char/amiserial.c b/drivers/char/amiserial.c index b97aebd7aeb8..4e0cfdeab146 100644 --- a/drivers/char/amiserial.c +++ b/drivers/char/amiserial.c | |||
@@ -170,7 +170,7 @@ static __inline__ void rtsdtr_ctrl(int bits) | |||
170 | */ | 170 | */ |
171 | static void rs_stop(struct tty_struct *tty) | 171 | static void rs_stop(struct tty_struct *tty) |
172 | { | 172 | { |
173 | struct async_struct *info = (struct async_struct *)tty->driver_data; | 173 | struct async_struct *info = tty->driver_data; |
174 | unsigned long flags; | 174 | unsigned long flags; |
175 | 175 | ||
176 | if (serial_paranoia_check(info, tty->name, "rs_stop")) | 176 | if (serial_paranoia_check(info, tty->name, "rs_stop")) |
@@ -190,7 +190,7 @@ static void rs_stop(struct tty_struct *tty) | |||
190 | 190 | ||
191 | static void rs_start(struct tty_struct *tty) | 191 | static void rs_start(struct tty_struct *tty) |
192 | { | 192 | { |
193 | struct async_struct *info = (struct async_struct *)tty->driver_data; | 193 | struct async_struct *info = tty->driver_data; |
194 | unsigned long flags; | 194 | unsigned long flags; |
195 | 195 | ||
196 | if (serial_paranoia_check(info, tty->name, "rs_start")) | 196 | if (serial_paranoia_check(info, tty->name, "rs_start")) |
@@ -861,7 +861,7 @@ static int rs_put_char(struct tty_struct *tty, unsigned char ch) | |||
861 | 861 | ||
862 | static void rs_flush_chars(struct tty_struct *tty) | 862 | static void rs_flush_chars(struct tty_struct *tty) |
863 | { | 863 | { |
864 | struct async_struct *info = (struct async_struct *)tty->driver_data; | 864 | struct async_struct *info = tty->driver_data; |
865 | unsigned long flags; | 865 | unsigned long flags; |
866 | 866 | ||
867 | if (serial_paranoia_check(info, tty->name, "rs_flush_chars")) | 867 | if (serial_paranoia_check(info, tty->name, "rs_flush_chars")) |
@@ -934,7 +934,7 @@ static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count | |||
934 | 934 | ||
935 | static int rs_write_room(struct tty_struct *tty) | 935 | static int rs_write_room(struct tty_struct *tty) |
936 | { | 936 | { |
937 | struct async_struct *info = (struct async_struct *)tty->driver_data; | 937 | struct async_struct *info = tty->driver_data; |
938 | 938 | ||
939 | if (serial_paranoia_check(info, tty->name, "rs_write_room")) | 939 | if (serial_paranoia_check(info, tty->name, "rs_write_room")) |
940 | return 0; | 940 | return 0; |
@@ -943,7 +943,7 @@ static int rs_write_room(struct tty_struct *tty) | |||
943 | 943 | ||
944 | static int rs_chars_in_buffer(struct tty_struct *tty) | 944 | static int rs_chars_in_buffer(struct tty_struct *tty) |
945 | { | 945 | { |
946 | struct async_struct *info = (struct async_struct *)tty->driver_data; | 946 | struct async_struct *info = tty->driver_data; |
947 | 947 | ||
948 | if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer")) | 948 | if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer")) |
949 | return 0; | 949 | return 0; |
@@ -952,7 +952,7 @@ static int rs_chars_in_buffer(struct tty_struct *tty) | |||
952 | 952 | ||
953 | static void rs_flush_buffer(struct tty_struct *tty) | 953 | static void rs_flush_buffer(struct tty_struct *tty) |
954 | { | 954 | { |
955 | struct async_struct *info = (struct async_struct *)tty->driver_data; | 955 | struct async_struct *info = tty->driver_data; |
956 | unsigned long flags; | 956 | unsigned long flags; |
957 | 957 | ||
958 | if (serial_paranoia_check(info, tty->name, "rs_flush_buffer")) | 958 | if (serial_paranoia_check(info, tty->name, "rs_flush_buffer")) |
@@ -969,7 +969,7 @@ static void rs_flush_buffer(struct tty_struct *tty) | |||
969 | */ | 969 | */ |
970 | static void rs_send_xchar(struct tty_struct *tty, char ch) | 970 | static void rs_send_xchar(struct tty_struct *tty, char ch) |
971 | { | 971 | { |
972 | struct async_struct *info = (struct async_struct *)tty->driver_data; | 972 | struct async_struct *info = tty->driver_data; |
973 | unsigned long flags; | 973 | unsigned long flags; |
974 | 974 | ||
975 | if (serial_paranoia_check(info, tty->name, "rs_send_char")) | 975 | if (serial_paranoia_check(info, tty->name, "rs_send_char")) |
@@ -1004,7 +1004,7 @@ static void rs_send_xchar(struct tty_struct *tty, char ch) | |||
1004 | */ | 1004 | */ |
1005 | static void rs_throttle(struct tty_struct * tty) | 1005 | static void rs_throttle(struct tty_struct * tty) |
1006 | { | 1006 | { |
1007 | struct async_struct *info = (struct async_struct *)tty->driver_data; | 1007 | struct async_struct *info = tty->driver_data; |
1008 | unsigned long flags; | 1008 | unsigned long flags; |
1009 | #ifdef SERIAL_DEBUG_THROTTLE | 1009 | #ifdef SERIAL_DEBUG_THROTTLE |
1010 | char buf[64]; | 1010 | char buf[64]; |
@@ -1029,7 +1029,7 @@ static void rs_throttle(struct tty_struct * tty) | |||
1029 | 1029 | ||
1030 | static void rs_unthrottle(struct tty_struct * tty) | 1030 | static void rs_unthrottle(struct tty_struct * tty) |
1031 | { | 1031 | { |
1032 | struct async_struct *info = (struct async_struct *)tty->driver_data; | 1032 | struct async_struct *info = tty->driver_data; |
1033 | unsigned long flags; | 1033 | unsigned long flags; |
1034 | #ifdef SERIAL_DEBUG_THROTTLE | 1034 | #ifdef SERIAL_DEBUG_THROTTLE |
1035 | char buf[64]; | 1035 | char buf[64]; |
@@ -1194,7 +1194,7 @@ static int get_lsr_info(struct async_struct * info, unsigned int __user *value) | |||
1194 | 1194 | ||
1195 | static int rs_tiocmget(struct tty_struct *tty, struct file *file) | 1195 | static int rs_tiocmget(struct tty_struct *tty, struct file *file) |
1196 | { | 1196 | { |
1197 | struct async_struct * info = (struct async_struct *)tty->driver_data; | 1197 | struct async_struct * info = tty->driver_data; |
1198 | unsigned char control, status; | 1198 | unsigned char control, status; |
1199 | unsigned long flags; | 1199 | unsigned long flags; |
1200 | 1200 | ||
@@ -1217,7 +1217,7 @@ static int rs_tiocmget(struct tty_struct *tty, struct file *file) | |||
1217 | static int rs_tiocmset(struct tty_struct *tty, struct file *file, | 1217 | static int rs_tiocmset(struct tty_struct *tty, struct file *file, |
1218 | unsigned int set, unsigned int clear) | 1218 | unsigned int set, unsigned int clear) |
1219 | { | 1219 | { |
1220 | struct async_struct * info = (struct async_struct *)tty->driver_data; | 1220 | struct async_struct * info = tty->driver_data; |
1221 | unsigned long flags; | 1221 | unsigned long flags; |
1222 | 1222 | ||
1223 | if (serial_paranoia_check(info, tty->name, "rs_ioctl")) | 1223 | if (serial_paranoia_check(info, tty->name, "rs_ioctl")) |
@@ -1244,7 +1244,7 @@ static int rs_tiocmset(struct tty_struct *tty, struct file *file, | |||
1244 | */ | 1244 | */ |
1245 | static int rs_break(struct tty_struct *tty, int break_state) | 1245 | static int rs_break(struct tty_struct *tty, int break_state) |
1246 | { | 1246 | { |
1247 | struct async_struct * info = (struct async_struct *)tty->driver_data; | 1247 | struct async_struct * info = tty->driver_data; |
1248 | unsigned long flags; | 1248 | unsigned long flags; |
1249 | 1249 | ||
1250 | if (serial_paranoia_check(info, tty->name, "rs_break")) | 1250 | if (serial_paranoia_check(info, tty->name, "rs_break")) |
@@ -1264,7 +1264,7 @@ static int rs_break(struct tty_struct *tty, int break_state) | |||
1264 | static int rs_ioctl(struct tty_struct *tty, struct file * file, | 1264 | static int rs_ioctl(struct tty_struct *tty, struct file * file, |
1265 | unsigned int cmd, unsigned long arg) | 1265 | unsigned int cmd, unsigned long arg) |
1266 | { | 1266 | { |
1267 | struct async_struct * info = (struct async_struct *)tty->driver_data; | 1267 | struct async_struct * info = tty->driver_data; |
1268 | struct async_icount cprev, cnow; /* kernel counter temps */ | 1268 | struct async_icount cprev, cnow; /* kernel counter temps */ |
1269 | struct serial_icounter_struct icount; | 1269 | struct serial_icounter_struct icount; |
1270 | void __user *argp = (void __user *)arg; | 1270 | void __user *argp = (void __user *)arg; |
@@ -1368,7 +1368,7 @@ static int rs_ioctl(struct tty_struct *tty, struct file * file, | |||
1368 | 1368 | ||
1369 | static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | 1369 | static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) |
1370 | { | 1370 | { |
1371 | struct async_struct *info = (struct async_struct *)tty->driver_data; | 1371 | struct async_struct *info = tty->driver_data; |
1372 | unsigned long flags; | 1372 | unsigned long flags; |
1373 | unsigned int cflag = tty->termios->c_cflag; | 1373 | unsigned int cflag = tty->termios->c_cflag; |
1374 | 1374 | ||
@@ -1428,7 +1428,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
1428 | */ | 1428 | */ |
1429 | static void rs_close(struct tty_struct *tty, struct file * filp) | 1429 | static void rs_close(struct tty_struct *tty, struct file * filp) |
1430 | { | 1430 | { |
1431 | struct async_struct * info = (struct async_struct *)tty->driver_data; | 1431 | struct async_struct * info = tty->driver_data; |
1432 | struct serial_state *state; | 1432 | struct serial_state *state; |
1433 | unsigned long flags; | 1433 | unsigned long flags; |
1434 | 1434 | ||
@@ -1523,7 +1523,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp) | |||
1523 | */ | 1523 | */ |
1524 | static void rs_wait_until_sent(struct tty_struct *tty, int timeout) | 1524 | static void rs_wait_until_sent(struct tty_struct *tty, int timeout) |
1525 | { | 1525 | { |
1526 | struct async_struct * info = (struct async_struct *)tty->driver_data; | 1526 | struct async_struct * info = tty->driver_data; |
1527 | unsigned long orig_jiffies, char_time; | 1527 | unsigned long orig_jiffies, char_time; |
1528 | int lsr; | 1528 | int lsr; |
1529 | 1529 | ||
@@ -1587,7 +1587,7 @@ static void rs_wait_until_sent(struct tty_struct *tty, int timeout) | |||
1587 | */ | 1587 | */ |
1588 | static void rs_hangup(struct tty_struct *tty) | 1588 | static void rs_hangup(struct tty_struct *tty) |
1589 | { | 1589 | { |
1590 | struct async_struct * info = (struct async_struct *)tty->driver_data; | 1590 | struct async_struct * info = tty->driver_data; |
1591 | struct serial_state *state = info->state; | 1591 | struct serial_state *state = info->state; |
1592 | 1592 | ||
1593 | if (serial_paranoia_check(info, tty->name, "rs_hangup")) | 1593 | if (serial_paranoia_check(info, tty->name, "rs_hangup")) |
diff --git a/drivers/char/bsr.c b/drivers/char/bsr.c index 456f54db73e2..977dfb1096a0 100644 --- a/drivers/char/bsr.c +++ b/drivers/char/bsr.c | |||
@@ -60,6 +60,8 @@ struct bsr_dev { | |||
60 | unsigned bsr_num; /* bsr id number for its type */ | 60 | unsigned bsr_num; /* bsr id number for its type */ |
61 | int bsr_minor; | 61 | int bsr_minor; |
62 | 62 | ||
63 | struct list_head bsr_list; | ||
64 | |||
63 | dev_t bsr_dev; | 65 | dev_t bsr_dev; |
64 | struct cdev bsr_cdev; | 66 | struct cdev bsr_cdev; |
65 | struct device *bsr_device; | 67 | struct device *bsr_device; |
@@ -67,8 +69,8 @@ struct bsr_dev { | |||
67 | 69 | ||
68 | }; | 70 | }; |
69 | 71 | ||
70 | static unsigned num_bsr_devs; | 72 | static unsigned total_bsr_devs; |
71 | static struct bsr_dev *bsr_devs; | 73 | static struct list_head bsr_devs = LIST_HEAD_INIT(bsr_devs); |
72 | static struct class *bsr_class; | 74 | static struct class *bsr_class; |
73 | static int bsr_major; | 75 | static int bsr_major; |
74 | 76 | ||
@@ -146,24 +148,25 @@ const static struct file_operations bsr_fops = { | |||
146 | 148 | ||
147 | static void bsr_cleanup_devs(void) | 149 | static void bsr_cleanup_devs(void) |
148 | { | 150 | { |
149 | int i; | 151 | struct bsr_dev *cur, *n; |
150 | for (i=0 ; i < num_bsr_devs; i++) { | 152 | |
151 | struct bsr_dev *cur = bsr_devs + i; | 153 | list_for_each_entry_safe(cur, n, &bsr_devs, bsr_list) { |
152 | if (cur->bsr_device) { | 154 | if (cur->bsr_device) { |
153 | cdev_del(&cur->bsr_cdev); | 155 | cdev_del(&cur->bsr_cdev); |
154 | device_del(cur->bsr_device); | 156 | device_del(cur->bsr_device); |
155 | } | 157 | } |
158 | list_del(&cur->bsr_list); | ||
159 | kfree(cur); | ||
156 | } | 160 | } |
157 | |||
158 | kfree(bsr_devs); | ||
159 | } | 161 | } |
160 | 162 | ||
161 | static int bsr_create_devs(struct device_node *bn) | 163 | static int bsr_add_node(struct device_node *bn) |
162 | { | 164 | { |
163 | int bsr_stride_len, bsr_bytes_len; | 165 | int bsr_stride_len, bsr_bytes_len, num_bsr_devs; |
164 | const u32 *bsr_stride; | 166 | const u32 *bsr_stride; |
165 | const u32 *bsr_bytes; | 167 | const u32 *bsr_bytes; |
166 | unsigned i; | 168 | unsigned i; |
169 | int ret = -ENODEV; | ||
167 | 170 | ||
168 | bsr_stride = of_get_property(bn, "ibm,lock-stride", &bsr_stride_len); | 171 | bsr_stride = of_get_property(bn, "ibm,lock-stride", &bsr_stride_len); |
169 | bsr_bytes = of_get_property(bn, "ibm,#lock-bytes", &bsr_bytes_len); | 172 | bsr_bytes = of_get_property(bn, "ibm,#lock-bytes", &bsr_bytes_len); |
@@ -171,35 +174,36 @@ static int bsr_create_devs(struct device_node *bn) | |||
171 | if (!bsr_stride || !bsr_bytes || | 174 | if (!bsr_stride || !bsr_bytes || |
172 | (bsr_stride_len != bsr_bytes_len)) { | 175 | (bsr_stride_len != bsr_bytes_len)) { |
173 | printk(KERN_ERR "bsr of-node has missing/incorrect property\n"); | 176 | printk(KERN_ERR "bsr of-node has missing/incorrect property\n"); |
174 | return -ENODEV; | 177 | return ret; |
175 | } | 178 | } |
176 | 179 | ||
177 | num_bsr_devs = bsr_bytes_len / sizeof(u32); | 180 | num_bsr_devs = bsr_bytes_len / sizeof(u32); |
178 | 181 | ||
179 | /* only a warning, its informational since we'll fail and exit */ | ||
180 | WARN_ON(num_bsr_devs > BSR_MAX_DEVS); | ||
181 | |||
182 | bsr_devs = kzalloc(sizeof(struct bsr_dev) * num_bsr_devs, GFP_KERNEL); | ||
183 | if (!bsr_devs) | ||
184 | return -ENOMEM; | ||
185 | |||
186 | for (i = 0 ; i < num_bsr_devs; i++) { | 182 | for (i = 0 ; i < num_bsr_devs; i++) { |
187 | struct bsr_dev *cur = bsr_devs + i; | 183 | struct bsr_dev *cur = kzalloc(sizeof(struct bsr_dev), |
184 | GFP_KERNEL); | ||
188 | struct resource res; | 185 | struct resource res; |
189 | int result; | 186 | int result; |
190 | 187 | ||
188 | if (!cur) { | ||
189 | printk(KERN_ERR "Unable to alloc bsr dev\n"); | ||
190 | ret = -ENOMEM; | ||
191 | goto out_err; | ||
192 | } | ||
193 | |||
191 | result = of_address_to_resource(bn, i, &res); | 194 | result = of_address_to_resource(bn, i, &res); |
192 | if (result < 0) { | 195 | if (result < 0) { |
193 | printk(KERN_ERR "bsr of-node has invalid reg property\n"); | 196 | printk(KERN_ERR "bsr of-node has invalid reg property, skipping\n"); |
194 | goto out_err; | 197 | kfree(cur); |
198 | continue; | ||
195 | } | 199 | } |
196 | 200 | ||
197 | cur->bsr_minor = i; | 201 | cur->bsr_minor = i + total_bsr_devs; |
198 | cur->bsr_addr = res.start; | 202 | cur->bsr_addr = res.start; |
199 | cur->bsr_len = res.end - res.start + 1; | 203 | cur->bsr_len = res.end - res.start + 1; |
200 | cur->bsr_bytes = bsr_bytes[i]; | 204 | cur->bsr_bytes = bsr_bytes[i]; |
201 | cur->bsr_stride = bsr_stride[i]; | 205 | cur->bsr_stride = bsr_stride[i]; |
202 | cur->bsr_dev = MKDEV(bsr_major, i); | 206 | cur->bsr_dev = MKDEV(bsr_major, i + total_bsr_devs); |
203 | 207 | ||
204 | switch(cur->bsr_bytes) { | 208 | switch(cur->bsr_bytes) { |
205 | case 8: | 209 | case 8: |
@@ -220,14 +224,15 @@ static int bsr_create_devs(struct device_node *bn) | |||
220 | } | 224 | } |
221 | 225 | ||
222 | cur->bsr_num = bsr_types[cur->bsr_type]; | 226 | cur->bsr_num = bsr_types[cur->bsr_type]; |
223 | bsr_types[cur->bsr_type] = cur->bsr_num + 1; | ||
224 | snprintf(cur->bsr_name, 32, "bsr%d_%d", | 227 | snprintf(cur->bsr_name, 32, "bsr%d_%d", |
225 | cur->bsr_bytes, cur->bsr_num); | 228 | cur->bsr_bytes, cur->bsr_num); |
226 | 229 | ||
227 | cdev_init(&cur->bsr_cdev, &bsr_fops); | 230 | cdev_init(&cur->bsr_cdev, &bsr_fops); |
228 | result = cdev_add(&cur->bsr_cdev, cur->bsr_dev, 1); | 231 | result = cdev_add(&cur->bsr_cdev, cur->bsr_dev, 1); |
229 | if (result) | 232 | if (result) { |
233 | kfree(cur); | ||
230 | goto out_err; | 234 | goto out_err; |
235 | } | ||
231 | 236 | ||
232 | cur->bsr_device = device_create(bsr_class, NULL, cur->bsr_dev, | 237 | cur->bsr_device = device_create(bsr_class, NULL, cur->bsr_dev, |
233 | cur, cur->bsr_name); | 238 | cur, cur->bsr_name); |
@@ -235,16 +240,37 @@ static int bsr_create_devs(struct device_node *bn) | |||
235 | printk(KERN_ERR "device_create failed for %s\n", | 240 | printk(KERN_ERR "device_create failed for %s\n", |
236 | cur->bsr_name); | 241 | cur->bsr_name); |
237 | cdev_del(&cur->bsr_cdev); | 242 | cdev_del(&cur->bsr_cdev); |
243 | kfree(cur); | ||
238 | goto out_err; | 244 | goto out_err; |
239 | } | 245 | } |
246 | |||
247 | bsr_types[cur->bsr_type] = cur->bsr_num + 1; | ||
248 | list_add_tail(&cur->bsr_list, &bsr_devs); | ||
240 | } | 249 | } |
241 | 250 | ||
251 | total_bsr_devs += num_bsr_devs; | ||
252 | |||
242 | return 0; | 253 | return 0; |
243 | 254 | ||
244 | out_err: | 255 | out_err: |
245 | 256 | ||
246 | bsr_cleanup_devs(); | 257 | bsr_cleanup_devs(); |
247 | return -ENODEV; | 258 | return ret; |
259 | } | ||
260 | |||
261 | static int bsr_create_devs(struct device_node *bn) | ||
262 | { | ||
263 | int ret; | ||
264 | |||
265 | while (bn) { | ||
266 | ret = bsr_add_node(bn); | ||
267 | if (ret) { | ||
268 | of_node_put(bn); | ||
269 | return ret; | ||
270 | } | ||
271 | bn = of_find_compatible_node(bn, NULL, "ibm,bsr"); | ||
272 | } | ||
273 | return 0; | ||
248 | } | 274 | } |
249 | 275 | ||
250 | static int __init bsr_init(void) | 276 | static int __init bsr_init(void) |
@@ -254,7 +280,7 @@ static int __init bsr_init(void) | |||
254 | int ret = -ENODEV; | 280 | int ret = -ENODEV; |
255 | int result; | 281 | int result; |
256 | 282 | ||
257 | np = of_find_compatible_node(NULL, "ibm,bsr", "ibm,bsr"); | 283 | np = of_find_compatible_node(NULL, NULL, "ibm,bsr"); |
258 | if (!np) | 284 | if (!np) |
259 | goto out_err; | 285 | goto out_err; |
260 | 286 | ||
@@ -272,10 +298,10 @@ static int __init bsr_init(void) | |||
272 | goto out_err_2; | 298 | goto out_err_2; |
273 | } | 299 | } |
274 | 300 | ||
275 | if ((ret = bsr_create_devs(np)) < 0) | 301 | if ((ret = bsr_create_devs(np)) < 0) { |
302 | np = NULL; | ||
276 | goto out_err_3; | 303 | goto out_err_3; |
277 | 304 | } | |
278 | of_node_put(np); | ||
279 | 305 | ||
280 | return 0; | 306 | return 0; |
281 | 307 | ||
diff --git a/drivers/char/consolemap.c b/drivers/char/consolemap.c index 4246b8e36cb3..45d3e80156d4 100644 --- a/drivers/char/consolemap.c +++ b/drivers/char/consolemap.c | |||
@@ -554,7 +554,7 @@ int con_set_unimap(struct vc_data *vc, ushort ct, struct unipair __user *list) | |||
554 | __get_user(fontpos, &list->fontpos); | 554 | __get_user(fontpos, &list->fontpos); |
555 | if ((err1 = con_insert_unipair(p, unicode,fontpos)) != 0) | 555 | if ((err1 = con_insert_unipair(p, unicode,fontpos)) != 0) |
556 | err = err1; | 556 | err = err1; |
557 | list++; | 557 | list++; |
558 | } | 558 | } |
559 | 559 | ||
560 | if (con_unify_unimap(vc, p)) | 560 | if (con_unify_unimap(vc, p)) |
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index 5e5b1dc1a0a7..6a59f72a9c21 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c | |||
@@ -5010,7 +5010,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev, | |||
5010 | if (nchan == 0) { | 5010 | if (nchan == 0) { |
5011 | dev_err(&pdev->dev, "Cyclom-Y PCI host card with no " | 5011 | dev_err(&pdev->dev, "Cyclom-Y PCI host card with no " |
5012 | "Serial-Modules\n"); | 5012 | "Serial-Modules\n"); |
5013 | return -EIO; | 5013 | goto err_unmap; |
5014 | } | 5014 | } |
5015 | } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Hi) { | 5015 | } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Hi) { |
5016 | struct RUNTIME_9060 __iomem *ctl_addr; | 5016 | struct RUNTIME_9060 __iomem *ctl_addr; |
diff --git a/drivers/char/ds1620.c b/drivers/char/ds1620.c index 74e9cd81b5b2..61f0146e215d 100644 --- a/drivers/char/ds1620.c +++ b/drivers/char/ds1620.c | |||
@@ -43,52 +43,51 @@ static const char *fan_state[] = { "off", "on", "on (hardwired)" }; | |||
43 | * chance that the WaveArtist driver could touch these bits to | 43 | * chance that the WaveArtist driver could touch these bits to |
44 | * enable or disable the speaker. | 44 | * enable or disable the speaker. |
45 | */ | 45 | */ |
46 | extern spinlock_t gpio_lock; | ||
47 | extern unsigned int system_rev; | 46 | extern unsigned int system_rev; |
48 | 47 | ||
49 | static inline void netwinder_ds1620_set_clk(int clk) | 48 | static inline void netwinder_ds1620_set_clk(int clk) |
50 | { | 49 | { |
51 | gpio_modify_op(GPIO_DSCLK, clk ? GPIO_DSCLK : 0); | 50 | nw_gpio_modify_op(GPIO_DSCLK, clk ? GPIO_DSCLK : 0); |
52 | } | 51 | } |
53 | 52 | ||
54 | static inline void netwinder_ds1620_set_data(int dat) | 53 | static inline void netwinder_ds1620_set_data(int dat) |
55 | { | 54 | { |
56 | gpio_modify_op(GPIO_DATA, dat ? GPIO_DATA : 0); | 55 | nw_gpio_modify_op(GPIO_DATA, dat ? GPIO_DATA : 0); |
57 | } | 56 | } |
58 | 57 | ||
59 | static inline int netwinder_ds1620_get_data(void) | 58 | static inline int netwinder_ds1620_get_data(void) |
60 | { | 59 | { |
61 | return gpio_read() & GPIO_DATA; | 60 | return nw_gpio_read() & GPIO_DATA; |
62 | } | 61 | } |
63 | 62 | ||
64 | static inline void netwinder_ds1620_set_data_dir(int dir) | 63 | static inline void netwinder_ds1620_set_data_dir(int dir) |
65 | { | 64 | { |
66 | gpio_modify_io(GPIO_DATA, dir ? GPIO_DATA : 0); | 65 | nw_gpio_modify_io(GPIO_DATA, dir ? GPIO_DATA : 0); |
67 | } | 66 | } |
68 | 67 | ||
69 | static inline void netwinder_ds1620_reset(void) | 68 | static inline void netwinder_ds1620_reset(void) |
70 | { | 69 | { |
71 | cpld_modify(CPLD_DS_ENABLE, 0); | 70 | nw_cpld_modify(CPLD_DS_ENABLE, 0); |
72 | cpld_modify(CPLD_DS_ENABLE, CPLD_DS_ENABLE); | 71 | nw_cpld_modify(CPLD_DS_ENABLE, CPLD_DS_ENABLE); |
73 | } | 72 | } |
74 | 73 | ||
75 | static inline void netwinder_lock(unsigned long *flags) | 74 | static inline void netwinder_lock(unsigned long *flags) |
76 | { | 75 | { |
77 | spin_lock_irqsave(&gpio_lock, *flags); | 76 | spin_lock_irqsave(&nw_gpio_lock, *flags); |
78 | } | 77 | } |
79 | 78 | ||
80 | static inline void netwinder_unlock(unsigned long *flags) | 79 | static inline void netwinder_unlock(unsigned long *flags) |
81 | { | 80 | { |
82 | spin_unlock_irqrestore(&gpio_lock, *flags); | 81 | spin_unlock_irqrestore(&nw_gpio_lock, *flags); |
83 | } | 82 | } |
84 | 83 | ||
85 | static inline void netwinder_set_fan(int i) | 84 | static inline void netwinder_set_fan(int i) |
86 | { | 85 | { |
87 | unsigned long flags; | 86 | unsigned long flags; |
88 | 87 | ||
89 | spin_lock_irqsave(&gpio_lock, flags); | 88 | spin_lock_irqsave(&nw_gpio_lock, flags); |
90 | gpio_modify_op(GPIO_FAN, i ? GPIO_FAN : 0); | 89 | nw_gpio_modify_op(GPIO_FAN, i ? GPIO_FAN : 0); |
91 | spin_unlock_irqrestore(&gpio_lock, flags); | 90 | spin_unlock_irqrestore(&nw_gpio_lock, flags); |
92 | } | 91 | } |
93 | 92 | ||
94 | static inline int netwinder_get_fan(void) | 93 | static inline int netwinder_get_fan(void) |
@@ -96,7 +95,7 @@ static inline int netwinder_get_fan(void) | |||
96 | if ((system_rev & 0xf000) == 0x4000) | 95 | if ((system_rev & 0xf000) == 0x4000) |
97 | return FAN_ALWAYS_ON; | 96 | return FAN_ALWAYS_ON; |
98 | 97 | ||
99 | return (gpio_read() & GPIO_FAN) ? FAN_ON : FAN_OFF; | 98 | return (nw_gpio_read() & GPIO_FAN) ? FAN_ON : FAN_OFF; |
100 | } | 99 | } |
101 | 100 | ||
102 | /* | 101 | /* |
diff --git a/drivers/char/epca.c b/drivers/char/epca.c index cf2461d34e5f..af7c13ca9493 100644 --- a/drivers/char/epca.c +++ b/drivers/char/epca.c | |||
@@ -69,7 +69,9 @@ static int invalid_lilo_config; | |||
69 | 69 | ||
70 | /* | 70 | /* |
71 | * The ISA boards do window flipping into the same spaces so its only sane with | 71 | * The ISA boards do window flipping into the same spaces so its only sane with |
72 | * a single lock. It's still pretty efficient. | 72 | * a single lock. It's still pretty efficient. This lock guards the hardware |
73 | * and the tty_port lock guards the kernel side stuff like use counts. Take | ||
74 | * this lock inside the port lock if you must take both. | ||
73 | */ | 75 | */ |
74 | static DEFINE_SPINLOCK(epca_lock); | 76 | static DEFINE_SPINLOCK(epca_lock); |
75 | 77 | ||
@@ -156,14 +158,12 @@ static struct channel *verifyChannel(struct tty_struct *); | |||
156 | static void pc_sched_event(struct channel *, int); | 158 | static void pc_sched_event(struct channel *, int); |
157 | static void epca_error(int, char *); | 159 | static void epca_error(int, char *); |
158 | static void pc_close(struct tty_struct *, struct file *); | 160 | static void pc_close(struct tty_struct *, struct file *); |
159 | static void shutdown(struct channel *); | 161 | static void shutdown(struct channel *, struct tty_struct *tty); |
160 | static void pc_hangup(struct tty_struct *); | 162 | static void pc_hangup(struct tty_struct *); |
161 | static int pc_write_room(struct tty_struct *); | 163 | static int pc_write_room(struct tty_struct *); |
162 | static int pc_chars_in_buffer(struct tty_struct *); | 164 | static int pc_chars_in_buffer(struct tty_struct *); |
163 | static void pc_flush_buffer(struct tty_struct *); | 165 | static void pc_flush_buffer(struct tty_struct *); |
164 | static void pc_flush_chars(struct tty_struct *); | 166 | static void pc_flush_chars(struct tty_struct *); |
165 | static int block_til_ready(struct tty_struct *, struct file *, | ||
166 | struct channel *); | ||
167 | static int pc_open(struct tty_struct *, struct file *); | 167 | static int pc_open(struct tty_struct *, struct file *); |
168 | static void post_fep_init(unsigned int crd); | 168 | static void post_fep_init(unsigned int crd); |
169 | static void epcapoll(unsigned long); | 169 | static void epcapoll(unsigned long); |
@@ -173,7 +173,7 @@ static unsigned termios2digi_h(struct channel *ch, unsigned); | |||
173 | static unsigned termios2digi_i(struct channel *ch, unsigned); | 173 | static unsigned termios2digi_i(struct channel *ch, unsigned); |
174 | static unsigned termios2digi_c(struct channel *ch, unsigned); | 174 | static unsigned termios2digi_c(struct channel *ch, unsigned); |
175 | static void epcaparam(struct tty_struct *, struct channel *); | 175 | static void epcaparam(struct tty_struct *, struct channel *); |
176 | static void receive_data(struct channel *); | 176 | static void receive_data(struct channel *, struct tty_struct *tty); |
177 | static int pc_ioctl(struct tty_struct *, struct file *, | 177 | static int pc_ioctl(struct tty_struct *, struct file *, |
178 | unsigned int, unsigned long); | 178 | unsigned int, unsigned long); |
179 | static int info_ioctl(struct tty_struct *, struct file *, | 179 | static int info_ioctl(struct tty_struct *, struct file *, |
@@ -392,7 +392,7 @@ static struct channel *verifyChannel(struct tty_struct *tty) | |||
392 | * through tty->driver_data this should catch it. | 392 | * through tty->driver_data this should catch it. |
393 | */ | 393 | */ |
394 | if (tty) { | 394 | if (tty) { |
395 | struct channel *ch = (struct channel *)tty->driver_data; | 395 | struct channel *ch = tty->driver_data; |
396 | if (ch >= &digi_channels[0] && ch < &digi_channels[nbdevs]) { | 396 | if (ch >= &digi_channels[0] && ch < &digi_channels[nbdevs]) { |
397 | if (ch->magic == EPCA_MAGIC) | 397 | if (ch->magic == EPCA_MAGIC) |
398 | return ch; | 398 | return ch; |
@@ -419,76 +419,34 @@ static void epca_error(int line, char *msg) | |||
419 | static void pc_close(struct tty_struct *tty, struct file *filp) | 419 | static void pc_close(struct tty_struct *tty, struct file *filp) |
420 | { | 420 | { |
421 | struct channel *ch; | 421 | struct channel *ch; |
422 | unsigned long flags; | 422 | struct tty_port *port; |
423 | /* | 423 | /* |
424 | * verifyChannel returns the channel from the tty struct if it is | 424 | * verifyChannel returns the channel from the tty struct if it is |
425 | * valid. This serves as a sanity check. | 425 | * valid. This serves as a sanity check. |
426 | */ | 426 | */ |
427 | ch = verifyChannel(tty); | 427 | ch = verifyChannel(tty); |
428 | if (ch != NULL) { | 428 | if (ch == NULL) |
429 | spin_lock_irqsave(&epca_lock, flags); | 429 | return; |
430 | if (tty_hung_up_p(filp)) { | 430 | port = &ch->port; |
431 | spin_unlock_irqrestore(&epca_lock, flags); | ||
432 | return; | ||
433 | } | ||
434 | if (ch->port.count-- > 1) { | ||
435 | /* Begin channel is open more than once */ | ||
436 | /* | ||
437 | * Return without doing anything. Someone might still | ||
438 | * be using the channel. | ||
439 | */ | ||
440 | spin_unlock_irqrestore(&epca_lock, flags); | ||
441 | return; | ||
442 | } | ||
443 | /* Port open only once go ahead with shutdown & reset */ | ||
444 | BUG_ON(ch->port.count < 0); | ||
445 | |||
446 | /* | ||
447 | * Let the rest of the driver know the channel is being closed. | ||
448 | * This becomes important if an open is attempted before close | ||
449 | * is finished. | ||
450 | */ | ||
451 | ch->port.flags |= ASYNC_CLOSING; | ||
452 | tty->closing = 1; | ||
453 | |||
454 | spin_unlock_irqrestore(&epca_lock, flags); | ||
455 | |||
456 | if (ch->port.flags & ASYNC_INITIALIZED) { | ||
457 | /* Setup an event to indicate when the | ||
458 | transmit buffer empties */ | ||
459 | setup_empty_event(tty, ch); | ||
460 | /* 30 seconds timeout */ | ||
461 | tty_wait_until_sent(tty, 3000); | ||
462 | } | ||
463 | pc_flush_buffer(tty); | ||
464 | 431 | ||
465 | tty_ldisc_flush(tty); | 432 | if (tty_port_close_start(port, tty, filp) == 0) |
466 | shutdown(ch); | 433 | return; |
467 | 434 | ||
468 | spin_lock_irqsave(&epca_lock, flags); | 435 | pc_flush_buffer(tty); |
469 | tty->closing = 0; | 436 | shutdown(ch, tty); |
470 | ch->event = 0; | ||
471 | ch->port.tty = NULL; | ||
472 | spin_unlock_irqrestore(&epca_lock, flags); | ||
473 | 437 | ||
474 | if (ch->port.blocked_open) { | 438 | tty_port_close_end(port, tty); |
475 | if (ch->close_delay) | 439 | ch->event = 0; /* FIXME: review ch->event locking */ |
476 | msleep_interruptible(jiffies_to_msecs(ch->close_delay)); | 440 | tty_port_tty_set(port, NULL); |
477 | wake_up_interruptible(&ch->port.open_wait); | ||
478 | } | ||
479 | ch->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED | | ||
480 | ASYNC_CLOSING); | ||
481 | wake_up_interruptible(&ch->port.close_wait); | ||
482 | } | ||
483 | } | 441 | } |
484 | 442 | ||
485 | static void shutdown(struct channel *ch) | 443 | static void shutdown(struct channel *ch, struct tty_struct *tty) |
486 | { | 444 | { |
487 | unsigned long flags; | 445 | unsigned long flags; |
488 | struct tty_struct *tty; | ||
489 | struct board_chan __iomem *bc; | 446 | struct board_chan __iomem *bc; |
447 | struct tty_port *port = &ch->port; | ||
490 | 448 | ||
491 | if (!(ch->port.flags & ASYNC_INITIALIZED)) | 449 | if (!(port->flags & ASYNC_INITIALIZED)) |
492 | return; | 450 | return; |
493 | 451 | ||
494 | spin_lock_irqsave(&epca_lock, flags); | 452 | spin_lock_irqsave(&epca_lock, flags); |
@@ -503,7 +461,6 @@ static void shutdown(struct channel *ch) | |||
503 | */ | 461 | */ |
504 | if (bc) | 462 | if (bc) |
505 | writeb(0, &bc->idata); | 463 | writeb(0, &bc->idata); |
506 | tty = ch->port.tty; | ||
507 | 464 | ||
508 | /* If we're a modem control device and HUPCL is on, drop RTS & DTR. */ | 465 | /* If we're a modem control device and HUPCL is on, drop RTS & DTR. */ |
509 | if (tty->termios->c_cflag & HUPCL) { | 466 | if (tty->termios->c_cflag & HUPCL) { |
@@ -517,32 +474,26 @@ static void shutdown(struct channel *ch) | |||
517 | * will have to reinitialized. Set a flag to indicate this. | 474 | * will have to reinitialized. Set a flag to indicate this. |
518 | */ | 475 | */ |
519 | /* Prevent future Digi programmed interrupts from coming active */ | 476 | /* Prevent future Digi programmed interrupts from coming active */ |
520 | ch->port.flags &= ~ASYNC_INITIALIZED; | 477 | port->flags &= ~ASYNC_INITIALIZED; |
521 | spin_unlock_irqrestore(&epca_lock, flags); | 478 | spin_unlock_irqrestore(&epca_lock, flags); |
522 | } | 479 | } |
523 | 480 | ||
524 | static void pc_hangup(struct tty_struct *tty) | 481 | static void pc_hangup(struct tty_struct *tty) |
525 | { | 482 | { |
526 | struct channel *ch; | 483 | struct channel *ch; |
484 | |||
527 | /* | 485 | /* |
528 | * verifyChannel returns the channel from the tty struct if it is | 486 | * verifyChannel returns the channel from the tty struct if it is |
529 | * valid. This serves as a sanity check. | 487 | * valid. This serves as a sanity check. |
530 | */ | 488 | */ |
531 | ch = verifyChannel(tty); | 489 | ch = verifyChannel(tty); |
532 | if (ch != NULL) { | 490 | if (ch != NULL) { |
533 | unsigned long flags; | ||
534 | |||
535 | pc_flush_buffer(tty); | 491 | pc_flush_buffer(tty); |
536 | tty_ldisc_flush(tty); | 492 | tty_ldisc_flush(tty); |
537 | shutdown(ch); | 493 | shutdown(ch, tty); |
538 | 494 | ||
539 | spin_lock_irqsave(&epca_lock, flags); | 495 | ch->event = 0; /* FIXME: review locking of ch->event */ |
540 | ch->port.tty = NULL; | 496 | tty_port_hangup(&ch->port); |
541 | ch->event = 0; | ||
542 | ch->port.count = 0; | ||
543 | ch->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_INITIALIZED); | ||
544 | spin_unlock_irqrestore(&epca_lock, flags); | ||
545 | wake_up_interruptible(&ch->port.open_wait); | ||
546 | } | 497 | } |
547 | } | 498 | } |
548 | 499 | ||
@@ -786,100 +737,22 @@ static void pc_flush_chars(struct tty_struct *tty) | |||
786 | } | 737 | } |
787 | } | 738 | } |
788 | 739 | ||
789 | static int block_til_ready(struct tty_struct *tty, | 740 | static int epca_carrier_raised(struct tty_port *port) |
790 | struct file *filp, struct channel *ch) | ||
791 | { | 741 | { |
792 | DECLARE_WAITQUEUE(wait, current); | 742 | struct channel *ch = container_of(port, struct channel, port); |
793 | int retval, do_clocal = 0; | 743 | if (ch->imodem & ch->dcd) |
794 | unsigned long flags; | 744 | return 1; |
795 | |||
796 | if (tty_hung_up_p(filp)) { | ||
797 | if (ch->port.flags & ASYNC_HUP_NOTIFY) | ||
798 | retval = -EAGAIN; | ||
799 | else | ||
800 | retval = -ERESTARTSYS; | ||
801 | return retval; | ||
802 | } | ||
803 | |||
804 | /* | ||
805 | * If the device is in the middle of being closed, then block until | ||
806 | * it's done, and then try again. | ||
807 | */ | ||
808 | if (ch->port.flags & ASYNC_CLOSING) { | ||
809 | interruptible_sleep_on(&ch->port.close_wait); | ||
810 | |||
811 | if (ch->port.flags & ASYNC_HUP_NOTIFY) | ||
812 | return -EAGAIN; | ||
813 | else | ||
814 | return -ERESTARTSYS; | ||
815 | } | ||
816 | |||
817 | if (filp->f_flags & O_NONBLOCK) { | ||
818 | /* | ||
819 | * If non-blocking mode is set, then make the check up front | ||
820 | * and then exit. | ||
821 | */ | ||
822 | ch->port.flags |= ASYNC_NORMAL_ACTIVE; | ||
823 | return 0; | ||
824 | } | ||
825 | if (tty->termios->c_cflag & CLOCAL) | ||
826 | do_clocal = 1; | ||
827 | /* Block waiting for the carrier detect and the line to become free */ | ||
828 | |||
829 | retval = 0; | ||
830 | add_wait_queue(&ch->port.open_wait, &wait); | ||
831 | |||
832 | spin_lock_irqsave(&epca_lock, flags); | ||
833 | /* We dec count so that pc_close will know when to free things */ | ||
834 | if (!tty_hung_up_p(filp)) | ||
835 | ch->port.count--; | ||
836 | ch->port.blocked_open++; | ||
837 | while (1) { | ||
838 | set_current_state(TASK_INTERRUPTIBLE); | ||
839 | if (tty_hung_up_p(filp) || | ||
840 | !(ch->port.flags & ASYNC_INITIALIZED)) { | ||
841 | if (ch->port.flags & ASYNC_HUP_NOTIFY) | ||
842 | retval = -EAGAIN; | ||
843 | else | ||
844 | retval = -ERESTARTSYS; | ||
845 | break; | ||
846 | } | ||
847 | if (!(ch->port.flags & ASYNC_CLOSING) && | ||
848 | (do_clocal || (ch->imodem & ch->dcd))) | ||
849 | break; | ||
850 | if (signal_pending(current)) { | ||
851 | retval = -ERESTARTSYS; | ||
852 | break; | ||
853 | } | ||
854 | spin_unlock_irqrestore(&epca_lock, flags); | ||
855 | /* | ||
856 | * Allow someone else to be scheduled. We will occasionally go | ||
857 | * through this loop until one of the above conditions change. | ||
858 | * The below schedule call will allow other processes to enter | ||
859 | * and prevent this loop from hogging the cpu. | ||
860 | */ | ||
861 | schedule(); | ||
862 | spin_lock_irqsave(&epca_lock, flags); | ||
863 | } | ||
864 | |||
865 | __set_current_state(TASK_RUNNING); | ||
866 | remove_wait_queue(&ch->port.open_wait, &wait); | ||
867 | if (!tty_hung_up_p(filp)) | ||
868 | ch->port.count++; | ||
869 | ch->port.blocked_open--; | ||
870 | |||
871 | spin_unlock_irqrestore(&epca_lock, flags); | ||
872 | |||
873 | if (retval) | ||
874 | return retval; | ||
875 | |||
876 | ch->port.flags |= ASYNC_NORMAL_ACTIVE; | ||
877 | return 0; | 745 | return 0; |
878 | } | 746 | } |
879 | 747 | ||
748 | static void epca_raise_dtr_rts(struct tty_port *port) | ||
749 | { | ||
750 | } | ||
751 | |||
880 | static int pc_open(struct tty_struct *tty, struct file *filp) | 752 | static int pc_open(struct tty_struct *tty, struct file *filp) |
881 | { | 753 | { |
882 | struct channel *ch; | 754 | struct channel *ch; |
755 | struct tty_port *port; | ||
883 | unsigned long flags; | 756 | unsigned long flags; |
884 | int line, retval, boardnum; | 757 | int line, retval, boardnum; |
885 | struct board_chan __iomem *bc; | 758 | struct board_chan __iomem *bc; |
@@ -890,12 +763,13 @@ static int pc_open(struct tty_struct *tty, struct file *filp) | |||
890 | return -ENODEV; | 763 | return -ENODEV; |
891 | 764 | ||
892 | ch = &digi_channels[line]; | 765 | ch = &digi_channels[line]; |
766 | port = &ch->port; | ||
893 | boardnum = ch->boardnum; | 767 | boardnum = ch->boardnum; |
894 | 768 | ||
895 | /* Check status of board configured in system. */ | 769 | /* Check status of board configured in system. */ |
896 | 770 | ||
897 | /* | 771 | /* |
898 | * I check to see if the epca_setup routine detected an user error. It | 772 | * I check to see if the epca_setup routine detected a user error. It |
899 | * might be better to put this in pc_init, but for the moment it goes | 773 | * might be better to put this in pc_init, but for the moment it goes |
900 | * here. | 774 | * here. |
901 | */ | 775 | */ |
@@ -926,22 +800,24 @@ static int pc_open(struct tty_struct *tty, struct file *filp) | |||
926 | return -ENODEV; | 800 | return -ENODEV; |
927 | } | 801 | } |
928 | 802 | ||
929 | spin_lock_irqsave(&epca_lock, flags); | 803 | spin_lock_irqsave(&port->lock, flags); |
930 | /* | 804 | /* |
931 | * Every time a channel is opened, increment a counter. This is | 805 | * Every time a channel is opened, increment a counter. This is |
932 | * necessary because we do not wish to flush and shutdown the channel | 806 | * necessary because we do not wish to flush and shutdown the channel |
933 | * until the last app holding the channel open, closes it. | 807 | * until the last app holding the channel open, closes it. |
934 | */ | 808 | */ |
935 | ch->port.count++; | 809 | port->count++; |
936 | /* | 810 | /* |
937 | * Set a kernel structures pointer to our local channel structure. This | 811 | * Set a kernel structures pointer to our local channel structure. This |
938 | * way we can get to it when passed only a tty struct. | 812 | * way we can get to it when passed only a tty struct. |
939 | */ | 813 | */ |
940 | tty->driver_data = ch; | 814 | tty->driver_data = ch; |
815 | port->tty = tty; | ||
941 | /* | 816 | /* |
942 | * If this is the first time the channel has been opened, initialize | 817 | * If this is the first time the channel has been opened, initialize |
943 | * the tty->termios struct otherwise let pc_close handle it. | 818 | * the tty->termios struct otherwise let pc_close handle it. |
944 | */ | 819 | */ |
820 | spin_lock(&epca_lock); | ||
945 | globalwinon(ch); | 821 | globalwinon(ch); |
946 | ch->statusflags = 0; | 822 | ch->statusflags = 0; |
947 | 823 | ||
@@ -956,31 +832,33 @@ static int pc_open(struct tty_struct *tty, struct file *filp) | |||
956 | writew(head, &bc->rout); | 832 | writew(head, &bc->rout); |
957 | 833 | ||
958 | /* Set the channels associated tty structure */ | 834 | /* Set the channels associated tty structure */ |
959 | ch->port.tty = tty; | ||
960 | 835 | ||
961 | /* | 836 | /* |
962 | * The below routine generally sets up parity, baud, flow control | 837 | * The below routine generally sets up parity, baud, flow control |
963 | * issues, etc.... It effect both control flags and input flags. | 838 | * issues, etc.... It effect both control flags and input flags. |
964 | */ | 839 | */ |
965 | epcaparam(tty, ch); | 840 | epcaparam(tty, ch); |
966 | ch->port.flags |= ASYNC_INITIALIZED; | ||
967 | memoff(ch); | 841 | memoff(ch); |
968 | spin_unlock_irqrestore(&epca_lock, flags); | 842 | spin_unlock(&epca_lock); |
843 | port->flags |= ASYNC_INITIALIZED; | ||
844 | spin_unlock_irqrestore(&port->lock, flags); | ||
969 | 845 | ||
970 | retval = block_til_ready(tty, filp, ch); | 846 | retval = tty_port_block_til_ready(port, tty, filp); |
971 | if (retval) | 847 | if (retval) |
972 | return retval; | 848 | return retval; |
973 | /* | 849 | /* |
974 | * Set this again in case a hangup set it to zero while this open() was | 850 | * Set this again in case a hangup set it to zero while this open() was |
975 | * waiting for the line... | 851 | * waiting for the line... |
976 | */ | 852 | */ |
977 | spin_lock_irqsave(&epca_lock, flags); | 853 | spin_lock_irqsave(&port->lock, flags); |
978 | ch->port.tty = tty; | 854 | port->tty = tty; |
855 | spin_lock(&epca_lock); | ||
979 | globalwinon(ch); | 856 | globalwinon(ch); |
980 | /* Enable Digi Data events */ | 857 | /* Enable Digi Data events */ |
981 | writeb(1, &bc->idata); | 858 | writeb(1, &bc->idata); |
982 | memoff(ch); | 859 | memoff(ch); |
983 | spin_unlock_irqrestore(&epca_lock, flags); | 860 | spin_unlock(&epca_lock); |
861 | spin_unlock_irqrestore(&port->lock, flags); | ||
984 | return 0; | 862 | return 0; |
985 | } | 863 | } |
986 | 864 | ||
@@ -1016,8 +894,11 @@ static void __exit epca_module_exit(void) | |||
1016 | } | 894 | } |
1017 | ch = card_ptr[crd]; | 895 | ch = card_ptr[crd]; |
1018 | for (count = 0; count < bd->numports; count++, ch++) { | 896 | for (count = 0; count < bd->numports; count++, ch++) { |
1019 | if (ch && ch->port.tty) | 897 | struct tty_struct *tty = tty_port_tty_get(&ch->port); |
1020 | tty_hangup(ch->port.tty); | 898 | if (tty) { |
899 | tty_hangup(tty); | ||
900 | tty_kref_put(tty); | ||
901 | } | ||
1021 | } | 902 | } |
1022 | } | 903 | } |
1023 | pci_unregister_driver(&epca_driver); | 904 | pci_unregister_driver(&epca_driver); |
@@ -1042,6 +923,11 @@ static const struct tty_operations pc_ops = { | |||
1042 | .break_ctl = pc_send_break | 923 | .break_ctl = pc_send_break |
1043 | }; | 924 | }; |
1044 | 925 | ||
926 | static const struct tty_port_operations epca_port_ops = { | ||
927 | .carrier_raised = epca_carrier_raised, | ||
928 | .raise_dtr_rts = epca_raise_dtr_rts, | ||
929 | }; | ||
930 | |||
1045 | static int info_open(struct tty_struct *tty, struct file *filp) | 931 | static int info_open(struct tty_struct *tty, struct file *filp) |
1046 | { | 932 | { |
1047 | return 0; | 933 | return 0; |
@@ -1377,6 +1263,7 @@ static void post_fep_init(unsigned int crd) | |||
1377 | u16 tseg, rseg; | 1263 | u16 tseg, rseg; |
1378 | 1264 | ||
1379 | tty_port_init(&ch->port); | 1265 | tty_port_init(&ch->port); |
1266 | ch->port.ops = &epca_port_ops; | ||
1380 | ch->brdchan = bc; | 1267 | ch->brdchan = bc; |
1381 | ch->mailbox = gd; | 1268 | ch->mailbox = gd; |
1382 | INIT_WORK(&ch->tqueue, do_softint); | 1269 | INIT_WORK(&ch->tqueue, do_softint); |
@@ -1428,7 +1315,7 @@ static void post_fep_init(unsigned int crd) | |||
1428 | ch->boardnum = crd; | 1315 | ch->boardnum = crd; |
1429 | ch->channelnum = i; | 1316 | ch->channelnum = i; |
1430 | ch->magic = EPCA_MAGIC; | 1317 | ch->magic = EPCA_MAGIC; |
1431 | ch->port.tty = NULL; | 1318 | tty_port_tty_set(&ch->port, NULL); |
1432 | 1319 | ||
1433 | if (shrinkmem) { | 1320 | if (shrinkmem) { |
1434 | fepcmd(ch, SETBUFFER, 32, 0, 0, 0); | 1321 | fepcmd(ch, SETBUFFER, 32, 0, 0, 0); |
@@ -1510,7 +1397,7 @@ static void post_fep_init(unsigned int crd) | |||
1510 | ch->fepstartca = 0; | 1397 | ch->fepstartca = 0; |
1511 | ch->fepstopca = 0; | 1398 | ch->fepstopca = 0; |
1512 | 1399 | ||
1513 | ch->close_delay = 50; | 1400 | ch->port.close_delay = 50; |
1514 | 1401 | ||
1515 | spin_unlock_irqrestore(&epca_lock, flags); | 1402 | spin_unlock_irqrestore(&epca_lock, flags); |
1516 | } | 1403 | } |
@@ -1622,15 +1509,16 @@ static void doevent(int crd) | |||
1622 | if (bc == NULL) | 1509 | if (bc == NULL) |
1623 | goto next; | 1510 | goto next; |
1624 | 1511 | ||
1512 | tty = tty_port_tty_get(&ch->port); | ||
1625 | if (event & DATA_IND) { /* Begin DATA_IND */ | 1513 | if (event & DATA_IND) { /* Begin DATA_IND */ |
1626 | receive_data(ch); | 1514 | receive_data(ch, tty); |
1627 | assertgwinon(ch); | 1515 | assertgwinon(ch); |
1628 | } /* End DATA_IND */ | 1516 | } /* End DATA_IND */ |
1629 | /* else *//* Fix for DCD transition missed bug */ | 1517 | /* else *//* Fix for DCD transition missed bug */ |
1630 | if (event & MODEMCHG_IND) { | 1518 | if (event & MODEMCHG_IND) { |
1631 | /* A modem signal change has been indicated */ | 1519 | /* A modem signal change has been indicated */ |
1632 | ch->imodem = mstat; | 1520 | ch->imodem = mstat; |
1633 | if (ch->port.flags & ASYNC_CHECK_CD) { | 1521 | if (test_bit(ASYNC_CHECK_CD, &ch->port.flags)) { |
1634 | /* We are now receiving dcd */ | 1522 | /* We are now receiving dcd */ |
1635 | if (mstat & ch->dcd) | 1523 | if (mstat & ch->dcd) |
1636 | wake_up_interruptible(&ch->port.open_wait); | 1524 | wake_up_interruptible(&ch->port.open_wait); |
@@ -1638,7 +1526,6 @@ static void doevent(int crd) | |||
1638 | pc_sched_event(ch, EPCA_EVENT_HANGUP); | 1526 | pc_sched_event(ch, EPCA_EVENT_HANGUP); |
1639 | } | 1527 | } |
1640 | } | 1528 | } |
1641 | tty = ch->port.tty; | ||
1642 | if (tty) { | 1529 | if (tty) { |
1643 | if (event & BREAK_IND) { | 1530 | if (event & BREAK_IND) { |
1644 | /* A break has been indicated */ | 1531 | /* A break has been indicated */ |
@@ -1658,6 +1545,7 @@ static void doevent(int crd) | |||
1658 | tty_wakeup(tty); | 1545 | tty_wakeup(tty); |
1659 | } | 1546 | } |
1660 | } | 1547 | } |
1548 | tty_kref_put(tty); | ||
1661 | } | 1549 | } |
1662 | next: | 1550 | next: |
1663 | globalwinon(ch); | 1551 | globalwinon(ch); |
@@ -1877,9 +1765,9 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch) | |||
1877 | * that the driver will wait on carrier detect. | 1765 | * that the driver will wait on carrier detect. |
1878 | */ | 1766 | */ |
1879 | if (ts->c_cflag & CLOCAL) | 1767 | if (ts->c_cflag & CLOCAL) |
1880 | ch->port.flags &= ~ASYNC_CHECK_CD; | 1768 | clear_bit(ASYNC_CHECK_CD, &ch->port.flags); |
1881 | else | 1769 | else |
1882 | ch->port.flags |= ASYNC_CHECK_CD; | 1770 | set_bit(ASYNC_CHECK_CD, &ch->port.flags); |
1883 | mval = ch->m_dtr | ch->m_rts; | 1771 | mval = ch->m_dtr | ch->m_rts; |
1884 | } /* End CBAUD not detected */ | 1772 | } /* End CBAUD not detected */ |
1885 | iflag = termios2digi_i(ch, ts->c_iflag); | 1773 | iflag = termios2digi_i(ch, ts->c_iflag); |
@@ -1952,11 +1840,10 @@ static void epcaparam(struct tty_struct *tty, struct channel *ch) | |||
1952 | } | 1840 | } |
1953 | 1841 | ||
1954 | /* Caller holds lock */ | 1842 | /* Caller holds lock */ |
1955 | static void receive_data(struct channel *ch) | 1843 | static void receive_data(struct channel *ch, struct tty_struct *tty) |
1956 | { | 1844 | { |
1957 | unchar *rptr; | 1845 | unchar *rptr; |
1958 | struct ktermios *ts = NULL; | 1846 | struct ktermios *ts = NULL; |
1959 | struct tty_struct *tty; | ||
1960 | struct board_chan __iomem *bc; | 1847 | struct board_chan __iomem *bc; |
1961 | int dataToRead, wrapgap, bytesAvailable; | 1848 | int dataToRead, wrapgap, bytesAvailable; |
1962 | unsigned int tail, head; | 1849 | unsigned int tail, head; |
@@ -1969,7 +1856,6 @@ static void receive_data(struct channel *ch) | |||
1969 | globalwinon(ch); | 1856 | globalwinon(ch); |
1970 | if (ch->statusflags & RXSTOPPED) | 1857 | if (ch->statusflags & RXSTOPPED) |
1971 | return; | 1858 | return; |
1972 | tty = ch->port.tty; | ||
1973 | if (tty) | 1859 | if (tty) |
1974 | ts = tty->termios; | 1860 | ts = tty->termios; |
1975 | bc = ch->brdchan; | 1861 | bc = ch->brdchan; |
@@ -2029,7 +1915,7 @@ static void receive_data(struct channel *ch) | |||
2029 | globalwinon(ch); | 1915 | globalwinon(ch); |
2030 | writew(tail, &bc->rout); | 1916 | writew(tail, &bc->rout); |
2031 | /* Must be called with global data */ | 1917 | /* Must be called with global data */ |
2032 | tty_schedule_flip(ch->port.tty); | 1918 | tty_schedule_flip(tty); |
2033 | } | 1919 | } |
2034 | 1920 | ||
2035 | static int info_ioctl(struct tty_struct *tty, struct file *file, | 1921 | static int info_ioctl(struct tty_struct *tty, struct file *file, |
@@ -2097,7 +1983,7 @@ static int info_ioctl(struct tty_struct *tty, struct file *file, | |||
2097 | 1983 | ||
2098 | static int pc_tiocmget(struct tty_struct *tty, struct file *file) | 1984 | static int pc_tiocmget(struct tty_struct *tty, struct file *file) |
2099 | { | 1985 | { |
2100 | struct channel *ch = (struct channel *) tty->driver_data; | 1986 | struct channel *ch = tty->driver_data; |
2101 | struct board_chan __iomem *bc; | 1987 | struct board_chan __iomem *bc; |
2102 | unsigned int mstat, mflag = 0; | 1988 | unsigned int mstat, mflag = 0; |
2103 | unsigned long flags; | 1989 | unsigned long flags; |
@@ -2131,7 +2017,7 @@ static int pc_tiocmget(struct tty_struct *tty, struct file *file) | |||
2131 | static int pc_tiocmset(struct tty_struct *tty, struct file *file, | 2017 | static int pc_tiocmset(struct tty_struct *tty, struct file *file, |
2132 | unsigned int set, unsigned int clear) | 2018 | unsigned int set, unsigned int clear) |
2133 | { | 2019 | { |
2134 | struct channel *ch = (struct channel *) tty->driver_data; | 2020 | struct channel *ch = tty->driver_data; |
2135 | unsigned long flags; | 2021 | unsigned long flags; |
2136 | 2022 | ||
2137 | if (!ch) | 2023 | if (!ch) |
@@ -2178,7 +2064,7 @@ static int pc_ioctl(struct tty_struct *tty, struct file *file, | |||
2178 | unsigned int mflag, mstat; | 2064 | unsigned int mflag, mstat; |
2179 | unsigned char startc, stopc; | 2065 | unsigned char startc, stopc; |
2180 | struct board_chan __iomem *bc; | 2066 | struct board_chan __iomem *bc; |
2181 | struct channel *ch = (struct channel *) tty->driver_data; | 2067 | struct channel *ch = tty->driver_data; |
2182 | void __user *argp = (void __user *)arg; | 2068 | void __user *argp = (void __user *)arg; |
2183 | 2069 | ||
2184 | if (ch) | 2070 | if (ch) |
@@ -2352,15 +2238,16 @@ static void do_softint(struct work_struct *work) | |||
2352 | struct channel *ch = container_of(work, struct channel, tqueue); | 2238 | struct channel *ch = container_of(work, struct channel, tqueue); |
2353 | /* Called in response to a modem change event */ | 2239 | /* Called in response to a modem change event */ |
2354 | if (ch && ch->magic == EPCA_MAGIC) { | 2240 | if (ch && ch->magic == EPCA_MAGIC) { |
2355 | struct tty_struct *tty = ch->port.tty; | 2241 | struct tty_struct *tty = tty_port_tty_get(&ch->port);; |
2356 | 2242 | ||
2357 | if (tty && tty->driver_data) { | 2243 | if (tty && tty->driver_data) { |
2358 | if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) { | 2244 | if (test_and_clear_bit(EPCA_EVENT_HANGUP, &ch->event)) { |
2359 | tty_hangup(tty); | 2245 | tty_hangup(tty); |
2360 | wake_up_interruptible(&ch->port.open_wait); | 2246 | wake_up_interruptible(&ch->port.open_wait); |
2361 | ch->port.flags &= ~ASYNC_NORMAL_ACTIVE; | 2247 | clear_bit(ASYNC_NORMAL_ACTIVE, &ch->port.flags); |
2362 | } | 2248 | } |
2363 | } | 2249 | } |
2250 | tty_kref_put(tty); | ||
2364 | } | 2251 | } |
2365 | } | 2252 | } |
2366 | 2253 | ||
@@ -2473,7 +2360,7 @@ static void pc_unthrottle(struct tty_struct *tty) | |||
2473 | 2360 | ||
2474 | static int pc_send_break(struct tty_struct *tty, int msec) | 2361 | static int pc_send_break(struct tty_struct *tty, int msec) |
2475 | { | 2362 | { |
2476 | struct channel *ch = (struct channel *) tty->driver_data; | 2363 | struct channel *ch = tty->driver_data; |
2477 | unsigned long flags; | 2364 | unsigned long flags; |
2478 | 2365 | ||
2479 | if (msec == -1) | 2366 | if (msec == -1) |
diff --git a/drivers/char/esp.c b/drivers/char/esp.c index 7f077c0097f6..45ec263ec012 100644 --- a/drivers/char/esp.c +++ b/drivers/char/esp.c | |||
@@ -2054,6 +2054,15 @@ static void esp_hangup(struct tty_struct *tty) | |||
2054 | wake_up_interruptible(&info->port.open_wait); | 2054 | wake_up_interruptible(&info->port.open_wait); |
2055 | } | 2055 | } |
2056 | 2056 | ||
2057 | static int esp_carrier_raised(struct tty_port *port) | ||
2058 | { | ||
2059 | struct esp_struct *info = container_of(port, struct esp_struct, port); | ||
2060 | serial_out(info, UART_ESI_CMD1, ESI_GET_UART_STAT); | ||
2061 | if (serial_in(info, UART_ESI_STAT2) & UART_MSR_DCD) | ||
2062 | return 1; | ||
2063 | return 0; | ||
2064 | } | ||
2065 | |||
2057 | /* | 2066 | /* |
2058 | * ------------------------------------------------------------ | 2067 | * ------------------------------------------------------------ |
2059 | * esp_open() and friends | 2068 | * esp_open() and friends |
@@ -2066,17 +2075,19 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
2066 | int retval; | 2075 | int retval; |
2067 | int do_clocal = 0; | 2076 | int do_clocal = 0; |
2068 | unsigned long flags; | 2077 | unsigned long flags; |
2078 | int cd; | ||
2079 | struct tty_port *port = &info->port; | ||
2069 | 2080 | ||
2070 | /* | 2081 | /* |
2071 | * If the device is in the middle of being closed, then block | 2082 | * If the device is in the middle of being closed, then block |
2072 | * until it's done, and then try again. | 2083 | * until it's done, and then try again. |
2073 | */ | 2084 | */ |
2074 | if (tty_hung_up_p(filp) || | 2085 | if (tty_hung_up_p(filp) || |
2075 | (info->port.flags & ASYNC_CLOSING)) { | 2086 | (port->flags & ASYNC_CLOSING)) { |
2076 | if (info->port.flags & ASYNC_CLOSING) | 2087 | if (port->flags & ASYNC_CLOSING) |
2077 | interruptible_sleep_on(&info->port.close_wait); | 2088 | interruptible_sleep_on(&port->close_wait); |
2078 | #ifdef SERIAL_DO_RESTART | 2089 | #ifdef SERIAL_DO_RESTART |
2079 | if (info->port.flags & ASYNC_HUP_NOTIFY) | 2090 | if (port->flags & ASYNC_HUP_NOTIFY) |
2080 | return -EAGAIN; | 2091 | return -EAGAIN; |
2081 | else | 2092 | else |
2082 | return -ERESTARTSYS; | 2093 | return -ERESTARTSYS; |
@@ -2091,7 +2102,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
2091 | */ | 2102 | */ |
2092 | if ((filp->f_flags & O_NONBLOCK) || | 2103 | if ((filp->f_flags & O_NONBLOCK) || |
2093 | (tty->flags & (1 << TTY_IO_ERROR))) { | 2104 | (tty->flags & (1 << TTY_IO_ERROR))) { |
2094 | info->port.flags |= ASYNC_NORMAL_ACTIVE; | 2105 | port->flags |= ASYNC_NORMAL_ACTIVE; |
2095 | return 0; | 2106 | return 0; |
2096 | } | 2107 | } |
2097 | 2108 | ||
@@ -2101,20 +2112,20 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
2101 | /* | 2112 | /* |
2102 | * Block waiting for the carrier detect and the line to become | 2113 | * Block waiting for the carrier detect and the line to become |
2103 | * free (i.e., not in use by the callout). While we are in | 2114 | * free (i.e., not in use by the callout). While we are in |
2104 | * this loop, info->port.count is dropped by one, so that | 2115 | * this loop, port->count is dropped by one, so that |
2105 | * rs_close() knows when to free things. We restore it upon | 2116 | * rs_close() knows when to free things. We restore it upon |
2106 | * exit, either normal or abnormal. | 2117 | * exit, either normal or abnormal. |
2107 | */ | 2118 | */ |
2108 | retval = 0; | 2119 | retval = 0; |
2109 | add_wait_queue(&info->port.open_wait, &wait); | 2120 | add_wait_queue(&port->open_wait, &wait); |
2110 | #ifdef SERIAL_DEBUG_OPEN | 2121 | #ifdef SERIAL_DEBUG_OPEN |
2111 | printk(KERN_DEBUG "block_til_ready before block: ttys%d, count = %d\n", | 2122 | printk(KERN_DEBUG "block_til_ready before block: ttys%d, count = %d\n", |
2112 | info->line, info->port.count); | 2123 | info->line, port->count); |
2113 | #endif | 2124 | #endif |
2114 | spin_lock_irqsave(&info->lock, flags); | 2125 | spin_lock_irqsave(&info->lock, flags); |
2115 | if (!tty_hung_up_p(filp)) | 2126 | if (!tty_hung_up_p(filp)) |
2116 | info->port.count--; | 2127 | port->count--; |
2117 | info->port.blocked_open++; | 2128 | port->blocked_open++; |
2118 | while (1) { | 2129 | while (1) { |
2119 | if ((tty->termios->c_cflag & CBAUD)) { | 2130 | if ((tty->termios->c_cflag & CBAUD)) { |
2120 | unsigned int scratch; | 2131 | unsigned int scratch; |
@@ -2129,9 +2140,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
2129 | } | 2140 | } |
2130 | set_current_state(TASK_INTERRUPTIBLE); | 2141 | set_current_state(TASK_INTERRUPTIBLE); |
2131 | if (tty_hung_up_p(filp) || | 2142 | if (tty_hung_up_p(filp) || |
2132 | !(info->port.flags & ASYNC_INITIALIZED)) { | 2143 | !(port->flags & ASYNC_INITIALIZED)) { |
2133 | #ifdef SERIAL_DO_RESTART | 2144 | #ifdef SERIAL_DO_RESTART |
2134 | if (info->port.flags & ASYNC_HUP_NOTIFY) | 2145 | if (port->flags & ASYNC_HUP_NOTIFY) |
2135 | retval = -EAGAIN; | 2146 | retval = -EAGAIN; |
2136 | else | 2147 | else |
2137 | retval = -ERESTARTSYS; | 2148 | retval = -ERESTARTSYS; |
@@ -2141,11 +2152,9 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
2141 | break; | 2152 | break; |
2142 | } | 2153 | } |
2143 | 2154 | ||
2144 | serial_out(info, UART_ESI_CMD1, ESI_GET_UART_STAT); | 2155 | cd = tty_port_carrier_raised(port); |
2145 | if (serial_in(info, UART_ESI_STAT2) & UART_MSR_DCD) | ||
2146 | do_clocal = 1; | ||
2147 | 2156 | ||
2148 | if (!(info->port.flags & ASYNC_CLOSING) && | 2157 | if (!(port->flags & ASYNC_CLOSING) && |
2149 | (do_clocal)) | 2158 | (do_clocal)) |
2150 | break; | 2159 | break; |
2151 | if (signal_pending(current)) { | 2160 | if (signal_pending(current)) { |
@@ -2154,25 +2163,25 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
2154 | } | 2163 | } |
2155 | #ifdef SERIAL_DEBUG_OPEN | 2164 | #ifdef SERIAL_DEBUG_OPEN |
2156 | printk(KERN_DEBUG "block_til_ready blocking: ttys%d, count = %d\n", | 2165 | printk(KERN_DEBUG "block_til_ready blocking: ttys%d, count = %d\n", |
2157 | info->line, info->port.count); | 2166 | info->line, port->count); |
2158 | #endif | 2167 | #endif |
2159 | spin_unlock_irqrestore(&info->lock, flags); | 2168 | spin_unlock_irqrestore(&info->lock, flags); |
2160 | schedule(); | 2169 | schedule(); |
2161 | spin_lock_irqsave(&info->lock, flags); | 2170 | spin_lock_irqsave(&info->lock, flags); |
2162 | } | 2171 | } |
2163 | set_current_state(TASK_RUNNING); | 2172 | set_current_state(TASK_RUNNING); |
2164 | remove_wait_queue(&info->port.open_wait, &wait); | 2173 | remove_wait_queue(&port->open_wait, &wait); |
2165 | if (!tty_hung_up_p(filp)) | 2174 | if (!tty_hung_up_p(filp)) |
2166 | info->port.count++; | 2175 | port->count++; |
2167 | info->port.blocked_open--; | 2176 | port->blocked_open--; |
2168 | spin_unlock_irqrestore(&info->lock, flags); | 2177 | spin_unlock_irqrestore(&info->lock, flags); |
2169 | #ifdef SERIAL_DEBUG_OPEN | 2178 | #ifdef SERIAL_DEBUG_OPEN |
2170 | printk(KERN_DEBUG "block_til_ready after blocking: ttys%d, count = %d\n", | 2179 | printk(KERN_DEBUG "block_til_ready after blocking: ttys%d, count = %d\n", |
2171 | info->line, info->port.count); | 2180 | info->line, port->count); |
2172 | #endif | 2181 | #endif |
2173 | if (retval) | 2182 | if (retval) |
2174 | return retval; | 2183 | return retval; |
2175 | info->port.flags |= ASYNC_NORMAL_ACTIVE; | 2184 | port->flags |= ASYNC_NORMAL_ACTIVE; |
2176 | return 0; | 2185 | return 0; |
2177 | } | 2186 | } |
2178 | 2187 | ||
@@ -2329,6 +2338,10 @@ static const struct tty_operations esp_ops = { | |||
2329 | .tiocmset = esp_tiocmset, | 2338 | .tiocmset = esp_tiocmset, |
2330 | }; | 2339 | }; |
2331 | 2340 | ||
2341 | static const struct tty_port_operations esp_port_ops = { | ||
2342 | .esp_carrier_raised, | ||
2343 | }; | ||
2344 | |||
2332 | /* | 2345 | /* |
2333 | * The serial driver boot-time initialization code! | 2346 | * The serial driver boot-time initialization code! |
2334 | */ | 2347 | */ |
@@ -2415,6 +2428,8 @@ static int __init espserial_init(void) | |||
2415 | offset = 0; | 2428 | offset = 0; |
2416 | 2429 | ||
2417 | do { | 2430 | do { |
2431 | tty_port_init(&info->port); | ||
2432 | info->port.ops = &esp_port_ops; | ||
2418 | info->io_port = esp[i] + offset; | 2433 | info->io_port = esp[i] + offset; |
2419 | info->irq = irq[i]; | 2434 | info->irq = irq[i]; |
2420 | info->line = (i * 8) + (offset / 8); | 2435 | info->line = (i * 8) + (offset / 8); |
@@ -2437,8 +2452,6 @@ static int __init espserial_init(void) | |||
2437 | info->config.flow_off = flow_off; | 2452 | info->config.flow_off = flow_off; |
2438 | info->config.pio_threshold = pio_threshold; | 2453 | info->config.pio_threshold = pio_threshold; |
2439 | info->next_port = ports; | 2454 | info->next_port = ports; |
2440 | init_waitqueue_head(&info->port.open_wait); | ||
2441 | init_waitqueue_head(&info->port.close_wait); | ||
2442 | init_waitqueue_head(&info->delta_msr_wait); | 2455 | init_waitqueue_head(&info->delta_msr_wait); |
2443 | init_waitqueue_head(&info->break_wait); | 2456 | init_waitqueue_head(&info->break_wait); |
2444 | ports = info; | 2457 | ports = info; |
diff --git a/drivers/char/generic_serial.c b/drivers/char/generic_serial.c index c6090f84a2e4..9e4e569dc00d 100644 --- a/drivers/char/generic_serial.c +++ b/drivers/char/generic_serial.c | |||
@@ -376,7 +376,8 @@ static void gs_shutdown_port (struct gs_port *port) | |||
376 | 376 | ||
377 | void gs_hangup(struct tty_struct *tty) | 377 | void gs_hangup(struct tty_struct *tty) |
378 | { | 378 | { |
379 | struct gs_port *port; | 379 | struct gs_port *port; |
380 | unsigned long flags; | ||
380 | 381 | ||
381 | func_enter (); | 382 | func_enter (); |
382 | 383 | ||
@@ -386,9 +387,11 @@ void gs_hangup(struct tty_struct *tty) | |||
386 | return; | 387 | return; |
387 | 388 | ||
388 | gs_shutdown_port (port); | 389 | gs_shutdown_port (port); |
390 | spin_lock_irqsave(&port->port.lock, flags); | ||
389 | port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|GS_ACTIVE); | 391 | port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|GS_ACTIVE); |
390 | port->port.tty = NULL; | 392 | port->port.tty = NULL; |
391 | port->port.count = 0; | 393 | port->port.count = 0; |
394 | spin_unlock_irqrestore(&port->port.lock, flags); | ||
392 | 395 | ||
393 | wake_up_interruptible(&port->port.open_wait); | 396 | wake_up_interruptible(&port->port.open_wait); |
394 | func_exit (); | 397 | func_exit (); |
@@ -397,7 +400,8 @@ void gs_hangup(struct tty_struct *tty) | |||
397 | 400 | ||
398 | int gs_block_til_ready(void *port_, struct file * filp) | 401 | int gs_block_til_ready(void *port_, struct file * filp) |
399 | { | 402 | { |
400 | struct gs_port *port = port_; | 403 | struct gs_port *gp = port_; |
404 | struct tty_port *port = &gp->port; | ||
401 | DECLARE_WAITQUEUE(wait, current); | 405 | DECLARE_WAITQUEUE(wait, current); |
402 | int retval; | 406 | int retval; |
403 | int do_clocal = 0; | 407 | int do_clocal = 0; |
@@ -409,16 +413,16 @@ int gs_block_til_ready(void *port_, struct file * filp) | |||
409 | 413 | ||
410 | if (!port) return 0; | 414 | if (!port) return 0; |
411 | 415 | ||
412 | tty = port->port.tty; | 416 | tty = port->tty; |
413 | 417 | ||
414 | gs_dprintk (GS_DEBUG_BTR, "Entering gs_block_till_ready.\n"); | 418 | gs_dprintk (GS_DEBUG_BTR, "Entering gs_block_till_ready.\n"); |
415 | /* | 419 | /* |
416 | * If the device is in the middle of being closed, then block | 420 | * If the device is in the middle of being closed, then block |
417 | * until it's done, and then try again. | 421 | * until it's done, and then try again. |
418 | */ | 422 | */ |
419 | if (tty_hung_up_p(filp) || port->port.flags & ASYNC_CLOSING) { | 423 | if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { |
420 | interruptible_sleep_on(&port->port.close_wait); | 424 | interruptible_sleep_on(&port->close_wait); |
421 | if (port->port.flags & ASYNC_HUP_NOTIFY) | 425 | if (port->flags & ASYNC_HUP_NOTIFY) |
422 | return -EAGAIN; | 426 | return -EAGAIN; |
423 | else | 427 | else |
424 | return -ERESTARTSYS; | 428 | return -ERESTARTSYS; |
@@ -432,7 +436,7 @@ int gs_block_til_ready(void *port_, struct file * filp) | |||
432 | */ | 436 | */ |
433 | if ((filp->f_flags & O_NONBLOCK) || | 437 | if ((filp->f_flags & O_NONBLOCK) || |
434 | (tty->flags & (1 << TTY_IO_ERROR))) { | 438 | (tty->flags & (1 << TTY_IO_ERROR))) { |
435 | port->port.flags |= ASYNC_NORMAL_ACTIVE; | 439 | port->flags |= ASYNC_NORMAL_ACTIVE; |
436 | return 0; | 440 | return 0; |
437 | } | 441 | } |
438 | 442 | ||
@@ -444,34 +448,34 @@ int gs_block_til_ready(void *port_, struct file * filp) | |||
444 | /* | 448 | /* |
445 | * Block waiting for the carrier detect and the line to become | 449 | * Block waiting for the carrier detect and the line to become |
446 | * free (i.e., not in use by the callout). While we are in | 450 | * free (i.e., not in use by the callout). While we are in |
447 | * this loop, port->port.count is dropped by one, so that | 451 | * this loop, port->count is dropped by one, so that |
448 | * rs_close() knows when to free things. We restore it upon | 452 | * rs_close() knows when to free things. We restore it upon |
449 | * exit, either normal or abnormal. | 453 | * exit, either normal or abnormal. |
450 | */ | 454 | */ |
451 | retval = 0; | 455 | retval = 0; |
452 | 456 | ||
453 | add_wait_queue(&port->port.open_wait, &wait); | 457 | add_wait_queue(&port->open_wait, &wait); |
454 | 458 | ||
455 | gs_dprintk (GS_DEBUG_BTR, "after add waitq.\n"); | 459 | gs_dprintk (GS_DEBUG_BTR, "after add waitq.\n"); |
456 | spin_lock_irqsave(&port->driver_lock, flags); | 460 | spin_lock_irqsave(&port->lock, flags); |
457 | if (!tty_hung_up_p(filp)) { | 461 | if (!tty_hung_up_p(filp)) { |
458 | port->port.count--; | 462 | port->count--; |
459 | } | 463 | } |
460 | spin_unlock_irqrestore(&port->driver_lock, flags); | 464 | port->blocked_open++; |
461 | port->port.blocked_open++; | 465 | spin_unlock_irqrestore(&port->lock, flags); |
462 | while (1) { | 466 | while (1) { |
463 | CD = port->rd->get_CD (port); | 467 | CD = tty_port_carrier_raised(port); |
464 | gs_dprintk (GS_DEBUG_BTR, "CD is now %d.\n", CD); | 468 | gs_dprintk (GS_DEBUG_BTR, "CD is now %d.\n", CD); |
465 | set_current_state (TASK_INTERRUPTIBLE); | 469 | set_current_state (TASK_INTERRUPTIBLE); |
466 | if (tty_hung_up_p(filp) || | 470 | if (tty_hung_up_p(filp) || |
467 | !(port->port.flags & ASYNC_INITIALIZED)) { | 471 | !(port->flags & ASYNC_INITIALIZED)) { |
468 | if (port->port.flags & ASYNC_HUP_NOTIFY) | 472 | if (port->flags & ASYNC_HUP_NOTIFY) |
469 | retval = -EAGAIN; | 473 | retval = -EAGAIN; |
470 | else | 474 | else |
471 | retval = -ERESTARTSYS; | 475 | retval = -ERESTARTSYS; |
472 | break; | 476 | break; |
473 | } | 477 | } |
474 | if (!(port->port.flags & ASYNC_CLOSING) && | 478 | if (!(port->flags & ASYNC_CLOSING) && |
475 | (do_clocal || CD)) | 479 | (do_clocal || CD)) |
476 | break; | 480 | break; |
477 | gs_dprintk (GS_DEBUG_BTR, "signal_pending is now: %d (%lx)\n", | 481 | gs_dprintk (GS_DEBUG_BTR, "signal_pending is now: %d (%lx)\n", |
@@ -483,19 +487,20 @@ int gs_block_til_ready(void *port_, struct file * filp) | |||
483 | schedule(); | 487 | schedule(); |
484 | } | 488 | } |
485 | gs_dprintk (GS_DEBUG_BTR, "Got out of the loop. (%d)\n", | 489 | gs_dprintk (GS_DEBUG_BTR, "Got out of the loop. (%d)\n", |
486 | port->port.blocked_open); | 490 | port->blocked_open); |
487 | set_current_state (TASK_RUNNING); | 491 | set_current_state (TASK_RUNNING); |
488 | remove_wait_queue(&port->port.open_wait, &wait); | 492 | remove_wait_queue(&port->open_wait, &wait); |
493 | |||
494 | spin_lock_irqsave(&port->lock, flags); | ||
489 | if (!tty_hung_up_p(filp)) { | 495 | if (!tty_hung_up_p(filp)) { |
490 | port->port.count++; | 496 | port->count++; |
491 | } | 497 | } |
492 | port->port.blocked_open--; | 498 | port->blocked_open--; |
493 | if (retval) | 499 | if (retval == 0) |
494 | return retval; | 500 | port->flags |= ASYNC_NORMAL_ACTIVE; |
495 | 501 | spin_unlock_irqrestore(&port->lock, flags); | |
496 | port->port.flags |= ASYNC_NORMAL_ACTIVE; | ||
497 | func_exit (); | 502 | func_exit (); |
498 | return 0; | 503 | return retval; |
499 | } | 504 | } |
500 | 505 | ||
501 | 506 | ||
@@ -506,7 +511,7 @@ void gs_close(struct tty_struct * tty, struct file * filp) | |||
506 | 511 | ||
507 | func_enter (); | 512 | func_enter (); |
508 | 513 | ||
509 | port = (struct gs_port *) tty->driver_data; | 514 | port = tty->driver_data; |
510 | 515 | ||
511 | if (!port) return; | 516 | if (!port) return; |
512 | 517 | ||
@@ -516,10 +521,10 @@ void gs_close(struct tty_struct * tty, struct file * filp) | |||
516 | port->port.tty = tty; | 521 | port->port.tty = tty; |
517 | } | 522 | } |
518 | 523 | ||
519 | spin_lock_irqsave(&port->driver_lock, flags); | 524 | spin_lock_irqsave(&port->port.lock, flags); |
520 | 525 | ||
521 | if (tty_hung_up_p(filp)) { | 526 | if (tty_hung_up_p(filp)) { |
522 | spin_unlock_irqrestore(&port->driver_lock, flags); | 527 | spin_unlock_irqrestore(&port->port.lock, flags); |
523 | if (port->rd->hungup) | 528 | if (port->rd->hungup) |
524 | port->rd->hungup (port); | 529 | port->rd->hungup (port); |
525 | func_exit (); | 530 | func_exit (); |
@@ -538,7 +543,7 @@ void gs_close(struct tty_struct * tty, struct file * filp) | |||
538 | 543 | ||
539 | if (port->port.count) { | 544 | if (port->port.count) { |
540 | gs_dprintk(GS_DEBUG_CLOSE, "gs_close port %p: count: %d\n", port, port->port.count); | 545 | gs_dprintk(GS_DEBUG_CLOSE, "gs_close port %p: count: %d\n", port, port->port.count); |
541 | spin_unlock_irqrestore(&port->driver_lock, flags); | 546 | spin_unlock_irqrestore(&port->port.lock, flags); |
542 | func_exit (); | 547 | func_exit (); |
543 | return; | 548 | return; |
544 | } | 549 | } |
@@ -559,8 +564,10 @@ void gs_close(struct tty_struct * tty, struct file * filp) | |||
559 | * line status register. | 564 | * line status register. |
560 | */ | 565 | */ |
561 | 566 | ||
567 | spin_lock_irqsave(&port->driver_lock, flags); | ||
562 | port->rd->disable_rx_interrupts (port); | 568 | port->rd->disable_rx_interrupts (port); |
563 | spin_unlock_irqrestore(&port->driver_lock, flags); | 569 | spin_unlock_irqrestore(&port->driver_lock, flags); |
570 | spin_unlock_irqrestore(&port->port.lock, flags); | ||
564 | 571 | ||
565 | /* close has no way of returning "EINTR", so discard return value */ | 572 | /* close has no way of returning "EINTR", so discard return value */ |
566 | if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) | 573 | if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE) |
@@ -573,20 +580,25 @@ void gs_close(struct tty_struct * tty, struct file * filp) | |||
573 | tty_ldisc_flush(tty); | 580 | tty_ldisc_flush(tty); |
574 | tty->closing = 0; | 581 | tty->closing = 0; |
575 | 582 | ||
583 | spin_lock_irqsave(&port->driver_lock, flags); | ||
576 | port->event = 0; | 584 | port->event = 0; |
577 | port->rd->close (port); | 585 | port->rd->close (port); |
578 | port->rd->shutdown_port (port); | 586 | port->rd->shutdown_port (port); |
587 | spin_unlock_irqrestore(&port->driver_lock, flags); | ||
588 | |||
589 | spin_lock_irqsave(&port->port.lock, flags); | ||
579 | port->port.tty = NULL; | 590 | port->port.tty = NULL; |
580 | 591 | ||
581 | if (port->port.blocked_open) { | 592 | if (port->port.blocked_open) { |
582 | if (port->close_delay) { | 593 | if (port->close_delay) { |
583 | spin_unlock_irqrestore(&port->driver_lock, flags); | 594 | spin_unlock_irqrestore(&port->port.lock, flags); |
584 | msleep_interruptible(jiffies_to_msecs(port->close_delay)); | 595 | msleep_interruptible(jiffies_to_msecs(port->close_delay)); |
585 | spin_lock_irqsave(&port->driver_lock, flags); | 596 | spin_lock_irqsave(&port->port.lock, flags); |
586 | } | 597 | } |
587 | wake_up_interruptible(&port->port.open_wait); | 598 | wake_up_interruptible(&port->port.open_wait); |
588 | } | 599 | } |
589 | port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING | ASYNC_INITIALIZED); | 600 | port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING | ASYNC_INITIALIZED); |
601 | spin_unlock_irqrestore(&port->port.lock, flags); | ||
590 | wake_up_interruptible(&port->port.close_wait); | 602 | wake_up_interruptible(&port->port.close_wait); |
591 | 603 | ||
592 | func_exit (); | 604 | func_exit (); |
diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c index 53fdc7ff3870..32b8bbf5003e 100644 --- a/drivers/char/hpet.c +++ b/drivers/char/hpet.c | |||
@@ -46,7 +46,7 @@ | |||
46 | /* | 46 | /* |
47 | * The High Precision Event Timer driver. | 47 | * The High Precision Event Timer driver. |
48 | * This driver is closely modelled after the rtc.c driver. | 48 | * This driver is closely modelled after the rtc.c driver. |
49 | * http://www.intel.com/hardwaredesign/hpetspec.htm | 49 | * http://www.intel.com/hardwaredesign/hpetspec_1.pdf |
50 | */ | 50 | */ |
51 | #define HPET_USER_FREQ (64) | 51 | #define HPET_USER_FREQ (64) |
52 | #define HPET_DRIFT (500) | 52 | #define HPET_DRIFT (500) |
diff --git a/drivers/char/hvc_beat.c b/drivers/char/hvc_beat.c index 91cdb35a9204..0afc8b82212e 100644 --- a/drivers/char/hvc_beat.c +++ b/drivers/char/hvc_beat.c | |||
@@ -44,7 +44,7 @@ static int hvc_beat_get_chars(uint32_t vtermno, char *buf, int cnt) | |||
44 | static unsigned char q[sizeof(unsigned long) * 2] | 44 | static unsigned char q[sizeof(unsigned long) * 2] |
45 | __attribute__((aligned(sizeof(unsigned long)))); | 45 | __attribute__((aligned(sizeof(unsigned long)))); |
46 | static int qlen = 0; | 46 | static int qlen = 0; |
47 | unsigned long got; | 47 | u64 got; |
48 | 48 | ||
49 | again: | 49 | again: |
50 | if (qlen) { | 50 | if (qlen) { |
@@ -63,7 +63,7 @@ again: | |||
63 | } | 63 | } |
64 | } | 64 | } |
65 | if (beat_get_term_char(vtermno, &got, | 65 | if (beat_get_term_char(vtermno, &got, |
66 | ((unsigned long *)q), ((unsigned long *)q) + 1) == 0) { | 66 | ((u64 *)q), ((u64 *)q) + 1) == 0) { |
67 | qlen = got; | 67 | qlen = got; |
68 | goto again; | 68 | goto again; |
69 | } | 69 | } |
diff --git a/drivers/char/hvc_console.c b/drivers/char/hvc_console.c index 5b819b12675a..5a8a4c28c867 100644 --- a/drivers/char/hvc_console.c +++ b/drivers/char/hvc_console.c | |||
@@ -529,7 +529,7 @@ static void hvc_set_winsz(struct work_struct *work) | |||
529 | tty = tty_kref_get(hp->tty); | 529 | tty = tty_kref_get(hp->tty); |
530 | spin_unlock_irqrestore(&hp->lock, hvc_flags); | 530 | spin_unlock_irqrestore(&hp->lock, hvc_flags); |
531 | 531 | ||
532 | tty_do_resize(tty, tty, &ws); | 532 | tty_do_resize(tty, &ws); |
533 | tty_kref_put(tty); | 533 | tty_kref_put(tty); |
534 | } | 534 | } |
535 | 535 | ||
@@ -642,8 +642,11 @@ int hvc_poll(struct hvc_struct *hp) | |||
642 | /* Handle the SysRq Hack */ | 642 | /* Handle the SysRq Hack */ |
643 | /* XXX should support a sequence */ | 643 | /* XXX should support a sequence */ |
644 | if (buf[i] == '\x0f') { /* ^O */ | 644 | if (buf[i] == '\x0f') { /* ^O */ |
645 | sysrq_pressed = 1; | 645 | /* if ^O is pressed again, reset |
646 | continue; | 646 | * sysrq_pressed and flip ^O char */ |
647 | sysrq_pressed = !sysrq_pressed; | ||
648 | if (sysrq_pressed) | ||
649 | continue; | ||
647 | } else if (sysrq_pressed) { | 650 | } else if (sysrq_pressed) { |
648 | handle_sysrq(buf[i], tty); | 651 | handle_sysrq(buf[i], tty); |
649 | sysrq_pressed = 0; | 652 | sysrq_pressed = 0; |
@@ -689,11 +692,10 @@ EXPORT_SYMBOL_GPL(hvc_poll); | |||
689 | */ | 692 | */ |
690 | void hvc_resize(struct hvc_struct *hp, struct winsize ws) | 693 | void hvc_resize(struct hvc_struct *hp, struct winsize ws) |
691 | { | 694 | { |
692 | if ((hp->ws.ws_row != ws.ws_row) || (hp->ws.ws_col != ws.ws_col)) { | 695 | hp->ws = ws; |
693 | hp->ws = ws; | 696 | schedule_work(&hp->tty_resize); |
694 | schedule_work(&hp->tty_resize); | ||
695 | } | ||
696 | } | 697 | } |
698 | EXPORT_SYMBOL_GPL(hvc_resize); | ||
697 | 699 | ||
698 | /* | 700 | /* |
699 | * This kthread is either polling or interrupt driven. This is determined by | 701 | * This kthread is either polling or interrupt driven. This is determined by |
diff --git a/drivers/char/hvc_console.h b/drivers/char/hvc_console.h index 8297dbc2e6ec..3c85d78c975c 100644 --- a/drivers/char/hvc_console.h +++ b/drivers/char/hvc_console.h | |||
@@ -48,7 +48,7 @@ struct hvc_struct { | |||
48 | spinlock_t lock; | 48 | spinlock_t lock; |
49 | int index; | 49 | int index; |
50 | struct tty_struct *tty; | 50 | struct tty_struct *tty; |
51 | unsigned int count; | 51 | int count; |
52 | int do_wakeup; | 52 | int do_wakeup; |
53 | char *outbuf; | 53 | char *outbuf; |
54 | int outbuf_size; | 54 | int outbuf_size; |
diff --git a/drivers/char/hvc_iseries.c b/drivers/char/hvc_iseries.c index b74a2f8ab908..449727b6166d 100644 --- a/drivers/char/hvc_iseries.c +++ b/drivers/char/hvc_iseries.c | |||
@@ -575,8 +575,10 @@ static int __init hvc_find_vtys(void) | |||
575 | * of console adapters. | 575 | * of console adapters. |
576 | */ | 576 | */ |
577 | if ((num_found >= MAX_NR_HVC_CONSOLES) || | 577 | if ((num_found >= MAX_NR_HVC_CONSOLES) || |
578 | (num_found >= VTTY_PORTS)) | 578 | (num_found >= VTTY_PORTS)) { |
579 | of_node_put(vty); | ||
579 | break; | 580 | break; |
581 | } | ||
580 | 582 | ||
581 | vtermno = of_get_property(vty, "reg", NULL); | 583 | vtermno = of_get_property(vty, "reg", NULL); |
582 | if (!vtermno) | 584 | if (!vtermno) |
diff --git a/drivers/char/hvc_iucv.c b/drivers/char/hvc_iucv.c new file mode 100644 index 000000000000..5ea7d7713fca --- /dev/null +++ b/drivers/char/hvc_iucv.c | |||
@@ -0,0 +1,850 @@ | |||
1 | /* | ||
2 | * hvc_iucv.c - z/VM IUCV back-end for the Hypervisor Console (HVC) | ||
3 | * | ||
4 | * This back-end for HVC provides terminal access via | ||
5 | * z/VM IUCV communication paths. | ||
6 | * | ||
7 | * Copyright IBM Corp. 2008. | ||
8 | * | ||
9 | * Author(s): Hendrik Brueckner <brueckner@linux.vnet.ibm.com> | ||
10 | */ | ||
11 | #define KMSG_COMPONENT "hvc_iucv" | ||
12 | |||
13 | #include <linux/types.h> | ||
14 | #include <asm/ebcdic.h> | ||
15 | #include <linux/mempool.h> | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/tty.h> | ||
18 | #include <net/iucv/iucv.h> | ||
19 | |||
20 | #include "hvc_console.h" | ||
21 | |||
22 | |||
23 | /* HVC backend for z/VM IUCV */ | ||
24 | #define HVC_IUCV_MAGIC 0xc9e4c3e5 | ||
25 | #define MAX_HVC_IUCV_LINES HVC_ALLOC_TTY_ADAPTERS | ||
26 | #define MEMPOOL_MIN_NR (PAGE_SIZE / sizeof(struct iucv_tty_buffer)/4) | ||
27 | |||
28 | /* IUCV TTY message */ | ||
29 | #define MSG_VERSION 0x02 /* Message version */ | ||
30 | #define MSG_TYPE_ERROR 0x01 /* Error message */ | ||
31 | #define MSG_TYPE_TERMENV 0x02 /* Terminal environment variable */ | ||
32 | #define MSG_TYPE_TERMIOS 0x04 /* Terminal IO struct update */ | ||
33 | #define MSG_TYPE_WINSIZE 0x08 /* Terminal window size update */ | ||
34 | #define MSG_TYPE_DATA 0x10 /* Terminal data */ | ||
35 | |||
36 | #define MSG_SIZE(s) ((s) + offsetof(struct iucv_tty_msg, data)) | ||
37 | struct iucv_tty_msg { | ||
38 | u8 version; /* Message version */ | ||
39 | u8 type; /* Message type */ | ||
40 | #define MSG_MAX_DATALEN (~(u16)0) | ||
41 | u16 datalen; /* Payload length */ | ||
42 | u8 data[]; /* Payload buffer */ | ||
43 | } __attribute__((packed)); | ||
44 | |||
45 | enum iucv_state_t { | ||
46 | IUCV_DISCONN = 0, | ||
47 | IUCV_CONNECTED = 1, | ||
48 | IUCV_SEVERED = 2, | ||
49 | }; | ||
50 | |||
51 | enum tty_state_t { | ||
52 | TTY_CLOSED = 0, | ||
53 | TTY_OPENED = 1, | ||
54 | }; | ||
55 | |||
56 | struct hvc_iucv_private { | ||
57 | struct hvc_struct *hvc; /* HVC console struct reference */ | ||
58 | u8 srv_name[8]; /* IUCV service name (ebcdic) */ | ||
59 | enum iucv_state_t iucv_state; /* IUCV connection status */ | ||
60 | enum tty_state_t tty_state; /* TTY status */ | ||
61 | struct iucv_path *path; /* IUCV path pointer */ | ||
62 | spinlock_t lock; /* hvc_iucv_private lock */ | ||
63 | struct list_head tty_outqueue; /* outgoing IUCV messages */ | ||
64 | struct list_head tty_inqueue; /* incoming IUCV messages */ | ||
65 | }; | ||
66 | |||
67 | struct iucv_tty_buffer { | ||
68 | struct list_head list; /* list pointer */ | ||
69 | struct iucv_message msg; /* store an incoming IUCV message */ | ||
70 | size_t offset; /* data buffer offset */ | ||
71 | struct iucv_tty_msg *mbuf; /* buffer to store input/output data */ | ||
72 | }; | ||
73 | |||
74 | /* IUCV callback handler */ | ||
75 | static int hvc_iucv_path_pending(struct iucv_path *, u8[8], u8[16]); | ||
76 | static void hvc_iucv_path_severed(struct iucv_path *, u8[16]); | ||
77 | static void hvc_iucv_msg_pending(struct iucv_path *, struct iucv_message *); | ||
78 | static void hvc_iucv_msg_complete(struct iucv_path *, struct iucv_message *); | ||
79 | |||
80 | |||
81 | /* Kernel module parameters */ | ||
82 | static unsigned long hvc_iucv_devices; | ||
83 | |||
84 | /* Array of allocated hvc iucv tty lines... */ | ||
85 | static struct hvc_iucv_private *hvc_iucv_table[MAX_HVC_IUCV_LINES]; | ||
86 | |||
87 | /* Kmem cache and mempool for iucv_tty_buffer elements */ | ||
88 | static struct kmem_cache *hvc_iucv_buffer_cache; | ||
89 | static mempool_t *hvc_iucv_mempool; | ||
90 | |||
91 | /* IUCV handler callback functions */ | ||
92 | static struct iucv_handler hvc_iucv_handler = { | ||
93 | .path_pending = hvc_iucv_path_pending, | ||
94 | .path_severed = hvc_iucv_path_severed, | ||
95 | .message_complete = hvc_iucv_msg_complete, | ||
96 | .message_pending = hvc_iucv_msg_pending, | ||
97 | }; | ||
98 | |||
99 | |||
100 | /** | ||
101 | * hvc_iucv_get_private() - Return a struct hvc_iucv_private instance. | ||
102 | * @num: The HVC virtual terminal number (vtermno) | ||
103 | * | ||
104 | * This function returns the struct hvc_iucv_private instance that corresponds | ||
105 | * to the HVC virtual terminal number specified as parameter @num. | ||
106 | */ | ||
107 | struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num) | ||
108 | { | ||
109 | if ((num < HVC_IUCV_MAGIC) || (num - HVC_IUCV_MAGIC > hvc_iucv_devices)) | ||
110 | return NULL; | ||
111 | return hvc_iucv_table[num - HVC_IUCV_MAGIC]; | ||
112 | } | ||
113 | |||
114 | /** | ||
115 | * alloc_tty_buffer() - Returns a new struct iucv_tty_buffer element. | ||
116 | * @size: Size of the internal buffer used to store data. | ||
117 | * @flags: Memory allocation flags passed to mempool. | ||
118 | * | ||
119 | * This function allocates a new struct iucv_tty_buffer element and, optionally, | ||
120 | * allocates an internal data buffer with the specified size @size. | ||
121 | * Note: The total message size arises from the internal buffer size and the | ||
122 | * members of the iucv_tty_msg structure. | ||
123 | * | ||
124 | * The function returns NULL if memory allocation has failed. | ||
125 | */ | ||
126 | static struct iucv_tty_buffer *alloc_tty_buffer(size_t size, gfp_t flags) | ||
127 | { | ||
128 | struct iucv_tty_buffer *bufp; | ||
129 | |||
130 | bufp = mempool_alloc(hvc_iucv_mempool, flags); | ||
131 | if (!bufp) | ||
132 | return NULL; | ||
133 | memset(bufp, 0, sizeof(struct iucv_tty_buffer)); | ||
134 | |||
135 | if (size > 0) { | ||
136 | bufp->msg.length = MSG_SIZE(size); | ||
137 | bufp->mbuf = kmalloc(bufp->msg.length, flags); | ||
138 | if (!bufp->mbuf) { | ||
139 | mempool_free(bufp, hvc_iucv_mempool); | ||
140 | return NULL; | ||
141 | } | ||
142 | bufp->mbuf->version = MSG_VERSION; | ||
143 | bufp->mbuf->type = MSG_TYPE_DATA; | ||
144 | bufp->mbuf->datalen = (u16) size; | ||
145 | } | ||
146 | return bufp; | ||
147 | } | ||
148 | |||
149 | /** | ||
150 | * destroy_tty_buffer() - destroy struct iucv_tty_buffer element. | ||
151 | * @bufp: Pointer to a struct iucv_tty_buffer element, SHALL NOT be NULL. | ||
152 | * | ||
153 | * The destroy_tty_buffer() function frees the internal data buffer and returns | ||
154 | * the struct iucv_tty_buffer element back to the mempool for freeing. | ||
155 | */ | ||
156 | static void destroy_tty_buffer(struct iucv_tty_buffer *bufp) | ||
157 | { | ||
158 | kfree(bufp->mbuf); | ||
159 | mempool_free(bufp, hvc_iucv_mempool); | ||
160 | } | ||
161 | |||
162 | /** | ||
163 | * destroy_tty_buffer_list() - call destroy_tty_buffer() for each list element. | ||
164 | * @list: List head pointer to a list containing struct iucv_tty_buffer | ||
165 | * elements. | ||
166 | * | ||
167 | * Calls destroy_tty_buffer() for each struct iucv_tty_buffer element in the | ||
168 | * list @list. | ||
169 | */ | ||
170 | static void destroy_tty_buffer_list(struct list_head *list) | ||
171 | { | ||
172 | struct iucv_tty_buffer *ent, *next; | ||
173 | |||
174 | list_for_each_entry_safe(ent, next, list, list) { | ||
175 | list_del(&ent->list); | ||
176 | destroy_tty_buffer(ent); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | /** | ||
181 | * hvc_iucv_write() - Receive IUCV message write data to HVC console buffer. | ||
182 | * @priv: Pointer to hvc_iucv_private structure. | ||
183 | * @buf: HVC console buffer for writing received terminal data. | ||
184 | * @count: HVC console buffer size. | ||
185 | * @has_more_data: Pointer to an int variable. | ||
186 | * | ||
187 | * The function picks up pending messages from the input queue and receives | ||
188 | * the message data that is then written to the specified buffer @buf. | ||
189 | * If the buffer size @count is less than the data message size, then the | ||
190 | * message is kept on the input queue and @has_more_data is set to 1. | ||
191 | * If the message data has been entirely written, the message is removed from | ||
192 | * the input queue. | ||
193 | * | ||
194 | * The function returns the number of bytes written to the terminal, zero if | ||
195 | * there are no pending data messages available or if there is no established | ||
196 | * IUCV path. | ||
197 | * If the IUCV path has been severed, then -EPIPE is returned to cause a | ||
198 | * hang up (that is issued by the HVC console layer). | ||
199 | */ | ||
200 | static int hvc_iucv_write(struct hvc_iucv_private *priv, | ||
201 | char *buf, int count, int *has_more_data) | ||
202 | { | ||
203 | struct iucv_tty_buffer *rb; | ||
204 | int written; | ||
205 | int rc; | ||
206 | |||
207 | /* Immediately return if there is no IUCV connection */ | ||
208 | if (priv->iucv_state == IUCV_DISCONN) | ||
209 | return 0; | ||
210 | |||
211 | /* If the IUCV path has been severed, return -EPIPE to inform the | ||
212 | * hvc console layer to hang up the tty device. */ | ||
213 | if (priv->iucv_state == IUCV_SEVERED) | ||
214 | return -EPIPE; | ||
215 | |||
216 | /* check if there are pending messages */ | ||
217 | if (list_empty(&priv->tty_inqueue)) | ||
218 | return 0; | ||
219 | |||
220 | /* receive a iucv message and flip data to the tty (ldisc) */ | ||
221 | rb = list_first_entry(&priv->tty_inqueue, struct iucv_tty_buffer, list); | ||
222 | |||
223 | written = 0; | ||
224 | if (!rb->mbuf) { /* message not yet received ... */ | ||
225 | /* allocate mem to store msg data; if no memory is available | ||
226 | * then leave the buffer on the list and re-try later */ | ||
227 | rb->mbuf = kmalloc(rb->msg.length, GFP_ATOMIC); | ||
228 | if (!rb->mbuf) | ||
229 | return -ENOMEM; | ||
230 | |||
231 | rc = __iucv_message_receive(priv->path, &rb->msg, 0, | ||
232 | rb->mbuf, rb->msg.length, NULL); | ||
233 | switch (rc) { | ||
234 | case 0: /* Successful */ | ||
235 | break; | ||
236 | case 2: /* No message found */ | ||
237 | case 9: /* Message purged */ | ||
238 | break; | ||
239 | default: | ||
240 | written = -EIO; | ||
241 | } | ||
242 | /* remove buffer if an error has occured or received data | ||
243 | * is not correct */ | ||
244 | if (rc || (rb->mbuf->version != MSG_VERSION) || | ||
245 | (rb->msg.length != MSG_SIZE(rb->mbuf->datalen))) | ||
246 | goto out_remove_buffer; | ||
247 | } | ||
248 | |||
249 | switch (rb->mbuf->type) { | ||
250 | case MSG_TYPE_DATA: | ||
251 | written = min_t(int, rb->mbuf->datalen - rb->offset, count); | ||
252 | memcpy(buf, rb->mbuf->data + rb->offset, written); | ||
253 | if (written < (rb->mbuf->datalen - rb->offset)) { | ||
254 | rb->offset += written; | ||
255 | *has_more_data = 1; | ||
256 | goto out_written; | ||
257 | } | ||
258 | break; | ||
259 | |||
260 | case MSG_TYPE_WINSIZE: | ||
261 | if (rb->mbuf->datalen != sizeof(struct winsize)) | ||
262 | break; | ||
263 | hvc_resize(priv->hvc, *((struct winsize *)rb->mbuf->data)); | ||
264 | break; | ||
265 | |||
266 | case MSG_TYPE_ERROR: /* ignored ... */ | ||
267 | case MSG_TYPE_TERMENV: /* ignored ... */ | ||
268 | case MSG_TYPE_TERMIOS: /* ignored ... */ | ||
269 | break; | ||
270 | } | ||
271 | |||
272 | out_remove_buffer: | ||
273 | list_del(&rb->list); | ||
274 | destroy_tty_buffer(rb); | ||
275 | *has_more_data = !list_empty(&priv->tty_inqueue); | ||
276 | |||
277 | out_written: | ||
278 | return written; | ||
279 | } | ||
280 | |||
281 | /** | ||
282 | * hvc_iucv_get_chars() - HVC get_chars operation. | ||
283 | * @vtermno: HVC virtual terminal number. | ||
284 | * @buf: Pointer to a buffer to store data | ||
285 | * @count: Size of buffer available for writing | ||
286 | * | ||
287 | * The hvc_console thread calls this method to read characters from | ||
288 | * the terminal backend. If an IUCV communication path has been established, | ||
289 | * pending IUCV messages are received and data is copied into buffer @buf | ||
290 | * up to @count bytes. | ||
291 | * | ||
292 | * Locking: The routine gets called under an irqsave() spinlock; and | ||
293 | * the routine locks the struct hvc_iucv_private->lock to call | ||
294 | * helper functions. | ||
295 | */ | ||
296 | static int hvc_iucv_get_chars(uint32_t vtermno, char *buf, int count) | ||
297 | { | ||
298 | struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno); | ||
299 | int written; | ||
300 | int has_more_data; | ||
301 | |||
302 | if (count <= 0) | ||
303 | return 0; | ||
304 | |||
305 | if (!priv) | ||
306 | return -ENODEV; | ||
307 | |||
308 | spin_lock(&priv->lock); | ||
309 | has_more_data = 0; | ||
310 | written = hvc_iucv_write(priv, buf, count, &has_more_data); | ||
311 | spin_unlock(&priv->lock); | ||
312 | |||
313 | /* if there are still messages on the queue... schedule another run */ | ||
314 | if (has_more_data) | ||
315 | hvc_kick(); | ||
316 | |||
317 | return written; | ||
318 | } | ||
319 | |||
320 | /** | ||
321 | * hvc_iucv_send() - Send an IUCV message containing terminal data. | ||
322 | * @priv: Pointer to struct hvc_iucv_private instance. | ||
323 | * @buf: Buffer containing data to send. | ||
324 | * @size: Size of buffer and amount of data to send. | ||
325 | * | ||
326 | * If an IUCV communication path is established, the function copies the buffer | ||
327 | * data to a newly allocated struct iucv_tty_buffer element, sends the data and | ||
328 | * puts the element to the outqueue. | ||
329 | * | ||
330 | * If there is no IUCV communication path established, the function returns 0. | ||
331 | * If an existing IUCV communicaton path has been severed, the function returns | ||
332 | * -EPIPE (can be passed to HVC layer to cause a tty hangup). | ||
333 | */ | ||
334 | static int hvc_iucv_send(struct hvc_iucv_private *priv, const char *buf, | ||
335 | int count) | ||
336 | { | ||
337 | struct iucv_tty_buffer *sb; | ||
338 | int rc; | ||
339 | u16 len; | ||
340 | |||
341 | if (priv->iucv_state == IUCV_SEVERED) | ||
342 | return -EPIPE; | ||
343 | |||
344 | if (priv->iucv_state == IUCV_DISCONN) | ||
345 | return 0; | ||
346 | |||
347 | len = min_t(u16, MSG_MAX_DATALEN, count); | ||
348 | |||
349 | /* allocate internal buffer to store msg data and also compute total | ||
350 | * message length */ | ||
351 | sb = alloc_tty_buffer(len, GFP_ATOMIC); | ||
352 | if (!sb) | ||
353 | return -ENOMEM; | ||
354 | |||
355 | sb->mbuf->datalen = len; | ||
356 | memcpy(sb->mbuf->data, buf, len); | ||
357 | |||
358 | list_add_tail(&sb->list, &priv->tty_outqueue); | ||
359 | |||
360 | rc = __iucv_message_send(priv->path, &sb->msg, 0, 0, | ||
361 | (void *) sb->mbuf, sb->msg.length); | ||
362 | if (rc) { | ||
363 | list_del(&sb->list); | ||
364 | destroy_tty_buffer(sb); | ||
365 | len = 0; | ||
366 | } | ||
367 | |||
368 | return len; | ||
369 | } | ||
370 | |||
371 | /** | ||
372 | * hvc_iucv_put_chars() - HVC put_chars operation. | ||
373 | * @vtermno: HVC virtual terminal number. | ||
374 | * @buf: Pointer to an buffer to read data from | ||
375 | * @count: Size of buffer available for reading | ||
376 | * | ||
377 | * The hvc_console thread calls this method to write characters from | ||
378 | * to the terminal backend. | ||
379 | * The function calls hvc_iucv_send() under the lock of the | ||
380 | * struct hvc_iucv_private instance that corresponds to the tty @vtermno. | ||
381 | * | ||
382 | * Locking: The method gets called under an irqsave() spinlock; and | ||
383 | * locks struct hvc_iucv_private->lock. | ||
384 | */ | ||
385 | static int hvc_iucv_put_chars(uint32_t vtermno, const char *buf, int count) | ||
386 | { | ||
387 | struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno); | ||
388 | int sent; | ||
389 | |||
390 | if (count <= 0) | ||
391 | return 0; | ||
392 | |||
393 | if (!priv) | ||
394 | return -ENODEV; | ||
395 | |||
396 | spin_lock(&priv->lock); | ||
397 | sent = hvc_iucv_send(priv, buf, count); | ||
398 | spin_unlock(&priv->lock); | ||
399 | |||
400 | return sent; | ||
401 | } | ||
402 | |||
403 | /** | ||
404 | * hvc_iucv_notifier_add() - HVC notifier for opening a TTY for the first time. | ||
405 | * @hp: Pointer to the HVC device (struct hvc_struct) | ||
406 | * @id: Additional data (originally passed to hvc_alloc): the index of an struct | ||
407 | * hvc_iucv_private instance. | ||
408 | * | ||
409 | * The function sets the tty state to TTY_OPEN for the struct hvc_iucv_private | ||
410 | * instance that is derived from @id. Always returns 0. | ||
411 | * | ||
412 | * Locking: struct hvc_iucv_private->lock, spin_lock_bh | ||
413 | */ | ||
414 | static int hvc_iucv_notifier_add(struct hvc_struct *hp, int id) | ||
415 | { | ||
416 | struct hvc_iucv_private *priv; | ||
417 | |||
418 | priv = hvc_iucv_get_private(id); | ||
419 | if (!priv) | ||
420 | return 0; | ||
421 | |||
422 | spin_lock_bh(&priv->lock); | ||
423 | priv->tty_state = TTY_OPENED; | ||
424 | spin_unlock_bh(&priv->lock); | ||
425 | |||
426 | return 0; | ||
427 | } | ||
428 | |||
429 | /** | ||
430 | * hvc_iucv_cleanup() - Clean up function if the tty portion is finally closed. | ||
431 | * @priv: Pointer to the struct hvc_iucv_private instance. | ||
432 | * | ||
433 | * The functions severs the established IUCV communication path (if any), and | ||
434 | * destroy struct iucv_tty_buffer elements from the in- and outqueue. Finally, | ||
435 | * the functions resets the states to TTY_CLOSED and IUCV_DISCONN. | ||
436 | */ | ||
437 | static void hvc_iucv_cleanup(struct hvc_iucv_private *priv) | ||
438 | { | ||
439 | destroy_tty_buffer_list(&priv->tty_outqueue); | ||
440 | destroy_tty_buffer_list(&priv->tty_inqueue); | ||
441 | |||
442 | priv->tty_state = TTY_CLOSED; | ||
443 | priv->iucv_state = IUCV_DISCONN; | ||
444 | } | ||
445 | |||
446 | /** | ||
447 | * hvc_iucv_notifier_hangup() - HVC notifier for tty hangups. | ||
448 | * @hp: Pointer to the HVC device (struct hvc_struct) | ||
449 | * @id: Additional data (originally passed to hvc_alloc): the index of an struct | ||
450 | * hvc_iucv_private instance. | ||
451 | * | ||
452 | * This routine notifies the HVC backend that a tty hangup (carrier loss, | ||
453 | * virtual or otherwise) has occured. | ||
454 | * | ||
455 | * The HVC backend for z/VM IUCV ignores virtual hangups (vhangup()), to keep | ||
456 | * an existing IUCV communication path established. | ||
457 | * (Background: vhangup() is called from user space (by getty or login) to | ||
458 | * disable writing to the tty by other applications). | ||
459 | * | ||
460 | * If the tty has been opened (e.g. getty) and an established IUCV path has been | ||
461 | * severed (we caused the tty hangup in that case), then the functions invokes | ||
462 | * hvc_iucv_cleanup() to clean up. | ||
463 | * | ||
464 | * Locking: struct hvc_iucv_private->lock | ||
465 | */ | ||
466 | static void hvc_iucv_notifier_hangup(struct hvc_struct *hp, int id) | ||
467 | { | ||
468 | struct hvc_iucv_private *priv; | ||
469 | |||
470 | priv = hvc_iucv_get_private(id); | ||
471 | if (!priv) | ||
472 | return; | ||
473 | |||
474 | spin_lock_bh(&priv->lock); | ||
475 | /* NOTE: If the hangup was scheduled by ourself (from the iucv | ||
476 | * path_servered callback [IUCV_SEVERED]), then we have to | ||
477 | * finally clean up the tty backend structure and set state to | ||
478 | * TTY_CLOSED. | ||
479 | * | ||
480 | * If the tty was hung up otherwise (e.g. vhangup()), then we | ||
481 | * ignore this hangup and keep an established IUCV path open... | ||
482 | * (...the reason is that we are not able to connect back to the | ||
483 | * client if we disconnect on hang up) */ | ||
484 | priv->tty_state = TTY_CLOSED; | ||
485 | |||
486 | if (priv->iucv_state == IUCV_SEVERED) | ||
487 | hvc_iucv_cleanup(priv); | ||
488 | spin_unlock_bh(&priv->lock); | ||
489 | } | ||
490 | |||
491 | /** | ||
492 | * hvc_iucv_notifier_del() - HVC notifier for closing a TTY for the last time. | ||
493 | * @hp: Pointer to the HVC device (struct hvc_struct) | ||
494 | * @id: Additional data (originally passed to hvc_alloc): | ||
495 | * the index of an struct hvc_iucv_private instance. | ||
496 | * | ||
497 | * This routine notifies the HVC backend that the last tty device file | ||
498 | * descriptor has been closed. | ||
499 | * The function calls hvc_iucv_cleanup() to clean up the struct hvc_iucv_private | ||
500 | * instance. | ||
501 | * | ||
502 | * Locking: struct hvc_iucv_private->lock | ||
503 | */ | ||
504 | static void hvc_iucv_notifier_del(struct hvc_struct *hp, int id) | ||
505 | { | ||
506 | struct hvc_iucv_private *priv; | ||
507 | struct iucv_path *path; | ||
508 | |||
509 | priv = hvc_iucv_get_private(id); | ||
510 | if (!priv) | ||
511 | return; | ||
512 | |||
513 | spin_lock_bh(&priv->lock); | ||
514 | path = priv->path; /* save reference to IUCV path */ | ||
515 | priv->path = NULL; | ||
516 | hvc_iucv_cleanup(priv); | ||
517 | spin_unlock_bh(&priv->lock); | ||
518 | |||
519 | /* sever IUCV path outside of priv->lock due to lock ordering of: | ||
520 | * priv->lock <--> iucv_table_lock */ | ||
521 | if (path) { | ||
522 | iucv_path_sever(path, NULL); | ||
523 | iucv_path_free(path); | ||
524 | } | ||
525 | } | ||
526 | |||
527 | /** | ||
528 | * hvc_iucv_path_pending() - IUCV handler to process a connection request. | ||
529 | * @path: Pending path (struct iucv_path) | ||
530 | * @ipvmid: Originator z/VM system identifier | ||
531 | * @ipuser: User specified data for this path | ||
532 | * (AF_IUCV: port/service name and originator port) | ||
533 | * | ||
534 | * The function uses the @ipuser data to check to determine if the pending | ||
535 | * path belongs to a terminal managed by this HVC backend. | ||
536 | * If the check is successful, then an additional check is done to ensure | ||
537 | * that a terminal cannot be accessed multiple times (only one connection | ||
538 | * to a terminal is allowed). In that particular case, the pending path is | ||
539 | * severed. If it is the first connection, the pending path is accepted and | ||
540 | * associated to the struct hvc_iucv_private. The iucv state is updated to | ||
541 | * reflect that a communication path has been established. | ||
542 | * | ||
543 | * Returns 0 if the path belongs to a terminal managed by the this HVC backend; | ||
544 | * otherwise returns -ENODEV in order to dispatch this path to other handlers. | ||
545 | * | ||
546 | * Locking: struct hvc_iucv_private->lock | ||
547 | */ | ||
548 | static int hvc_iucv_path_pending(struct iucv_path *path, | ||
549 | u8 ipvmid[8], u8 ipuser[16]) | ||
550 | { | ||
551 | struct hvc_iucv_private *priv; | ||
552 | u8 nuser_data[16]; | ||
553 | int i, rc; | ||
554 | |||
555 | priv = NULL; | ||
556 | for (i = 0; i < hvc_iucv_devices; i++) | ||
557 | if (hvc_iucv_table[i] && | ||
558 | (0 == memcmp(hvc_iucv_table[i]->srv_name, ipuser, 8))) { | ||
559 | priv = hvc_iucv_table[i]; | ||
560 | break; | ||
561 | } | ||
562 | |||
563 | if (!priv) | ||
564 | return -ENODEV; | ||
565 | |||
566 | spin_lock(&priv->lock); | ||
567 | |||
568 | /* If the terminal is already connected or being severed, then sever | ||
569 | * this path to enforce that there is only ONE established communication | ||
570 | * path per terminal. */ | ||
571 | if (priv->iucv_state != IUCV_DISCONN) { | ||
572 | iucv_path_sever(path, ipuser); | ||
573 | iucv_path_free(path); | ||
574 | goto out_path_handled; | ||
575 | } | ||
576 | |||
577 | /* accept path */ | ||
578 | memcpy(nuser_data, ipuser + 8, 8); /* remote service (for af_iucv) */ | ||
579 | memcpy(nuser_data + 8, ipuser, 8); /* local service (for af_iucv) */ | ||
580 | path->msglim = 0xffff; /* IUCV MSGLIMIT */ | ||
581 | path->flags &= ~IUCV_IPRMDATA; /* TODO: use IUCV_IPRMDATA */ | ||
582 | rc = iucv_path_accept(path, &hvc_iucv_handler, nuser_data, priv); | ||
583 | if (rc) { | ||
584 | iucv_path_sever(path, ipuser); | ||
585 | iucv_path_free(path); | ||
586 | goto out_path_handled; | ||
587 | } | ||
588 | priv->path = path; | ||
589 | priv->iucv_state = IUCV_CONNECTED; | ||
590 | |||
591 | out_path_handled: | ||
592 | spin_unlock(&priv->lock); | ||
593 | return 0; | ||
594 | } | ||
595 | |||
596 | /** | ||
597 | * hvc_iucv_path_severed() - IUCV handler to process a path sever. | ||
598 | * @path: Pending path (struct iucv_path) | ||
599 | * @ipuser: User specified data for this path | ||
600 | * (AF_IUCV: port/service name and originator port) | ||
601 | * | ||
602 | * The function also severs the path (as required by the IUCV protocol) and | ||
603 | * sets the iucv state to IUCV_SEVERED for the associated struct | ||
604 | * hvc_iucv_private instance. Later, the IUCV_SEVERED state triggers a tty | ||
605 | * hangup (hvc_iucv_get_chars() / hvc_iucv_write()). | ||
606 | * | ||
607 | * If tty portion of the HVC is closed then clean up the outqueue in addition. | ||
608 | * | ||
609 | * Locking: struct hvc_iucv_private->lock | ||
610 | */ | ||
611 | static void hvc_iucv_path_severed(struct iucv_path *path, u8 ipuser[16]) | ||
612 | { | ||
613 | struct hvc_iucv_private *priv = path->private; | ||
614 | |||
615 | spin_lock(&priv->lock); | ||
616 | priv->iucv_state = IUCV_SEVERED; | ||
617 | |||
618 | /* NOTE: If the tty has not yet been opened by a getty program | ||
619 | * (e.g. to see console messages), then cleanup the | ||
620 | * hvc_iucv_private structure to allow re-connects. | ||
621 | * | ||
622 | * If the tty has been opened, the get_chars() callback returns | ||
623 | * -EPIPE to signal the hvc console layer to hang up the tty. */ | ||
624 | priv->path = NULL; | ||
625 | if (priv->tty_state == TTY_CLOSED) | ||
626 | hvc_iucv_cleanup(priv); | ||
627 | spin_unlock(&priv->lock); | ||
628 | |||
629 | /* finally sever path (outside of priv->lock due to lock ordering) */ | ||
630 | iucv_path_sever(path, ipuser); | ||
631 | iucv_path_free(path); | ||
632 | } | ||
633 | |||
634 | /** | ||
635 | * hvc_iucv_msg_pending() - IUCV handler to process an incoming IUCV message. | ||
636 | * @path: Pending path (struct iucv_path) | ||
637 | * @msg: Pointer to the IUCV message | ||
638 | * | ||
639 | * The function stores an incoming message on the input queue for later | ||
640 | * processing (by hvc_iucv_get_chars() / hvc_iucv_write()). | ||
641 | * However, if the tty has not yet been opened, the message is rejected. | ||
642 | * | ||
643 | * Locking: struct hvc_iucv_private->lock | ||
644 | */ | ||
645 | static void hvc_iucv_msg_pending(struct iucv_path *path, | ||
646 | struct iucv_message *msg) | ||
647 | { | ||
648 | struct hvc_iucv_private *priv = path->private; | ||
649 | struct iucv_tty_buffer *rb; | ||
650 | |||
651 | spin_lock(&priv->lock); | ||
652 | |||
653 | /* reject messages if tty has not yet been opened */ | ||
654 | if (priv->tty_state == TTY_CLOSED) { | ||
655 | iucv_message_reject(path, msg); | ||
656 | goto unlock_return; | ||
657 | } | ||
658 | |||
659 | /* allocate buffer an empty buffer element */ | ||
660 | rb = alloc_tty_buffer(0, GFP_ATOMIC); | ||
661 | if (!rb) { | ||
662 | iucv_message_reject(path, msg); | ||
663 | goto unlock_return; /* -ENOMEM */ | ||
664 | } | ||
665 | rb->msg = *msg; | ||
666 | |||
667 | list_add_tail(&rb->list, &priv->tty_inqueue); | ||
668 | |||
669 | hvc_kick(); /* wakup hvc console thread */ | ||
670 | |||
671 | unlock_return: | ||
672 | spin_unlock(&priv->lock); | ||
673 | } | ||
674 | |||
675 | /** | ||
676 | * hvc_iucv_msg_complete() - IUCV handler to process message completion | ||
677 | * @path: Pending path (struct iucv_path) | ||
678 | * @msg: Pointer to the IUCV message | ||
679 | * | ||
680 | * The function is called upon completion of message delivery and the | ||
681 | * message is removed from the outqueue. Additional delivery information | ||
682 | * can be found in msg->audit: rejected messages (0x040000 (IPADRJCT)) and | ||
683 | * purged messages (0x010000 (IPADPGNR)). | ||
684 | * | ||
685 | * Locking: struct hvc_iucv_private->lock | ||
686 | */ | ||
687 | static void hvc_iucv_msg_complete(struct iucv_path *path, | ||
688 | struct iucv_message *msg) | ||
689 | { | ||
690 | struct hvc_iucv_private *priv = path->private; | ||
691 | struct iucv_tty_buffer *ent, *next; | ||
692 | LIST_HEAD(list_remove); | ||
693 | |||
694 | spin_lock(&priv->lock); | ||
695 | list_for_each_entry_safe(ent, next, &priv->tty_outqueue, list) | ||
696 | if (ent->msg.id == msg->id) { | ||
697 | list_move(&ent->list, &list_remove); | ||
698 | break; | ||
699 | } | ||
700 | spin_unlock(&priv->lock); | ||
701 | destroy_tty_buffer_list(&list_remove); | ||
702 | } | ||
703 | |||
704 | |||
705 | /* HVC operations */ | ||
706 | static struct hv_ops hvc_iucv_ops = { | ||
707 | .get_chars = hvc_iucv_get_chars, | ||
708 | .put_chars = hvc_iucv_put_chars, | ||
709 | .notifier_add = hvc_iucv_notifier_add, | ||
710 | .notifier_del = hvc_iucv_notifier_del, | ||
711 | .notifier_hangup = hvc_iucv_notifier_hangup, | ||
712 | }; | ||
713 | |||
714 | /** | ||
715 | * hvc_iucv_alloc() - Allocates a new struct hvc_iucv_private instance | ||
716 | * @id: hvc_iucv_table index | ||
717 | * | ||
718 | * This function allocates a new hvc_iucv_private struct and put the | ||
719 | * instance into hvc_iucv_table at index @id. | ||
720 | * Returns 0 on success; otherwise non-zero. | ||
721 | */ | ||
722 | static int __init hvc_iucv_alloc(int id) | ||
723 | { | ||
724 | struct hvc_iucv_private *priv; | ||
725 | char name[9]; | ||
726 | int rc; | ||
727 | |||
728 | priv = kzalloc(sizeof(struct hvc_iucv_private), GFP_KERNEL); | ||
729 | if (!priv) | ||
730 | return -ENOMEM; | ||
731 | |||
732 | spin_lock_init(&priv->lock); | ||
733 | INIT_LIST_HEAD(&priv->tty_outqueue); | ||
734 | INIT_LIST_HEAD(&priv->tty_inqueue); | ||
735 | |||
736 | /* Finally allocate hvc */ | ||
737 | priv->hvc = hvc_alloc(HVC_IUCV_MAGIC + id, | ||
738 | HVC_IUCV_MAGIC + id, &hvc_iucv_ops, PAGE_SIZE); | ||
739 | if (IS_ERR(priv->hvc)) { | ||
740 | rc = PTR_ERR(priv->hvc); | ||
741 | kfree(priv); | ||
742 | return rc; | ||
743 | } | ||
744 | |||
745 | /* setup iucv related information */ | ||
746 | snprintf(name, 9, "ihvc%-4d", id); | ||
747 | memcpy(priv->srv_name, name, 8); | ||
748 | ASCEBC(priv->srv_name, 8); | ||
749 | |||
750 | hvc_iucv_table[id] = priv; | ||
751 | return 0; | ||
752 | } | ||
753 | |||
754 | /** | ||
755 | * hvc_iucv_init() - Initialization of HVC backend for z/VM IUCV | ||
756 | */ | ||
757 | static int __init hvc_iucv_init(void) | ||
758 | { | ||
759 | int rc, i; | ||
760 | |||
761 | if (!MACHINE_IS_VM) { | ||
762 | pr_warning("The z/VM IUCV Hypervisor console cannot be " | ||
763 | "used without z/VM.\n"); | ||
764 | return -ENODEV; | ||
765 | } | ||
766 | |||
767 | if (!hvc_iucv_devices) | ||
768 | return -ENODEV; | ||
769 | |||
770 | if (hvc_iucv_devices > MAX_HVC_IUCV_LINES) | ||
771 | return -EINVAL; | ||
772 | |||
773 | hvc_iucv_buffer_cache = kmem_cache_create(KMSG_COMPONENT, | ||
774 | sizeof(struct iucv_tty_buffer), | ||
775 | 0, 0, NULL); | ||
776 | if (!hvc_iucv_buffer_cache) { | ||
777 | pr_err("Not enough memory for driver initialization " | ||
778 | "(rs=%d).\n", 1); | ||
779 | return -ENOMEM; | ||
780 | } | ||
781 | |||
782 | hvc_iucv_mempool = mempool_create_slab_pool(MEMPOOL_MIN_NR, | ||
783 | hvc_iucv_buffer_cache); | ||
784 | if (!hvc_iucv_mempool) { | ||
785 | pr_err("Not enough memory for driver initialization " | ||
786 | "(rs=%d).\n", 2); | ||
787 | kmem_cache_destroy(hvc_iucv_buffer_cache); | ||
788 | return -ENOMEM; | ||
789 | } | ||
790 | |||
791 | /* allocate hvc_iucv_private structs */ | ||
792 | for (i = 0; i < hvc_iucv_devices; i++) { | ||
793 | rc = hvc_iucv_alloc(i); | ||
794 | if (rc) { | ||
795 | pr_err("Could not create new z/VM IUCV HVC backend " | ||
796 | "rc=%d.\n", rc); | ||
797 | goto out_error_hvc; | ||
798 | } | ||
799 | } | ||
800 | |||
801 | /* register IUCV callback handler */ | ||
802 | rc = iucv_register(&hvc_iucv_handler, 0); | ||
803 | if (rc) { | ||
804 | pr_err("Could not register iucv handler (rc=%d).\n", rc); | ||
805 | goto out_error_iucv; | ||
806 | } | ||
807 | |||
808 | return 0; | ||
809 | |||
810 | out_error_iucv: | ||
811 | iucv_unregister(&hvc_iucv_handler, 0); | ||
812 | out_error_hvc: | ||
813 | for (i = 0; i < hvc_iucv_devices; i++) | ||
814 | if (hvc_iucv_table[i]) { | ||
815 | if (hvc_iucv_table[i]->hvc) | ||
816 | hvc_remove(hvc_iucv_table[i]->hvc); | ||
817 | kfree(hvc_iucv_table[i]); | ||
818 | } | ||
819 | mempool_destroy(hvc_iucv_mempool); | ||
820 | kmem_cache_destroy(hvc_iucv_buffer_cache); | ||
821 | return rc; | ||
822 | } | ||
823 | |||
824 | /** | ||
825 | * hvc_iucv_console_init() - Early console initialization | ||
826 | */ | ||
827 | static int __init hvc_iucv_console_init(void) | ||
828 | { | ||
829 | if (!MACHINE_IS_VM || !hvc_iucv_devices) | ||
830 | return -ENODEV; | ||
831 | return hvc_instantiate(HVC_IUCV_MAGIC, 0, &hvc_iucv_ops); | ||
832 | } | ||
833 | |||
834 | /** | ||
835 | * hvc_iucv_config() - Parsing of hvc_iucv= kernel command line parameter | ||
836 | * @val: Parameter value (numeric) | ||
837 | */ | ||
838 | static int __init hvc_iucv_config(char *val) | ||
839 | { | ||
840 | return strict_strtoul(val, 10, &hvc_iucv_devices); | ||
841 | } | ||
842 | |||
843 | |||
844 | module_init(hvc_iucv_init); | ||
845 | console_initcall(hvc_iucv_console_init); | ||
846 | __setup("hvc_iucv=", hvc_iucv_config); | ||
847 | |||
848 | MODULE_LICENSE("GPL"); | ||
849 | MODULE_DESCRIPTION("HVC back-end for z/VM IUCV."); | ||
850 | MODULE_AUTHOR("Hendrik Brueckner <brueckner@linux.vnet.ibm.com>"); | ||
diff --git a/drivers/char/hvc_udbg.c b/drivers/char/hvc_udbg.c new file mode 100644 index 000000000000..bd63ba878a56 --- /dev/null +++ b/drivers/char/hvc_udbg.c | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | * udbg interface to hvc_console.c | ||
3 | * | ||
4 | * (C) Copyright David Gibson, IBM Corporation 2008. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License | ||
17 | * along with this program; if not, write to the Free Software | ||
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
19 | */ | ||
20 | |||
21 | #include <linux/console.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include <linux/err.h> | ||
24 | #include <linux/init.h> | ||
25 | #include <linux/moduleparam.h> | ||
26 | #include <linux/types.h> | ||
27 | #include <linux/irq.h> | ||
28 | |||
29 | #include <asm/udbg.h> | ||
30 | |||
31 | #include "hvc_console.h" | ||
32 | |||
33 | struct hvc_struct *hvc_udbg_dev; | ||
34 | |||
35 | static int hvc_udbg_put(uint32_t vtermno, const char *buf, int count) | ||
36 | { | ||
37 | int i; | ||
38 | |||
39 | for (i = 0; i < count; i++) | ||
40 | udbg_putc(buf[i]); | ||
41 | |||
42 | return i; | ||
43 | } | ||
44 | |||
45 | static int hvc_udbg_get(uint32_t vtermno, char *buf, int count) | ||
46 | { | ||
47 | int i, c; | ||
48 | |||
49 | if (!udbg_getc_poll) | ||
50 | return 0; | ||
51 | |||
52 | for (i = 0; i < count; i++) { | ||
53 | if ((c = udbg_getc_poll()) == -1) | ||
54 | break; | ||
55 | buf[i] = c; | ||
56 | } | ||
57 | |||
58 | return i; | ||
59 | } | ||
60 | |||
61 | static struct hv_ops hvc_udbg_ops = { | ||
62 | .get_chars = hvc_udbg_get, | ||
63 | .put_chars = hvc_udbg_put, | ||
64 | }; | ||
65 | |||
66 | static int __init hvc_udbg_init(void) | ||
67 | { | ||
68 | struct hvc_struct *hp; | ||
69 | |||
70 | BUG_ON(hvc_udbg_dev); | ||
71 | |||
72 | hp = hvc_alloc(0, NO_IRQ, &hvc_udbg_ops, 16); | ||
73 | if (IS_ERR(hp)) | ||
74 | return PTR_ERR(hp); | ||
75 | |||
76 | hvc_udbg_dev = hp; | ||
77 | |||
78 | return 0; | ||
79 | } | ||
80 | module_init(hvc_udbg_init); | ||
81 | |||
82 | static void __exit hvc_udbg_exit(void) | ||
83 | { | ||
84 | if (hvc_udbg_dev) | ||
85 | hvc_remove(hvc_udbg_dev); | ||
86 | } | ||
87 | module_exit(hvc_udbg_exit); | ||
88 | |||
89 | static int __init hvc_udbg_console_init(void) | ||
90 | { | ||
91 | hvc_instantiate(0, 0, &hvc_udbg_ops); | ||
92 | add_preferred_console("hvc", 0, NULL); | ||
93 | |||
94 | return 0; | ||
95 | } | ||
96 | console_initcall(hvc_udbg_console_init); | ||
diff --git a/drivers/char/hvc_vio.c b/drivers/char/hvc_vio.c index 019e0b58593d..bd62dc86b47d 100644 --- a/drivers/char/hvc_vio.c +++ b/drivers/char/hvc_vio.c | |||
@@ -153,8 +153,10 @@ static int hvc_find_vtys(void) | |||
153 | /* We have statically defined space for only a certain number | 153 | /* We have statically defined space for only a certain number |
154 | * of console adapters. | 154 | * of console adapters. |
155 | */ | 155 | */ |
156 | if (num_found >= MAX_NR_HVC_CONSOLES) | 156 | if (num_found >= MAX_NR_HVC_CONSOLES) { |
157 | of_node_put(vty); | ||
157 | break; | 158 | break; |
159 | } | ||
158 | 160 | ||
159 | vtermno = of_get_property(vty, "reg", NULL); | 161 | vtermno = of_get_property(vty, "reg", NULL); |
160 | if (!vtermno) | 162 | if (!vtermno) |
diff --git a/drivers/char/hvcs.c b/drivers/char/hvcs.c index 473d9b14439a..6e6eb445d374 100644 --- a/drivers/char/hvcs.c +++ b/drivers/char/hvcs.c | |||
@@ -269,7 +269,7 @@ struct hvcs_struct { | |||
269 | unsigned int index; | 269 | unsigned int index; |
270 | 270 | ||
271 | struct tty_struct *tty; | 271 | struct tty_struct *tty; |
272 | unsigned int open_count; | 272 | int open_count; |
273 | 273 | ||
274 | /* | 274 | /* |
275 | * Used to tell the driver kernel_thread what operations need to take | 275 | * Used to tell the driver kernel_thread what operations need to take |
diff --git a/drivers/char/hvsi.c b/drivers/char/hvsi.c index 59c6f9ab94e4..406f8742a260 100644 --- a/drivers/char/hvsi.c +++ b/drivers/char/hvsi.c | |||
@@ -75,7 +75,7 @@ struct hvsi_struct { | |||
75 | spinlock_t lock; | 75 | spinlock_t lock; |
76 | int index; | 76 | int index; |
77 | struct tty_struct *tty; | 77 | struct tty_struct *tty; |
78 | unsigned int count; | 78 | int count; |
79 | uint8_t throttle_buf[128]; | 79 | uint8_t throttle_buf[128]; |
80 | uint8_t outbuf[N_OUTBUF]; /* to implement write_room and chars_in_buffer */ | 80 | uint8_t outbuf[N_OUTBUF]; /* to implement write_room and chars_in_buffer */ |
81 | /* inbuf is for packet reassembly. leave a little room for leftovers. */ | 81 | /* inbuf is for packet reassembly. leave a little room for leftovers. */ |
@@ -997,14 +997,14 @@ out: | |||
997 | 997 | ||
998 | static int hvsi_write_room(struct tty_struct *tty) | 998 | static int hvsi_write_room(struct tty_struct *tty) |
999 | { | 999 | { |
1000 | struct hvsi_struct *hp = (struct hvsi_struct *)tty->driver_data; | 1000 | struct hvsi_struct *hp = tty->driver_data; |
1001 | 1001 | ||
1002 | return N_OUTBUF - hp->n_outbuf; | 1002 | return N_OUTBUF - hp->n_outbuf; |
1003 | } | 1003 | } |
1004 | 1004 | ||
1005 | static int hvsi_chars_in_buffer(struct tty_struct *tty) | 1005 | static int hvsi_chars_in_buffer(struct tty_struct *tty) |
1006 | { | 1006 | { |
1007 | struct hvsi_struct *hp = (struct hvsi_struct *)tty->driver_data; | 1007 | struct hvsi_struct *hp = tty->driver_data; |
1008 | 1008 | ||
1009 | return hp->n_outbuf; | 1009 | return hp->n_outbuf; |
1010 | } | 1010 | } |
@@ -1070,7 +1070,7 @@ out: | |||
1070 | */ | 1070 | */ |
1071 | static void hvsi_throttle(struct tty_struct *tty) | 1071 | static void hvsi_throttle(struct tty_struct *tty) |
1072 | { | 1072 | { |
1073 | struct hvsi_struct *hp = (struct hvsi_struct *)tty->driver_data; | 1073 | struct hvsi_struct *hp = tty->driver_data; |
1074 | 1074 | ||
1075 | pr_debug("%s\n", __func__); | 1075 | pr_debug("%s\n", __func__); |
1076 | 1076 | ||
@@ -1079,7 +1079,7 @@ static void hvsi_throttle(struct tty_struct *tty) | |||
1079 | 1079 | ||
1080 | static void hvsi_unthrottle(struct tty_struct *tty) | 1080 | static void hvsi_unthrottle(struct tty_struct *tty) |
1081 | { | 1081 | { |
1082 | struct hvsi_struct *hp = (struct hvsi_struct *)tty->driver_data; | 1082 | struct hvsi_struct *hp = tty->driver_data; |
1083 | unsigned long flags; | 1083 | unsigned long flags; |
1084 | int shouldflip = 0; | 1084 | int shouldflip = 0; |
1085 | 1085 | ||
@@ -1100,7 +1100,7 @@ static void hvsi_unthrottle(struct tty_struct *tty) | |||
1100 | 1100 | ||
1101 | static int hvsi_tiocmget(struct tty_struct *tty, struct file *file) | 1101 | static int hvsi_tiocmget(struct tty_struct *tty, struct file *file) |
1102 | { | 1102 | { |
1103 | struct hvsi_struct *hp = (struct hvsi_struct *)tty->driver_data; | 1103 | struct hvsi_struct *hp = tty->driver_data; |
1104 | 1104 | ||
1105 | hvsi_get_mctrl(hp); | 1105 | hvsi_get_mctrl(hp); |
1106 | return hp->mctrl; | 1106 | return hp->mctrl; |
@@ -1109,7 +1109,7 @@ static int hvsi_tiocmget(struct tty_struct *tty, struct file *file) | |||
1109 | static int hvsi_tiocmset(struct tty_struct *tty, struct file *file, | 1109 | static int hvsi_tiocmset(struct tty_struct *tty, struct file *file, |
1110 | unsigned int set, unsigned int clear) | 1110 | unsigned int set, unsigned int clear) |
1111 | { | 1111 | { |
1112 | struct hvsi_struct *hp = (struct hvsi_struct *)tty->driver_data; | 1112 | struct hvsi_struct *hp = tty->driver_data; |
1113 | unsigned long flags; | 1113 | unsigned long flags; |
1114 | uint16_t new_mctrl; | 1114 | uint16_t new_mctrl; |
1115 | 1115 | ||
diff --git a/drivers/char/hw_random/n2-drv.c b/drivers/char/hw_random/n2-drv.c index 8859aeac2d25..9b3e09cd41f9 100644 --- a/drivers/char/hw_random/n2-drv.c +++ b/drivers/char/hw_random/n2-drv.c | |||
@@ -482,7 +482,7 @@ static void n2rng_dump_test_buffer(struct n2rng *np) | |||
482 | int i; | 482 | int i; |
483 | 483 | ||
484 | for (i = 0; i < SELFTEST_BUFFER_WORDS; i++) | 484 | for (i = 0; i < SELFTEST_BUFFER_WORDS; i++) |
485 | dev_err(&np->op->dev, "Test buffer slot %d [0x%016lx]\n", | 485 | dev_err(&np->op->dev, "Test buffer slot %d [0x%016llx]\n", |
486 | i, np->test_buffer[i]); | 486 | i, np->test_buffer[i]); |
487 | } | 487 | } |
488 | 488 | ||
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c index b60d425ce8d1..fc8cf7ac7f2b 100644 --- a/drivers/char/i8k.c +++ b/drivers/char/i8k.c | |||
@@ -485,7 +485,21 @@ static struct dmi_system_id __initdata i8k_dmi_table[] = { | |||
485 | DMI_MATCH(DMI_PRODUCT_NAME, "MP061"), | 485 | DMI_MATCH(DMI_PRODUCT_NAME, "MP061"), |
486 | }, | 486 | }, |
487 | }, | 487 | }, |
488 | { } | 488 | { |
489 | .ident = "Dell Precision", | ||
490 | .matches = { | ||
491 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
492 | DMI_MATCH(DMI_PRODUCT_NAME, "Precision"), | ||
493 | }, | ||
494 | }, | ||
495 | { | ||
496 | .ident = "Dell Vostro", | ||
497 | .matches = { | ||
498 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
499 | DMI_MATCH(DMI_PRODUCT_NAME, "Vostro"), | ||
500 | }, | ||
501 | }, | ||
502 | { } | ||
489 | }; | 503 | }; |
490 | 504 | ||
491 | /* | 505 | /* |
diff --git a/drivers/char/isicom.c b/drivers/char/isicom.c index 04e4549299ba..24aa6e88e223 100644 --- a/drivers/char/isicom.c +++ b/drivers/char/isicom.c | |||
@@ -328,11 +328,13 @@ static inline void drop_rts(struct isi_port *port) | |||
328 | } | 328 | } |
329 | 329 | ||
330 | /* card->lock MUST NOT be held */ | 330 | /* card->lock MUST NOT be held */ |
331 | static inline void raise_dtr_rts(struct isi_port *port) | 331 | |
332 | static void isicom_raise_dtr_rts(struct tty_port *port) | ||
332 | { | 333 | { |
333 | struct isi_board *card = port->card; | 334 | struct isi_port *ip = container_of(port, struct isi_port, port); |
335 | struct isi_board *card = ip->card; | ||
334 | unsigned long base = card->base; | 336 | unsigned long base = card->base; |
335 | u16 channel = port->channel; | 337 | u16 channel = ip->channel; |
336 | 338 | ||
337 | if (!lock_card(card)) | 339 | if (!lock_card(card)) |
338 | return; | 340 | return; |
@@ -340,7 +342,7 @@ static inline void raise_dtr_rts(struct isi_port *port) | |||
340 | outw(0x8000 | (channel << card->shift_count) | 0x02, base); | 342 | outw(0x8000 | (channel << card->shift_count) | 0x02, base); |
341 | outw(0x0f04, base); | 343 | outw(0x0f04, base); |
342 | InterruptTheCard(base); | 344 | InterruptTheCard(base); |
343 | port->status |= (ISI_DTR | ISI_RTS); | 345 | ip->status |= (ISI_DTR | ISI_RTS); |
344 | unlock_card(card); | 346 | unlock_card(card); |
345 | } | 347 | } |
346 | 348 | ||
@@ -830,80 +832,10 @@ static int isicom_setup_port(struct tty_struct *tty) | |||
830 | return 0; | 832 | return 0; |
831 | } | 833 | } |
832 | 834 | ||
833 | static int block_til_ready(struct tty_struct *tty, struct file *filp, | 835 | static int isicom_carrier_raised(struct tty_port *port) |
834 | struct isi_port *port) | ||
835 | { | 836 | { |
836 | struct isi_board *card = port->card; | 837 | struct isi_port *ip = container_of(port, struct isi_port, port); |
837 | int do_clocal = 0, retval; | 838 | return (ip->status & ISI_DCD)?1 : 0; |
838 | unsigned long flags; | ||
839 | DECLARE_WAITQUEUE(wait, current); | ||
840 | |||
841 | /* block if port is in the process of being closed */ | ||
842 | |||
843 | if (tty_hung_up_p(filp) || port->port.flags & ASYNC_CLOSING) { | ||
844 | pr_dbg("block_til_ready: close in progress.\n"); | ||
845 | interruptible_sleep_on(&port->port.close_wait); | ||
846 | if (port->port.flags & ASYNC_HUP_NOTIFY) | ||
847 | return -EAGAIN; | ||
848 | else | ||
849 | return -ERESTARTSYS; | ||
850 | } | ||
851 | |||
852 | /* if non-blocking mode is set ... */ | ||
853 | |||
854 | if ((filp->f_flags & O_NONBLOCK) || | ||
855 | (tty->flags & (1 << TTY_IO_ERROR))) { | ||
856 | pr_dbg("block_til_ready: non-block mode.\n"); | ||
857 | port->port.flags |= ASYNC_NORMAL_ACTIVE; | ||
858 | return 0; | ||
859 | } | ||
860 | |||
861 | if (C_CLOCAL(tty)) | ||
862 | do_clocal = 1; | ||
863 | |||
864 | /* block waiting for DCD to be asserted, and while | ||
865 | callout dev is busy */ | ||
866 | retval = 0; | ||
867 | add_wait_queue(&port->port.open_wait, &wait); | ||
868 | |||
869 | spin_lock_irqsave(&card->card_lock, flags); | ||
870 | if (!tty_hung_up_p(filp)) | ||
871 | port->port.count--; | ||
872 | port->port.blocked_open++; | ||
873 | spin_unlock_irqrestore(&card->card_lock, flags); | ||
874 | |||
875 | while (1) { | ||
876 | raise_dtr_rts(port); | ||
877 | |||
878 | set_current_state(TASK_INTERRUPTIBLE); | ||
879 | if (tty_hung_up_p(filp) || !(port->port.flags & ASYNC_INITIALIZED)) { | ||
880 | if (port->port.flags & ASYNC_HUP_NOTIFY) | ||
881 | retval = -EAGAIN; | ||
882 | else | ||
883 | retval = -ERESTARTSYS; | ||
884 | break; | ||
885 | } | ||
886 | if (!(port->port.flags & ASYNC_CLOSING) && | ||
887 | (do_clocal || (port->status & ISI_DCD))) { | ||
888 | break; | ||
889 | } | ||
890 | if (signal_pending(current)) { | ||
891 | retval = -ERESTARTSYS; | ||
892 | break; | ||
893 | } | ||
894 | schedule(); | ||
895 | } | ||
896 | set_current_state(TASK_RUNNING); | ||
897 | remove_wait_queue(&port->port.open_wait, &wait); | ||
898 | spin_lock_irqsave(&card->card_lock, flags); | ||
899 | if (!tty_hung_up_p(filp)) | ||
900 | port->port.count++; | ||
901 | port->port.blocked_open--; | ||
902 | spin_unlock_irqrestore(&card->card_lock, flags); | ||
903 | if (retval) | ||
904 | return retval; | ||
905 | port->port.flags |= ASYNC_NORMAL_ACTIVE; | ||
906 | return 0; | ||
907 | } | 839 | } |
908 | 840 | ||
909 | static int isicom_open(struct tty_struct *tty, struct file *filp) | 841 | static int isicom_open(struct tty_struct *tty, struct file *filp) |
@@ -932,12 +864,13 @@ static int isicom_open(struct tty_struct *tty, struct file *filp) | |||
932 | 864 | ||
933 | isicom_setup_board(card); | 865 | isicom_setup_board(card); |
934 | 866 | ||
867 | /* FIXME: locking on port.count etc */ | ||
935 | port->port.count++; | 868 | port->port.count++; |
936 | tty->driver_data = port; | 869 | tty->driver_data = port; |
937 | tty_port_tty_set(&port->port, tty); | 870 | tty_port_tty_set(&port->port, tty); |
938 | error = isicom_setup_port(tty); | 871 | error = isicom_setup_port(tty); |
939 | if (error == 0) | 872 | if (error == 0) |
940 | error = block_til_ready(tty, filp, port); | 873 | error = tty_port_block_til_ready(&port->port, tty, filp); |
941 | return error; | 874 | return error; |
942 | } | 875 | } |
943 | 876 | ||
@@ -1012,76 +945,30 @@ static void isicom_flush_buffer(struct tty_struct *tty) | |||
1012 | 945 | ||
1013 | static void isicom_close(struct tty_struct *tty, struct file *filp) | 946 | static void isicom_close(struct tty_struct *tty, struct file *filp) |
1014 | { | 947 | { |
1015 | struct isi_port *port = tty->driver_data; | 948 | struct isi_port *ip = tty->driver_data; |
949 | struct tty_port *port = &ip->port; | ||
1016 | struct isi_board *card; | 950 | struct isi_board *card; |
1017 | unsigned long flags; | 951 | unsigned long flags; |
1018 | 952 | ||
1019 | if (!port) | 953 | BUG_ON(!ip); |
1020 | return; | ||
1021 | card = port->card; | ||
1022 | if (isicom_paranoia_check(port, tty->name, "isicom_close")) | ||
1023 | return; | ||
1024 | |||
1025 | pr_dbg("Close start!!!.\n"); | ||
1026 | |||
1027 | spin_lock_irqsave(&card->card_lock, flags); | ||
1028 | if (tty_hung_up_p(filp)) { | ||
1029 | spin_unlock_irqrestore(&card->card_lock, flags); | ||
1030 | return; | ||
1031 | } | ||
1032 | |||
1033 | if (tty->count == 1 && port->port.count != 1) { | ||
1034 | printk(KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port " | ||
1035 | "count tty->count = 1 port count = %d.\n", | ||
1036 | card->base, port->port.count); | ||
1037 | port->port.count = 1; | ||
1038 | } | ||
1039 | if (--port->port.count < 0) { | ||
1040 | printk(KERN_WARNING "ISICOM:(0x%lx) isicom_close: bad port " | ||
1041 | "count for channel%d = %d", card->base, port->channel, | ||
1042 | port->port.count); | ||
1043 | port->port.count = 0; | ||
1044 | } | ||
1045 | 954 | ||
1046 | if (port->port.count) { | 955 | card = ip->card; |
1047 | spin_unlock_irqrestore(&card->card_lock, flags); | 956 | if (isicom_paranoia_check(ip, tty->name, "isicom_close")) |
1048 | return; | 957 | return; |
1049 | } | ||
1050 | port->port.flags |= ASYNC_CLOSING; | ||
1051 | tty->closing = 1; | ||
1052 | spin_unlock_irqrestore(&card->card_lock, flags); | ||
1053 | 958 | ||
1054 | if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) | ||
1055 | tty_wait_until_sent(tty, port->port.closing_wait); | ||
1056 | /* indicate to the card that no more data can be received | 959 | /* indicate to the card that no more data can be received |
1057 | on this port */ | 960 | on this port */ |
1058 | spin_lock_irqsave(&card->card_lock, flags); | 961 | spin_lock_irqsave(&card->card_lock, flags); |
1059 | if (port->port.flags & ASYNC_INITIALIZED) { | 962 | if (port->flags & ASYNC_INITIALIZED) { |
1060 | card->port_status &= ~(1 << port->channel); | 963 | card->port_status &= ~(1 << ip->channel); |
1061 | outw(card->port_status, card->base + 0x02); | 964 | outw(card->port_status, card->base + 0x02); |
1062 | } | 965 | } |
1063 | isicom_shutdown_port(port); | 966 | isicom_shutdown_port(ip); |
1064 | spin_unlock_irqrestore(&card->card_lock, flags); | 967 | spin_unlock_irqrestore(&card->card_lock, flags); |
1065 | 968 | ||
1066 | isicom_flush_buffer(tty); | 969 | isicom_flush_buffer(tty); |
1067 | tty_ldisc_flush(tty); | 970 | |
1068 | 971 | tty_port_close_end(port, tty); | |
1069 | spin_lock_irqsave(&card->card_lock, flags); | ||
1070 | tty->closing = 0; | ||
1071 | |||
1072 | if (port->port.blocked_open) { | ||
1073 | spin_unlock_irqrestore(&card->card_lock, flags); | ||
1074 | if (port->port.close_delay) { | ||
1075 | pr_dbg("scheduling until time out.\n"); | ||
1076 | msleep_interruptible( | ||
1077 | jiffies_to_msecs(port->port.close_delay)); | ||
1078 | } | ||
1079 | spin_lock_irqsave(&card->card_lock, flags); | ||
1080 | wake_up_interruptible(&port->port.open_wait); | ||
1081 | } | ||
1082 | port->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); | ||
1083 | wake_up_interruptible(&port->port.close_wait); | ||
1084 | spin_unlock_irqrestore(&card->card_lock, flags); | ||
1085 | } | 972 | } |
1086 | 973 | ||
1087 | /* write et all */ | 974 | /* write et all */ |
@@ -1420,10 +1307,7 @@ static void isicom_hangup(struct tty_struct *tty) | |||
1420 | isicom_shutdown_port(port); | 1307 | isicom_shutdown_port(port); |
1421 | spin_unlock_irqrestore(&port->card->card_lock, flags); | 1308 | spin_unlock_irqrestore(&port->card->card_lock, flags); |
1422 | 1309 | ||
1423 | port->port.count = 0; | 1310 | tty_port_hangup(&port->port); |
1424 | port->port.flags &= ~ASYNC_NORMAL_ACTIVE; | ||
1425 | tty_port_tty_set(&port->port, NULL); | ||
1426 | wake_up_interruptible(&port->port.open_wait); | ||
1427 | } | 1311 | } |
1428 | 1312 | ||
1429 | 1313 | ||
@@ -1452,6 +1336,11 @@ static const struct tty_operations isicom_ops = { | |||
1452 | .break_ctl = isicom_send_break, | 1336 | .break_ctl = isicom_send_break, |
1453 | }; | 1337 | }; |
1454 | 1338 | ||
1339 | static const struct tty_port_operations isicom_port_ops = { | ||
1340 | .carrier_raised = isicom_carrier_raised, | ||
1341 | .raise_dtr_rts = isicom_raise_dtr_rts, | ||
1342 | }; | ||
1343 | |||
1455 | static int __devinit reset_card(struct pci_dev *pdev, | 1344 | static int __devinit reset_card(struct pci_dev *pdev, |
1456 | const unsigned int card, unsigned int *signature) | 1345 | const unsigned int card, unsigned int *signature) |
1457 | { | 1346 | { |
@@ -1794,6 +1683,7 @@ static int __init isicom_init(void) | |||
1794 | spin_lock_init(&isi_card[idx].card_lock); | 1683 | spin_lock_init(&isi_card[idx].card_lock); |
1795 | for (channel = 0; channel < 16; channel++, port++) { | 1684 | for (channel = 0; channel < 16; channel++, port++) { |
1796 | tty_port_init(&port->port); | 1685 | tty_port_init(&port->port); |
1686 | port->port.ops = &isicom_port_ops; | ||
1797 | port->magic = ISICOM_MAGIC; | 1687 | port->magic = ISICOM_MAGIC; |
1798 | port->card = &isi_card[idx]; | 1688 | port->card = &isi_card[idx]; |
1799 | port->channel = channel; | 1689 | port->channel = channel; |
diff --git a/drivers/char/istallion.c b/drivers/char/istallion.c index 4b10770fa937..5c3dc6b8411c 100644 --- a/drivers/char/istallion.c +++ b/drivers/char/istallion.c | |||
@@ -151,7 +151,7 @@ static char *stli_drvversion = "5.6.0"; | |||
151 | static char *stli_serialname = "ttyE"; | 151 | static char *stli_serialname = "ttyE"; |
152 | 152 | ||
153 | static struct tty_driver *stli_serial; | 153 | static struct tty_driver *stli_serial; |
154 | 154 | static const struct tty_port_operations stli_port_ops; | |
155 | 155 | ||
156 | #define STLI_TXBUFSIZE 4096 | 156 | #define STLI_TXBUFSIZE 4096 |
157 | 157 | ||
@@ -626,8 +626,6 @@ static int stli_hostcmd(struct stlibrd *brdp, struct stliport *portp); | |||
626 | static int stli_initopen(struct tty_struct *tty, struct stlibrd *brdp, struct stliport *portp); | 626 | static int stli_initopen(struct tty_struct *tty, struct stlibrd *brdp, struct stliport *portp); |
627 | static int stli_rawopen(struct stlibrd *brdp, struct stliport *portp, unsigned long arg, int wait); | 627 | static int stli_rawopen(struct stlibrd *brdp, struct stliport *portp, unsigned long arg, int wait); |
628 | static int stli_rawclose(struct stlibrd *brdp, struct stliport *portp, unsigned long arg, int wait); | 628 | static int stli_rawclose(struct stlibrd *brdp, struct stliport *portp, unsigned long arg, int wait); |
629 | static int stli_waitcarrier(struct tty_struct *tty, struct stlibrd *brdp, | ||
630 | struct stliport *portp, struct file *filp); | ||
631 | static int stli_setport(struct tty_struct *tty); | 629 | static int stli_setport(struct tty_struct *tty); |
632 | static int stli_cmdwait(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback); | 630 | static int stli_cmdwait(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback); |
633 | static void stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback); | 631 | static void stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigned long cmd, void *arg, int size, int copyback); |
@@ -769,7 +767,7 @@ static int stli_parsebrd(struct stlconf *confp, char **argp) | |||
769 | break; | 767 | break; |
770 | } | 768 | } |
771 | if (i == ARRAY_SIZE(stli_brdstr)) { | 769 | if (i == ARRAY_SIZE(stli_brdstr)) { |
772 | printk("STALLION: unknown board name, %s?\n", argp[0]); | 770 | printk(KERN_WARNING "istallion: unknown board name, %s?\n", argp[0]); |
773 | return 0; | 771 | return 0; |
774 | } | 772 | } |
775 | 773 | ||
@@ -787,6 +785,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp) | |||
787 | { | 785 | { |
788 | struct stlibrd *brdp; | 786 | struct stlibrd *brdp; |
789 | struct stliport *portp; | 787 | struct stliport *portp; |
788 | struct tty_port *port; | ||
790 | unsigned int minordev, brdnr, portnr; | 789 | unsigned int minordev, brdnr, portnr; |
791 | int rc; | 790 | int rc; |
792 | 791 | ||
@@ -808,30 +807,19 @@ static int stli_open(struct tty_struct *tty, struct file *filp) | |||
808 | return -ENODEV; | 807 | return -ENODEV; |
809 | if (portp->devnr < 1) | 808 | if (portp->devnr < 1) |
810 | return -ENODEV; | 809 | return -ENODEV; |
811 | 810 | port = &portp->port; | |
812 | |||
813 | /* | ||
814 | * Check if this port is in the middle of closing. If so then wait | ||
815 | * until it is closed then return error status based on flag settings. | ||
816 | * The sleep here does not need interrupt protection since the wakeup | ||
817 | * for it is done with the same context. | ||
818 | */ | ||
819 | if (portp->port.flags & ASYNC_CLOSING) { | ||
820 | interruptible_sleep_on(&portp->port.close_wait); | ||
821 | if (portp->port.flags & ASYNC_HUP_NOTIFY) | ||
822 | return -EAGAIN; | ||
823 | return -ERESTARTSYS; | ||
824 | } | ||
825 | 811 | ||
826 | /* | 812 | /* |
827 | * On the first open of the device setup the port hardware, and | 813 | * On the first open of the device setup the port hardware, and |
828 | * initialize the per port data structure. Since initializing the port | 814 | * initialize the per port data structure. Since initializing the port |
829 | * requires several commands to the board we will need to wait for any | 815 | * requires several commands to the board we will need to wait for any |
830 | * other open that is already initializing the port. | 816 | * other open that is already initializing the port. |
817 | * | ||
818 | * Review - locking | ||
831 | */ | 819 | */ |
832 | tty_port_tty_set(&portp->port, tty); | 820 | tty_port_tty_set(port, tty); |
833 | tty->driver_data = portp; | 821 | tty->driver_data = portp; |
834 | portp->port.count++; | 822 | port->count++; |
835 | 823 | ||
836 | wait_event_interruptible(portp->raw_wait, | 824 | wait_event_interruptible(portp->raw_wait, |
837 | !test_bit(ST_INITIALIZING, &portp->state)); | 825 | !test_bit(ST_INITIALIZING, &portp->state)); |
@@ -841,7 +829,8 @@ static int stli_open(struct tty_struct *tty, struct file *filp) | |||
841 | if ((portp->port.flags & ASYNC_INITIALIZED) == 0) { | 829 | if ((portp->port.flags & ASYNC_INITIALIZED) == 0) { |
842 | set_bit(ST_INITIALIZING, &portp->state); | 830 | set_bit(ST_INITIALIZING, &portp->state); |
843 | if ((rc = stli_initopen(tty, brdp, portp)) >= 0) { | 831 | if ((rc = stli_initopen(tty, brdp, portp)) >= 0) { |
844 | portp->port.flags |= ASYNC_INITIALIZED; | 832 | /* Locking */ |
833 | port->flags |= ASYNC_INITIALIZED; | ||
845 | clear_bit(TTY_IO_ERROR, &tty->flags); | 834 | clear_bit(TTY_IO_ERROR, &tty->flags); |
846 | } | 835 | } |
847 | clear_bit(ST_INITIALIZING, &portp->state); | 836 | clear_bit(ST_INITIALIZING, &portp->state); |
@@ -849,31 +838,7 @@ static int stli_open(struct tty_struct *tty, struct file *filp) | |||
849 | if (rc < 0) | 838 | if (rc < 0) |
850 | return rc; | 839 | return rc; |
851 | } | 840 | } |
852 | 841 | return tty_port_block_til_ready(&portp->port, tty, filp); | |
853 | /* | ||
854 | * Check if this port is in the middle of closing. If so then wait | ||
855 | * until it is closed then return error status, based on flag settings. | ||
856 | * The sleep here does not need interrupt protection since the wakeup | ||
857 | * for it is done with the same context. | ||
858 | */ | ||
859 | if (portp->port.flags & ASYNC_CLOSING) { | ||
860 | interruptible_sleep_on(&portp->port.close_wait); | ||
861 | if (portp->port.flags & ASYNC_HUP_NOTIFY) | ||
862 | return -EAGAIN; | ||
863 | return -ERESTARTSYS; | ||
864 | } | ||
865 | |||
866 | /* | ||
867 | * Based on type of open being done check if it can overlap with any | ||
868 | * previous opens still in effect. If we are a normal serial device | ||
869 | * then also we might have to wait for carrier. | ||
870 | */ | ||
871 | if (!(filp->f_flags & O_NONBLOCK)) { | ||
872 | if ((rc = stli_waitcarrier(tty, brdp, portp, filp)) != 0) | ||
873 | return rc; | ||
874 | } | ||
875 | portp->port.flags |= ASYNC_NORMAL_ACTIVE; | ||
876 | return 0; | ||
877 | } | 842 | } |
878 | 843 | ||
879 | /*****************************************************************************/ | 844 | /*****************************************************************************/ |
@@ -882,25 +847,16 @@ static void stli_close(struct tty_struct *tty, struct file *filp) | |||
882 | { | 847 | { |
883 | struct stlibrd *brdp; | 848 | struct stlibrd *brdp; |
884 | struct stliport *portp; | 849 | struct stliport *portp; |
850 | struct tty_port *port; | ||
885 | unsigned long flags; | 851 | unsigned long flags; |
886 | 852 | ||
887 | portp = tty->driver_data; | 853 | portp = tty->driver_data; |
888 | if (portp == NULL) | 854 | if (portp == NULL) |
889 | return; | 855 | return; |
856 | port = &portp->port; | ||
890 | 857 | ||
891 | spin_lock_irqsave(&stli_lock, flags); | 858 | if (tty_port_close_start(port, tty, filp) == 0) |
892 | if (tty_hung_up_p(filp)) { | ||
893 | spin_unlock_irqrestore(&stli_lock, flags); | ||
894 | return; | ||
895 | } | ||
896 | if ((tty->count == 1) && (portp->port.count != 1)) | ||
897 | portp->port.count = 1; | ||
898 | if (portp->port.count-- > 1) { | ||
899 | spin_unlock_irqrestore(&stli_lock, flags); | ||
900 | return; | 859 | return; |
901 | } | ||
902 | |||
903 | portp->port.flags |= ASYNC_CLOSING; | ||
904 | 860 | ||
905 | /* | 861 | /* |
906 | * May want to wait for data to drain before closing. The BUSY flag | 862 | * May want to wait for data to drain before closing. The BUSY flag |
@@ -908,15 +864,19 @@ static void stli_close(struct tty_struct *tty, struct file *filp) | |||
908 | * updated by messages from the slave - indicating when all chars | 864 | * updated by messages from the slave - indicating when all chars |
909 | * really have drained. | 865 | * really have drained. |
910 | */ | 866 | */ |
867 | spin_lock_irqsave(&stli_lock, flags); | ||
911 | if (tty == stli_txcooktty) | 868 | if (tty == stli_txcooktty) |
912 | stli_flushchars(tty); | 869 | stli_flushchars(tty); |
913 | tty->closing = 1; | ||
914 | spin_unlock_irqrestore(&stli_lock, flags); | 870 | spin_unlock_irqrestore(&stli_lock, flags); |
915 | 871 | ||
872 | /* We end up doing this twice for the moment. This needs looking at | ||
873 | eventually. Note we still use portp->closing_wait as a result */ | ||
916 | if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE) | 874 | if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE) |
917 | tty_wait_until_sent(tty, portp->closing_wait); | 875 | tty_wait_until_sent(tty, portp->closing_wait); |
918 | 876 | ||
919 | portp->port.flags &= ~ASYNC_INITIALIZED; | 877 | /* FIXME: port locking here needs attending to */ |
878 | port->flags &= ~ASYNC_INITIALIZED; | ||
879 | |||
920 | brdp = stli_brds[portp->brdnr]; | 880 | brdp = stli_brds[portp->brdnr]; |
921 | stli_rawclose(brdp, portp, 0, 0); | 881 | stli_rawclose(brdp, portp, 0, 0); |
922 | if (tty->termios->c_cflag & HUPCL) { | 882 | if (tty->termios->c_cflag & HUPCL) { |
@@ -934,17 +894,8 @@ static void stli_close(struct tty_struct *tty, struct file *filp) | |||
934 | set_bit(ST_DOFLUSHRX, &portp->state); | 894 | set_bit(ST_DOFLUSHRX, &portp->state); |
935 | stli_flushbuffer(tty); | 895 | stli_flushbuffer(tty); |
936 | 896 | ||
937 | tty->closing = 0; | 897 | tty_port_close_end(port, tty); |
938 | tty_port_tty_set(&portp->port, NULL); | 898 | tty_port_tty_set(port, NULL); |
939 | |||
940 | if (portp->openwaitcnt) { | ||
941 | if (portp->close_delay) | ||
942 | msleep_interruptible(jiffies_to_msecs(portp->close_delay)); | ||
943 | wake_up_interruptible(&portp->port.open_wait); | ||
944 | } | ||
945 | |||
946 | portp->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); | ||
947 | wake_up_interruptible(&portp->port.close_wait); | ||
948 | } | 899 | } |
949 | 900 | ||
950 | /*****************************************************************************/ | 901 | /*****************************************************************************/ |
@@ -1183,62 +1134,23 @@ static int stli_setport(struct tty_struct *tty) | |||
1183 | 1134 | ||
1184 | /*****************************************************************************/ | 1135 | /*****************************************************************************/ |
1185 | 1136 | ||
1186 | /* | 1137 | static int stli_carrier_raised(struct tty_port *port) |
1187 | * Possibly need to wait for carrier (DCD signal) to come high. Say | ||
1188 | * maybe because if we are clocal then we don't need to wait... | ||
1189 | */ | ||
1190 | |||
1191 | static int stli_waitcarrier(struct tty_struct *tty, struct stlibrd *brdp, | ||
1192 | struct stliport *portp, struct file *filp) | ||
1193 | { | 1138 | { |
1194 | unsigned long flags; | 1139 | struct stliport *portp = container_of(port, struct stliport, port); |
1195 | int rc, doclocal; | 1140 | return (portp->sigs & TIOCM_CD) ? 1 : 0; |
1196 | 1141 | } | |
1197 | rc = 0; | ||
1198 | doclocal = 0; | ||
1199 | |||
1200 | if (tty->termios->c_cflag & CLOCAL) | ||
1201 | doclocal++; | ||
1202 | |||
1203 | spin_lock_irqsave(&stli_lock, flags); | ||
1204 | portp->openwaitcnt++; | ||
1205 | if (! tty_hung_up_p(filp)) | ||
1206 | portp->port.count--; | ||
1207 | spin_unlock_irqrestore(&stli_lock, flags); | ||
1208 | |||
1209 | for (;;) { | ||
1210 | stli_mkasysigs(&portp->asig, 1, 1); | ||
1211 | if ((rc = stli_cmdwait(brdp, portp, A_SETSIGNALS, | ||
1212 | &portp->asig, sizeof(asysigs_t), 0)) < 0) | ||
1213 | break; | ||
1214 | if (tty_hung_up_p(filp) || | ||
1215 | ((portp->port.flags & ASYNC_INITIALIZED) == 0)) { | ||
1216 | if (portp->port.flags & ASYNC_HUP_NOTIFY) | ||
1217 | rc = -EBUSY; | ||
1218 | else | ||
1219 | rc = -ERESTARTSYS; | ||
1220 | break; | ||
1221 | } | ||
1222 | if (((portp->port.flags & ASYNC_CLOSING) == 0) && | ||
1223 | (doclocal || (portp->sigs & TIOCM_CD))) { | ||
1224 | break; | ||
1225 | } | ||
1226 | if (signal_pending(current)) { | ||
1227 | rc = -ERESTARTSYS; | ||
1228 | break; | ||
1229 | } | ||
1230 | interruptible_sleep_on(&portp->port.open_wait); | ||
1231 | } | ||
1232 | |||
1233 | spin_lock_irqsave(&stli_lock, flags); | ||
1234 | if (! tty_hung_up_p(filp)) | ||
1235 | portp->port.count++; | ||
1236 | portp->openwaitcnt--; | ||
1237 | spin_unlock_irqrestore(&stli_lock, flags); | ||
1238 | 1142 | ||
1239 | return rc; | 1143 | static void stli_raise_dtr_rts(struct tty_port *port) |
1144 | { | ||
1145 | struct stliport *portp = container_of(port, struct stliport, port); | ||
1146 | struct stlibrd *brdp = stli_brds[portp->brdnr]; | ||
1147 | stli_mkasysigs(&portp->asig, 1, 1); | ||
1148 | if (stli_cmdwait(brdp, portp, A_SETSIGNALS, &portp->asig, | ||
1149 | sizeof(asysigs_t), 0) < 0) | ||
1150 | printk(KERN_WARNING "istallion: dtr raise failed.\n"); | ||
1240 | } | 1151 | } |
1241 | 1152 | ||
1153 | |||
1242 | /*****************************************************************************/ | 1154 | /*****************************************************************************/ |
1243 | 1155 | ||
1244 | /* | 1156 | /* |
@@ -1550,7 +1462,7 @@ static int stli_getserial(struct stliport *portp, struct serial_struct __user *s | |||
1550 | sio.irq = 0; | 1462 | sio.irq = 0; |
1551 | sio.flags = portp->port.flags; | 1463 | sio.flags = portp->port.flags; |
1552 | sio.baud_base = portp->baud_base; | 1464 | sio.baud_base = portp->baud_base; |
1553 | sio.close_delay = portp->close_delay; | 1465 | sio.close_delay = portp->port.close_delay; |
1554 | sio.closing_wait = portp->closing_wait; | 1466 | sio.closing_wait = portp->closing_wait; |
1555 | sio.custom_divisor = portp->custom_divisor; | 1467 | sio.custom_divisor = portp->custom_divisor; |
1556 | sio.xmit_fifo_size = 0; | 1468 | sio.xmit_fifo_size = 0; |
@@ -1582,7 +1494,7 @@ static int stli_setserial(struct tty_struct *tty, struct serial_struct __user *s | |||
1582 | return -EFAULT; | 1494 | return -EFAULT; |
1583 | if (!capable(CAP_SYS_ADMIN)) { | 1495 | if (!capable(CAP_SYS_ADMIN)) { |
1584 | if ((sio.baud_base != portp->baud_base) || | 1496 | if ((sio.baud_base != portp->baud_base) || |
1585 | (sio.close_delay != portp->close_delay) || | 1497 | (sio.close_delay != portp->port.close_delay) || |
1586 | ((sio.flags & ~ASYNC_USR_MASK) != | 1498 | ((sio.flags & ~ASYNC_USR_MASK) != |
1587 | (portp->port.flags & ~ASYNC_USR_MASK))) | 1499 | (portp->port.flags & ~ASYNC_USR_MASK))) |
1588 | return -EPERM; | 1500 | return -EPERM; |
@@ -1591,7 +1503,7 @@ static int stli_setserial(struct tty_struct *tty, struct serial_struct __user *s | |||
1591 | portp->port.flags = (portp->port.flags & ~ASYNC_USR_MASK) | | 1503 | portp->port.flags = (portp->port.flags & ~ASYNC_USR_MASK) | |
1592 | (sio.flags & ASYNC_USR_MASK); | 1504 | (sio.flags & ASYNC_USR_MASK); |
1593 | portp->baud_base = sio.baud_base; | 1505 | portp->baud_base = sio.baud_base; |
1594 | portp->close_delay = sio.close_delay; | 1506 | portp->port.close_delay = sio.close_delay; |
1595 | portp->closing_wait = sio.closing_wait; | 1507 | portp->closing_wait = sio.closing_wait; |
1596 | portp->custom_divisor = sio.custom_divisor; | 1508 | portp->custom_divisor = sio.custom_divisor; |
1597 | 1509 | ||
@@ -1821,6 +1733,7 @@ static void stli_hangup(struct tty_struct *tty) | |||
1821 | { | 1733 | { |
1822 | struct stliport *portp; | 1734 | struct stliport *portp; |
1823 | struct stlibrd *brdp; | 1735 | struct stlibrd *brdp; |
1736 | struct tty_port *port; | ||
1824 | unsigned long flags; | 1737 | unsigned long flags; |
1825 | 1738 | ||
1826 | portp = tty->driver_data; | 1739 | portp = tty->driver_data; |
@@ -1831,8 +1744,11 @@ static void stli_hangup(struct tty_struct *tty) | |||
1831 | brdp = stli_brds[portp->brdnr]; | 1744 | brdp = stli_brds[portp->brdnr]; |
1832 | if (brdp == NULL) | 1745 | if (brdp == NULL) |
1833 | return; | 1746 | return; |
1747 | port = &portp->port; | ||
1834 | 1748 | ||
1835 | portp->port.flags &= ~ASYNC_INITIALIZED; | 1749 | spin_lock_irqsave(&port->lock, flags); |
1750 | port->flags &= ~ASYNC_INITIALIZED; | ||
1751 | spin_unlock_irqrestore(&port->lock, flags); | ||
1836 | 1752 | ||
1837 | if (!test_bit(ST_CLOSING, &portp->state)) | 1753 | if (!test_bit(ST_CLOSING, &portp->state)) |
1838 | stli_rawclose(brdp, portp, 0, 0); | 1754 | stli_rawclose(brdp, portp, 0, 0); |
@@ -1853,12 +1769,9 @@ static void stli_hangup(struct tty_struct *tty) | |||
1853 | clear_bit(ST_TXBUSY, &portp->state); | 1769 | clear_bit(ST_TXBUSY, &portp->state); |
1854 | clear_bit(ST_RXSTOP, &portp->state); | 1770 | clear_bit(ST_RXSTOP, &portp->state); |
1855 | set_bit(TTY_IO_ERROR, &tty->flags); | 1771 | set_bit(TTY_IO_ERROR, &tty->flags); |
1856 | tty_port_tty_set(&portp->port, NULL); | ||
1857 | portp->port.flags &= ~ASYNC_NORMAL_ACTIVE; | ||
1858 | portp->port.count = 0; | ||
1859 | spin_unlock_irqrestore(&stli_lock, flags); | 1772 | spin_unlock_irqrestore(&stli_lock, flags); |
1860 | 1773 | ||
1861 | wake_up_interruptible(&portp->port.open_wait); | 1774 | tty_port_hangup(port); |
1862 | } | 1775 | } |
1863 | 1776 | ||
1864 | /*****************************************************************************/ | 1777 | /*****************************************************************************/ |
@@ -2132,7 +2045,7 @@ static void __stli_sendcmd(struct stlibrd *brdp, struct stliport *portp, unsigne | |||
2132 | unsigned char __iomem *bits; | 2045 | unsigned char __iomem *bits; |
2133 | 2046 | ||
2134 | if (test_bit(ST_CMDING, &portp->state)) { | 2047 | if (test_bit(ST_CMDING, &portp->state)) { |
2135 | printk(KERN_ERR "STALLION: command already busy, cmd=%x!\n", | 2048 | printk(KERN_ERR "istallion: command already busy, cmd=%x!\n", |
2136 | (int) cmd); | 2049 | (int) cmd); |
2137 | return; | 2050 | return; |
2138 | } | 2051 | } |
@@ -2692,16 +2605,17 @@ static int stli_initports(struct stlibrd *brdp) | |||
2692 | for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) { | 2605 | for (i = 0, panelnr = 0, panelport = 0; (i < brdp->nrports); i++) { |
2693 | portp = kzalloc(sizeof(struct stliport), GFP_KERNEL); | 2606 | portp = kzalloc(sizeof(struct stliport), GFP_KERNEL); |
2694 | if (!portp) { | 2607 | if (!portp) { |
2695 | printk("STALLION: failed to allocate port structure\n"); | 2608 | printk(KERN_WARNING "istallion: failed to allocate port structure\n"); |
2696 | continue; | 2609 | continue; |
2697 | } | 2610 | } |
2698 | tty_port_init(&portp->port); | 2611 | tty_port_init(&portp->port); |
2612 | portp->port.ops = &stli_port_ops; | ||
2699 | portp->magic = STLI_PORTMAGIC; | 2613 | portp->magic = STLI_PORTMAGIC; |
2700 | portp->portnr = i; | 2614 | portp->portnr = i; |
2701 | portp->brdnr = brdp->brdnr; | 2615 | portp->brdnr = brdp->brdnr; |
2702 | portp->panelnr = panelnr; | 2616 | portp->panelnr = panelnr; |
2703 | portp->baud_base = STL_BAUDBASE; | 2617 | portp->baud_base = STL_BAUDBASE; |
2704 | portp->close_delay = STL_CLOSEDELAY; | 2618 | portp->port.close_delay = STL_CLOSEDELAY; |
2705 | portp->closing_wait = 30 * HZ; | 2619 | portp->closing_wait = 30 * HZ; |
2706 | init_waitqueue_head(&portp->port.open_wait); | 2620 | init_waitqueue_head(&portp->port.open_wait); |
2707 | init_waitqueue_head(&portp->port.close_wait); | 2621 | init_waitqueue_head(&portp->port.close_wait); |
@@ -2758,7 +2672,7 @@ static void __iomem *stli_ecpgetmemptr(struct stlibrd *brdp, unsigned long offse | |||
2758 | unsigned char val; | 2672 | unsigned char val; |
2759 | 2673 | ||
2760 | if (offset > brdp->memsize) { | 2674 | if (offset > brdp->memsize) { |
2761 | printk(KERN_ERR "STALLION: shared memory pointer=%x out of " | 2675 | printk(KERN_ERR "istallion: shared memory pointer=%x out of " |
2762 | "range at line=%d(%d), brd=%d\n", | 2676 | "range at line=%d(%d), brd=%d\n", |
2763 | (int) offset, line, __LINE__, brdp->brdnr); | 2677 | (int) offset, line, __LINE__, brdp->brdnr); |
2764 | ptr = NULL; | 2678 | ptr = NULL; |
@@ -2832,7 +2746,7 @@ static void __iomem *stli_ecpeigetmemptr(struct stlibrd *brdp, unsigned long off | |||
2832 | unsigned char val; | 2746 | unsigned char val; |
2833 | 2747 | ||
2834 | if (offset > brdp->memsize) { | 2748 | if (offset > brdp->memsize) { |
2835 | printk(KERN_ERR "STALLION: shared memory pointer=%x out of " | 2749 | printk(KERN_ERR "istallion: shared memory pointer=%x out of " |
2836 | "range at line=%d(%d), brd=%d\n", | 2750 | "range at line=%d(%d), brd=%d\n", |
2837 | (int) offset, line, __LINE__, brdp->brdnr); | 2751 | (int) offset, line, __LINE__, brdp->brdnr); |
2838 | ptr = NULL; | 2752 | ptr = NULL; |
@@ -2884,7 +2798,7 @@ static void __iomem *stli_ecpmcgetmemptr(struct stlibrd *brdp, unsigned long off | |||
2884 | unsigned char val; | 2798 | unsigned char val; |
2885 | 2799 | ||
2886 | if (offset > brdp->memsize) { | 2800 | if (offset > brdp->memsize) { |
2887 | printk(KERN_ERR "STALLION: shared memory pointer=%x out of " | 2801 | printk(KERN_ERR "istallion: shared memory pointer=%x out of " |
2888 | "range at line=%d(%d), brd=%d\n", | 2802 | "range at line=%d(%d), brd=%d\n", |
2889 | (int) offset, line, __LINE__, brdp->brdnr); | 2803 | (int) offset, line, __LINE__, brdp->brdnr); |
2890 | ptr = NULL; | 2804 | ptr = NULL; |
@@ -2929,7 +2843,7 @@ static void __iomem *stli_ecppcigetmemptr(struct stlibrd *brdp, unsigned long of | |||
2929 | unsigned char val; | 2843 | unsigned char val; |
2930 | 2844 | ||
2931 | if (offset > brdp->memsize) { | 2845 | if (offset > brdp->memsize) { |
2932 | printk(KERN_ERR "STALLION: shared memory pointer=%x out of " | 2846 | printk(KERN_ERR "istallion: shared memory pointer=%x out of " |
2933 | "range at line=%d(%d), board=%d\n", | 2847 | "range at line=%d(%d), board=%d\n", |
2934 | (int) offset, line, __LINE__, brdp->brdnr); | 2848 | (int) offset, line, __LINE__, brdp->brdnr); |
2935 | ptr = NULL; | 2849 | ptr = NULL; |
@@ -2994,7 +2908,7 @@ static void __iomem *stli_onbgetmemptr(struct stlibrd *brdp, unsigned long offse | |||
2994 | void __iomem *ptr; | 2908 | void __iomem *ptr; |
2995 | 2909 | ||
2996 | if (offset > brdp->memsize) { | 2910 | if (offset > brdp->memsize) { |
2997 | printk(KERN_ERR "STALLION: shared memory pointer=%x out of " | 2911 | printk(KERN_ERR "istallion: shared memory pointer=%x out of " |
2998 | "range at line=%d(%d), brd=%d\n", | 2912 | "range at line=%d(%d), brd=%d\n", |
2999 | (int) offset, line, __LINE__, brdp->brdnr); | 2913 | (int) offset, line, __LINE__, brdp->brdnr); |
3000 | ptr = NULL; | 2914 | ptr = NULL; |
@@ -3060,7 +2974,7 @@ static void __iomem *stli_onbegetmemptr(struct stlibrd *brdp, unsigned long offs | |||
3060 | unsigned char val; | 2974 | unsigned char val; |
3061 | 2975 | ||
3062 | if (offset > brdp->memsize) { | 2976 | if (offset > brdp->memsize) { |
3063 | printk(KERN_ERR "STALLION: shared memory pointer=%x out of " | 2977 | printk(KERN_ERR "istallion: shared memory pointer=%x out of " |
3064 | "range at line=%d(%d), brd=%d\n", | 2978 | "range at line=%d(%d), brd=%d\n", |
3065 | (int) offset, line, __LINE__, brdp->brdnr); | 2979 | (int) offset, line, __LINE__, brdp->brdnr); |
3066 | ptr = NULL; | 2980 | ptr = NULL; |
@@ -3499,7 +3413,7 @@ static int stli_startbrd(struct stlibrd *brdp) | |||
3499 | #endif | 3413 | #endif |
3500 | 3414 | ||
3501 | if (nrdevs < (brdp->nrports + 1)) { | 3415 | if (nrdevs < (brdp->nrports + 1)) { |
3502 | printk(KERN_ERR "STALLION: slave failed to allocate memory for " | 3416 | printk(KERN_ERR "istallion: slave failed to allocate memory for " |
3503 | "all devices, devices=%d\n", nrdevs); | 3417 | "all devices, devices=%d\n", nrdevs); |
3504 | brdp->nrports = nrdevs - 1; | 3418 | brdp->nrports = nrdevs - 1; |
3505 | } | 3419 | } |
@@ -3509,13 +3423,13 @@ static int stli_startbrd(struct stlibrd *brdp) | |||
3509 | brdp->bitsize = (nrdevs + 7) / 8; | 3423 | brdp->bitsize = (nrdevs + 7) / 8; |
3510 | memoff = readl(&hdrp->memp); | 3424 | memoff = readl(&hdrp->memp); |
3511 | if (memoff > brdp->memsize) { | 3425 | if (memoff > brdp->memsize) { |
3512 | printk(KERN_ERR "STALLION: corrupted shared memory region?\n"); | 3426 | printk(KERN_ERR "istallion: corrupted shared memory region?\n"); |
3513 | rc = -EIO; | 3427 | rc = -EIO; |
3514 | goto stli_donestartup; | 3428 | goto stli_donestartup; |
3515 | } | 3429 | } |
3516 | memp = (cdkmem_t __iomem *) EBRDGETMEMPTR(brdp, memoff); | 3430 | memp = (cdkmem_t __iomem *) EBRDGETMEMPTR(brdp, memoff); |
3517 | if (readw(&memp->dtype) != TYP_ASYNCTRL) { | 3431 | if (readw(&memp->dtype) != TYP_ASYNCTRL) { |
3518 | printk(KERN_ERR "STALLION: no slave control device found\n"); | 3432 | printk(KERN_ERR "istallion: no slave control device found\n"); |
3519 | goto stli_donestartup; | 3433 | goto stli_donestartup; |
3520 | } | 3434 | } |
3521 | memp++; | 3435 | memp++; |
@@ -3600,7 +3514,7 @@ static int __devinit stli_brdinit(struct stlibrd *brdp) | |||
3600 | retval = stli_initonb(brdp); | 3514 | retval = stli_initonb(brdp); |
3601 | break; | 3515 | break; |
3602 | default: | 3516 | default: |
3603 | printk(KERN_ERR "STALLION: board=%d is unknown board " | 3517 | printk(KERN_ERR "istallion: board=%d is unknown board " |
3604 | "type=%d\n", brdp->brdnr, brdp->brdtype); | 3518 | "type=%d\n", brdp->brdnr, brdp->brdtype); |
3605 | retval = -ENODEV; | 3519 | retval = -ENODEV; |
3606 | } | 3520 | } |
@@ -3609,7 +3523,7 @@ static int __devinit stli_brdinit(struct stlibrd *brdp) | |||
3609 | return retval; | 3523 | return retval; |
3610 | 3524 | ||
3611 | stli_initports(brdp); | 3525 | stli_initports(brdp); |
3612 | printk(KERN_INFO "STALLION: %s found, board=%d io=%x mem=%x " | 3526 | printk(KERN_INFO "istallion: %s found, board=%d io=%x mem=%x " |
3613 | "nrpanels=%d nrports=%d\n", stli_brdnames[brdp->brdtype], | 3527 | "nrpanels=%d nrports=%d\n", stli_brdnames[brdp->brdtype], |
3614 | brdp->brdnr, brdp->iobase, (int) brdp->memaddr, | 3528 | brdp->brdnr, brdp->iobase, (int) brdp->memaddr, |
3615 | brdp->nrpanels, brdp->nrports); | 3529 | brdp->nrpanels, brdp->nrports); |
@@ -3703,7 +3617,7 @@ static int stli_eisamemprobe(struct stlibrd *brdp) | |||
3703 | if (! foundit) { | 3617 | if (! foundit) { |
3704 | brdp->memaddr = 0; | 3618 | brdp->memaddr = 0; |
3705 | brdp->membase = NULL; | 3619 | brdp->membase = NULL; |
3706 | printk(KERN_ERR "STALLION: failed to probe shared memory " | 3620 | printk(KERN_ERR "istallion: failed to probe shared memory " |
3707 | "region for %s in EISA slot=%d\n", | 3621 | "region for %s in EISA slot=%d\n", |
3708 | stli_brdnames[brdp->brdtype], (brdp->iobase >> 12)); | 3622 | stli_brdnames[brdp->brdtype], (brdp->iobase >> 12)); |
3709 | return -ENODEV; | 3623 | return -ENODEV; |
@@ -3848,7 +3762,7 @@ static int __devinit stli_pciprobe(struct pci_dev *pdev, | |||
3848 | mutex_lock(&stli_brdslock); | 3762 | mutex_lock(&stli_brdslock); |
3849 | brdnr = stli_getbrdnr(); | 3763 | brdnr = stli_getbrdnr(); |
3850 | if (brdnr < 0) { | 3764 | if (brdnr < 0) { |
3851 | printk(KERN_INFO "STALLION: too many boards found, " | 3765 | printk(KERN_INFO "istallion: too many boards found, " |
3852 | "maximum supported %d\n", STL_MAXBRDS); | 3766 | "maximum supported %d\n", STL_MAXBRDS); |
3853 | mutex_unlock(&stli_brdslock); | 3767 | mutex_unlock(&stli_brdslock); |
3854 | retval = -EIO; | 3768 | retval = -EIO; |
@@ -3920,7 +3834,7 @@ static struct stlibrd *stli_allocbrd(void) | |||
3920 | 3834 | ||
3921 | brdp = kzalloc(sizeof(struct stlibrd), GFP_KERNEL); | 3835 | brdp = kzalloc(sizeof(struct stlibrd), GFP_KERNEL); |
3922 | if (!brdp) { | 3836 | if (!brdp) { |
3923 | printk(KERN_ERR "STALLION: failed to allocate memory " | 3837 | printk(KERN_ERR "istallion: failed to allocate memory " |
3924 | "(size=%Zd)\n", sizeof(struct stlibrd)); | 3838 | "(size=%Zd)\n", sizeof(struct stlibrd)); |
3925 | return NULL; | 3839 | return NULL; |
3926 | } | 3840 | } |
@@ -4518,6 +4432,11 @@ static const struct tty_operations stli_ops = { | |||
4518 | .tiocmset = stli_tiocmset, | 4432 | .tiocmset = stli_tiocmset, |
4519 | }; | 4433 | }; |
4520 | 4434 | ||
4435 | static const struct tty_port_operations stli_port_ops = { | ||
4436 | .carrier_raised = stli_carrier_raised, | ||
4437 | .raise_dtr_rts = stli_raise_dtr_rts, | ||
4438 | }; | ||
4439 | |||
4521 | /*****************************************************************************/ | 4440 | /*****************************************************************************/ |
4522 | /* | 4441 | /* |
4523 | * Loadable module initialization stuff. | 4442 | * Loadable module initialization stuff. |
@@ -4554,7 +4473,7 @@ static int __init istallion_module_init(void) | |||
4554 | 4473 | ||
4555 | stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL); | 4474 | stli_txcookbuf = kmalloc(STLI_TXBUFSIZE, GFP_KERNEL); |
4556 | if (!stli_txcookbuf) { | 4475 | if (!stli_txcookbuf) { |
4557 | printk(KERN_ERR "STALLION: failed to allocate memory " | 4476 | printk(KERN_ERR "istallion: failed to allocate memory " |
4558 | "(size=%d)\n", STLI_TXBUFSIZE); | 4477 | "(size=%d)\n", STLI_TXBUFSIZE); |
4559 | retval = -ENOMEM; | 4478 | retval = -ENOMEM; |
4560 | goto err; | 4479 | goto err; |
@@ -4579,7 +4498,7 @@ static int __init istallion_module_init(void) | |||
4579 | 4498 | ||
4580 | retval = tty_register_driver(stli_serial); | 4499 | retval = tty_register_driver(stli_serial); |
4581 | if (retval) { | 4500 | if (retval) { |
4582 | printk(KERN_ERR "STALLION: failed to register serial driver\n"); | 4501 | printk(KERN_ERR "istallion: failed to register serial driver\n"); |
4583 | goto err_ttyput; | 4502 | goto err_ttyput; |
4584 | } | 4503 | } |
4585 | 4504 | ||
@@ -4593,7 +4512,7 @@ static int __init istallion_module_init(void) | |||
4593 | */ | 4512 | */ |
4594 | retval = register_chrdev(STL_SIOMEMMAJOR, "staliomem", &stli_fsiomem); | 4513 | retval = register_chrdev(STL_SIOMEMMAJOR, "staliomem", &stli_fsiomem); |
4595 | if (retval) { | 4514 | if (retval) { |
4596 | printk(KERN_ERR "STALLION: failed to register serial memory " | 4515 | printk(KERN_ERR "istallion: failed to register serial memory " |
4597 | "device\n"); | 4516 | "device\n"); |
4598 | goto err_deinit; | 4517 | goto err_deinit; |
4599 | } | 4518 | } |
diff --git a/drivers/char/mem.c b/drivers/char/mem.c index 6431f6921a67..3586b3b3df3f 100644 --- a/drivers/char/mem.c +++ b/drivers/char/mem.c | |||
@@ -425,9 +425,6 @@ static ssize_t read_oldmem(struct file *file, char __user *buf, | |||
425 | } | 425 | } |
426 | #endif | 426 | #endif |
427 | 427 | ||
428 | extern long vread(char *buf, char *addr, unsigned long count); | ||
429 | extern long vwrite(char *buf, char *addr, unsigned long count); | ||
430 | |||
431 | #ifdef CONFIG_DEVKMEM | 428 | #ifdef CONFIG_DEVKMEM |
432 | /* | 429 | /* |
433 | * This function reads the *virtual* memory as seen by the kernel. | 430 | * This function reads the *virtual* memory as seen by the kernel. |
diff --git a/drivers/char/moxa.c b/drivers/char/moxa.c index 12d327a2c9ba..8b0da97d5293 100644 --- a/drivers/char/moxa.c +++ b/drivers/char/moxa.c | |||
@@ -206,6 +206,7 @@ static void moxa_poll(unsigned long); | |||
206 | static void moxa_set_tty_param(struct tty_struct *, struct ktermios *); | 206 | static void moxa_set_tty_param(struct tty_struct *, struct ktermios *); |
207 | static void moxa_setup_empty_event(struct tty_struct *); | 207 | static void moxa_setup_empty_event(struct tty_struct *); |
208 | static void moxa_shut_down(struct tty_struct *); | 208 | static void moxa_shut_down(struct tty_struct *); |
209 | static int moxa_carrier_raised(struct tty_port *); | ||
209 | /* | 210 | /* |
210 | * moxa board interface functions: | 211 | * moxa board interface functions: |
211 | */ | 212 | */ |
@@ -405,6 +406,10 @@ static const struct tty_operations moxa_ops = { | |||
405 | .tiocmset = moxa_tiocmset, | 406 | .tiocmset = moxa_tiocmset, |
406 | }; | 407 | }; |
407 | 408 | ||
409 | static const struct tty_port_operations moxa_port_ops = { | ||
410 | .carrier_raised = moxa_carrier_raised, | ||
411 | }; | ||
412 | |||
408 | static struct tty_driver *moxaDriver; | 413 | static struct tty_driver *moxaDriver; |
409 | static DEFINE_TIMER(moxaTimer, moxa_poll, 0, 0); | 414 | static DEFINE_TIMER(moxaTimer, moxa_poll, 0, 0); |
410 | static DEFINE_SPINLOCK(moxa_lock); | 415 | static DEFINE_SPINLOCK(moxa_lock); |
@@ -826,6 +831,7 @@ static int moxa_init_board(struct moxa_board_conf *brd, struct device *dev) | |||
826 | 831 | ||
827 | for (i = 0, p = brd->ports; i < MAX_PORTS_PER_BOARD; i++, p++) { | 832 | for (i = 0, p = brd->ports; i < MAX_PORTS_PER_BOARD; i++, p++) { |
828 | tty_port_init(&p->port); | 833 | tty_port_init(&p->port); |
834 | p->port.ops = &moxa_port_ops; | ||
829 | p->type = PORT_16550A; | 835 | p->type = PORT_16550A; |
830 | p->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL; | 836 | p->cflag = B9600 | CS8 | CREAD | CLOCAL | HUPCL; |
831 | } | 837 | } |
@@ -1115,15 +1121,27 @@ static void moxa_close_port(struct tty_struct *tty) | |||
1115 | tty_port_tty_set(&ch->port, NULL); | 1121 | tty_port_tty_set(&ch->port, NULL); |
1116 | } | 1122 | } |
1117 | 1123 | ||
1124 | static int moxa_carrier_raised(struct tty_port *port) | ||
1125 | { | ||
1126 | struct moxa_port *ch = container_of(port, struct moxa_port, port); | ||
1127 | int dcd; | ||
1128 | |||
1129 | spin_lock_bh(&moxa_lock); | ||
1130 | dcd = ch->DCDState; | ||
1131 | spin_unlock_bh(&moxa_lock); | ||
1132 | return dcd; | ||
1133 | } | ||
1134 | |||
1118 | static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp, | 1135 | static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp, |
1119 | struct moxa_port *ch) | 1136 | struct moxa_port *ch) |
1120 | { | 1137 | { |
1138 | struct tty_port *port = &ch->port; | ||
1121 | DEFINE_WAIT(wait); | 1139 | DEFINE_WAIT(wait); |
1122 | int retval = 0; | 1140 | int retval = 0; |
1123 | u8 dcd; | 1141 | u8 dcd; |
1124 | 1142 | ||
1125 | while (1) { | 1143 | while (1) { |
1126 | prepare_to_wait(&ch->port.open_wait, &wait, TASK_INTERRUPTIBLE); | 1144 | prepare_to_wait(&port->open_wait, &wait, TASK_INTERRUPTIBLE); |
1127 | if (tty_hung_up_p(filp)) { | 1145 | if (tty_hung_up_p(filp)) { |
1128 | #ifdef SERIAL_DO_RESTART | 1146 | #ifdef SERIAL_DO_RESTART |
1129 | retval = -ERESTARTSYS; | 1147 | retval = -ERESTARTSYS; |
@@ -1132,9 +1150,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp, | |||
1132 | #endif | 1150 | #endif |
1133 | break; | 1151 | break; |
1134 | } | 1152 | } |
1135 | spin_lock_bh(&moxa_lock); | 1153 | dcd = tty_port_carrier_raised(port); |
1136 | dcd = ch->DCDState; | ||
1137 | spin_unlock_bh(&moxa_lock); | ||
1138 | if (dcd) | 1154 | if (dcd) |
1139 | break; | 1155 | break; |
1140 | 1156 | ||
@@ -1144,7 +1160,7 @@ static int moxa_block_till_ready(struct tty_struct *tty, struct file *filp, | |||
1144 | } | 1160 | } |
1145 | schedule(); | 1161 | schedule(); |
1146 | } | 1162 | } |
1147 | finish_wait(&ch->port.open_wait, &wait); | 1163 | finish_wait(&port->open_wait, &wait); |
1148 | 1164 | ||
1149 | return retval; | 1165 | return retval; |
1150 | } | 1166 | } |
diff --git a/drivers/char/mwave/mwavedd.c b/drivers/char/mwave/mwavedd.c index 4f8d67fed292..94ad2c3bfc4a 100644 --- a/drivers/char/mwave/mwavedd.c +++ b/drivers/char/mwave/mwavedd.c | |||
@@ -663,7 +663,7 @@ static int __init mwave_init(void) | |||
663 | #if 0 | 663 | #if 0 |
664 | /* sysfs */ | 664 | /* sysfs */ |
665 | memset(&mwave_device, 0, sizeof (struct device)); | 665 | memset(&mwave_device, 0, sizeof (struct device)); |
666 | snprintf(mwave_device.bus_id, BUS_ID_SIZE, "mwave"); | 666 | dev_set_name(&mwave_device, "mwave"); |
667 | 667 | ||
668 | if (device_register(&mwave_device)) | 668 | if (device_register(&mwave_device)) |
669 | goto cleanup_error; | 669 | goto cleanup_error; |
diff --git a/drivers/char/mxser.c b/drivers/char/mxser.c index 047766915411..402c9f217f83 100644 --- a/drivers/char/mxser.c +++ b/drivers/char/mxser.c | |||
@@ -541,74 +541,21 @@ static unsigned char mxser_get_msr(int baseaddr, int mode, int port) | |||
541 | return status; | 541 | return status; |
542 | } | 542 | } |
543 | 543 | ||
544 | static int mxser_block_til_ready(struct tty_struct *tty, struct file *filp, | 544 | static int mxser_carrier_raised(struct tty_port *port) |
545 | struct mxser_port *port) | ||
546 | { | 545 | { |
547 | DECLARE_WAITQUEUE(wait, current); | 546 | struct mxser_port *mp = container_of(port, struct mxser_port, port); |
548 | int retval; | 547 | return (inb(mp->ioaddr + UART_MSR) & UART_MSR_DCD)?1:0; |
549 | int do_clocal = 0; | 548 | } |
550 | unsigned long flags; | ||
551 | |||
552 | /* | ||
553 | * If non-blocking mode is set, or the port is not enabled, | ||
554 | * then make the check up front and then exit. | ||
555 | */ | ||
556 | if ((filp->f_flags & O_NONBLOCK) || | ||
557 | test_bit(TTY_IO_ERROR, &tty->flags)) { | ||
558 | port->port.flags |= ASYNC_NORMAL_ACTIVE; | ||
559 | return 0; | ||
560 | } | ||
561 | 549 | ||
562 | if (tty->termios->c_cflag & CLOCAL) | 550 | static void mxser_raise_dtr_rts(struct tty_port *port) |
563 | do_clocal = 1; | 551 | { |
552 | struct mxser_port *mp = container_of(port, struct mxser_port, port); | ||
553 | unsigned long flags; | ||
564 | 554 | ||
565 | /* | 555 | spin_lock_irqsave(&mp->slock, flags); |
566 | * Block waiting for the carrier detect and the line to become | 556 | outb(inb(mp->ioaddr + UART_MCR) | |
567 | * free (i.e., not in use by the callout). While we are in | 557 | UART_MCR_DTR | UART_MCR_RTS, mp->ioaddr + UART_MCR); |
568 | * this loop, port->port.count is dropped by one, so that | 558 | spin_unlock_irqrestore(&mp->slock, flags); |
569 | * mxser_close() knows when to free things. We restore it upon | ||
570 | * exit, either normal or abnormal. | ||
571 | */ | ||
572 | retval = 0; | ||
573 | add_wait_queue(&port->port.open_wait, &wait); | ||
574 | |||
575 | spin_lock_irqsave(&port->slock, flags); | ||
576 | if (!tty_hung_up_p(filp)) | ||
577 | port->port.count--; | ||
578 | spin_unlock_irqrestore(&port->slock, flags); | ||
579 | port->port.blocked_open++; | ||
580 | while (1) { | ||
581 | spin_lock_irqsave(&port->slock, flags); | ||
582 | outb(inb(port->ioaddr + UART_MCR) | | ||
583 | UART_MCR_DTR | UART_MCR_RTS, port->ioaddr + UART_MCR); | ||
584 | spin_unlock_irqrestore(&port->slock, flags); | ||
585 | set_current_state(TASK_INTERRUPTIBLE); | ||
586 | if (tty_hung_up_p(filp) || !(port->port.flags & ASYNC_INITIALIZED)) { | ||
587 | if (port->port.flags & ASYNC_HUP_NOTIFY) | ||
588 | retval = -EAGAIN; | ||
589 | else | ||
590 | retval = -ERESTARTSYS; | ||
591 | break; | ||
592 | } | ||
593 | if (!(port->port.flags & ASYNC_CLOSING) && | ||
594 | (do_clocal || | ||
595 | (inb(port->ioaddr + UART_MSR) & UART_MSR_DCD))) | ||
596 | break; | ||
597 | if (signal_pending(current)) { | ||
598 | retval = -ERESTARTSYS; | ||
599 | break; | ||
600 | } | ||
601 | schedule(); | ||
602 | } | ||
603 | set_current_state(TASK_RUNNING); | ||
604 | remove_wait_queue(&port->port.open_wait, &wait); | ||
605 | if (!tty_hung_up_p(filp)) | ||
606 | port->port.count++; | ||
607 | port->port.blocked_open--; | ||
608 | if (retval) | ||
609 | return retval; | ||
610 | port->port.flags |= ASYNC_NORMAL_ACTIVE; | ||
611 | return 0; | ||
612 | } | 559 | } |
613 | 560 | ||
614 | static int mxser_set_baud(struct tty_struct *tty, long newspd) | 561 | static int mxser_set_baud(struct tty_struct *tty, long newspd) |
@@ -1087,14 +1034,14 @@ static int mxser_open(struct tty_struct *tty, struct file *filp) | |||
1087 | /* | 1034 | /* |
1088 | * Start up serial port | 1035 | * Start up serial port |
1089 | */ | 1036 | */ |
1090 | spin_lock_irqsave(&info->slock, flags); | 1037 | spin_lock_irqsave(&info->port.lock, flags); |
1091 | info->port.count++; | 1038 | info->port.count++; |
1092 | spin_unlock_irqrestore(&info->slock, flags); | 1039 | spin_unlock_irqrestore(&info->port.lock, flags); |
1093 | retval = mxser_startup(tty); | 1040 | retval = mxser_startup(tty); |
1094 | if (retval) | 1041 | if (retval) |
1095 | return retval; | 1042 | return retval; |
1096 | 1043 | ||
1097 | retval = mxser_block_til_ready(tty, filp, info); | 1044 | retval = tty_port_block_til_ready(&info->port, tty, filp); |
1098 | if (retval) | 1045 | if (retval) |
1099 | return retval; | 1046 | return retval; |
1100 | 1047 | ||
@@ -1133,58 +1080,27 @@ static void mxser_flush_buffer(struct tty_struct *tty) | |||
1133 | static void mxser_close(struct tty_struct *tty, struct file *filp) | 1080 | static void mxser_close(struct tty_struct *tty, struct file *filp) |
1134 | { | 1081 | { |
1135 | struct mxser_port *info = tty->driver_data; | 1082 | struct mxser_port *info = tty->driver_data; |
1083 | struct tty_port *port = &info->port; | ||
1136 | 1084 | ||
1137 | unsigned long timeout; | 1085 | unsigned long timeout; |
1138 | unsigned long flags; | ||
1139 | 1086 | ||
1140 | if (tty->index == MXSER_PORTS) | 1087 | if (tty->index == MXSER_PORTS) |
1141 | return; | 1088 | return; |
1142 | if (!info) | 1089 | if (!info) |
1143 | return; | 1090 | return; |
1144 | 1091 | ||
1145 | spin_lock_irqsave(&info->slock, flags); | 1092 | if (tty_port_close_start(port, tty, filp) == 0) |
1146 | |||
1147 | if (tty_hung_up_p(filp)) { | ||
1148 | spin_unlock_irqrestore(&info->slock, flags); | ||
1149 | return; | ||
1150 | } | ||
1151 | if ((tty->count == 1) && (info->port.count != 1)) { | ||
1152 | /* | ||
1153 | * Uh, oh. tty->count is 1, which means that the tty | ||
1154 | * structure will be freed. Info->port.count should always | ||
1155 | * be one in these conditions. If it's greater than | ||
1156 | * one, we've got real problems, since it means the | ||
1157 | * serial port won't be shutdown. | ||
1158 | */ | ||
1159 | printk(KERN_ERR "mxser_close: bad serial port count; " | ||
1160 | "tty->count is 1, info->port.count is %d\n", info->port.count); | ||
1161 | info->port.count = 1; | ||
1162 | } | ||
1163 | if (--info->port.count < 0) { | ||
1164 | printk(KERN_ERR "mxser_close: bad serial port count for " | ||
1165 | "ttys%d: %d\n", tty->index, info->port.count); | ||
1166 | info->port.count = 0; | ||
1167 | } | ||
1168 | if (info->port.count) { | ||
1169 | spin_unlock_irqrestore(&info->slock, flags); | ||
1170 | return; | 1093 | return; |
1171 | } | 1094 | |
1172 | info->port.flags |= ASYNC_CLOSING; | ||
1173 | spin_unlock_irqrestore(&info->slock, flags); | ||
1174 | /* | 1095 | /* |
1175 | * Save the termios structure, since this port may have | 1096 | * Save the termios structure, since this port may have |
1176 | * separate termios for callout and dialin. | 1097 | * separate termios for callout and dialin. |
1098 | * | ||
1099 | * FIXME: Can this go ? | ||
1177 | */ | 1100 | */ |
1178 | if (info->port.flags & ASYNC_NORMAL_ACTIVE) | 1101 | if (info->port.flags & ASYNC_NORMAL_ACTIVE) |
1179 | info->normal_termios = *tty->termios; | 1102 | info->normal_termios = *tty->termios; |
1180 | /* | 1103 | /* |
1181 | * Now we wait for the transmit buffer to clear; and we notify | ||
1182 | * the line discipline to only process XON/XOFF characters. | ||
1183 | */ | ||
1184 | tty->closing = 1; | ||
1185 | if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) | ||
1186 | tty_wait_until_sent(tty, info->port.closing_wait); | ||
1187 | /* | ||
1188 | * At this point we stop accepting input. To do this, we | 1104 | * At this point we stop accepting input. To do this, we |
1189 | * disable the receive line status interrupts, and tell the | 1105 | * disable the receive line status interrupts, and tell the |
1190 | * interrupt driver to stop checking the data ready bit in the | 1106 | * interrupt driver to stop checking the data ready bit in the |
@@ -1209,19 +1125,12 @@ static void mxser_close(struct tty_struct *tty, struct file *filp) | |||
1209 | } | 1125 | } |
1210 | } | 1126 | } |
1211 | mxser_shutdown(tty); | 1127 | mxser_shutdown(tty); |
1212 | |||
1213 | mxser_flush_buffer(tty); | 1128 | mxser_flush_buffer(tty); |
1214 | tty_ldisc_flush(tty); | ||
1215 | |||
1216 | tty->closing = 0; | ||
1217 | tty_port_tty_set(&info->port, NULL); | ||
1218 | if (info->port.blocked_open) { | ||
1219 | if (info->port.close_delay) | ||
1220 | schedule_timeout_interruptible(info->port.close_delay); | ||
1221 | wake_up_interruptible(&info->port.open_wait); | ||
1222 | } | ||
1223 | 1129 | ||
1224 | info->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); | 1130 | /* Right now the tty_port set is done outside of the close_end helper |
1131 | as we don't yet have everyone using refcounts */ | ||
1132 | tty_port_close_end(port, tty); | ||
1133 | tty_port_tty_set(port, NULL); | ||
1225 | } | 1134 | } |
1226 | 1135 | ||
1227 | static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count) | 1136 | static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count) |
@@ -2146,10 +2055,7 @@ static void mxser_hangup(struct tty_struct *tty) | |||
2146 | 2055 | ||
2147 | mxser_flush_buffer(tty); | 2056 | mxser_flush_buffer(tty); |
2148 | mxser_shutdown(tty); | 2057 | mxser_shutdown(tty); |
2149 | info->port.count = 0; | 2058 | tty_port_hangup(&info->port); |
2150 | info->port.flags &= ~ASYNC_NORMAL_ACTIVE; | ||
2151 | tty_port_tty_set(&info->port, NULL); | ||
2152 | wake_up_interruptible(&info->port.open_wait); | ||
2153 | } | 2059 | } |
2154 | 2060 | ||
2155 | /* | 2061 | /* |
@@ -2449,6 +2355,11 @@ static const struct tty_operations mxser_ops = { | |||
2449 | .tiocmset = mxser_tiocmset, | 2355 | .tiocmset = mxser_tiocmset, |
2450 | }; | 2356 | }; |
2451 | 2357 | ||
2358 | struct tty_port_operations mxser_port_ops = { | ||
2359 | .carrier_raised = mxser_carrier_raised, | ||
2360 | .raise_dtr_rts = mxser_raise_dtr_rts, | ||
2361 | }; | ||
2362 | |||
2452 | /* | 2363 | /* |
2453 | * The MOXA Smartio/Industio serial driver boot-time initialization code! | 2364 | * The MOXA Smartio/Industio serial driver boot-time initialization code! |
2454 | */ | 2365 | */ |
@@ -2482,6 +2393,7 @@ static int __devinit mxser_initbrd(struct mxser_board *brd, | |||
2482 | for (i = 0; i < brd->info->nports; i++) { | 2393 | for (i = 0; i < brd->info->nports; i++) { |
2483 | info = &brd->ports[i]; | 2394 | info = &brd->ports[i]; |
2484 | tty_port_init(&info->port); | 2395 | tty_port_init(&info->port); |
2396 | info->port.ops = &mxser_port_ops; | ||
2485 | info->board = brd; | 2397 | info->board = brd; |
2486 | info->stop_rx = 0; | 2398 | info->stop_rx = 0; |
2487 | info->ldisc_stop_rx = 0; | 2399 | info->ldisc_stop_rx = 0; |
diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c index 4a8215a89ad3..d2e93e343226 100644 --- a/drivers/char/n_r3964.c +++ b/drivers/char/n_r3964.c | |||
@@ -1003,7 +1003,7 @@ static int r3964_open(struct tty_struct *tty) | |||
1003 | 1003 | ||
1004 | static void r3964_close(struct tty_struct *tty) | 1004 | static void r3964_close(struct tty_struct *tty) |
1005 | { | 1005 | { |
1006 | struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data; | 1006 | struct r3964_info *pInfo = tty->disc_data; |
1007 | struct r3964_client_info *pClient, *pNext; | 1007 | struct r3964_client_info *pClient, *pNext; |
1008 | struct r3964_message *pMsg; | 1008 | struct r3964_message *pMsg; |
1009 | struct r3964_block_header *pHeader, *pNextHeader; | 1009 | struct r3964_block_header *pHeader, *pNextHeader; |
@@ -1058,7 +1058,7 @@ static void r3964_close(struct tty_struct *tty) | |||
1058 | static ssize_t r3964_read(struct tty_struct *tty, struct file *file, | 1058 | static ssize_t r3964_read(struct tty_struct *tty, struct file *file, |
1059 | unsigned char __user * buf, size_t nr) | 1059 | unsigned char __user * buf, size_t nr) |
1060 | { | 1060 | { |
1061 | struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data; | 1061 | struct r3964_info *pInfo = tty->disc_data; |
1062 | struct r3964_client_info *pClient; | 1062 | struct r3964_client_info *pClient; |
1063 | struct r3964_message *pMsg; | 1063 | struct r3964_message *pMsg; |
1064 | struct r3964_client_message theMsg; | 1064 | struct r3964_client_message theMsg; |
@@ -1113,7 +1113,7 @@ static ssize_t r3964_read(struct tty_struct *tty, struct file *file, | |||
1113 | static ssize_t r3964_write(struct tty_struct *tty, struct file *file, | 1113 | static ssize_t r3964_write(struct tty_struct *tty, struct file *file, |
1114 | const unsigned char *data, size_t count) | 1114 | const unsigned char *data, size_t count) |
1115 | { | 1115 | { |
1116 | struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data; | 1116 | struct r3964_info *pInfo = tty->disc_data; |
1117 | struct r3964_block_header *pHeader; | 1117 | struct r3964_block_header *pHeader; |
1118 | struct r3964_client_info *pClient; | 1118 | struct r3964_client_info *pClient; |
1119 | unsigned char *new_data; | 1119 | unsigned char *new_data; |
@@ -1182,7 +1182,7 @@ static ssize_t r3964_write(struct tty_struct *tty, struct file *file, | |||
1182 | static int r3964_ioctl(struct tty_struct *tty, struct file *file, | 1182 | static int r3964_ioctl(struct tty_struct *tty, struct file *file, |
1183 | unsigned int cmd, unsigned long arg) | 1183 | unsigned int cmd, unsigned long arg) |
1184 | { | 1184 | { |
1185 | struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data; | 1185 | struct r3964_info *pInfo = tty->disc_data; |
1186 | if (pInfo == NULL) | 1186 | if (pInfo == NULL) |
1187 | return -EINVAL; | 1187 | return -EINVAL; |
1188 | switch (cmd) { | 1188 | switch (cmd) { |
@@ -1216,7 +1216,7 @@ static void r3964_set_termios(struct tty_struct *tty, struct ktermios *old) | |||
1216 | static unsigned int r3964_poll(struct tty_struct *tty, struct file *file, | 1216 | static unsigned int r3964_poll(struct tty_struct *tty, struct file *file, |
1217 | struct poll_table_struct *wait) | 1217 | struct poll_table_struct *wait) |
1218 | { | 1218 | { |
1219 | struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data; | 1219 | struct r3964_info *pInfo = tty->disc_data; |
1220 | struct r3964_client_info *pClient; | 1220 | struct r3964_client_info *pClient; |
1221 | struct r3964_message *pMsg = NULL; | 1221 | struct r3964_message *pMsg = NULL; |
1222 | unsigned long flags; | 1222 | unsigned long flags; |
@@ -1241,7 +1241,7 @@ static unsigned int r3964_poll(struct tty_struct *tty, struct file *file, | |||
1241 | static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp, | 1241 | static void r3964_receive_buf(struct tty_struct *tty, const unsigned char *cp, |
1242 | char *fp, int count) | 1242 | char *fp, int count) |
1243 | { | 1243 | { |
1244 | struct r3964_info *pInfo = (struct r3964_info *)tty->disc_data; | 1244 | struct r3964_info *pInfo = tty->disc_data; |
1245 | const unsigned char *p; | 1245 | const unsigned char *p; |
1246 | char *f, flags = 0; | 1246 | char *f, flags = 0; |
1247 | int i; | 1247 | int i; |
diff --git a/drivers/char/n_tty.c b/drivers/char/n_tty.c index efbfe9612658..f6f0e4ec2b51 100644 --- a/drivers/char/n_tty.c +++ b/drivers/char/n_tty.c | |||
@@ -47,8 +47,8 @@ | |||
47 | #include <linux/bitops.h> | 47 | #include <linux/bitops.h> |
48 | #include <linux/audit.h> | 48 | #include <linux/audit.h> |
49 | #include <linux/file.h> | 49 | #include <linux/file.h> |
50 | #include <linux/uaccess.h> | ||
50 | 51 | ||
51 | #include <asm/uaccess.h> | ||
52 | #include <asm/system.h> | 52 | #include <asm/system.h> |
53 | 53 | ||
54 | /* number of characters left in xmit buffer before select has we have room */ | 54 | /* number of characters left in xmit buffer before select has we have room */ |
@@ -62,6 +62,17 @@ | |||
62 | #define TTY_THRESHOLD_THROTTLE 128 /* now based on remaining room */ | 62 | #define TTY_THRESHOLD_THROTTLE 128 /* now based on remaining room */ |
63 | #define TTY_THRESHOLD_UNTHROTTLE 128 | 63 | #define TTY_THRESHOLD_UNTHROTTLE 128 |
64 | 64 | ||
65 | /* | ||
66 | * Special byte codes used in the echo buffer to represent operations | ||
67 | * or special handling of characters. Bytes in the echo buffer that | ||
68 | * are not part of such special blocks are treated as normal character | ||
69 | * codes. | ||
70 | */ | ||
71 | #define ECHO_OP_START 0xff | ||
72 | #define ECHO_OP_MOVE_BACK_COL 0x80 | ||
73 | #define ECHO_OP_SET_CANON_COL 0x81 | ||
74 | #define ECHO_OP_ERASE_TAB 0x82 | ||
75 | |||
65 | static inline unsigned char *alloc_buf(void) | 76 | static inline unsigned char *alloc_buf(void) |
66 | { | 77 | { |
67 | gfp_t prio = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; | 78 | gfp_t prio = in_interrupt() ? GFP_ATOMIC : GFP_KERNEL; |
@@ -169,6 +180,7 @@ static void check_unthrottle(struct tty_struct *tty) | |||
169 | * | 180 | * |
170 | * Locking: tty_read_lock for read fields. | 181 | * Locking: tty_read_lock for read fields. |
171 | */ | 182 | */ |
183 | |||
172 | static void reset_buffer_flags(struct tty_struct *tty) | 184 | static void reset_buffer_flags(struct tty_struct *tty) |
173 | { | 185 | { |
174 | unsigned long flags; | 186 | unsigned long flags; |
@@ -176,6 +188,11 @@ static void reset_buffer_flags(struct tty_struct *tty) | |||
176 | spin_lock_irqsave(&tty->read_lock, flags); | 188 | spin_lock_irqsave(&tty->read_lock, flags); |
177 | tty->read_head = tty->read_tail = tty->read_cnt = 0; | 189 | tty->read_head = tty->read_tail = tty->read_cnt = 0; |
178 | spin_unlock_irqrestore(&tty->read_lock, flags); | 190 | spin_unlock_irqrestore(&tty->read_lock, flags); |
191 | |||
192 | mutex_lock(&tty->echo_lock); | ||
193 | tty->echo_pos = tty->echo_cnt = tty->echo_overrun = 0; | ||
194 | mutex_unlock(&tty->echo_lock); | ||
195 | |||
179 | tty->canon_head = tty->canon_data = tty->erasing = 0; | 196 | tty->canon_head = tty->canon_data = tty->erasing = 0; |
180 | memset(&tty->read_flags, 0, sizeof tty->read_flags); | 197 | memset(&tty->read_flags, 0, sizeof tty->read_flags); |
181 | n_tty_set_room(tty); | 198 | n_tty_set_room(tty); |
@@ -266,89 +283,118 @@ static inline int is_continuation(unsigned char c, struct tty_struct *tty) | |||
266 | } | 283 | } |
267 | 284 | ||
268 | /** | 285 | /** |
269 | * opost - output post processor | 286 | * do_output_char - output one character |
270 | * @c: character (or partial unicode symbol) | 287 | * @c: character (or partial unicode symbol) |
271 | * @tty: terminal device | 288 | * @tty: terminal device |
289 | * @space: space available in tty driver write buffer | ||
272 | * | 290 | * |
273 | * Perform OPOST processing. Returns -1 when the output device is | 291 | * This is a helper function that handles one output character |
274 | * full and the character must be retried. Note that Linux currently | 292 | * (including special characters like TAB, CR, LF, etc.), |
275 | * ignores TABDLY, CRDLY, VTDLY, FFDLY and NLDLY. They simply aren't | 293 | * putting the results in the tty driver's write buffer. |
276 | * relevant in the world today. If you ever need them, add them here. | 294 | * |
295 | * Note that Linux currently ignores TABDLY, CRDLY, VTDLY, FFDLY | ||
296 | * and NLDLY. They simply aren't relevant in the world today. | ||
297 | * If you ever need them, add them here. | ||
298 | * | ||
299 | * Returns the number of bytes of buffer space used or -1 if | ||
300 | * no space left. | ||
277 | * | 301 | * |
278 | * Called from both the receive and transmit sides and can be called | 302 | * Locking: should be called under the output_lock to protect |
279 | * re-entrantly. Relies on lock_kernel() for tty->column state. | 303 | * the column state and space left in the buffer |
280 | */ | 304 | */ |
281 | 305 | ||
282 | static int opost(unsigned char c, struct tty_struct *tty) | 306 | static int do_output_char(unsigned char c, struct tty_struct *tty, int space) |
283 | { | 307 | { |
284 | int space, spaces; | 308 | int spaces; |
285 | 309 | ||
286 | space = tty_write_room(tty); | ||
287 | if (!space) | 310 | if (!space) |
288 | return -1; | 311 | return -1; |
289 | 312 | ||
290 | lock_kernel(); | 313 | switch (c) { |
291 | if (O_OPOST(tty)) { | 314 | case '\n': |
292 | switch (c) { | 315 | if (O_ONLRET(tty)) |
293 | case '\n': | 316 | tty->column = 0; |
294 | if (O_ONLRET(tty)) | 317 | if (O_ONLCR(tty)) { |
295 | tty->column = 0; | 318 | if (space < 2) |
296 | if (O_ONLCR(tty)) { | 319 | return -1; |
297 | if (space < 2) { | ||
298 | unlock_kernel(); | ||
299 | return -1; | ||
300 | } | ||
301 | tty_put_char(tty, '\r'); | ||
302 | tty->column = 0; | ||
303 | } | ||
304 | tty->canon_column = tty->column; | ||
305 | break; | ||
306 | case '\r': | ||
307 | if (O_ONOCR(tty) && tty->column == 0) { | ||
308 | unlock_kernel(); | ||
309 | return 0; | ||
310 | } | ||
311 | if (O_OCRNL(tty)) { | ||
312 | c = '\n'; | ||
313 | if (O_ONLRET(tty)) | ||
314 | tty->canon_column = tty->column = 0; | ||
315 | break; | ||
316 | } | ||
317 | tty->canon_column = tty->column = 0; | 320 | tty->canon_column = tty->column = 0; |
321 | tty_put_char(tty, '\r'); | ||
322 | tty_put_char(tty, c); | ||
323 | return 2; | ||
324 | } | ||
325 | tty->canon_column = tty->column; | ||
326 | break; | ||
327 | case '\r': | ||
328 | if (O_ONOCR(tty) && tty->column == 0) | ||
329 | return 0; | ||
330 | if (O_OCRNL(tty)) { | ||
331 | c = '\n'; | ||
332 | if (O_ONLRET(tty)) | ||
333 | tty->canon_column = tty->column = 0; | ||
318 | break; | 334 | break; |
319 | case '\t': | 335 | } |
320 | spaces = 8 - (tty->column & 7); | 336 | tty->canon_column = tty->column = 0; |
321 | if (O_TABDLY(tty) == XTABS) { | 337 | break; |
322 | if (space < spaces) { | 338 | case '\t': |
323 | unlock_kernel(); | 339 | spaces = 8 - (tty->column & 7); |
324 | return -1; | 340 | if (O_TABDLY(tty) == XTABS) { |
325 | } | 341 | if (space < spaces) |
326 | tty->column += spaces; | 342 | return -1; |
327 | tty->ops->write(tty, " ", spaces); | ||
328 | unlock_kernel(); | ||
329 | return 0; | ||
330 | } | ||
331 | tty->column += spaces; | 343 | tty->column += spaces; |
332 | break; | 344 | tty->ops->write(tty, " ", spaces); |
333 | case '\b': | 345 | return spaces; |
334 | if (tty->column > 0) | 346 | } |
335 | tty->column--; | 347 | tty->column += spaces; |
336 | break; | 348 | break; |
337 | default: | 349 | case '\b': |
350 | if (tty->column > 0) | ||
351 | tty->column--; | ||
352 | break; | ||
353 | default: | ||
354 | if (!iscntrl(c)) { | ||
338 | if (O_OLCUC(tty)) | 355 | if (O_OLCUC(tty)) |
339 | c = toupper(c); | 356 | c = toupper(c); |
340 | if (!iscntrl(c) && !is_continuation(c, tty)) | 357 | if (!is_continuation(c, tty)) |
341 | tty->column++; | 358 | tty->column++; |
342 | break; | ||
343 | } | 359 | } |
360 | break; | ||
344 | } | 361 | } |
362 | |||
345 | tty_put_char(tty, c); | 363 | tty_put_char(tty, c); |
346 | unlock_kernel(); | 364 | return 1; |
347 | return 0; | ||
348 | } | 365 | } |
349 | 366 | ||
350 | /** | 367 | /** |
351 | * opost_block - block postprocess | 368 | * process_output - output post processor |
369 | * @c: character (or partial unicode symbol) | ||
370 | * @tty: terminal device | ||
371 | * | ||
372 | * Perform OPOST processing. Returns -1 when the output device is | ||
373 | * full and the character must be retried. | ||
374 | * | ||
375 | * Locking: output_lock to protect column state and space left | ||
376 | * (also, this is called from n_tty_write under the | ||
377 | * tty layer write lock) | ||
378 | */ | ||
379 | |||
380 | static int process_output(unsigned char c, struct tty_struct *tty) | ||
381 | { | ||
382 | int space, retval; | ||
383 | |||
384 | mutex_lock(&tty->output_lock); | ||
385 | |||
386 | space = tty_write_room(tty); | ||
387 | retval = do_output_char(c, tty, space); | ||
388 | |||
389 | mutex_unlock(&tty->output_lock); | ||
390 | if (retval < 0) | ||
391 | return -1; | ||
392 | else | ||
393 | return 0; | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * process_output_block - block post processor | ||
352 | * @tty: terminal device | 398 | * @tty: terminal device |
353 | * @inbuf: user buffer | 399 | * @inbuf: user buffer |
354 | * @nr: number of bytes | 400 | * @nr: number of bytes |
@@ -358,26 +404,32 @@ static int opost(unsigned char c, struct tty_struct *tty) | |||
358 | * the simple cases normally found and helps to generate blocks of | 404 | * the simple cases normally found and helps to generate blocks of |
359 | * symbols for the console driver and thus improve performance. | 405 | * symbols for the console driver and thus improve performance. |
360 | * | 406 | * |
361 | * Called from n_tty_write under the tty layer write lock. Relies | 407 | * Locking: output_lock to protect column state and space left |
362 | * on lock_kernel for the tty->column state. | 408 | * (also, this is called from n_tty_write under the |
409 | * tty layer write lock) | ||
363 | */ | 410 | */ |
364 | 411 | ||
365 | static ssize_t opost_block(struct tty_struct *tty, | 412 | static ssize_t process_output_block(struct tty_struct *tty, |
366 | const unsigned char *buf, unsigned int nr) | 413 | const unsigned char *buf, unsigned int nr) |
367 | { | 414 | { |
368 | int space; | 415 | int space; |
369 | int i; | 416 | int i; |
370 | const unsigned char *cp; | 417 | const unsigned char *cp; |
371 | 418 | ||
419 | mutex_lock(&tty->output_lock); | ||
420 | |||
372 | space = tty_write_room(tty); | 421 | space = tty_write_room(tty); |
373 | if (!space) | 422 | if (!space) { |
423 | mutex_unlock(&tty->output_lock); | ||
374 | return 0; | 424 | return 0; |
425 | } | ||
375 | if (nr > space) | 426 | if (nr > space) |
376 | nr = space; | 427 | nr = space; |
377 | 428 | ||
378 | lock_kernel(); | ||
379 | for (i = 0, cp = buf; i < nr; i++, cp++) { | 429 | for (i = 0, cp = buf; i < nr; i++, cp++) { |
380 | switch (*cp) { | 430 | unsigned char c = *cp; |
431 | |||
432 | switch (c) { | ||
381 | case '\n': | 433 | case '\n': |
382 | if (O_ONLRET(tty)) | 434 | if (O_ONLRET(tty)) |
383 | tty->column = 0; | 435 | tty->column = 0; |
@@ -399,54 +451,403 @@ static ssize_t opost_block(struct tty_struct *tty, | |||
399 | tty->column--; | 451 | tty->column--; |
400 | break; | 452 | break; |
401 | default: | 453 | default: |
402 | if (O_OLCUC(tty)) | 454 | if (!iscntrl(c)) { |
403 | goto break_out; | 455 | if (O_OLCUC(tty)) |
404 | if (!iscntrl(*cp)) | 456 | goto break_out; |
405 | tty->column++; | 457 | if (!is_continuation(c, tty)) |
458 | tty->column++; | ||
459 | } | ||
406 | break; | 460 | break; |
407 | } | 461 | } |
408 | } | 462 | } |
409 | break_out: | 463 | break_out: |
410 | if (tty->ops->flush_chars) | ||
411 | tty->ops->flush_chars(tty); | ||
412 | i = tty->ops->write(tty, buf, i); | 464 | i = tty->ops->write(tty, buf, i); |
413 | unlock_kernel(); | 465 | |
466 | mutex_unlock(&tty->output_lock); | ||
414 | return i; | 467 | return i; |
415 | } | 468 | } |
416 | 469 | ||
470 | /** | ||
471 | * process_echoes - write pending echo characters | ||
472 | * @tty: terminal device | ||
473 | * | ||
474 | * Write previously buffered echo (and other ldisc-generated) | ||
475 | * characters to the tty. | ||
476 | * | ||
477 | * Characters generated by the ldisc (including echoes) need to | ||
478 | * be buffered because the driver's write buffer can fill during | ||
479 | * heavy program output. Echoing straight to the driver will | ||
480 | * often fail under these conditions, causing lost characters and | ||
481 | * resulting mismatches of ldisc state information. | ||
482 | * | ||
483 | * Since the ldisc state must represent the characters actually sent | ||
484 | * to the driver at the time of the write, operations like certain | ||
485 | * changes in column state are also saved in the buffer and executed | ||
486 | * here. | ||
487 | * | ||
488 | * A circular fifo buffer is used so that the most recent characters | ||
489 | * are prioritized. Also, when control characters are echoed with a | ||
490 | * prefixed "^", the pair is treated atomically and thus not separated. | ||
491 | * | ||
492 | * Locking: output_lock to protect column state and space left, | ||
493 | * echo_lock to protect the echo buffer | ||
494 | */ | ||
495 | |||
496 | static void process_echoes(struct tty_struct *tty) | ||
497 | { | ||
498 | int space, nr; | ||
499 | unsigned char c; | ||
500 | unsigned char *cp, *buf_end; | ||
501 | |||
502 | if (!tty->echo_cnt) | ||
503 | return; | ||
504 | |||
505 | mutex_lock(&tty->output_lock); | ||
506 | mutex_lock(&tty->echo_lock); | ||
507 | |||
508 | space = tty_write_room(tty); | ||
509 | |||
510 | buf_end = tty->echo_buf + N_TTY_BUF_SIZE; | ||
511 | cp = tty->echo_buf + tty->echo_pos; | ||
512 | nr = tty->echo_cnt; | ||
513 | while (nr > 0) { | ||
514 | c = *cp; | ||
515 | if (c == ECHO_OP_START) { | ||
516 | unsigned char op; | ||
517 | unsigned char *opp; | ||
518 | int no_space_left = 0; | ||
519 | |||
520 | /* | ||
521 | * If the buffer byte is the start of a multi-byte | ||
522 | * operation, get the next byte, which is either the | ||
523 | * op code or a control character value. | ||
524 | */ | ||
525 | opp = cp + 1; | ||
526 | if (opp == buf_end) | ||
527 | opp -= N_TTY_BUF_SIZE; | ||
528 | op = *opp; | ||
529 | |||
530 | switch (op) { | ||
531 | unsigned int num_chars, num_bs; | ||
532 | |||
533 | case ECHO_OP_ERASE_TAB: | ||
534 | if (++opp == buf_end) | ||
535 | opp -= N_TTY_BUF_SIZE; | ||
536 | num_chars = *opp; | ||
537 | |||
538 | /* | ||
539 | * Determine how many columns to go back | ||
540 | * in order to erase the tab. | ||
541 | * This depends on the number of columns | ||
542 | * used by other characters within the tab | ||
543 | * area. If this (modulo 8) count is from | ||
544 | * the start of input rather than from a | ||
545 | * previous tab, we offset by canon column. | ||
546 | * Otherwise, tab spacing is normal. | ||
547 | */ | ||
548 | if (!(num_chars & 0x80)) | ||
549 | num_chars += tty->canon_column; | ||
550 | num_bs = 8 - (num_chars & 7); | ||
551 | |||
552 | if (num_bs > space) { | ||
553 | no_space_left = 1; | ||
554 | break; | ||
555 | } | ||
556 | space -= num_bs; | ||
557 | while (num_bs--) { | ||
558 | tty_put_char(tty, '\b'); | ||
559 | if (tty->column > 0) | ||
560 | tty->column--; | ||
561 | } | ||
562 | cp += 3; | ||
563 | nr -= 3; | ||
564 | break; | ||
565 | |||
566 | case ECHO_OP_SET_CANON_COL: | ||
567 | tty->canon_column = tty->column; | ||
568 | cp += 2; | ||
569 | nr -= 2; | ||
570 | break; | ||
571 | |||
572 | case ECHO_OP_MOVE_BACK_COL: | ||
573 | if (tty->column > 0) | ||
574 | tty->column--; | ||
575 | cp += 2; | ||
576 | nr -= 2; | ||
577 | break; | ||
578 | |||
579 | case ECHO_OP_START: | ||
580 | /* This is an escaped echo op start code */ | ||
581 | if (!space) { | ||
582 | no_space_left = 1; | ||
583 | break; | ||
584 | } | ||
585 | tty_put_char(tty, ECHO_OP_START); | ||
586 | tty->column++; | ||
587 | space--; | ||
588 | cp += 2; | ||
589 | nr -= 2; | ||
590 | break; | ||
591 | |||
592 | default: | ||
593 | if (iscntrl(op)) { | ||
594 | if (L_ECHOCTL(tty)) { | ||
595 | /* | ||
596 | * Ensure there is enough space | ||
597 | * for the whole ctrl pair. | ||
598 | */ | ||
599 | if (space < 2) { | ||
600 | no_space_left = 1; | ||
601 | break; | ||
602 | } | ||
603 | tty_put_char(tty, '^'); | ||
604 | tty_put_char(tty, op ^ 0100); | ||
605 | tty->column += 2; | ||
606 | space -= 2; | ||
607 | } else { | ||
608 | if (!space) { | ||
609 | no_space_left = 1; | ||
610 | break; | ||
611 | } | ||
612 | tty_put_char(tty, op); | ||
613 | space--; | ||
614 | } | ||
615 | } | ||
616 | /* | ||
617 | * If above falls through, this was an | ||
618 | * undefined op. | ||
619 | */ | ||
620 | cp += 2; | ||
621 | nr -= 2; | ||
622 | } | ||
623 | |||
624 | if (no_space_left) | ||
625 | break; | ||
626 | } else { | ||
627 | int retval; | ||
628 | |||
629 | retval = do_output_char(c, tty, space); | ||
630 | if (retval < 0) | ||
631 | break; | ||
632 | space -= retval; | ||
633 | cp += 1; | ||
634 | nr -= 1; | ||
635 | } | ||
636 | |||
637 | /* When end of circular buffer reached, wrap around */ | ||
638 | if (cp >= buf_end) | ||
639 | cp -= N_TTY_BUF_SIZE; | ||
640 | } | ||
641 | |||
642 | if (nr == 0) { | ||
643 | tty->echo_pos = 0; | ||
644 | tty->echo_cnt = 0; | ||
645 | tty->echo_overrun = 0; | ||
646 | } else { | ||
647 | int num_processed = tty->echo_cnt - nr; | ||
648 | tty->echo_pos += num_processed; | ||
649 | tty->echo_pos &= N_TTY_BUF_SIZE - 1; | ||
650 | tty->echo_cnt = nr; | ||
651 | if (num_processed > 0) | ||
652 | tty->echo_overrun = 0; | ||
653 | } | ||
654 | |||
655 | mutex_unlock(&tty->echo_lock); | ||
656 | mutex_unlock(&tty->output_lock); | ||
657 | |||
658 | if (tty->ops->flush_chars) | ||
659 | tty->ops->flush_chars(tty); | ||
660 | } | ||
417 | 661 | ||
418 | /** | 662 | /** |
419 | * echo_char - echo characters | 663 | * add_echo_byte - add a byte to the echo buffer |
664 | * @c: unicode byte to echo | ||
665 | * @tty: terminal device | ||
666 | * | ||
667 | * Add a character or operation byte to the echo buffer. | ||
668 | * | ||
669 | * Should be called under the echo lock to protect the echo buffer. | ||
670 | */ | ||
671 | |||
672 | static void add_echo_byte(unsigned char c, struct tty_struct *tty) | ||
673 | { | ||
674 | int new_byte_pos; | ||
675 | |||
676 | if (tty->echo_cnt == N_TTY_BUF_SIZE) { | ||
677 | /* Circular buffer is already at capacity */ | ||
678 | new_byte_pos = tty->echo_pos; | ||
679 | |||
680 | /* | ||
681 | * Since the buffer start position needs to be advanced, | ||
682 | * be sure to step by a whole operation byte group. | ||
683 | */ | ||
684 | if (tty->echo_buf[tty->echo_pos] == ECHO_OP_START) { | ||
685 | if (tty->echo_buf[(tty->echo_pos + 1) & | ||
686 | (N_TTY_BUF_SIZE - 1)] == | ||
687 | ECHO_OP_ERASE_TAB) { | ||
688 | tty->echo_pos += 3; | ||
689 | tty->echo_cnt -= 2; | ||
690 | } else { | ||
691 | tty->echo_pos += 2; | ||
692 | tty->echo_cnt -= 1; | ||
693 | } | ||
694 | } else { | ||
695 | tty->echo_pos++; | ||
696 | } | ||
697 | tty->echo_pos &= N_TTY_BUF_SIZE - 1; | ||
698 | |||
699 | tty->echo_overrun = 1; | ||
700 | } else { | ||
701 | new_byte_pos = tty->echo_pos + tty->echo_cnt; | ||
702 | new_byte_pos &= N_TTY_BUF_SIZE - 1; | ||
703 | tty->echo_cnt++; | ||
704 | } | ||
705 | |||
706 | tty->echo_buf[new_byte_pos] = c; | ||
707 | } | ||
708 | |||
709 | /** | ||
710 | * echo_move_back_col - add operation to move back a column | ||
711 | * @tty: terminal device | ||
712 | * | ||
713 | * Add an operation to the echo buffer to move back one column. | ||
714 | * | ||
715 | * Locking: echo_lock to protect the echo buffer | ||
716 | */ | ||
717 | |||
718 | static void echo_move_back_col(struct tty_struct *tty) | ||
719 | { | ||
720 | mutex_lock(&tty->echo_lock); | ||
721 | |||
722 | add_echo_byte(ECHO_OP_START, tty); | ||
723 | add_echo_byte(ECHO_OP_MOVE_BACK_COL, tty); | ||
724 | |||
725 | mutex_unlock(&tty->echo_lock); | ||
726 | } | ||
727 | |||
728 | /** | ||
729 | * echo_set_canon_col - add operation to set the canon column | ||
730 | * @tty: terminal device | ||
731 | * | ||
732 | * Add an operation to the echo buffer to set the canon column | ||
733 | * to the current column. | ||
734 | * | ||
735 | * Locking: echo_lock to protect the echo buffer | ||
736 | */ | ||
737 | |||
738 | static void echo_set_canon_col(struct tty_struct *tty) | ||
739 | { | ||
740 | mutex_lock(&tty->echo_lock); | ||
741 | |||
742 | add_echo_byte(ECHO_OP_START, tty); | ||
743 | add_echo_byte(ECHO_OP_SET_CANON_COL, tty); | ||
744 | |||
745 | mutex_unlock(&tty->echo_lock); | ||
746 | } | ||
747 | |||
748 | /** | ||
749 | * echo_erase_tab - add operation to erase a tab | ||
750 | * @num_chars: number of character columns already used | ||
751 | * @after_tab: true if num_chars starts after a previous tab | ||
752 | * @tty: terminal device | ||
753 | * | ||
754 | * Add an operation to the echo buffer to erase a tab. | ||
755 | * | ||
756 | * Called by the eraser function, which knows how many character | ||
757 | * columns have been used since either a previous tab or the start | ||
758 | * of input. This information will be used later, along with | ||
759 | * canon column (if applicable), to go back the correct number | ||
760 | * of columns. | ||
761 | * | ||
762 | * Locking: echo_lock to protect the echo buffer | ||
763 | */ | ||
764 | |||
765 | static void echo_erase_tab(unsigned int num_chars, int after_tab, | ||
766 | struct tty_struct *tty) | ||
767 | { | ||
768 | mutex_lock(&tty->echo_lock); | ||
769 | |||
770 | add_echo_byte(ECHO_OP_START, tty); | ||
771 | add_echo_byte(ECHO_OP_ERASE_TAB, tty); | ||
772 | |||
773 | /* We only need to know this modulo 8 (tab spacing) */ | ||
774 | num_chars &= 7; | ||
775 | |||
776 | /* Set the high bit as a flag if num_chars is after a previous tab */ | ||
777 | if (after_tab) | ||
778 | num_chars |= 0x80; | ||
779 | |||
780 | add_echo_byte(num_chars, tty); | ||
781 | |||
782 | mutex_unlock(&tty->echo_lock); | ||
783 | } | ||
784 | |||
785 | /** | ||
786 | * echo_char_raw - echo a character raw | ||
420 | * @c: unicode byte to echo | 787 | * @c: unicode byte to echo |
421 | * @tty: terminal device | 788 | * @tty: terminal device |
422 | * | 789 | * |
423 | * Echo user input back onto the screen. This must be called only when | 790 | * Echo user input back onto the screen. This must be called only when |
424 | * L_ECHO(tty) is true. Called from the driver receive_buf path. | 791 | * L_ECHO(tty) is true. Called from the driver receive_buf path. |
425 | * | 792 | * |
426 | * Relies on BKL for tty column locking | 793 | * This variant does not treat control characters specially. |
794 | * | ||
795 | * Locking: echo_lock to protect the echo buffer | ||
796 | */ | ||
797 | |||
798 | static void echo_char_raw(unsigned char c, struct tty_struct *tty) | ||
799 | { | ||
800 | mutex_lock(&tty->echo_lock); | ||
801 | |||
802 | if (c == ECHO_OP_START) { | ||
803 | add_echo_byte(ECHO_OP_START, tty); | ||
804 | add_echo_byte(ECHO_OP_START, tty); | ||
805 | } else { | ||
806 | add_echo_byte(c, tty); | ||
807 | } | ||
808 | |||
809 | mutex_unlock(&tty->echo_lock); | ||
810 | } | ||
811 | |||
812 | /** | ||
813 | * echo_char - echo a character | ||
814 | * @c: unicode byte to echo | ||
815 | * @tty: terminal device | ||
816 | * | ||
817 | * Echo user input back onto the screen. This must be called only when | ||
818 | * L_ECHO(tty) is true. Called from the driver receive_buf path. | ||
819 | * | ||
820 | * This variant tags control characters to be possibly echoed as | ||
821 | * as "^X" (where X is the letter representing the control char). | ||
822 | * | ||
823 | * Locking: echo_lock to protect the echo buffer | ||
427 | */ | 824 | */ |
428 | 825 | ||
429 | static void echo_char(unsigned char c, struct tty_struct *tty) | 826 | static void echo_char(unsigned char c, struct tty_struct *tty) |
430 | { | 827 | { |
431 | if (L_ECHOCTL(tty) && iscntrl(c) && c != '\t') { | 828 | mutex_lock(&tty->echo_lock); |
432 | tty_put_char(tty, '^'); | 829 | |
433 | tty_put_char(tty, c ^ 0100); | 830 | if (c == ECHO_OP_START) { |
434 | tty->column += 2; | 831 | add_echo_byte(ECHO_OP_START, tty); |
435 | } else | 832 | add_echo_byte(ECHO_OP_START, tty); |
436 | opost(c, tty); | 833 | } else { |
834 | if (iscntrl(c) && c != '\t') | ||
835 | add_echo_byte(ECHO_OP_START, tty); | ||
836 | add_echo_byte(c, tty); | ||
837 | } | ||
838 | |||
839 | mutex_unlock(&tty->echo_lock); | ||
437 | } | 840 | } |
438 | 841 | ||
439 | /** | 842 | /** |
440 | * finsh_erasing - complete erase | 843 | * finish_erasing - complete erase |
441 | * @tty: tty doing the erase | 844 | * @tty: tty doing the erase |
442 | * | ||
443 | * Relies on BKL for tty column locking | ||
444 | */ | 845 | */ |
846 | |||
445 | static inline void finish_erasing(struct tty_struct *tty) | 847 | static inline void finish_erasing(struct tty_struct *tty) |
446 | { | 848 | { |
447 | if (tty->erasing) { | 849 | if (tty->erasing) { |
448 | tty_put_char(tty, '/'); | 850 | echo_char_raw('/', tty); |
449 | tty->column++; | ||
450 | tty->erasing = 0; | 851 | tty->erasing = 0; |
451 | } | 852 | } |
452 | } | 853 | } |
@@ -460,7 +861,7 @@ static inline void finish_erasing(struct tty_struct *tty) | |||
460 | * present in the stream from the driver layer. Handles the complexities | 861 | * present in the stream from the driver layer. Handles the complexities |
461 | * of UTF-8 multibyte symbols. | 862 | * of UTF-8 multibyte symbols. |
462 | * | 863 | * |
463 | * Locking: read_lock for tty buffers, BKL for column/erasing state | 864 | * Locking: read_lock for tty buffers |
464 | */ | 865 | */ |
465 | 866 | ||
466 | static void eraser(unsigned char c, struct tty_struct *tty) | 867 | static void eraser(unsigned char c, struct tty_struct *tty) |
@@ -471,7 +872,7 @@ static void eraser(unsigned char c, struct tty_struct *tty) | |||
471 | 872 | ||
472 | /* FIXME: locking needed ? */ | 873 | /* FIXME: locking needed ? */ |
473 | if (tty->read_head == tty->canon_head) { | 874 | if (tty->read_head == tty->canon_head) { |
474 | /* opost('\a', tty); */ /* what do you think? */ | 875 | /* process_output('\a', tty); */ /* what do you think? */ |
475 | return; | 876 | return; |
476 | } | 877 | } |
477 | if (c == ERASE_CHAR(tty)) | 878 | if (c == ERASE_CHAR(tty)) |
@@ -497,7 +898,7 @@ static void eraser(unsigned char c, struct tty_struct *tty) | |||
497 | echo_char(KILL_CHAR(tty), tty); | 898 | echo_char(KILL_CHAR(tty), tty); |
498 | /* Add a newline if ECHOK is on and ECHOKE is off. */ | 899 | /* Add a newline if ECHOK is on and ECHOKE is off. */ |
499 | if (L_ECHOK(tty)) | 900 | if (L_ECHOK(tty)) |
500 | opost('\n', tty); | 901 | echo_char_raw('\n', tty); |
501 | return; | 902 | return; |
502 | } | 903 | } |
503 | kill_type = KILL; | 904 | kill_type = KILL; |
@@ -533,67 +934,61 @@ static void eraser(unsigned char c, struct tty_struct *tty) | |||
533 | if (L_ECHO(tty)) { | 934 | if (L_ECHO(tty)) { |
534 | if (L_ECHOPRT(tty)) { | 935 | if (L_ECHOPRT(tty)) { |
535 | if (!tty->erasing) { | 936 | if (!tty->erasing) { |
536 | tty_put_char(tty, '\\'); | 937 | echo_char_raw('\\', tty); |
537 | tty->column++; | ||
538 | tty->erasing = 1; | 938 | tty->erasing = 1; |
539 | } | 939 | } |
540 | /* if cnt > 1, output a multi-byte character */ | 940 | /* if cnt > 1, output a multi-byte character */ |
541 | echo_char(c, tty); | 941 | echo_char(c, tty); |
542 | while (--cnt > 0) { | 942 | while (--cnt > 0) { |
543 | head = (head+1) & (N_TTY_BUF_SIZE-1); | 943 | head = (head+1) & (N_TTY_BUF_SIZE-1); |
544 | tty_put_char(tty, tty->read_buf[head]); | 944 | echo_char_raw(tty->read_buf[head], tty); |
945 | echo_move_back_col(tty); | ||
545 | } | 946 | } |
546 | } else if (kill_type == ERASE && !L_ECHOE(tty)) { | 947 | } else if (kill_type == ERASE && !L_ECHOE(tty)) { |
547 | echo_char(ERASE_CHAR(tty), tty); | 948 | echo_char(ERASE_CHAR(tty), tty); |
548 | } else if (c == '\t') { | 949 | } else if (c == '\t') { |
549 | unsigned int col = tty->canon_column; | 950 | unsigned int num_chars = 0; |
550 | unsigned long tail = tty->canon_head; | 951 | int after_tab = 0; |
551 | 952 | unsigned long tail = tty->read_head; | |
552 | /* Find the column of the last char. */ | 953 | |
553 | while (tail != tty->read_head) { | 954 | /* |
955 | * Count the columns used for characters | ||
956 | * since the start of input or after a | ||
957 | * previous tab. | ||
958 | * This info is used to go back the correct | ||
959 | * number of columns. | ||
960 | */ | ||
961 | while (tail != tty->canon_head) { | ||
962 | tail = (tail-1) & (N_TTY_BUF_SIZE-1); | ||
554 | c = tty->read_buf[tail]; | 963 | c = tty->read_buf[tail]; |
555 | if (c == '\t') | 964 | if (c == '\t') { |
556 | col = (col | 7) + 1; | 965 | after_tab = 1; |
557 | else if (iscntrl(c)) { | 966 | break; |
967 | } else if (iscntrl(c)) { | ||
558 | if (L_ECHOCTL(tty)) | 968 | if (L_ECHOCTL(tty)) |
559 | col += 2; | 969 | num_chars += 2; |
560 | } else if (!is_continuation(c, tty)) | 970 | } else if (!is_continuation(c, tty)) { |
561 | col++; | 971 | num_chars++; |
562 | tail = (tail+1) & (N_TTY_BUF_SIZE-1); | 972 | } |
563 | } | ||
564 | |||
565 | /* should never happen */ | ||
566 | if (tty->column > 0x80000000) | ||
567 | tty->column = 0; | ||
568 | |||
569 | /* Now backup to that column. */ | ||
570 | while (tty->column > col) { | ||
571 | /* Can't use opost here. */ | ||
572 | tty_put_char(tty, '\b'); | ||
573 | if (tty->column > 0) | ||
574 | tty->column--; | ||
575 | } | 973 | } |
974 | echo_erase_tab(num_chars, after_tab, tty); | ||
576 | } else { | 975 | } else { |
577 | if (iscntrl(c) && L_ECHOCTL(tty)) { | 976 | if (iscntrl(c) && L_ECHOCTL(tty)) { |
578 | tty_put_char(tty, '\b'); | 977 | echo_char_raw('\b', tty); |
579 | tty_put_char(tty, ' '); | 978 | echo_char_raw(' ', tty); |
580 | tty_put_char(tty, '\b'); | 979 | echo_char_raw('\b', tty); |
581 | if (tty->column > 0) | ||
582 | tty->column--; | ||
583 | } | 980 | } |
584 | if (!iscntrl(c) || L_ECHOCTL(tty)) { | 981 | if (!iscntrl(c) || L_ECHOCTL(tty)) { |
585 | tty_put_char(tty, '\b'); | 982 | echo_char_raw('\b', tty); |
586 | tty_put_char(tty, ' '); | 983 | echo_char_raw(' ', tty); |
587 | tty_put_char(tty, '\b'); | 984 | echo_char_raw('\b', tty); |
588 | if (tty->column > 0) | ||
589 | tty->column--; | ||
590 | } | 985 | } |
591 | } | 986 | } |
592 | } | 987 | } |
593 | if (kill_type == ERASE) | 988 | if (kill_type == ERASE) |
594 | break; | 989 | break; |
595 | } | 990 | } |
596 | if (tty->read_head == tty->canon_head) | 991 | if (tty->read_head == tty->canon_head && L_ECHO(tty)) |
597 | finish_erasing(tty); | 992 | finish_erasing(tty); |
598 | } | 993 | } |
599 | 994 | ||
@@ -712,6 +1107,7 @@ static inline void n_tty_receive_parity_error(struct tty_struct *tty, | |||
712 | static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) | 1107 | static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) |
713 | { | 1108 | { |
714 | unsigned long flags; | 1109 | unsigned long flags; |
1110 | int parmrk; | ||
715 | 1111 | ||
716 | if (tty->raw) { | 1112 | if (tty->raw) { |
717 | put_tty_queue(c, tty); | 1113 | put_tty_queue(c, tty); |
@@ -721,18 +1117,21 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) | |||
721 | if (I_ISTRIP(tty)) | 1117 | if (I_ISTRIP(tty)) |
722 | c &= 0x7f; | 1118 | c &= 0x7f; |
723 | if (I_IUCLC(tty) && L_IEXTEN(tty)) | 1119 | if (I_IUCLC(tty) && L_IEXTEN(tty)) |
724 | c=tolower(c); | 1120 | c = tolower(c); |
725 | 1121 | ||
726 | if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && | 1122 | if (tty->stopped && !tty->flow_stopped && I_IXON(tty) && |
727 | ((I_IXANY(tty) && c != START_CHAR(tty) && c != STOP_CHAR(tty)) || | 1123 | I_IXANY(tty) && c != START_CHAR(tty) && c != STOP_CHAR(tty) && |
728 | c == INTR_CHAR(tty) || c == QUIT_CHAR(tty) || c == SUSP_CHAR(tty))) | 1124 | c != INTR_CHAR(tty) && c != QUIT_CHAR(tty) && c != SUSP_CHAR(tty)) { |
729 | start_tty(tty); | 1125 | start_tty(tty); |
1126 | process_echoes(tty); | ||
1127 | } | ||
730 | 1128 | ||
731 | if (tty->closing) { | 1129 | if (tty->closing) { |
732 | if (I_IXON(tty)) { | 1130 | if (I_IXON(tty)) { |
733 | if (c == START_CHAR(tty)) | 1131 | if (c == START_CHAR(tty)) { |
734 | start_tty(tty); | 1132 | start_tty(tty); |
735 | else if (c == STOP_CHAR(tty)) | 1133 | process_echoes(tty); |
1134 | } else if (c == STOP_CHAR(tty)) | ||
736 | stop_tty(tty); | 1135 | stop_tty(tty); |
737 | } | 1136 | } |
738 | return; | 1137 | return; |
@@ -745,19 +1144,23 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) | |||
745 | * up. | 1144 | * up. |
746 | */ | 1145 | */ |
747 | if (!test_bit(c, tty->process_char_map) || tty->lnext) { | 1146 | if (!test_bit(c, tty->process_char_map) || tty->lnext) { |
748 | finish_erasing(tty); | ||
749 | tty->lnext = 0; | 1147 | tty->lnext = 0; |
1148 | parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0; | ||
1149 | if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) { | ||
1150 | /* beep if no space */ | ||
1151 | if (L_ECHO(tty)) | ||
1152 | process_output('\a', tty); | ||
1153 | return; | ||
1154 | } | ||
750 | if (L_ECHO(tty)) { | 1155 | if (L_ECHO(tty)) { |
751 | if (tty->read_cnt >= N_TTY_BUF_SIZE-1) { | 1156 | finish_erasing(tty); |
752 | tty_put_char(tty, '\a'); /* beep if no space */ | ||
753 | return; | ||
754 | } | ||
755 | /* Record the column of first canon char. */ | 1157 | /* Record the column of first canon char. */ |
756 | if (tty->canon_head == tty->read_head) | 1158 | if (tty->canon_head == tty->read_head) |
757 | tty->canon_column = tty->column; | 1159 | echo_set_canon_col(tty); |
758 | echo_char(c, tty); | 1160 | echo_char(c, tty); |
1161 | process_echoes(tty); | ||
759 | } | 1162 | } |
760 | if (I_PARMRK(tty) && c == (unsigned char) '\377') | 1163 | if (parmrk) |
761 | put_tty_queue(c, tty); | 1164 | put_tty_queue(c, tty); |
762 | put_tty_queue(c, tty); | 1165 | put_tty_queue(c, tty); |
763 | return; | 1166 | return; |
@@ -766,6 +1169,7 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) | |||
766 | if (I_IXON(tty)) { | 1169 | if (I_IXON(tty)) { |
767 | if (c == START_CHAR(tty)) { | 1170 | if (c == START_CHAR(tty)) { |
768 | start_tty(tty); | 1171 | start_tty(tty); |
1172 | process_echoes(tty); | ||
769 | return; | 1173 | return; |
770 | } | 1174 | } |
771 | if (c == STOP_CHAR(tty)) { | 1175 | if (c == STOP_CHAR(tty)) { |
@@ -786,7 +1190,6 @@ static inline void n_tty_receive_char(struct tty_struct *tty, unsigned char c) | |||
786 | if (c == SUSP_CHAR(tty)) { | 1190 | if (c == SUSP_CHAR(tty)) { |
787 | send_signal: | 1191 | send_signal: |
788 | /* | 1192 | /* |
789 | * Echo character, and then send the signal. | ||
790 | * Note that we do not use isig() here because we want | 1193 | * Note that we do not use isig() here because we want |
791 | * the order to be: | 1194 | * the order to be: |
792 | * 1) flush, 2) echo, 3) signal | 1195 | * 1) flush, 2) echo, 3) signal |
@@ -795,8 +1198,12 @@ send_signal: | |||
795 | n_tty_flush_buffer(tty); | 1198 | n_tty_flush_buffer(tty); |
796 | tty_driver_flush_buffer(tty); | 1199 | tty_driver_flush_buffer(tty); |
797 | } | 1200 | } |
798 | if (L_ECHO(tty)) | 1201 | if (I_IXON(tty)) |
1202 | start_tty(tty); | ||
1203 | if (L_ECHO(tty)) { | ||
799 | echo_char(c, tty); | 1204 | echo_char(c, tty); |
1205 | process_echoes(tty); | ||
1206 | } | ||
800 | if (tty->pgrp) | 1207 | if (tty->pgrp) |
801 | kill_pgrp(tty->pgrp, signal, 1); | 1208 | kill_pgrp(tty->pgrp, signal, 1); |
802 | return; | 1209 | return; |
@@ -815,6 +1222,7 @@ send_signal: | |||
815 | if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || | 1222 | if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || |
816 | (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { | 1223 | (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { |
817 | eraser(c, tty); | 1224 | eraser(c, tty); |
1225 | process_echoes(tty); | ||
818 | return; | 1226 | return; |
819 | } | 1227 | } |
820 | if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) { | 1228 | if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) { |
@@ -822,8 +1230,9 @@ send_signal: | |||
822 | if (L_ECHO(tty)) { | 1230 | if (L_ECHO(tty)) { |
823 | finish_erasing(tty); | 1231 | finish_erasing(tty); |
824 | if (L_ECHOCTL(tty)) { | 1232 | if (L_ECHOCTL(tty)) { |
825 | tty_put_char(tty, '^'); | 1233 | echo_char_raw('^', tty); |
826 | tty_put_char(tty, '\b'); | 1234 | echo_char_raw('\b', tty); |
1235 | process_echoes(tty); | ||
827 | } | 1236 | } |
828 | } | 1237 | } |
829 | return; | 1238 | return; |
@@ -834,22 +1243,29 @@ send_signal: | |||
834 | 1243 | ||
835 | finish_erasing(tty); | 1244 | finish_erasing(tty); |
836 | echo_char(c, tty); | 1245 | echo_char(c, tty); |
837 | opost('\n', tty); | 1246 | echo_char_raw('\n', tty); |
838 | while (tail != tty->read_head) { | 1247 | while (tail != tty->read_head) { |
839 | echo_char(tty->read_buf[tail], tty); | 1248 | echo_char(tty->read_buf[tail], tty); |
840 | tail = (tail+1) & (N_TTY_BUF_SIZE-1); | 1249 | tail = (tail+1) & (N_TTY_BUF_SIZE-1); |
841 | } | 1250 | } |
1251 | process_echoes(tty); | ||
842 | return; | 1252 | return; |
843 | } | 1253 | } |
844 | if (c == '\n') { | 1254 | if (c == '\n') { |
1255 | if (tty->read_cnt >= N_TTY_BUF_SIZE) { | ||
1256 | if (L_ECHO(tty)) | ||
1257 | process_output('\a', tty); | ||
1258 | return; | ||
1259 | } | ||
845 | if (L_ECHO(tty) || L_ECHONL(tty)) { | 1260 | if (L_ECHO(tty) || L_ECHONL(tty)) { |
846 | if (tty->read_cnt >= N_TTY_BUF_SIZE-1) | 1261 | echo_char_raw('\n', tty); |
847 | tty_put_char(tty, '\a'); | 1262 | process_echoes(tty); |
848 | opost('\n', tty); | ||
849 | } | 1263 | } |
850 | goto handle_newline; | 1264 | goto handle_newline; |
851 | } | 1265 | } |
852 | if (c == EOF_CHAR(tty)) { | 1266 | if (c == EOF_CHAR(tty)) { |
1267 | if (tty->read_cnt >= N_TTY_BUF_SIZE) | ||
1268 | return; | ||
853 | if (tty->canon_head != tty->read_head) | 1269 | if (tty->canon_head != tty->read_head) |
854 | set_bit(TTY_PUSH, &tty->flags); | 1270 | set_bit(TTY_PUSH, &tty->flags); |
855 | c = __DISABLED_CHAR; | 1271 | c = __DISABLED_CHAR; |
@@ -857,22 +1273,28 @@ send_signal: | |||
857 | } | 1273 | } |
858 | if ((c == EOL_CHAR(tty)) || | 1274 | if ((c == EOL_CHAR(tty)) || |
859 | (c == EOL2_CHAR(tty) && L_IEXTEN(tty))) { | 1275 | (c == EOL2_CHAR(tty) && L_IEXTEN(tty))) { |
1276 | parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) | ||
1277 | ? 1 : 0; | ||
1278 | if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk)) { | ||
1279 | if (L_ECHO(tty)) | ||
1280 | process_output('\a', tty); | ||
1281 | return; | ||
1282 | } | ||
860 | /* | 1283 | /* |
861 | * XXX are EOL_CHAR and EOL2_CHAR echoed?!? | 1284 | * XXX are EOL_CHAR and EOL2_CHAR echoed?!? |
862 | */ | 1285 | */ |
863 | if (L_ECHO(tty)) { | 1286 | if (L_ECHO(tty)) { |
864 | if (tty->read_cnt >= N_TTY_BUF_SIZE-1) | ||
865 | tty_put_char(tty, '\a'); | ||
866 | /* Record the column of first canon char. */ | 1287 | /* Record the column of first canon char. */ |
867 | if (tty->canon_head == tty->read_head) | 1288 | if (tty->canon_head == tty->read_head) |
868 | tty->canon_column = tty->column; | 1289 | echo_set_canon_col(tty); |
869 | echo_char(c, tty); | 1290 | echo_char(c, tty); |
1291 | process_echoes(tty); | ||
870 | } | 1292 | } |
871 | /* | 1293 | /* |
872 | * XXX does PARMRK doubling happen for | 1294 | * XXX does PARMRK doubling happen for |
873 | * EOL_CHAR and EOL2_CHAR? | 1295 | * EOL_CHAR and EOL2_CHAR? |
874 | */ | 1296 | */ |
875 | if (I_PARMRK(tty) && c == (unsigned char) '\377') | 1297 | if (parmrk) |
876 | put_tty_queue(c, tty); | 1298 | put_tty_queue(c, tty); |
877 | 1299 | ||
878 | handle_newline: | 1300 | handle_newline: |
@@ -889,23 +1311,27 @@ handle_newline: | |||
889 | } | 1311 | } |
890 | } | 1312 | } |
891 | 1313 | ||
892 | finish_erasing(tty); | 1314 | parmrk = (c == (unsigned char) '\377' && I_PARMRK(tty)) ? 1 : 0; |
1315 | if (tty->read_cnt >= (N_TTY_BUF_SIZE - parmrk - 1)) { | ||
1316 | /* beep if no space */ | ||
1317 | if (L_ECHO(tty)) | ||
1318 | process_output('\a', tty); | ||
1319 | return; | ||
1320 | } | ||
893 | if (L_ECHO(tty)) { | 1321 | if (L_ECHO(tty)) { |
894 | if (tty->read_cnt >= N_TTY_BUF_SIZE-1) { | 1322 | finish_erasing(tty); |
895 | tty_put_char(tty, '\a'); /* beep if no space */ | ||
896 | return; | ||
897 | } | ||
898 | if (c == '\n') | 1323 | if (c == '\n') |
899 | opost('\n', tty); | 1324 | echo_char_raw('\n', tty); |
900 | else { | 1325 | else { |
901 | /* Record the column of first canon char. */ | 1326 | /* Record the column of first canon char. */ |
902 | if (tty->canon_head == tty->read_head) | 1327 | if (tty->canon_head == tty->read_head) |
903 | tty->canon_column = tty->column; | 1328 | echo_set_canon_col(tty); |
904 | echo_char(c, tty); | 1329 | echo_char(c, tty); |
905 | } | 1330 | } |
1331 | process_echoes(tty); | ||
906 | } | 1332 | } |
907 | 1333 | ||
908 | if (I_PARMRK(tty) && c == (unsigned char) '\377') | 1334 | if (parmrk) |
909 | put_tty_queue(c, tty); | 1335 | put_tty_queue(c, tty); |
910 | 1336 | ||
911 | put_tty_queue(c, tty); | 1337 | put_tty_queue(c, tty); |
@@ -923,10 +1349,11 @@ handle_newline: | |||
923 | 1349 | ||
924 | static void n_tty_write_wakeup(struct tty_struct *tty) | 1350 | static void n_tty_write_wakeup(struct tty_struct *tty) |
925 | { | 1351 | { |
926 | if (tty->fasync) { | 1352 | /* Write out any echoed characters that are still pending */ |
927 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); | 1353 | process_echoes(tty); |
1354 | |||
1355 | if (tty->fasync && test_and_clear_bit(TTY_DO_WRITE_WAKEUP, &tty->flags)) | ||
928 | kill_fasync(&tty->fasync, SIGIO, POLL_OUT); | 1356 | kill_fasync(&tty->fasync, SIGIO, POLL_OUT); |
929 | } | ||
930 | } | 1357 | } |
931 | 1358 | ||
932 | /** | 1359 | /** |
@@ -1134,6 +1561,10 @@ static void n_tty_close(struct tty_struct *tty) | |||
1134 | free_buf(tty->read_buf); | 1561 | free_buf(tty->read_buf); |
1135 | tty->read_buf = NULL; | 1562 | tty->read_buf = NULL; |
1136 | } | 1563 | } |
1564 | if (tty->echo_buf) { | ||
1565 | free_buf(tty->echo_buf); | ||
1566 | tty->echo_buf = NULL; | ||
1567 | } | ||
1137 | } | 1568 | } |
1138 | 1569 | ||
1139 | /** | 1570 | /** |
@@ -1151,13 +1582,19 @@ static int n_tty_open(struct tty_struct *tty) | |||
1151 | if (!tty) | 1582 | if (!tty) |
1152 | return -EINVAL; | 1583 | return -EINVAL; |
1153 | 1584 | ||
1154 | /* This one is ugly. Currently a malloc failure here can panic */ | 1585 | /* These are ugly. Currently a malloc failure here can panic */ |
1155 | if (!tty->read_buf) { | 1586 | if (!tty->read_buf) { |
1156 | tty->read_buf = alloc_buf(); | 1587 | tty->read_buf = alloc_buf(); |
1157 | if (!tty->read_buf) | 1588 | if (!tty->read_buf) |
1158 | return -ENOMEM; | 1589 | return -ENOMEM; |
1159 | } | 1590 | } |
1591 | if (!tty->echo_buf) { | ||
1592 | tty->echo_buf = alloc_buf(); | ||
1593 | if (!tty->echo_buf) | ||
1594 | return -ENOMEM; | ||
1595 | } | ||
1160 | memset(tty->read_buf, 0, N_TTY_BUF_SIZE); | 1596 | memset(tty->read_buf, 0, N_TTY_BUF_SIZE); |
1597 | memset(tty->echo_buf, 0, N_TTY_BUF_SIZE); | ||
1161 | reset_buffer_flags(tty); | 1598 | reset_buffer_flags(tty); |
1162 | tty->column = 0; | 1599 | tty->column = 0; |
1163 | n_tty_set_termios(tty, NULL); | 1600 | n_tty_set_termios(tty, NULL); |
@@ -1487,16 +1924,23 @@ do_it_again: | |||
1487 | * @buf: userspace buffer pointer | 1924 | * @buf: userspace buffer pointer |
1488 | * @nr: size of I/O | 1925 | * @nr: size of I/O |
1489 | * | 1926 | * |
1490 | * Write function of the terminal device. This is serialized with | 1927 | * Write function of the terminal device. This is serialized with |
1491 | * respect to other write callers but not to termios changes, reads | 1928 | * respect to other write callers but not to termios changes, reads |
1492 | * and other such events. We must be careful with N_TTY as the receive | 1929 | * and other such events. Since the receive code will echo characters, |
1493 | * code will echo characters, thus calling driver write methods. | 1930 | * thus calling driver write methods, the output_lock is used in |
1931 | * the output processing functions called here as well as in the | ||
1932 | * echo processing function to protect the column state and space | ||
1933 | * left in the buffer. | ||
1494 | * | 1934 | * |
1495 | * This code must be sure never to sleep through a hangup. | 1935 | * This code must be sure never to sleep through a hangup. |
1936 | * | ||
1937 | * Locking: output_lock to protect column state and space left | ||
1938 | * (note that the process_output*() functions take this | ||
1939 | * lock themselves) | ||
1496 | */ | 1940 | */ |
1497 | 1941 | ||
1498 | static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, | 1942 | static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, |
1499 | const unsigned char *buf, size_t nr) | 1943 | const unsigned char *buf, size_t nr) |
1500 | { | 1944 | { |
1501 | const unsigned char *b = buf; | 1945 | const unsigned char *b = buf; |
1502 | DECLARE_WAITQUEUE(wait, current); | 1946 | DECLARE_WAITQUEUE(wait, current); |
@@ -1510,6 +1954,9 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, | |||
1510 | return retval; | 1954 | return retval; |
1511 | } | 1955 | } |
1512 | 1956 | ||
1957 | /* Write out any echoed characters that are still pending */ | ||
1958 | process_echoes(tty); | ||
1959 | |||
1513 | add_wait_queue(&tty->write_wait, &wait); | 1960 | add_wait_queue(&tty->write_wait, &wait); |
1514 | while (1) { | 1961 | while (1) { |
1515 | set_current_state(TASK_INTERRUPTIBLE); | 1962 | set_current_state(TASK_INTERRUPTIBLE); |
@@ -1523,7 +1970,7 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, | |||
1523 | } | 1970 | } |
1524 | if (O_OPOST(tty) && !(test_bit(TTY_HW_COOK_OUT, &tty->flags))) { | 1971 | if (O_OPOST(tty) && !(test_bit(TTY_HW_COOK_OUT, &tty->flags))) { |
1525 | while (nr > 0) { | 1972 | while (nr > 0) { |
1526 | ssize_t num = opost_block(tty, b, nr); | 1973 | ssize_t num = process_output_block(tty, b, nr); |
1527 | if (num < 0) { | 1974 | if (num < 0) { |
1528 | if (num == -EAGAIN) | 1975 | if (num == -EAGAIN) |
1529 | break; | 1976 | break; |
@@ -1535,7 +1982,7 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, | |||
1535 | if (nr == 0) | 1982 | if (nr == 0) |
1536 | break; | 1983 | break; |
1537 | c = *b; | 1984 | c = *b; |
1538 | if (opost(c, tty) < 0) | 1985 | if (process_output(c, tty) < 0) |
1539 | break; | 1986 | break; |
1540 | b++; nr--; | 1987 | b++; nr--; |
1541 | } | 1988 | } |
@@ -1565,6 +2012,8 @@ static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, | |||
1565 | break_out: | 2012 | break_out: |
1566 | __set_current_state(TASK_RUNNING); | 2013 | __set_current_state(TASK_RUNNING); |
1567 | remove_wait_queue(&tty->write_wait, &wait); | 2014 | remove_wait_queue(&tty->write_wait, &wait); |
2015 | if (b - buf != nr && tty->fasync) | ||
2016 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); | ||
1568 | return (b - buf) ? b - buf : retval; | 2017 | return (b - buf) ? b - buf : retval; |
1569 | } | 2018 | } |
1570 | 2019 | ||
@@ -1663,4 +2112,3 @@ struct tty_ldisc_ops tty_ldisc_N_TTY = { | |||
1663 | .receive_buf = n_tty_receive_buf, | 2112 | .receive_buf = n_tty_receive_buf, |
1664 | .write_wakeup = n_tty_write_wakeup | 2113 | .write_wakeup = n_tty_write_wakeup |
1665 | }; | 2114 | }; |
1666 | |||
diff --git a/drivers/char/nozomi.c b/drivers/char/nozomi.c index 9a34a1935283..d6102b644b55 100644 --- a/drivers/char/nozomi.c +++ b/drivers/char/nozomi.c | |||
@@ -353,6 +353,7 @@ struct ctrl_ul { | |||
353 | 353 | ||
354 | /* This holds all information that is needed regarding a port */ | 354 | /* This holds all information that is needed regarding a port */ |
355 | struct port { | 355 | struct port { |
356 | struct tty_port port; | ||
356 | u8 update_flow_control; | 357 | u8 update_flow_control; |
357 | struct ctrl_ul ctrl_ul; | 358 | struct ctrl_ul ctrl_ul; |
358 | struct ctrl_dl ctrl_dl; | 359 | struct ctrl_dl ctrl_dl; |
@@ -365,8 +366,6 @@ struct port { | |||
365 | u8 toggle_ul; | 366 | u8 toggle_ul; |
366 | u16 token_dl; | 367 | u16 token_dl; |
367 | 368 | ||
368 | struct tty_struct *tty; | ||
369 | int tty_open_count; | ||
370 | /* mutex to ensure one access patch to this port */ | 369 | /* mutex to ensure one access patch to this port */ |
371 | struct mutex tty_sem; | 370 | struct mutex tty_sem; |
372 | wait_queue_head_t tty_wait; | 371 | wait_queue_head_t tty_wait; |
@@ -788,14 +787,14 @@ static void disable_transmit_dl(enum port_type port, struct nozomi *dc) | |||
788 | * Return 1 - send buffer to card and ack. | 787 | * Return 1 - send buffer to card and ack. |
789 | * Return 0 - don't ack, don't send buffer to card. | 788 | * Return 0 - don't ack, don't send buffer to card. |
790 | */ | 789 | */ |
791 | static int send_data(enum port_type index, const struct nozomi *dc) | 790 | static int send_data(enum port_type index, struct nozomi *dc) |
792 | { | 791 | { |
793 | u32 size = 0; | 792 | u32 size = 0; |
794 | const struct port *port = &dc->port[index]; | 793 | struct port *port = &dc->port[index]; |
795 | const u8 toggle = port->toggle_ul; | 794 | const u8 toggle = port->toggle_ul; |
796 | void __iomem *addr = port->ul_addr[toggle]; | 795 | void __iomem *addr = port->ul_addr[toggle]; |
797 | const u32 ul_size = port->ul_size[toggle]; | 796 | const u32 ul_size = port->ul_size[toggle]; |
798 | struct tty_struct *tty = port->tty; | 797 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
799 | 798 | ||
800 | /* Get data from tty and place in buf for now */ | 799 | /* Get data from tty and place in buf for now */ |
801 | size = __kfifo_get(port->fifo_ul, dc->send_buf, | 800 | size = __kfifo_get(port->fifo_ul, dc->send_buf, |
@@ -803,6 +802,7 @@ static int send_data(enum port_type index, const struct nozomi *dc) | |||
803 | 802 | ||
804 | if (size == 0) { | 803 | if (size == 0) { |
805 | DBG4("No more data to send, disable link:"); | 804 | DBG4("No more data to send, disable link:"); |
805 | tty_kref_put(tty); | ||
806 | return 0; | 806 | return 0; |
807 | } | 807 | } |
808 | 808 | ||
@@ -815,6 +815,7 @@ static int send_data(enum port_type index, const struct nozomi *dc) | |||
815 | if (tty) | 815 | if (tty) |
816 | tty_wakeup(tty); | 816 | tty_wakeup(tty); |
817 | 817 | ||
818 | tty_kref_put(tty); | ||
818 | return 1; | 819 | return 1; |
819 | } | 820 | } |
820 | 821 | ||
@@ -826,7 +827,7 @@ static int receive_data(enum port_type index, struct nozomi *dc) | |||
826 | u32 offset = 4; | 827 | u32 offset = 4; |
827 | struct port *port = &dc->port[index]; | 828 | struct port *port = &dc->port[index]; |
828 | void __iomem *addr = port->dl_addr[port->toggle_dl]; | 829 | void __iomem *addr = port->dl_addr[port->toggle_dl]; |
829 | struct tty_struct *tty = port->tty; | 830 | struct tty_struct *tty = tty_port_tty_get(&port->port); |
830 | int i; | 831 | int i; |
831 | 832 | ||
832 | if (unlikely(!tty)) { | 833 | if (unlikely(!tty)) { |
@@ -870,7 +871,7 @@ static int receive_data(enum port_type index, struct nozomi *dc) | |||
870 | } | 871 | } |
871 | 872 | ||
872 | set_bit(index, &dc->flip); | 873 | set_bit(index, &dc->flip); |
873 | 874 | tty_kref_put(tty); | |
874 | return 1; | 875 | return 1; |
875 | } | 876 | } |
876 | 877 | ||
@@ -1276,9 +1277,15 @@ static irqreturn_t interrupt_handler(int irq, void *dev_id) | |||
1276 | 1277 | ||
1277 | exit_handler: | 1278 | exit_handler: |
1278 | spin_unlock(&dc->spin_mutex); | 1279 | spin_unlock(&dc->spin_mutex); |
1279 | for (a = 0; a < NOZOMI_MAX_PORTS; a++) | 1280 | for (a = 0; a < NOZOMI_MAX_PORTS; a++) { |
1280 | if (test_and_clear_bit(a, &dc->flip)) | 1281 | struct tty_struct *tty; |
1281 | tty_flip_buffer_push(dc->port[a].tty); | 1282 | if (test_and_clear_bit(a, &dc->flip)) { |
1283 | tty = tty_port_tty_get(&dc->port[a].port); | ||
1284 | if (tty) | ||
1285 | tty_flip_buffer_push(tty); | ||
1286 | tty_kref_put(tty); | ||
1287 | } | ||
1288 | } | ||
1282 | return IRQ_HANDLED; | 1289 | return IRQ_HANDLED; |
1283 | none: | 1290 | none: |
1284 | spin_unlock(&dc->spin_mutex); | 1291 | spin_unlock(&dc->spin_mutex); |
@@ -1453,12 +1460,10 @@ static int __devinit nozomi_card_init(struct pci_dev *pdev, | |||
1453 | 1460 | ||
1454 | for (i = 0; i < MAX_PORT; i++) { | 1461 | for (i = 0; i < MAX_PORT; i++) { |
1455 | mutex_init(&dc->port[i].tty_sem); | 1462 | mutex_init(&dc->port[i].tty_sem); |
1456 | dc->port[i].tty_open_count = 0; | 1463 | tty_port_init(&dc->port[i].port); |
1457 | dc->port[i].tty = NULL; | ||
1458 | tty_register_device(ntty_driver, dc->index_start + i, | 1464 | tty_register_device(ntty_driver, dc->index_start + i, |
1459 | &pdev->dev); | 1465 | &pdev->dev); |
1460 | } | 1466 | } |
1461 | |||
1462 | return 0; | 1467 | return 0; |
1463 | 1468 | ||
1464 | err_free_sbuf: | 1469 | err_free_sbuf: |
@@ -1482,14 +1487,16 @@ static void __devexit tty_exit(struct nozomi *dc) | |||
1482 | 1487 | ||
1483 | flush_scheduled_work(); | 1488 | flush_scheduled_work(); |
1484 | 1489 | ||
1485 | for (i = 0; i < MAX_PORT; ++i) | 1490 | for (i = 0; i < MAX_PORT; ++i) { |
1486 | if (dc->port[i].tty && \ | 1491 | struct tty_struct *tty = tty_port_tty_get(&dc->port[i].port); |
1487 | list_empty(&dc->port[i].tty->hangup_work.entry)) | 1492 | if (tty && list_empty(&tty->hangup_work.entry)) |
1488 | tty_hangup(dc->port[i].tty); | 1493 | tty_hangup(tty); |
1489 | 1494 | tty_kref_put(tty); | |
1495 | } | ||
1496 | /* Racy below - surely should wait for scheduled work to be done or | ||
1497 | complete off a hangup method ? */ | ||
1490 | while (dc->open_ttys) | 1498 | while (dc->open_ttys) |
1491 | msleep(1); | 1499 | msleep(1); |
1492 | |||
1493 | for (i = dc->index_start; i < dc->index_start + MAX_PORT; ++i) | 1500 | for (i = dc->index_start; i < dc->index_start + MAX_PORT; ++i) |
1494 | tty_unregister_device(ntty_driver, i); | 1501 | tty_unregister_device(ntty_driver, i); |
1495 | } | 1502 | } |
@@ -1579,23 +1586,22 @@ static int ntty_open(struct tty_struct *tty, struct file *file) | |||
1579 | if (mutex_lock_interruptible(&port->tty_sem)) | 1586 | if (mutex_lock_interruptible(&port->tty_sem)) |
1580 | return -ERESTARTSYS; | 1587 | return -ERESTARTSYS; |
1581 | 1588 | ||
1582 | port->tty_open_count++; | 1589 | port->port.count++; |
1583 | dc->open_ttys++; | 1590 | dc->open_ttys++; |
1584 | 1591 | ||
1585 | /* Enable interrupt downlink for channel */ | 1592 | /* Enable interrupt downlink for channel */ |
1586 | if (port->tty_open_count == 1) { | 1593 | if (port->port.count == 1) { |
1594 | /* FIXME: is this needed now ? */ | ||
1587 | tty->low_latency = 1; | 1595 | tty->low_latency = 1; |
1588 | tty->driver_data = port; | 1596 | tty->driver_data = port; |
1589 | port->tty = tty; | 1597 | tty_port_tty_set(&port->port, tty); |
1590 | DBG1("open: %d", port->token_dl); | 1598 | DBG1("open: %d", port->token_dl); |
1591 | spin_lock_irqsave(&dc->spin_mutex, flags); | 1599 | spin_lock_irqsave(&dc->spin_mutex, flags); |
1592 | dc->last_ier = dc->last_ier | port->token_dl; | 1600 | dc->last_ier = dc->last_ier | port->token_dl; |
1593 | writew(dc->last_ier, dc->reg_ier); | 1601 | writew(dc->last_ier, dc->reg_ier); |
1594 | spin_unlock_irqrestore(&dc->spin_mutex, flags); | 1602 | spin_unlock_irqrestore(&dc->spin_mutex, flags); |
1595 | } | 1603 | } |
1596 | |||
1597 | mutex_unlock(&port->tty_sem); | 1604 | mutex_unlock(&port->tty_sem); |
1598 | |||
1599 | return 0; | 1605 | return 0; |
1600 | } | 1606 | } |
1601 | 1607 | ||
@@ -1606,31 +1612,30 @@ static int ntty_open(struct tty_struct *tty, struct file *file) | |||
1606 | static void ntty_close(struct tty_struct *tty, struct file *file) | 1612 | static void ntty_close(struct tty_struct *tty, struct file *file) |
1607 | { | 1613 | { |
1608 | struct nozomi *dc = get_dc_by_tty(tty); | 1614 | struct nozomi *dc = get_dc_by_tty(tty); |
1609 | struct port *port = tty->driver_data; | 1615 | struct port *nport = tty->driver_data; |
1616 | struct tty_port *port = &nport->port; | ||
1610 | unsigned long flags; | 1617 | unsigned long flags; |
1611 | 1618 | ||
1612 | if (!dc || !port) | 1619 | if (!dc || !nport) |
1613 | return; | 1620 | return; |
1614 | 1621 | ||
1615 | if (mutex_lock_interruptible(&port->tty_sem)) | 1622 | /* Users cannot interrupt a close */ |
1616 | return; | 1623 | mutex_lock(&nport->tty_sem); |
1617 | 1624 | ||
1618 | if (!port->tty_open_count) | 1625 | WARN_ON(!port->count); |
1619 | goto exit; | ||
1620 | 1626 | ||
1621 | dc->open_ttys--; | 1627 | dc->open_ttys--; |
1622 | port->tty_open_count--; | 1628 | port->count--; |
1629 | tty_port_tty_set(port, NULL); | ||
1623 | 1630 | ||
1624 | if (port->tty_open_count == 0) { | 1631 | if (port->count == 0) { |
1625 | DBG1("close: %d", port->token_dl); | 1632 | DBG1("close: %d", nport->token_dl); |
1626 | spin_lock_irqsave(&dc->spin_mutex, flags); | 1633 | spin_lock_irqsave(&dc->spin_mutex, flags); |
1627 | dc->last_ier &= ~(port->token_dl); | 1634 | dc->last_ier &= ~(nport->token_dl); |
1628 | writew(dc->last_ier, dc->reg_ier); | 1635 | writew(dc->last_ier, dc->reg_ier); |
1629 | spin_unlock_irqrestore(&dc->spin_mutex, flags); | 1636 | spin_unlock_irqrestore(&dc->spin_mutex, flags); |
1630 | } | 1637 | } |
1631 | 1638 | mutex_unlock(&nport->tty_sem); | |
1632 | exit: | ||
1633 | mutex_unlock(&port->tty_sem); | ||
1634 | } | 1639 | } |
1635 | 1640 | ||
1636 | /* | 1641 | /* |
@@ -1660,7 +1665,7 @@ static int ntty_write(struct tty_struct *tty, const unsigned char *buffer, | |||
1660 | return -EAGAIN; | 1665 | return -EAGAIN; |
1661 | } | 1666 | } |
1662 | 1667 | ||
1663 | if (unlikely(!port->tty_open_count)) { | 1668 | if (unlikely(!port->port.count)) { |
1664 | DBG1(" "); | 1669 | DBG1(" "); |
1665 | goto exit; | 1670 | goto exit; |
1666 | } | 1671 | } |
@@ -1710,7 +1715,7 @@ static int ntty_write_room(struct tty_struct *tty) | |||
1710 | if (!mutex_trylock(&port->tty_sem)) | 1715 | if (!mutex_trylock(&port->tty_sem)) |
1711 | return 0; | 1716 | return 0; |
1712 | 1717 | ||
1713 | if (!port->tty_open_count) | 1718 | if (!port->port.count) |
1714 | goto exit; | 1719 | goto exit; |
1715 | 1720 | ||
1716 | room = port->fifo_ul->size - __kfifo_len(port->fifo_ul); | 1721 | room = port->fifo_ul->size - __kfifo_len(port->fifo_ul); |
@@ -1866,7 +1871,7 @@ static s32 ntty_chars_in_buffer(struct tty_struct *tty) | |||
1866 | goto exit_in_buffer; | 1871 | goto exit_in_buffer; |
1867 | } | 1872 | } |
1868 | 1873 | ||
1869 | if (unlikely(!port->tty_open_count)) { | 1874 | if (unlikely(!port->port.count)) { |
1870 | dev_err(&dc->pdev->dev, "No tty open?\n"); | 1875 | dev_err(&dc->pdev->dev, "No tty open?\n"); |
1871 | rval = -ENODEV; | 1876 | rval = -ENODEV; |
1872 | goto exit_in_buffer; | 1877 | goto exit_in_buffer; |
diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c index 8054ee839b3c..88cee4099be9 100644 --- a/drivers/char/nvram.c +++ b/drivers/char/nvram.c | |||
@@ -32,9 +32,10 @@ | |||
32 | * added changelog | 32 | * added changelog |
33 | * 1.2 Erik Gilling: Cobalt Networks support | 33 | * 1.2 Erik Gilling: Cobalt Networks support |
34 | * Tim Hockin: general cleanup, Cobalt support | 34 | * Tim Hockin: general cleanup, Cobalt support |
35 | * 1.3 Wim Van Sebroeck: convert PRINT_PROC to seq_file | ||
35 | */ | 36 | */ |
36 | 37 | ||
37 | #define NVRAM_VERSION "1.2" | 38 | #define NVRAM_VERSION "1.3" |
38 | 39 | ||
39 | #include <linux/module.h> | 40 | #include <linux/module.h> |
40 | #include <linux/smp_lock.h> | 41 | #include <linux/smp_lock.h> |
@@ -46,7 +47,7 @@ | |||
46 | /* select machine configuration */ | 47 | /* select machine configuration */ |
47 | #if defined(CONFIG_ATARI) | 48 | #if defined(CONFIG_ATARI) |
48 | # define MACH ATARI | 49 | # define MACH ATARI |
49 | #elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) /* and others?? */ | 50 | #elif defined(__i386__) || defined(__x86_64__) || defined(__arm__) /* and ?? */ |
50 | # define MACH PC | 51 | # define MACH PC |
51 | #else | 52 | #else |
52 | # error Cannot build nvram driver for this machine configuration. | 53 | # error Cannot build nvram driver for this machine configuration. |
@@ -106,10 +107,11 @@ | |||
106 | #include <linux/mc146818rtc.h> | 107 | #include <linux/mc146818rtc.h> |
107 | #include <linux/init.h> | 108 | #include <linux/init.h> |
108 | #include <linux/proc_fs.h> | 109 | #include <linux/proc_fs.h> |
110 | #include <linux/seq_file.h> | ||
109 | #include <linux/spinlock.h> | 111 | #include <linux/spinlock.h> |
112 | #include <linux/io.h> | ||
113 | #include <linux/uaccess.h> | ||
110 | 114 | ||
111 | #include <asm/io.h> | ||
112 | #include <asm/uaccess.h> | ||
113 | #include <asm/system.h> | 115 | #include <asm/system.h> |
114 | 116 | ||
115 | static DEFINE_SPINLOCK(nvram_state_lock); | 117 | static DEFINE_SPINLOCK(nvram_state_lock); |
@@ -122,8 +124,8 @@ static int mach_check_checksum(void); | |||
122 | static void mach_set_checksum(void); | 124 | static void mach_set_checksum(void); |
123 | 125 | ||
124 | #ifdef CONFIG_PROC_FS | 126 | #ifdef CONFIG_PROC_FS |
125 | static int mach_proc_infos(unsigned char *contents, char *buffer, int *len, | 127 | static void mach_proc_infos(unsigned char *contents, struct seq_file *seq, |
126 | off_t *begin, off_t offset, int size); | 128 | void *offset); |
127 | #endif | 129 | #endif |
128 | 130 | ||
129 | /* | 131 | /* |
@@ -133,18 +135,17 @@ static int mach_proc_infos(unsigned char *contents, char *buffer, int *len, | |||
133 | * | 135 | * |
134 | * It is worth noting that these functions all access bytes of general | 136 | * It is worth noting that these functions all access bytes of general |
135 | * purpose memory in the NVRAM - that is to say, they all add the | 137 | * purpose memory in the NVRAM - that is to say, they all add the |
136 | * NVRAM_FIRST_BYTE offset. Pass them offsets into NVRAM as if you did not | 138 | * NVRAM_FIRST_BYTE offset. Pass them offsets into NVRAM as if you did not |
137 | * know about the RTC cruft. | 139 | * know about the RTC cruft. |
138 | */ | 140 | */ |
139 | 141 | ||
140 | unsigned char | 142 | unsigned char __nvram_read_byte(int i) |
141 | __nvram_read_byte(int i) | ||
142 | { | 143 | { |
143 | return CMOS_READ(NVRAM_FIRST_BYTE + i); | 144 | return CMOS_READ(NVRAM_FIRST_BYTE + i); |
144 | } | 145 | } |
146 | EXPORT_SYMBOL(__nvram_read_byte); | ||
145 | 147 | ||
146 | unsigned char | 148 | unsigned char nvram_read_byte(int i) |
147 | nvram_read_byte(int i) | ||
148 | { | 149 | { |
149 | unsigned long flags; | 150 | unsigned long flags; |
150 | unsigned char c; | 151 | unsigned char c; |
@@ -154,16 +155,16 @@ nvram_read_byte(int i) | |||
154 | spin_unlock_irqrestore(&rtc_lock, flags); | 155 | spin_unlock_irqrestore(&rtc_lock, flags); |
155 | return c; | 156 | return c; |
156 | } | 157 | } |
158 | EXPORT_SYMBOL(nvram_read_byte); | ||
157 | 159 | ||
158 | /* This races nicely with trying to read with checksum checking (nvram_read) */ | 160 | /* This races nicely with trying to read with checksum checking (nvram_read) */ |
159 | void | 161 | void __nvram_write_byte(unsigned char c, int i) |
160 | __nvram_write_byte(unsigned char c, int i) | ||
161 | { | 162 | { |
162 | CMOS_WRITE(c, NVRAM_FIRST_BYTE + i); | 163 | CMOS_WRITE(c, NVRAM_FIRST_BYTE + i); |
163 | } | 164 | } |
165 | EXPORT_SYMBOL(__nvram_write_byte); | ||
164 | 166 | ||
165 | void | 167 | void nvram_write_byte(unsigned char c, int i) |
166 | nvram_write_byte(unsigned char c, int i) | ||
167 | { | 168 | { |
168 | unsigned long flags; | 169 | unsigned long flags; |
169 | 170 | ||
@@ -171,15 +172,15 @@ nvram_write_byte(unsigned char c, int i) | |||
171 | __nvram_write_byte(c, i); | 172 | __nvram_write_byte(c, i); |
172 | spin_unlock_irqrestore(&rtc_lock, flags); | 173 | spin_unlock_irqrestore(&rtc_lock, flags); |
173 | } | 174 | } |
175 | EXPORT_SYMBOL(nvram_write_byte); | ||
174 | 176 | ||
175 | int | 177 | int __nvram_check_checksum(void) |
176 | __nvram_check_checksum(void) | ||
177 | { | 178 | { |
178 | return mach_check_checksum(); | 179 | return mach_check_checksum(); |
179 | } | 180 | } |
181 | EXPORT_SYMBOL(__nvram_check_checksum); | ||
180 | 182 | ||
181 | int | 183 | int nvram_check_checksum(void) |
182 | nvram_check_checksum(void) | ||
183 | { | 184 | { |
184 | unsigned long flags; | 185 | unsigned long flags; |
185 | int rv; | 186 | int rv; |
@@ -189,16 +190,15 @@ nvram_check_checksum(void) | |||
189 | spin_unlock_irqrestore(&rtc_lock, flags); | 190 | spin_unlock_irqrestore(&rtc_lock, flags); |
190 | return rv; | 191 | return rv; |
191 | } | 192 | } |
193 | EXPORT_SYMBOL(nvram_check_checksum); | ||
192 | 194 | ||
193 | static void | 195 | static void __nvram_set_checksum(void) |
194 | __nvram_set_checksum(void) | ||
195 | { | 196 | { |
196 | mach_set_checksum(); | 197 | mach_set_checksum(); |
197 | } | 198 | } |
198 | 199 | ||
199 | #if 0 | 200 | #if 0 |
200 | void | 201 | void nvram_set_checksum(void) |
201 | nvram_set_checksum(void) | ||
202 | { | 202 | { |
203 | unsigned long flags; | 203 | unsigned long flags; |
204 | 204 | ||
@@ -212,7 +212,7 @@ nvram_set_checksum(void) | |||
212 | * The are the file operation function for user access to /dev/nvram | 212 | * The are the file operation function for user access to /dev/nvram |
213 | */ | 213 | */ |
214 | 214 | ||
215 | static loff_t nvram_llseek(struct file *file,loff_t offset, int origin ) | 215 | static loff_t nvram_llseek(struct file *file, loff_t offset, int origin) |
216 | { | 216 | { |
217 | lock_kernel(); | 217 | lock_kernel(); |
218 | switch (origin) { | 218 | switch (origin) { |
@@ -230,8 +230,8 @@ static loff_t nvram_llseek(struct file *file,loff_t offset, int origin ) | |||
230 | return (offset >= 0) ? (file->f_pos = offset) : -EINVAL; | 230 | return (offset >= 0) ? (file->f_pos = offset) : -EINVAL; |
231 | } | 231 | } |
232 | 232 | ||
233 | static ssize_t | 233 | static ssize_t nvram_read(struct file *file, char __user *buf, |
234 | nvram_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | 234 | size_t count, loff_t *ppos) |
235 | { | 235 | { |
236 | unsigned char contents[NVRAM_BYTES]; | 236 | unsigned char contents[NVRAM_BYTES]; |
237 | unsigned i = *ppos; | 237 | unsigned i = *ppos; |
@@ -254,13 +254,13 @@ nvram_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) | |||
254 | 254 | ||
255 | return tmp - contents; | 255 | return tmp - contents; |
256 | 256 | ||
257 | checksum_err: | 257 | checksum_err: |
258 | spin_unlock_irq(&rtc_lock); | 258 | spin_unlock_irq(&rtc_lock); |
259 | return -EIO; | 259 | return -EIO; |
260 | } | 260 | } |
261 | 261 | ||
262 | static ssize_t | 262 | static ssize_t nvram_write(struct file *file, const char __user *buf, |
263 | nvram_write(struct file *file, const char __user *buf, size_t count, loff_t *ppos) | 263 | size_t count, loff_t *ppos) |
264 | { | 264 | { |
265 | unsigned char contents[NVRAM_BYTES]; | 265 | unsigned char contents[NVRAM_BYTES]; |
266 | unsigned i = *ppos; | 266 | unsigned i = *ppos; |
@@ -287,14 +287,13 @@ nvram_write(struct file *file, const char __user *buf, size_t count, loff_t *ppo | |||
287 | 287 | ||
288 | return tmp - contents; | 288 | return tmp - contents; |
289 | 289 | ||
290 | checksum_err: | 290 | checksum_err: |
291 | spin_unlock_irq(&rtc_lock); | 291 | spin_unlock_irq(&rtc_lock); |
292 | return -EIO; | 292 | return -EIO; |
293 | } | 293 | } |
294 | 294 | ||
295 | static int | 295 | static int nvram_ioctl(struct inode *inode, struct file *file, |
296 | nvram_ioctl(struct inode *inode, struct file *file, | 296 | unsigned int cmd, unsigned long arg) |
297 | unsigned int cmd, unsigned long arg) | ||
298 | { | 297 | { |
299 | int i; | 298 | int i; |
300 | 299 | ||
@@ -315,7 +314,7 @@ nvram_ioctl(struct inode *inode, struct file *file, | |||
315 | return 0; | 314 | return 0; |
316 | 315 | ||
317 | case NVRAM_SETCKS: | 316 | case NVRAM_SETCKS: |
318 | /* just set checksum, contents unchanged (maybe useful after | 317 | /* just set checksum, contents unchanged (maybe useful after |
319 | * checksum garbaged somehow...) */ | 318 | * checksum garbaged somehow...) */ |
320 | if (!capable(CAP_SYS_ADMIN)) | 319 | if (!capable(CAP_SYS_ADMIN)) |
321 | return -EACCES; | 320 | return -EACCES; |
@@ -330,8 +329,7 @@ nvram_ioctl(struct inode *inode, struct file *file, | |||
330 | } | 329 | } |
331 | } | 330 | } |
332 | 331 | ||
333 | static int | 332 | static int nvram_open(struct inode *inode, struct file *file) |
334 | nvram_open(struct inode *inode, struct file *file) | ||
335 | { | 333 | { |
336 | lock_kernel(); | 334 | lock_kernel(); |
337 | spin_lock(&nvram_state_lock); | 335 | spin_lock(&nvram_state_lock); |
@@ -356,8 +354,7 @@ nvram_open(struct inode *inode, struct file *file) | |||
356 | return 0; | 354 | return 0; |
357 | } | 355 | } |
358 | 356 | ||
359 | static int | 357 | static int nvram_release(struct inode *inode, struct file *file) |
360 | nvram_release(struct inode *inode, struct file *file) | ||
361 | { | 358 | { |
362 | spin_lock(&nvram_state_lock); | 359 | spin_lock(&nvram_state_lock); |
363 | 360 | ||
@@ -375,48 +372,47 @@ nvram_release(struct inode *inode, struct file *file) | |||
375 | } | 372 | } |
376 | 373 | ||
377 | #ifndef CONFIG_PROC_FS | 374 | #ifndef CONFIG_PROC_FS |
378 | static int | 375 | static int nvram_add_proc_fs(void) |
379 | nvram_read_proc(char *buffer, char **start, off_t offset, | ||
380 | int size, int *eof, void *data) | ||
381 | { | 376 | { |
382 | return 0; | 377 | return 0; |
383 | } | 378 | } |
379 | |||
384 | #else | 380 | #else |
385 | 381 | ||
386 | static int | 382 | static int nvram_proc_read(struct seq_file *seq, void *offset) |
387 | nvram_read_proc(char *buffer, char **start, off_t offset, | ||
388 | int size, int *eof, void *data) | ||
389 | { | 383 | { |
390 | unsigned char contents[NVRAM_BYTES]; | 384 | unsigned char contents[NVRAM_BYTES]; |
391 | int i, len = 0; | 385 | int i = 0; |
392 | off_t begin = 0; | ||
393 | 386 | ||
394 | spin_lock_irq(&rtc_lock); | 387 | spin_lock_irq(&rtc_lock); |
395 | for (i = 0; i < NVRAM_BYTES; ++i) | 388 | for (i = 0; i < NVRAM_BYTES; ++i) |
396 | contents[i] = __nvram_read_byte(i); | 389 | contents[i] = __nvram_read_byte(i); |
397 | spin_unlock_irq(&rtc_lock); | 390 | spin_unlock_irq(&rtc_lock); |
398 | 391 | ||
399 | *eof = mach_proc_infos(contents, buffer, &len, &begin, offset, size); | 392 | mach_proc_infos(contents, seq, offset); |
400 | 393 | ||
401 | if (offset >= begin + len) | 394 | return 0; |
402 | return 0; | 395 | } |
403 | *start = buffer + (offset - begin); | ||
404 | return (size < begin + len - offset) ? size : begin + len - offset; | ||
405 | 396 | ||
397 | static int nvram_proc_open(struct inode *inode, struct file *file) | ||
398 | { | ||
399 | return single_open(file, nvram_proc_read, NULL); | ||
406 | } | 400 | } |
407 | 401 | ||
408 | /* This macro frees the machine specific function from bounds checking and | 402 | static const struct file_operations nvram_proc_fops = { |
409 | * this like that... */ | 403 | .owner = THIS_MODULE, |
410 | #define PRINT_PROC(fmt,args...) \ | 404 | .open = nvram_proc_open, |
411 | do { \ | 405 | .read = seq_read, |
412 | *len += sprintf(buffer+*len, fmt, ##args); \ | 406 | .llseek = seq_lseek, |
413 | if (*begin + *len > offset + size) \ | 407 | .release = single_release, |
414 | return 0; \ | 408 | }; |
415 | if (*begin + *len < offset) { \ | 409 | |
416 | *begin += *len; \ | 410 | static int nvram_add_proc_fs(void) |
417 | *len = 0; \ | 411 | { |
418 | } \ | 412 | if (!proc_create("driver/nvram", 0, NULL, &nvram_proc_fops)) |
419 | } while(0) | 413 | return -ENOMEM; |
414 | return 0; | ||
415 | } | ||
420 | 416 | ||
421 | #endif /* CONFIG_PROC_FS */ | 417 | #endif /* CONFIG_PROC_FS */ |
422 | 418 | ||
@@ -436,8 +432,7 @@ static struct miscdevice nvram_dev = { | |||
436 | &nvram_fops | 432 | &nvram_fops |
437 | }; | 433 | }; |
438 | 434 | ||
439 | static int __init | 435 | static int __init nvram_init(void) |
440 | nvram_init(void) | ||
441 | { | 436 | { |
442 | int ret; | 437 | int ret; |
443 | 438 | ||
@@ -451,23 +446,21 @@ nvram_init(void) | |||
451 | NVRAM_MINOR); | 446 | NVRAM_MINOR); |
452 | goto out; | 447 | goto out; |
453 | } | 448 | } |
454 | if (!create_proc_read_entry("driver/nvram", 0, NULL, nvram_read_proc, | 449 | ret = nvram_add_proc_fs(); |
455 | NULL)) { | 450 | if (ret) { |
456 | printk(KERN_ERR "nvram: can't create /proc/driver/nvram\n"); | 451 | printk(KERN_ERR "nvram: can't create /proc/driver/nvram\n"); |
457 | ret = -ENOMEM; | ||
458 | goto outmisc; | 452 | goto outmisc; |
459 | } | 453 | } |
460 | ret = 0; | 454 | ret = 0; |
461 | printk(KERN_INFO "Non-volatile memory driver v" NVRAM_VERSION "\n"); | 455 | printk(KERN_INFO "Non-volatile memory driver v" NVRAM_VERSION "\n"); |
462 | out: | 456 | out: |
463 | return ret; | 457 | return ret; |
464 | outmisc: | 458 | outmisc: |
465 | misc_deregister(&nvram_dev); | 459 | misc_deregister(&nvram_dev); |
466 | goto out; | 460 | goto out; |
467 | } | 461 | } |
468 | 462 | ||
469 | static void __exit | 463 | static void __exit nvram_cleanup_module(void) |
470 | nvram_cleanup_module(void) | ||
471 | { | 464 | { |
472 | remove_proc_entry("driver/nvram", NULL); | 465 | remove_proc_entry("driver/nvram", NULL); |
473 | misc_deregister(&nvram_dev); | 466 | misc_deregister(&nvram_dev); |
@@ -482,8 +475,7 @@ module_exit(nvram_cleanup_module); | |||
482 | 475 | ||
483 | #if MACH == PC | 476 | #if MACH == PC |
484 | 477 | ||
485 | static int | 478 | static int pc_check_checksum(void) |
486 | pc_check_checksum(void) | ||
487 | { | 479 | { |
488 | int i; | 480 | int i; |
489 | unsigned short sum = 0; | 481 | unsigned short sum = 0; |
@@ -493,11 +485,10 @@ pc_check_checksum(void) | |||
493 | sum += __nvram_read_byte(i); | 485 | sum += __nvram_read_byte(i); |
494 | expect = __nvram_read_byte(PC_CKS_LOC)<<8 | | 486 | expect = __nvram_read_byte(PC_CKS_LOC)<<8 | |
495 | __nvram_read_byte(PC_CKS_LOC+1); | 487 | __nvram_read_byte(PC_CKS_LOC+1); |
496 | return ((sum & 0xffff) == expect); | 488 | return (sum & 0xffff) == expect; |
497 | } | 489 | } |
498 | 490 | ||
499 | static void | 491 | static void pc_set_checksum(void) |
500 | pc_set_checksum(void) | ||
501 | { | 492 | { |
502 | int i; | 493 | int i; |
503 | unsigned short sum = 0; | 494 | unsigned short sum = 0; |
@@ -522,9 +513,8 @@ static char *gfx_types[] = { | |||
522 | "monochrome", | 513 | "monochrome", |
523 | }; | 514 | }; |
524 | 515 | ||
525 | static int | 516 | static void pc_proc_infos(unsigned char *nvram, struct seq_file *seq, |
526 | pc_proc_infos(unsigned char *nvram, char *buffer, int *len, | 517 | void *offset) |
527 | off_t *begin, off_t offset, int size) | ||
528 | { | 518 | { |
529 | int checksum; | 519 | int checksum; |
530 | int type; | 520 | int type; |
@@ -533,56 +523,57 @@ pc_proc_infos(unsigned char *nvram, char *buffer, int *len, | |||
533 | checksum = __nvram_check_checksum(); | 523 | checksum = __nvram_check_checksum(); |
534 | spin_unlock_irq(&rtc_lock); | 524 | spin_unlock_irq(&rtc_lock); |
535 | 525 | ||
536 | PRINT_PROC("Checksum status: %svalid\n", checksum ? "" : "not "); | 526 | seq_printf(seq, "Checksum status: %svalid\n", checksum ? "" : "not "); |
537 | 527 | ||
538 | PRINT_PROC("# floppies : %d\n", | 528 | seq_printf(seq, "# floppies : %d\n", |
539 | (nvram[6] & 1) ? (nvram[6] >> 6) + 1 : 0); | 529 | (nvram[6] & 1) ? (nvram[6] >> 6) + 1 : 0); |
540 | PRINT_PROC("Floppy 0 type : "); | 530 | seq_printf(seq, "Floppy 0 type : "); |
541 | type = nvram[2] >> 4; | 531 | type = nvram[2] >> 4; |
542 | if (type < ARRAY_SIZE(floppy_types)) | 532 | if (type < ARRAY_SIZE(floppy_types)) |
543 | PRINT_PROC("%s\n", floppy_types[type]); | 533 | seq_printf(seq, "%s\n", floppy_types[type]); |
544 | else | 534 | else |
545 | PRINT_PROC("%d (unknown)\n", type); | 535 | seq_printf(seq, "%d (unknown)\n", type); |
546 | PRINT_PROC("Floppy 1 type : "); | 536 | seq_printf(seq, "Floppy 1 type : "); |
547 | type = nvram[2] & 0x0f; | 537 | type = nvram[2] & 0x0f; |
548 | if (type < ARRAY_SIZE(floppy_types)) | 538 | if (type < ARRAY_SIZE(floppy_types)) |
549 | PRINT_PROC("%s\n", floppy_types[type]); | 539 | seq_printf(seq, "%s\n", floppy_types[type]); |
550 | else | 540 | else |
551 | PRINT_PROC("%d (unknown)\n", type); | 541 | seq_printf(seq, "%d (unknown)\n", type); |
552 | 542 | ||
553 | PRINT_PROC("HD 0 type : "); | 543 | seq_printf(seq, "HD 0 type : "); |
554 | type = nvram[4] >> 4; | 544 | type = nvram[4] >> 4; |
555 | if (type) | 545 | if (type) |
556 | PRINT_PROC("%02x\n", type == 0x0f ? nvram[11] : type); | 546 | seq_printf(seq, "%02x\n", type == 0x0f ? nvram[11] : type); |
557 | else | 547 | else |
558 | PRINT_PROC("none\n"); | 548 | seq_printf(seq, "none\n"); |
559 | 549 | ||
560 | PRINT_PROC("HD 1 type : "); | 550 | seq_printf(seq, "HD 1 type : "); |
561 | type = nvram[4] & 0x0f; | 551 | type = nvram[4] & 0x0f; |
562 | if (type) | 552 | if (type) |
563 | PRINT_PROC("%02x\n", type == 0x0f ? nvram[12] : type); | 553 | seq_printf(seq, "%02x\n", type == 0x0f ? nvram[12] : type); |
564 | else | 554 | else |
565 | PRINT_PROC("none\n"); | 555 | seq_printf(seq, "none\n"); |
566 | 556 | ||
567 | PRINT_PROC("HD type 48 data: %d/%d/%d C/H/S, precomp %d, lz %d\n", | 557 | seq_printf(seq, "HD type 48 data: %d/%d/%d C/H/S, precomp %d, lz %d\n", |
568 | nvram[18] | (nvram[19] << 8), | 558 | nvram[18] | (nvram[19] << 8), |
569 | nvram[20], nvram[25], | 559 | nvram[20], nvram[25], |
570 | nvram[21] | (nvram[22] << 8), nvram[23] | (nvram[24] << 8)); | 560 | nvram[21] | (nvram[22] << 8), nvram[23] | (nvram[24] << 8)); |
571 | PRINT_PROC("HD type 49 data: %d/%d/%d C/H/S, precomp %d, lz %d\n", | 561 | seq_printf(seq, "HD type 49 data: %d/%d/%d C/H/S, precomp %d, lz %d\n", |
572 | nvram[39] | (nvram[40] << 8), | 562 | nvram[39] | (nvram[40] << 8), |
573 | nvram[41], nvram[46], | 563 | nvram[41], nvram[46], |
574 | nvram[42] | (nvram[43] << 8), nvram[44] | (nvram[45] << 8)); | 564 | nvram[42] | (nvram[43] << 8), nvram[44] | (nvram[45] << 8)); |
575 | 565 | ||
576 | PRINT_PROC("DOS base memory: %d kB\n", nvram[7] | (nvram[8] << 8)); | 566 | seq_printf(seq, "DOS base memory: %d kB\n", nvram[7] | (nvram[8] << 8)); |
577 | PRINT_PROC("Extended memory: %d kB (configured), %d kB (tested)\n", | 567 | seq_printf(seq, "Extended memory: %d kB (configured), %d kB (tested)\n", |
578 | nvram[9] | (nvram[10] << 8), nvram[34] | (nvram[35] << 8)); | 568 | nvram[9] | (nvram[10] << 8), nvram[34] | (nvram[35] << 8)); |
579 | 569 | ||
580 | PRINT_PROC("Gfx adapter : %s\n", gfx_types[(nvram[6] >> 4) & 3]); | 570 | seq_printf(seq, "Gfx adapter : %s\n", |
571 | gfx_types[(nvram[6] >> 4) & 3]); | ||
581 | 572 | ||
582 | PRINT_PROC("FPU : %sinstalled\n", | 573 | seq_printf(seq, "FPU : %sinstalled\n", |
583 | (nvram[6] & 2) ? "" : "not "); | 574 | (nvram[6] & 2) ? "" : "not "); |
584 | 575 | ||
585 | return 1; | 576 | return; |
586 | } | 577 | } |
587 | #endif | 578 | #endif |
588 | 579 | ||
@@ -590,20 +581,18 @@ pc_proc_infos(unsigned char *nvram, char *buffer, int *len, | |||
590 | 581 | ||
591 | #if MACH == ATARI | 582 | #if MACH == ATARI |
592 | 583 | ||
593 | static int | 584 | static int atari_check_checksum(void) |
594 | atari_check_checksum(void) | ||
595 | { | 585 | { |
596 | int i; | 586 | int i; |
597 | unsigned char sum = 0; | 587 | unsigned char sum = 0; |
598 | 588 | ||
599 | for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i) | 589 | for (i = ATARI_CKS_RANGE_START; i <= ATARI_CKS_RANGE_END; ++i) |
600 | sum += __nvram_read_byte(i); | 590 | sum += __nvram_read_byte(i); |
601 | return (__nvram_read_byte(ATARI_CKS_LOC) == (~sum & 0xff) && | 591 | return (__nvram_read_byte(ATARI_CKS_LOC) == (~sum & 0xff)) && |
602 | __nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff)); | 592 | (__nvram_read_byte(ATARI_CKS_LOC + 1) == (sum & 0xff)); |
603 | } | 593 | } |
604 | 594 | ||
605 | static void | 595 | static void atari_set_checksum(void) |
606 | atari_set_checksum(void) | ||
607 | { | 596 | { |
608 | int i; | 597 | int i; |
609 | unsigned char sum = 0; | 598 | unsigned char sum = 0; |
@@ -654,82 +643,75 @@ static char *colors[] = { | |||
654 | "2", "4", "16", "256", "65536", "??", "??", "??" | 643 | "2", "4", "16", "256", "65536", "??", "??", "??" |
655 | }; | 644 | }; |
656 | 645 | ||
657 | static int | 646 | static void atari_proc_infos(unsigned char *nvram, struct seq_file *seq, |
658 | atari_proc_infos(unsigned char *nvram, char *buffer, int *len, | 647 | void *offset) |
659 | off_t *begin, off_t offset, int size) | ||
660 | { | 648 | { |
661 | int checksum = nvram_check_checksum(); | 649 | int checksum = nvram_check_checksum(); |
662 | int i; | 650 | int i; |
663 | unsigned vmode; | 651 | unsigned vmode; |
664 | 652 | ||
665 | PRINT_PROC("Checksum status : %svalid\n", checksum ? "" : "not "); | 653 | seq_printf(seq, "Checksum status : %svalid\n", checksum ? "" : "not "); |
666 | 654 | ||
667 | PRINT_PROC("Boot preference : "); | 655 | seq_printf(seq, "Boot preference : "); |
668 | for (i = ARRAY_SIZE(boot_prefs) - 1; i >= 0; --i) { | 656 | for (i = ARRAY_SIZE(boot_prefs) - 1; i >= 0; --i) { |
669 | if (nvram[1] == boot_prefs[i].val) { | 657 | if (nvram[1] == boot_prefs[i].val) { |
670 | PRINT_PROC("%s\n", boot_prefs[i].name); | 658 | seq_printf(seq, "%s\n", boot_prefs[i].name); |
671 | break; | 659 | break; |
672 | } | 660 | } |
673 | } | 661 | } |
674 | if (i < 0) | 662 | if (i < 0) |
675 | PRINT_PROC("0x%02x (undefined)\n", nvram[1]); | 663 | seq_printf(seq, "0x%02x (undefined)\n", nvram[1]); |
676 | 664 | ||
677 | PRINT_PROC("SCSI arbitration : %s\n", | 665 | seq_printf(seq, "SCSI arbitration : %s\n", |
678 | (nvram[16] & 0x80) ? "on" : "off"); | 666 | (nvram[16] & 0x80) ? "on" : "off"); |
679 | PRINT_PROC("SCSI host ID : "); | 667 | seq_printf(seq, "SCSI host ID : "); |
680 | if (nvram[16] & 0x80) | 668 | if (nvram[16] & 0x80) |
681 | PRINT_PROC("%d\n", nvram[16] & 7); | 669 | seq_printf(seq, "%d\n", nvram[16] & 7); |
682 | else | 670 | else |
683 | PRINT_PROC("n/a\n"); | 671 | seq_printf(seq, "n/a\n"); |
684 | 672 | ||
685 | /* the following entries are defined only for the Falcon */ | 673 | /* the following entries are defined only for the Falcon */ |
686 | if ((atari_mch_cookie >> 16) != ATARI_MCH_FALCON) | 674 | if ((atari_mch_cookie >> 16) != ATARI_MCH_FALCON) |
687 | return 1; | 675 | return; |
688 | 676 | ||
689 | PRINT_PROC("OS language : "); | 677 | seq_printf(seq, "OS language : "); |
690 | if (nvram[6] < ARRAY_SIZE(languages)) | 678 | if (nvram[6] < ARRAY_SIZE(languages)) |
691 | PRINT_PROC("%s\n", languages[nvram[6]]); | 679 | seq_printf(seq, "%s\n", languages[nvram[6]]); |
692 | else | 680 | else |
693 | PRINT_PROC("%u (undefined)\n", nvram[6]); | 681 | seq_printf(seq, "%u (undefined)\n", nvram[6]); |
694 | PRINT_PROC("Keyboard language: "); | 682 | seq_printf(seq, "Keyboard language: "); |
695 | if (nvram[7] < ARRAY_SIZE(languages)) | 683 | if (nvram[7] < ARRAY_SIZE(languages)) |
696 | PRINT_PROC("%s\n", languages[nvram[7]]); | 684 | seq_printf(seq, "%s\n", languages[nvram[7]]); |
697 | else | 685 | else |
698 | PRINT_PROC("%u (undefined)\n", nvram[7]); | 686 | seq_printf(seq, "%u (undefined)\n", nvram[7]); |
699 | PRINT_PROC("Date format : "); | 687 | seq_printf(seq, "Date format : "); |
700 | PRINT_PROC(dateformat[nvram[8] & 7], | 688 | seq_printf(seq, dateformat[nvram[8] & 7], |
701 | nvram[9] ? nvram[9] : '/', nvram[9] ? nvram[9] : '/'); | 689 | nvram[9] ? nvram[9] : '/', nvram[9] ? nvram[9] : '/'); |
702 | PRINT_PROC(", %dh clock\n", nvram[8] & 16 ? 24 : 12); | 690 | seq_printf(seq, ", %dh clock\n", nvram[8] & 16 ? 24 : 12); |
703 | PRINT_PROC("Boot delay : "); | 691 | seq_printf(seq, "Boot delay : "); |
704 | if (nvram[10] == 0) | 692 | if (nvram[10] == 0) |
705 | PRINT_PROC("default"); | 693 | seq_printf(seq, "default"); |
706 | else | 694 | else |
707 | PRINT_PROC("%ds%s\n", nvram[10], | 695 | seq_printf(seq, "%ds%s\n", nvram[10], |
708 | nvram[10] < 8 ? ", no memory test" : ""); | 696 | nvram[10] < 8 ? ", no memory test" : ""); |
709 | 697 | ||
710 | vmode = (nvram[14] << 8) || nvram[15]; | 698 | vmode = (nvram[14] << 8) || nvram[15]; |
711 | PRINT_PROC("Video mode : %s colors, %d columns, %s %s monitor\n", | 699 | seq_printf(seq, |
700 | "Video mode : %s colors, %d columns, %s %s monitor\n", | ||
712 | colors[vmode & 7], | 701 | colors[vmode & 7], |
713 | vmode & 8 ? 80 : 40, | 702 | vmode & 8 ? 80 : 40, |
714 | vmode & 16 ? "VGA" : "TV", vmode & 32 ? "PAL" : "NTSC"); | 703 | vmode & 16 ? "VGA" : "TV", vmode & 32 ? "PAL" : "NTSC"); |
715 | PRINT_PROC(" %soverscan, compat. mode %s%s\n", | 704 | seq_printf(seq, " %soverscan, compat. mode %s%s\n", |
716 | vmode & 64 ? "" : "no ", | 705 | vmode & 64 ? "" : "no ", |
717 | vmode & 128 ? "on" : "off", | 706 | vmode & 128 ? "on" : "off", |
718 | vmode & 256 ? | 707 | vmode & 256 ? |
719 | (vmode & 16 ? ", line doubling" : ", half screen") : ""); | 708 | (vmode & 16 ? ", line doubling" : ", half screen") : ""); |
720 | 709 | ||
721 | return 1; | 710 | return; |
722 | } | 711 | } |
723 | #endif | 712 | #endif |
724 | 713 | ||
725 | #endif /* MACH == ATARI */ | 714 | #endif /* MACH == ATARI */ |
726 | 715 | ||
727 | MODULE_LICENSE("GPL"); | 716 | MODULE_LICENSE("GPL"); |
728 | |||
729 | EXPORT_SYMBOL(__nvram_read_byte); | ||
730 | EXPORT_SYMBOL(nvram_read_byte); | ||
731 | EXPORT_SYMBOL(__nvram_write_byte); | ||
732 | EXPORT_SYMBOL(nvram_write_byte); | ||
733 | EXPORT_SYMBOL(__nvram_check_checksum); | ||
734 | EXPORT_SYMBOL(nvram_check_checksum); | ||
735 | MODULE_ALIAS_MISCDEV(NVRAM_MINOR); | 717 | MODULE_ALIAS_MISCDEV(NVRAM_MINOR); |
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c index 006be92ee3f3..8c7df5ba088f 100644 --- a/drivers/char/nwflash.c +++ b/drivers/char/nwflash.c | |||
@@ -58,8 +58,6 @@ static volatile unsigned char *FLASH_BASE; | |||
58 | static int gbFlashSize = KFLASH_SIZE; | 58 | static int gbFlashSize = KFLASH_SIZE; |
59 | static DEFINE_MUTEX(nwflash_mutex); | 59 | static DEFINE_MUTEX(nwflash_mutex); |
60 | 60 | ||
61 | extern spinlock_t gpio_lock; | ||
62 | |||
63 | static int get_flash_id(void) | 61 | static int get_flash_id(void) |
64 | { | 62 | { |
65 | volatile unsigned int c1, c2; | 63 | volatile unsigned int c1, c2; |
@@ -616,9 +614,9 @@ static void kick_open(void) | |||
616 | * we want to write a bit pattern XXX1 to Xilinx to enable | 614 | * we want to write a bit pattern XXX1 to Xilinx to enable |
617 | * the write gate, which will be open for about the next 2ms. | 615 | * the write gate, which will be open for about the next 2ms. |
618 | */ | 616 | */ |
619 | spin_lock_irqsave(&gpio_lock, flags); | 617 | spin_lock_irqsave(&nw_gpio_lock, flags); |
620 | cpld_modify(1, 1); | 618 | nw_cpld_modify(CPLD_FLASH_WR_ENABLE, CPLD_FLASH_WR_ENABLE); |
621 | spin_unlock_irqrestore(&gpio_lock, flags); | 619 | spin_unlock_irqrestore(&nw_gpio_lock, flags); |
622 | 620 | ||
623 | /* | 621 | /* |
624 | * let the ISA bus to catch on... | 622 | * let the ISA bus to catch on... |
diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c index 4d64a02612a4..dc073e167abc 100644 --- a/drivers/char/pcmcia/synclink_cs.c +++ b/drivers/char/pcmcia/synclink_cs.c | |||
@@ -138,20 +138,15 @@ struct _input_signal_events { | |||
138 | */ | 138 | */ |
139 | 139 | ||
140 | typedef struct _mgslpc_info { | 140 | typedef struct _mgslpc_info { |
141 | struct tty_port port; | ||
141 | void *if_ptr; /* General purpose pointer (used by SPPP) */ | 142 | void *if_ptr; /* General purpose pointer (used by SPPP) */ |
142 | int magic; | 143 | int magic; |
143 | int flags; | ||
144 | int count; /* count of opens */ | ||
145 | int line; | 144 | int line; |
146 | unsigned short close_delay; | ||
147 | unsigned short closing_wait; /* time to wait before closing */ | ||
148 | 145 | ||
149 | struct mgsl_icount icount; | 146 | struct mgsl_icount icount; |
150 | 147 | ||
151 | struct tty_struct *tty; | ||
152 | int timeout; | 148 | int timeout; |
153 | int x_char; /* xon/xoff character */ | 149 | int x_char; /* xon/xoff character */ |
154 | int blocked_open; /* # of blocked opens */ | ||
155 | unsigned char read_status_mask; | 150 | unsigned char read_status_mask; |
156 | unsigned char ignore_status_mask; | 151 | unsigned char ignore_status_mask; |
157 | 152 | ||
@@ -170,9 +165,6 @@ typedef struct _mgslpc_info { | |||
170 | int rx_buf_count; /* total number of rx buffers */ | 165 | int rx_buf_count; /* total number of rx buffers */ |
171 | int rx_frame_count; /* number of full rx buffers */ | 166 | int rx_frame_count; /* number of full rx buffers */ |
172 | 167 | ||
173 | wait_queue_head_t open_wait; | ||
174 | wait_queue_head_t close_wait; | ||
175 | |||
176 | wait_queue_head_t status_event_wait_q; | 168 | wait_queue_head_t status_event_wait_q; |
177 | wait_queue_head_t event_wait_q; | 169 | wait_queue_head_t event_wait_q; |
178 | struct timer_list tx_timer; /* HDLC transmit timeout timer */ | 170 | struct timer_list tx_timer; /* HDLC transmit timeout timer */ |
@@ -375,7 +367,7 @@ static void irq_enable(MGSLPC_INFO *info, unsigned char channel, unsigned short | |||
375 | static void rx_start(MGSLPC_INFO *info); | 367 | static void rx_start(MGSLPC_INFO *info); |
376 | static void rx_stop(MGSLPC_INFO *info); | 368 | static void rx_stop(MGSLPC_INFO *info); |
377 | 369 | ||
378 | static void tx_start(MGSLPC_INFO *info); | 370 | static void tx_start(MGSLPC_INFO *info, struct tty_struct *tty); |
379 | static void tx_stop(MGSLPC_INFO *info); | 371 | static void tx_stop(MGSLPC_INFO *info); |
380 | static void tx_set_idle(MGSLPC_INFO *info); | 372 | static void tx_set_idle(MGSLPC_INFO *info); |
381 | 373 | ||
@@ -389,7 +381,8 @@ static void async_mode(MGSLPC_INFO *info); | |||
389 | 381 | ||
390 | static void tx_timeout(unsigned long context); | 382 | static void tx_timeout(unsigned long context); |
391 | 383 | ||
392 | static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg); | 384 | static int carrier_raised(struct tty_port *port); |
385 | static void raise_dtr_rts(struct tty_port *port); | ||
393 | 386 | ||
394 | #if SYNCLINK_GENERIC_HDLC | 387 | #if SYNCLINK_GENERIC_HDLC |
395 | #define dev_to_port(D) (dev_to_hdlc(D)->priv) | 388 | #define dev_to_port(D) (dev_to_hdlc(D)->priv) |
@@ -410,7 +403,7 @@ static void release_resources(MGSLPC_INFO *info); | |||
410 | static void mgslpc_add_device(MGSLPC_INFO *info); | 403 | static void mgslpc_add_device(MGSLPC_INFO *info); |
411 | static void mgslpc_remove_device(MGSLPC_INFO *info); | 404 | static void mgslpc_remove_device(MGSLPC_INFO *info); |
412 | 405 | ||
413 | static bool rx_get_frame(MGSLPC_INFO *info); | 406 | static bool rx_get_frame(MGSLPC_INFO *info, struct tty_struct *tty); |
414 | static void rx_reset_buffers(MGSLPC_INFO *info); | 407 | static void rx_reset_buffers(MGSLPC_INFO *info); |
415 | static int rx_alloc_buffers(MGSLPC_INFO *info); | 408 | static int rx_alloc_buffers(MGSLPC_INFO *info); |
416 | static void rx_free_buffers(MGSLPC_INFO *info); | 409 | static void rx_free_buffers(MGSLPC_INFO *info); |
@@ -421,7 +414,7 @@ static irqreturn_t mgslpc_isr(int irq, void *dev_id); | |||
421 | * Bottom half interrupt handlers | 414 | * Bottom half interrupt handlers |
422 | */ | 415 | */ |
423 | static void bh_handler(struct work_struct *work); | 416 | static void bh_handler(struct work_struct *work); |
424 | static void bh_transmit(MGSLPC_INFO *info); | 417 | static void bh_transmit(MGSLPC_INFO *info, struct tty_struct *tty); |
425 | static void bh_status(MGSLPC_INFO *info); | 418 | static void bh_status(MGSLPC_INFO *info); |
426 | 419 | ||
427 | /* | 420 | /* |
@@ -432,10 +425,10 @@ static int tiocmset(struct tty_struct *tty, struct file *file, | |||
432 | unsigned int set, unsigned int clear); | 425 | unsigned int set, unsigned int clear); |
433 | static int get_stats(MGSLPC_INFO *info, struct mgsl_icount __user *user_icount); | 426 | static int get_stats(MGSLPC_INFO *info, struct mgsl_icount __user *user_icount); |
434 | static int get_params(MGSLPC_INFO *info, MGSL_PARAMS __user *user_params); | 427 | static int get_params(MGSLPC_INFO *info, MGSL_PARAMS __user *user_params); |
435 | static int set_params(MGSLPC_INFO *info, MGSL_PARAMS __user *new_params); | 428 | static int set_params(MGSLPC_INFO *info, MGSL_PARAMS __user *new_params, struct tty_struct *tty); |
436 | static int get_txidle(MGSLPC_INFO *info, int __user *idle_mode); | 429 | static int get_txidle(MGSLPC_INFO *info, int __user *idle_mode); |
437 | static int set_txidle(MGSLPC_INFO *info, int idle_mode); | 430 | static int set_txidle(MGSLPC_INFO *info, int idle_mode); |
438 | static int set_txenable(MGSLPC_INFO *info, int enable); | 431 | static int set_txenable(MGSLPC_INFO *info, int enable, struct tty_struct *tty); |
439 | static int tx_abort(MGSLPC_INFO *info); | 432 | static int tx_abort(MGSLPC_INFO *info); |
440 | static int set_rxenable(MGSLPC_INFO *info, int enable); | 433 | static int set_rxenable(MGSLPC_INFO *info, int enable); |
441 | static int wait_events(MGSLPC_INFO *info, int __user *mask); | 434 | static int wait_events(MGSLPC_INFO *info, int __user *mask); |
@@ -474,7 +467,7 @@ static struct tty_driver *serial_driver; | |||
474 | /* number of characters left in xmit buffer before we ask for more */ | 467 | /* number of characters left in xmit buffer before we ask for more */ |
475 | #define WAKEUP_CHARS 256 | 468 | #define WAKEUP_CHARS 256 |
476 | 469 | ||
477 | static void mgslpc_change_params(MGSLPC_INFO *info); | 470 | static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty); |
478 | static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout); | 471 | static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout); |
479 | 472 | ||
480 | /* PCMCIA prototypes */ | 473 | /* PCMCIA prototypes */ |
@@ -517,6 +510,11 @@ static void ldisc_receive_buf(struct tty_struct *tty, | |||
517 | } | 510 | } |
518 | } | 511 | } |
519 | 512 | ||
513 | static const struct tty_port_operations mgslpc_port_ops = { | ||
514 | .carrier_raised = carrier_raised, | ||
515 | .raise_dtr_rts = raise_dtr_rts | ||
516 | }; | ||
517 | |||
520 | static int mgslpc_probe(struct pcmcia_device *link) | 518 | static int mgslpc_probe(struct pcmcia_device *link) |
521 | { | 519 | { |
522 | MGSLPC_INFO *info; | 520 | MGSLPC_INFO *info; |
@@ -532,12 +530,12 @@ static int mgslpc_probe(struct pcmcia_device *link) | |||
532 | } | 530 | } |
533 | 531 | ||
534 | info->magic = MGSLPC_MAGIC; | 532 | info->magic = MGSLPC_MAGIC; |
533 | tty_port_init(&info->port); | ||
534 | info->port.ops = &mgslpc_port_ops; | ||
535 | INIT_WORK(&info->task, bh_handler); | 535 | INIT_WORK(&info->task, bh_handler); |
536 | info->max_frame_size = 4096; | 536 | info->max_frame_size = 4096; |
537 | info->close_delay = 5*HZ/10; | 537 | info->port.close_delay = 5*HZ/10; |
538 | info->closing_wait = 30*HZ; | 538 | info->port.closing_wait = 30*HZ; |
539 | init_waitqueue_head(&info->open_wait); | ||
540 | init_waitqueue_head(&info->close_wait); | ||
541 | init_waitqueue_head(&info->status_event_wait_q); | 539 | init_waitqueue_head(&info->status_event_wait_q); |
542 | init_waitqueue_head(&info->event_wait_q); | 540 | init_waitqueue_head(&info->event_wait_q); |
543 | spin_lock_init(&info->lock); | 541 | spin_lock_init(&info->lock); |
@@ -784,7 +782,7 @@ static void tx_release(struct tty_struct *tty) | |||
784 | 782 | ||
785 | spin_lock_irqsave(&info->lock,flags); | 783 | spin_lock_irqsave(&info->lock,flags); |
786 | if (!info->tx_enabled) | 784 | if (!info->tx_enabled) |
787 | tx_start(info); | 785 | tx_start(info, tty); |
788 | spin_unlock_irqrestore(&info->lock,flags); | 786 | spin_unlock_irqrestore(&info->lock,flags); |
789 | } | 787 | } |
790 | 788 | ||
@@ -823,6 +821,7 @@ static int bh_action(MGSLPC_INFO *info) | |||
823 | static void bh_handler(struct work_struct *work) | 821 | static void bh_handler(struct work_struct *work) |
824 | { | 822 | { |
825 | MGSLPC_INFO *info = container_of(work, MGSLPC_INFO, task); | 823 | MGSLPC_INFO *info = container_of(work, MGSLPC_INFO, task); |
824 | struct tty_struct *tty; | ||
826 | int action; | 825 | int action; |
827 | 826 | ||
828 | if (!info) | 827 | if (!info) |
@@ -833,6 +832,7 @@ static void bh_handler(struct work_struct *work) | |||
833 | __FILE__,__LINE__,info->device_name); | 832 | __FILE__,__LINE__,info->device_name); |
834 | 833 | ||
835 | info->bh_running = true; | 834 | info->bh_running = true; |
835 | tty = tty_port_tty_get(&info->port); | ||
836 | 836 | ||
837 | while((action = bh_action(info)) != 0) { | 837 | while((action = bh_action(info)) != 0) { |
838 | 838 | ||
@@ -844,10 +844,10 @@ static void bh_handler(struct work_struct *work) | |||
844 | switch (action) { | 844 | switch (action) { |
845 | 845 | ||
846 | case BH_RECEIVE: | 846 | case BH_RECEIVE: |
847 | while(rx_get_frame(info)); | 847 | while(rx_get_frame(info, tty)); |
848 | break; | 848 | break; |
849 | case BH_TRANSMIT: | 849 | case BH_TRANSMIT: |
850 | bh_transmit(info); | 850 | bh_transmit(info, tty); |
851 | break; | 851 | break; |
852 | case BH_STATUS: | 852 | case BH_STATUS: |
853 | bh_status(info); | 853 | bh_status(info); |
@@ -859,14 +859,14 @@ static void bh_handler(struct work_struct *work) | |||
859 | } | 859 | } |
860 | } | 860 | } |
861 | 861 | ||
862 | tty_kref_put(tty); | ||
862 | if (debug_level >= DEBUG_LEVEL_BH) | 863 | if (debug_level >= DEBUG_LEVEL_BH) |
863 | printk( "%s(%d):bh_handler(%s) exit\n", | 864 | printk( "%s(%d):bh_handler(%s) exit\n", |
864 | __FILE__,__LINE__,info->device_name); | 865 | __FILE__,__LINE__,info->device_name); |
865 | } | 866 | } |
866 | 867 | ||
867 | static void bh_transmit(MGSLPC_INFO *info) | 868 | static void bh_transmit(MGSLPC_INFO *info, struct tty_struct *tty) |
868 | { | 869 | { |
869 | struct tty_struct *tty = info->tty; | ||
870 | if (debug_level >= DEBUG_LEVEL_BH) | 870 | if (debug_level >= DEBUG_LEVEL_BH) |
871 | printk("bh_transmit() entry on %s\n", info->device_name); | 871 | printk("bh_transmit() entry on %s\n", info->device_name); |
872 | 872 | ||
@@ -945,12 +945,11 @@ static void rx_ready_hdlc(MGSLPC_INFO *info, int eom) | |||
945 | issue_command(info, CHA, CMD_RXFIFO); | 945 | issue_command(info, CHA, CMD_RXFIFO); |
946 | } | 946 | } |
947 | 947 | ||
948 | static void rx_ready_async(MGSLPC_INFO *info, int tcd) | 948 | static void rx_ready_async(MGSLPC_INFO *info, int tcd, struct tty_struct *tty) |
949 | { | 949 | { |
950 | unsigned char data, status, flag; | 950 | unsigned char data, status, flag; |
951 | int fifo_count; | 951 | int fifo_count; |
952 | int work = 0; | 952 | int work = 0; |
953 | struct tty_struct *tty = info->tty; | ||
954 | struct mgsl_icount *icount = &info->icount; | 953 | struct mgsl_icount *icount = &info->icount; |
955 | 954 | ||
956 | if (tcd) { | 955 | if (tcd) { |
@@ -1013,7 +1012,7 @@ static void rx_ready_async(MGSLPC_INFO *info, int tcd) | |||
1013 | } | 1012 | } |
1014 | 1013 | ||
1015 | 1014 | ||
1016 | static void tx_done(MGSLPC_INFO *info) | 1015 | static void tx_done(MGSLPC_INFO *info, struct tty_struct *tty) |
1017 | { | 1016 | { |
1018 | if (!info->tx_active) | 1017 | if (!info->tx_active) |
1019 | return; | 1018 | return; |
@@ -1042,7 +1041,7 @@ static void tx_done(MGSLPC_INFO *info) | |||
1042 | else | 1041 | else |
1043 | #endif | 1042 | #endif |
1044 | { | 1043 | { |
1045 | if (info->tty->stopped || info->tty->hw_stopped) { | 1044 | if (tty->stopped || tty->hw_stopped) { |
1046 | tx_stop(info); | 1045 | tx_stop(info); |
1047 | return; | 1046 | return; |
1048 | } | 1047 | } |
@@ -1050,7 +1049,7 @@ static void tx_done(MGSLPC_INFO *info) | |||
1050 | } | 1049 | } |
1051 | } | 1050 | } |
1052 | 1051 | ||
1053 | static void tx_ready(MGSLPC_INFO *info) | 1052 | static void tx_ready(MGSLPC_INFO *info, struct tty_struct *tty) |
1054 | { | 1053 | { |
1055 | unsigned char fifo_count = 32; | 1054 | unsigned char fifo_count = 32; |
1056 | int c; | 1055 | int c; |
@@ -1062,7 +1061,7 @@ static void tx_ready(MGSLPC_INFO *info) | |||
1062 | if (!info->tx_active) | 1061 | if (!info->tx_active) |
1063 | return; | 1062 | return; |
1064 | } else { | 1063 | } else { |
1065 | if (info->tty->stopped || info->tty->hw_stopped) { | 1064 | if (tty->stopped || tty->hw_stopped) { |
1066 | tx_stop(info); | 1065 | tx_stop(info); |
1067 | return; | 1066 | return; |
1068 | } | 1067 | } |
@@ -1099,7 +1098,7 @@ static void tx_ready(MGSLPC_INFO *info) | |||
1099 | } | 1098 | } |
1100 | } | 1099 | } |
1101 | 1100 | ||
1102 | static void cts_change(MGSLPC_INFO *info) | 1101 | static void cts_change(MGSLPC_INFO *info, struct tty_struct *tty) |
1103 | { | 1102 | { |
1104 | get_signals(info); | 1103 | get_signals(info); |
1105 | if ((info->cts_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) | 1104 | if ((info->cts_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) |
@@ -1112,14 +1111,14 @@ static void cts_change(MGSLPC_INFO *info) | |||
1112 | wake_up_interruptible(&info->status_event_wait_q); | 1111 | wake_up_interruptible(&info->status_event_wait_q); |
1113 | wake_up_interruptible(&info->event_wait_q); | 1112 | wake_up_interruptible(&info->event_wait_q); |
1114 | 1113 | ||
1115 | if (info->flags & ASYNC_CTS_FLOW) { | 1114 | if (info->port.flags & ASYNC_CTS_FLOW) { |
1116 | if (info->tty->hw_stopped) { | 1115 | if (tty->hw_stopped) { |
1117 | if (info->serial_signals & SerialSignal_CTS) { | 1116 | if (info->serial_signals & SerialSignal_CTS) { |
1118 | if (debug_level >= DEBUG_LEVEL_ISR) | 1117 | if (debug_level >= DEBUG_LEVEL_ISR) |
1119 | printk("CTS tx start..."); | 1118 | printk("CTS tx start..."); |
1120 | if (info->tty) | 1119 | if (tty) |
1121 | info->tty->hw_stopped = 0; | 1120 | tty->hw_stopped = 0; |
1122 | tx_start(info); | 1121 | tx_start(info, tty); |
1123 | info->pending_bh |= BH_TRANSMIT; | 1122 | info->pending_bh |= BH_TRANSMIT; |
1124 | return; | 1123 | return; |
1125 | } | 1124 | } |
@@ -1127,8 +1126,8 @@ static void cts_change(MGSLPC_INFO *info) | |||
1127 | if (!(info->serial_signals & SerialSignal_CTS)) { | 1126 | if (!(info->serial_signals & SerialSignal_CTS)) { |
1128 | if (debug_level >= DEBUG_LEVEL_ISR) | 1127 | if (debug_level >= DEBUG_LEVEL_ISR) |
1129 | printk("CTS tx stop..."); | 1128 | printk("CTS tx stop..."); |
1130 | if (info->tty) | 1129 | if (tty) |
1131 | info->tty->hw_stopped = 1; | 1130 | tty->hw_stopped = 1; |
1132 | tx_stop(info); | 1131 | tx_stop(info); |
1133 | } | 1132 | } |
1134 | } | 1133 | } |
@@ -1136,7 +1135,7 @@ static void cts_change(MGSLPC_INFO *info) | |||
1136 | info->pending_bh |= BH_STATUS; | 1135 | info->pending_bh |= BH_STATUS; |
1137 | } | 1136 | } |
1138 | 1137 | ||
1139 | static void dcd_change(MGSLPC_INFO *info) | 1138 | static void dcd_change(MGSLPC_INFO *info, struct tty_struct *tty) |
1140 | { | 1139 | { |
1141 | get_signals(info); | 1140 | get_signals(info); |
1142 | if ((info->dcd_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) | 1141 | if ((info->dcd_chkcount)++ >= IO_PIN_SHUTDOWN_LIMIT) |
@@ -1158,17 +1157,17 @@ static void dcd_change(MGSLPC_INFO *info) | |||
1158 | wake_up_interruptible(&info->status_event_wait_q); | 1157 | wake_up_interruptible(&info->status_event_wait_q); |
1159 | wake_up_interruptible(&info->event_wait_q); | 1158 | wake_up_interruptible(&info->event_wait_q); |
1160 | 1159 | ||
1161 | if (info->flags & ASYNC_CHECK_CD) { | 1160 | if (info->port.flags & ASYNC_CHECK_CD) { |
1162 | if (debug_level >= DEBUG_LEVEL_ISR) | 1161 | if (debug_level >= DEBUG_LEVEL_ISR) |
1163 | printk("%s CD now %s...", info->device_name, | 1162 | printk("%s CD now %s...", info->device_name, |
1164 | (info->serial_signals & SerialSignal_DCD) ? "on" : "off"); | 1163 | (info->serial_signals & SerialSignal_DCD) ? "on" : "off"); |
1165 | if (info->serial_signals & SerialSignal_DCD) | 1164 | if (info->serial_signals & SerialSignal_DCD) |
1166 | wake_up_interruptible(&info->open_wait); | 1165 | wake_up_interruptible(&info->port.open_wait); |
1167 | else { | 1166 | else { |
1168 | if (debug_level >= DEBUG_LEVEL_ISR) | 1167 | if (debug_level >= DEBUG_LEVEL_ISR) |
1169 | printk("doing serial hangup..."); | 1168 | printk("doing serial hangup..."); |
1170 | if (info->tty) | 1169 | if (tty) |
1171 | tty_hangup(info->tty); | 1170 | tty_hangup(tty); |
1172 | } | 1171 | } |
1173 | } | 1172 | } |
1174 | info->pending_bh |= BH_STATUS; | 1173 | info->pending_bh |= BH_STATUS; |
@@ -1214,6 +1213,7 @@ static void ri_change(MGSLPC_INFO *info) | |||
1214 | static irqreturn_t mgslpc_isr(int dummy, void *dev_id) | 1213 | static irqreturn_t mgslpc_isr(int dummy, void *dev_id) |
1215 | { | 1214 | { |
1216 | MGSLPC_INFO *info = dev_id; | 1215 | MGSLPC_INFO *info = dev_id; |
1216 | struct tty_struct *tty; | ||
1217 | unsigned short isr; | 1217 | unsigned short isr; |
1218 | unsigned char gis, pis; | 1218 | unsigned char gis, pis; |
1219 | int count=0; | 1219 | int count=0; |
@@ -1224,6 +1224,8 @@ static irqreturn_t mgslpc_isr(int dummy, void *dev_id) | |||
1224 | if (!(info->p_dev->_locked)) | 1224 | if (!(info->p_dev->_locked)) |
1225 | return IRQ_HANDLED; | 1225 | return IRQ_HANDLED; |
1226 | 1226 | ||
1227 | tty = tty_port_tty_get(&info->port); | ||
1228 | |||
1227 | spin_lock(&info->lock); | 1229 | spin_lock(&info->lock); |
1228 | 1230 | ||
1229 | while ((gis = read_reg(info, CHA + GIS))) { | 1231 | while ((gis = read_reg(info, CHA + GIS))) { |
@@ -1239,9 +1241,9 @@ static irqreturn_t mgslpc_isr(int dummy, void *dev_id) | |||
1239 | if (gis & (BIT1 + BIT0)) { | 1241 | if (gis & (BIT1 + BIT0)) { |
1240 | isr = read_reg16(info, CHB + ISR); | 1242 | isr = read_reg16(info, CHB + ISR); |
1241 | if (isr & IRQ_DCD) | 1243 | if (isr & IRQ_DCD) |
1242 | dcd_change(info); | 1244 | dcd_change(info, tty); |
1243 | if (isr & IRQ_CTS) | 1245 | if (isr & IRQ_CTS) |
1244 | cts_change(info); | 1246 | cts_change(info, tty); |
1245 | } | 1247 | } |
1246 | if (gis & (BIT3 + BIT2)) | 1248 | if (gis & (BIT3 + BIT2)) |
1247 | { | 1249 | { |
@@ -1258,8 +1260,8 @@ static irqreturn_t mgslpc_isr(int dummy, void *dev_id) | |||
1258 | } | 1260 | } |
1259 | if (isr & IRQ_BREAK_ON) { | 1261 | if (isr & IRQ_BREAK_ON) { |
1260 | info->icount.brk++; | 1262 | info->icount.brk++; |
1261 | if (info->flags & ASYNC_SAK) | 1263 | if (info->port.flags & ASYNC_SAK) |
1262 | do_SAK(info->tty); | 1264 | do_SAK(tty); |
1263 | } | 1265 | } |
1264 | if (isr & IRQ_RXTIME) { | 1266 | if (isr & IRQ_RXTIME) { |
1265 | issue_command(info, CHA, CMD_RXFIFO_READ); | 1267 | issue_command(info, CHA, CMD_RXFIFO_READ); |
@@ -1268,7 +1270,7 @@ static irqreturn_t mgslpc_isr(int dummy, void *dev_id) | |||
1268 | if (info->params.mode == MGSL_MODE_HDLC) | 1270 | if (info->params.mode == MGSL_MODE_HDLC) |
1269 | rx_ready_hdlc(info, isr & IRQ_RXEOM); | 1271 | rx_ready_hdlc(info, isr & IRQ_RXEOM); |
1270 | else | 1272 | else |
1271 | rx_ready_async(info, isr & IRQ_RXEOM); | 1273 | rx_ready_async(info, isr & IRQ_RXEOM, tty); |
1272 | } | 1274 | } |
1273 | 1275 | ||
1274 | /* transmit IRQs */ | 1276 | /* transmit IRQs */ |
@@ -1277,14 +1279,14 @@ static irqreturn_t mgslpc_isr(int dummy, void *dev_id) | |||
1277 | info->icount.txabort++; | 1279 | info->icount.txabort++; |
1278 | else | 1280 | else |
1279 | info->icount.txunder++; | 1281 | info->icount.txunder++; |
1280 | tx_done(info); | 1282 | tx_done(info, tty); |
1281 | } | 1283 | } |
1282 | else if (isr & IRQ_ALLSENT) { | 1284 | else if (isr & IRQ_ALLSENT) { |
1283 | info->icount.txok++; | 1285 | info->icount.txok++; |
1284 | tx_done(info); | 1286 | tx_done(info, tty); |
1285 | } | 1287 | } |
1286 | else if (isr & IRQ_TXFIFO) | 1288 | else if (isr & IRQ_TXFIFO) |
1287 | tx_ready(info); | 1289 | tx_ready(info, tty); |
1288 | } | 1290 | } |
1289 | if (gis & BIT7) { | 1291 | if (gis & BIT7) { |
1290 | pis = read_reg(info, CHA + PIS); | 1292 | pis = read_reg(info, CHA + PIS); |
@@ -1308,6 +1310,7 @@ static irqreturn_t mgslpc_isr(int dummy, void *dev_id) | |||
1308 | } | 1310 | } |
1309 | 1311 | ||
1310 | spin_unlock(&info->lock); | 1312 | spin_unlock(&info->lock); |
1313 | tty_kref_put(tty); | ||
1311 | 1314 | ||
1312 | if (debug_level >= DEBUG_LEVEL_ISR) | 1315 | if (debug_level >= DEBUG_LEVEL_ISR) |
1313 | printk("%s(%d):mgslpc_isr(%d)exit.\n", | 1316 | printk("%s(%d):mgslpc_isr(%d)exit.\n", |
@@ -1318,14 +1321,14 @@ static irqreturn_t mgslpc_isr(int dummy, void *dev_id) | |||
1318 | 1321 | ||
1319 | /* Initialize and start device. | 1322 | /* Initialize and start device. |
1320 | */ | 1323 | */ |
1321 | static int startup(MGSLPC_INFO * info) | 1324 | static int startup(MGSLPC_INFO * info, struct tty_struct *tty) |
1322 | { | 1325 | { |
1323 | int retval = 0; | 1326 | int retval = 0; |
1324 | 1327 | ||
1325 | if (debug_level >= DEBUG_LEVEL_INFO) | 1328 | if (debug_level >= DEBUG_LEVEL_INFO) |
1326 | printk("%s(%d):startup(%s)\n",__FILE__,__LINE__,info->device_name); | 1329 | printk("%s(%d):startup(%s)\n",__FILE__,__LINE__,info->device_name); |
1327 | 1330 | ||
1328 | if (info->flags & ASYNC_INITIALIZED) | 1331 | if (info->port.flags & ASYNC_INITIALIZED) |
1329 | return 0; | 1332 | return 0; |
1330 | 1333 | ||
1331 | if (!info->tx_buf) { | 1334 | if (!info->tx_buf) { |
@@ -1352,30 +1355,30 @@ static int startup(MGSLPC_INFO * info) | |||
1352 | retval = adapter_test(info); | 1355 | retval = adapter_test(info); |
1353 | 1356 | ||
1354 | if ( retval ) { | 1357 | if ( retval ) { |
1355 | if (capable(CAP_SYS_ADMIN) && info->tty) | 1358 | if (capable(CAP_SYS_ADMIN) && tty) |
1356 | set_bit(TTY_IO_ERROR, &info->tty->flags); | 1359 | set_bit(TTY_IO_ERROR, &tty->flags); |
1357 | release_resources(info); | 1360 | release_resources(info); |
1358 | return retval; | 1361 | return retval; |
1359 | } | 1362 | } |
1360 | 1363 | ||
1361 | /* program hardware for current parameters */ | 1364 | /* program hardware for current parameters */ |
1362 | mgslpc_change_params(info); | 1365 | mgslpc_change_params(info, tty); |
1363 | 1366 | ||
1364 | if (info->tty) | 1367 | if (tty) |
1365 | clear_bit(TTY_IO_ERROR, &info->tty->flags); | 1368 | clear_bit(TTY_IO_ERROR, &tty->flags); |
1366 | 1369 | ||
1367 | info->flags |= ASYNC_INITIALIZED; | 1370 | info->port.flags |= ASYNC_INITIALIZED; |
1368 | 1371 | ||
1369 | return 0; | 1372 | return 0; |
1370 | } | 1373 | } |
1371 | 1374 | ||
1372 | /* Called by mgslpc_close() and mgslpc_hangup() to shutdown hardware | 1375 | /* Called by mgslpc_close() and mgslpc_hangup() to shutdown hardware |
1373 | */ | 1376 | */ |
1374 | static void shutdown(MGSLPC_INFO * info) | 1377 | static void shutdown(MGSLPC_INFO * info, struct tty_struct *tty) |
1375 | { | 1378 | { |
1376 | unsigned long flags; | 1379 | unsigned long flags; |
1377 | 1380 | ||
1378 | if (!(info->flags & ASYNC_INITIALIZED)) | 1381 | if (!(info->port.flags & ASYNC_INITIALIZED)) |
1379 | return; | 1382 | return; |
1380 | 1383 | ||
1381 | if (debug_level >= DEBUG_LEVEL_INFO) | 1384 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -1402,7 +1405,7 @@ static void shutdown(MGSLPC_INFO * info) | |||
1402 | /* TODO:disable interrupts instead of reset to preserve signal states */ | 1405 | /* TODO:disable interrupts instead of reset to preserve signal states */ |
1403 | reset_device(info); | 1406 | reset_device(info); |
1404 | 1407 | ||
1405 | if (!info->tty || info->tty->termios->c_cflag & HUPCL) { | 1408 | if (!tty || tty->termios->c_cflag & HUPCL) { |
1406 | info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); | 1409 | info->serial_signals &= ~(SerialSignal_DTR + SerialSignal_RTS); |
1407 | set_signals(info); | 1410 | set_signals(info); |
1408 | } | 1411 | } |
@@ -1411,13 +1414,13 @@ static void shutdown(MGSLPC_INFO * info) | |||
1411 | 1414 | ||
1412 | release_resources(info); | 1415 | release_resources(info); |
1413 | 1416 | ||
1414 | if (info->tty) | 1417 | if (tty) |
1415 | set_bit(TTY_IO_ERROR, &info->tty->flags); | 1418 | set_bit(TTY_IO_ERROR, &tty->flags); |
1416 | 1419 | ||
1417 | info->flags &= ~ASYNC_INITIALIZED; | 1420 | info->port.flags &= ~ASYNC_INITIALIZED; |
1418 | } | 1421 | } |
1419 | 1422 | ||
1420 | static void mgslpc_program_hw(MGSLPC_INFO *info) | 1423 | static void mgslpc_program_hw(MGSLPC_INFO *info, struct tty_struct *tty) |
1421 | { | 1424 | { |
1422 | unsigned long flags; | 1425 | unsigned long flags; |
1423 | 1426 | ||
@@ -1443,7 +1446,7 @@ static void mgslpc_program_hw(MGSLPC_INFO *info) | |||
1443 | port_irq_enable(info, (unsigned char) PVR_DSR | PVR_RI); | 1446 | port_irq_enable(info, (unsigned char) PVR_DSR | PVR_RI); |
1444 | get_signals(info); | 1447 | get_signals(info); |
1445 | 1448 | ||
1446 | if (info->netcount || info->tty->termios->c_cflag & CREAD) | 1449 | if (info->netcount || (tty && (tty->termios->c_cflag & CREAD))) |
1447 | rx_start(info); | 1450 | rx_start(info); |
1448 | 1451 | ||
1449 | spin_unlock_irqrestore(&info->lock,flags); | 1452 | spin_unlock_irqrestore(&info->lock,flags); |
@@ -1451,19 +1454,19 @@ static void mgslpc_program_hw(MGSLPC_INFO *info) | |||
1451 | 1454 | ||
1452 | /* Reconfigure adapter based on new parameters | 1455 | /* Reconfigure adapter based on new parameters |
1453 | */ | 1456 | */ |
1454 | static void mgslpc_change_params(MGSLPC_INFO *info) | 1457 | static void mgslpc_change_params(MGSLPC_INFO *info, struct tty_struct *tty) |
1455 | { | 1458 | { |
1456 | unsigned cflag; | 1459 | unsigned cflag; |
1457 | int bits_per_char; | 1460 | int bits_per_char; |
1458 | 1461 | ||
1459 | if (!info->tty || !info->tty->termios) | 1462 | if (!tty || !tty->termios) |
1460 | return; | 1463 | return; |
1461 | 1464 | ||
1462 | if (debug_level >= DEBUG_LEVEL_INFO) | 1465 | if (debug_level >= DEBUG_LEVEL_INFO) |
1463 | printk("%s(%d):mgslpc_change_params(%s)\n", | 1466 | printk("%s(%d):mgslpc_change_params(%s)\n", |
1464 | __FILE__,__LINE__, info->device_name ); | 1467 | __FILE__,__LINE__, info->device_name ); |
1465 | 1468 | ||
1466 | cflag = info->tty->termios->c_cflag; | 1469 | cflag = tty->termios->c_cflag; |
1467 | 1470 | ||
1468 | /* if B0 rate (hangup) specified then negate DTR and RTS */ | 1471 | /* if B0 rate (hangup) specified then negate DTR and RTS */ |
1469 | /* otherwise assert DTR and RTS */ | 1472 | /* otherwise assert DTR and RTS */ |
@@ -1510,7 +1513,7 @@ static void mgslpc_change_params(MGSLPC_INFO *info) | |||
1510 | * current data rate. | 1513 | * current data rate. |
1511 | */ | 1514 | */ |
1512 | if (info->params.data_rate <= 460800) { | 1515 | if (info->params.data_rate <= 460800) { |
1513 | info->params.data_rate = tty_get_baud_rate(info->tty); | 1516 | info->params.data_rate = tty_get_baud_rate(tty); |
1514 | } | 1517 | } |
1515 | 1518 | ||
1516 | if ( info->params.data_rate ) { | 1519 | if ( info->params.data_rate ) { |
@@ -1520,24 +1523,24 @@ static void mgslpc_change_params(MGSLPC_INFO *info) | |||
1520 | info->timeout += HZ/50; /* Add .02 seconds of slop */ | 1523 | info->timeout += HZ/50; /* Add .02 seconds of slop */ |
1521 | 1524 | ||
1522 | if (cflag & CRTSCTS) | 1525 | if (cflag & CRTSCTS) |
1523 | info->flags |= ASYNC_CTS_FLOW; | 1526 | info->port.flags |= ASYNC_CTS_FLOW; |
1524 | else | 1527 | else |
1525 | info->flags &= ~ASYNC_CTS_FLOW; | 1528 | info->port.flags &= ~ASYNC_CTS_FLOW; |
1526 | 1529 | ||
1527 | if (cflag & CLOCAL) | 1530 | if (cflag & CLOCAL) |
1528 | info->flags &= ~ASYNC_CHECK_CD; | 1531 | info->port.flags &= ~ASYNC_CHECK_CD; |
1529 | else | 1532 | else |
1530 | info->flags |= ASYNC_CHECK_CD; | 1533 | info->port.flags |= ASYNC_CHECK_CD; |
1531 | 1534 | ||
1532 | /* process tty input control flags */ | 1535 | /* process tty input control flags */ |
1533 | 1536 | ||
1534 | info->read_status_mask = 0; | 1537 | info->read_status_mask = 0; |
1535 | if (I_INPCK(info->tty)) | 1538 | if (I_INPCK(tty)) |
1536 | info->read_status_mask |= BIT7 | BIT6; | 1539 | info->read_status_mask |= BIT7 | BIT6; |
1537 | if (I_IGNPAR(info->tty)) | 1540 | if (I_IGNPAR(tty)) |
1538 | info->ignore_status_mask |= BIT7 | BIT6; | 1541 | info->ignore_status_mask |= BIT7 | BIT6; |
1539 | 1542 | ||
1540 | mgslpc_program_hw(info); | 1543 | mgslpc_program_hw(info, tty); |
1541 | } | 1544 | } |
1542 | 1545 | ||
1543 | /* Add a character to the transmit buffer | 1546 | /* Add a character to the transmit buffer |
@@ -1597,7 +1600,7 @@ static void mgslpc_flush_chars(struct tty_struct *tty) | |||
1597 | 1600 | ||
1598 | spin_lock_irqsave(&info->lock,flags); | 1601 | spin_lock_irqsave(&info->lock,flags); |
1599 | if (!info->tx_active) | 1602 | if (!info->tx_active) |
1600 | tx_start(info); | 1603 | tx_start(info, tty); |
1601 | spin_unlock_irqrestore(&info->lock,flags); | 1604 | spin_unlock_irqrestore(&info->lock,flags); |
1602 | } | 1605 | } |
1603 | 1606 | ||
@@ -1659,7 +1662,7 @@ start: | |||
1659 | if (info->tx_count && !tty->stopped && !tty->hw_stopped) { | 1662 | if (info->tx_count && !tty->stopped && !tty->hw_stopped) { |
1660 | spin_lock_irqsave(&info->lock,flags); | 1663 | spin_lock_irqsave(&info->lock,flags); |
1661 | if (!info->tx_active) | 1664 | if (!info->tx_active) |
1662 | tx_start(info); | 1665 | tx_start(info, tty); |
1663 | spin_unlock_irqrestore(&info->lock,flags); | 1666 | spin_unlock_irqrestore(&info->lock,flags); |
1664 | } | 1667 | } |
1665 | cleanup: | 1668 | cleanup: |
@@ -1764,7 +1767,7 @@ static void mgslpc_send_xchar(struct tty_struct *tty, char ch) | |||
1764 | if (ch) { | 1767 | if (ch) { |
1765 | spin_lock_irqsave(&info->lock,flags); | 1768 | spin_lock_irqsave(&info->lock,flags); |
1766 | if (!info->tx_enabled) | 1769 | if (!info->tx_enabled) |
1767 | tx_start(info); | 1770 | tx_start(info, tty); |
1768 | spin_unlock_irqrestore(&info->lock,flags); | 1771 | spin_unlock_irqrestore(&info->lock,flags); |
1769 | } | 1772 | } |
1770 | } | 1773 | } |
@@ -1862,7 +1865,7 @@ static int get_params(MGSLPC_INFO * info, MGSL_PARAMS __user *user_params) | |||
1862 | * | 1865 | * |
1863 | * Returns: 0 if success, otherwise error code | 1866 | * Returns: 0 if success, otherwise error code |
1864 | */ | 1867 | */ |
1865 | static int set_params(MGSLPC_INFO * info, MGSL_PARAMS __user *new_params) | 1868 | static int set_params(MGSLPC_INFO * info, MGSL_PARAMS __user *new_params, struct tty_struct *tty) |
1866 | { | 1869 | { |
1867 | unsigned long flags; | 1870 | unsigned long flags; |
1868 | MGSL_PARAMS tmp_params; | 1871 | MGSL_PARAMS tmp_params; |
@@ -1883,7 +1886,7 @@ static int set_params(MGSLPC_INFO * info, MGSL_PARAMS __user *new_params) | |||
1883 | memcpy(&info->params,&tmp_params,sizeof(MGSL_PARAMS)); | 1886 | memcpy(&info->params,&tmp_params,sizeof(MGSL_PARAMS)); |
1884 | spin_unlock_irqrestore(&info->lock,flags); | 1887 | spin_unlock_irqrestore(&info->lock,flags); |
1885 | 1888 | ||
1886 | mgslpc_change_params(info); | 1889 | mgslpc_change_params(info, tty); |
1887 | 1890 | ||
1888 | return 0; | 1891 | return 0; |
1889 | } | 1892 | } |
@@ -1944,7 +1947,7 @@ static int set_interface(MGSLPC_INFO * info, int if_mode) | |||
1944 | return 0; | 1947 | return 0; |
1945 | } | 1948 | } |
1946 | 1949 | ||
1947 | static int set_txenable(MGSLPC_INFO * info, int enable) | 1950 | static int set_txenable(MGSLPC_INFO * info, int enable, struct tty_struct *tty) |
1948 | { | 1951 | { |
1949 | unsigned long flags; | 1952 | unsigned long flags; |
1950 | 1953 | ||
@@ -1954,7 +1957,7 @@ static int set_txenable(MGSLPC_INFO * info, int enable) | |||
1954 | spin_lock_irqsave(&info->lock,flags); | 1957 | spin_lock_irqsave(&info->lock,flags); |
1955 | if (enable) { | 1958 | if (enable) { |
1956 | if (!info->tx_enabled) | 1959 | if (!info->tx_enabled) |
1957 | tx_start(info); | 1960 | tx_start(info, tty); |
1958 | } else { | 1961 | } else { |
1959 | if (info->tx_enabled) | 1962 | if (info->tx_enabled) |
1960 | tx_stop(info); | 1963 | tx_stop(info); |
@@ -2263,6 +2266,11 @@ static int mgslpc_ioctl(struct tty_struct *tty, struct file * file, | |||
2263 | unsigned int cmd, unsigned long arg) | 2266 | unsigned int cmd, unsigned long arg) |
2264 | { | 2267 | { |
2265 | MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; | 2268 | MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; |
2269 | int error; | ||
2270 | struct mgsl_icount cnow; /* kernel counter temps */ | ||
2271 | struct serial_icounter_struct __user *p_cuser; /* user space */ | ||
2272 | void __user *argp = (void __user *)arg; | ||
2273 | unsigned long flags; | ||
2266 | 2274 | ||
2267 | if (debug_level >= DEBUG_LEVEL_INFO) | 2275 | if (debug_level >= DEBUG_LEVEL_INFO) |
2268 | printk("%s(%d):mgslpc_ioctl %s cmd=%08X\n", __FILE__,__LINE__, | 2276 | printk("%s(%d):mgslpc_ioctl %s cmd=%08X\n", __FILE__,__LINE__, |
@@ -2277,22 +2285,11 @@ static int mgslpc_ioctl(struct tty_struct *tty, struct file * file, | |||
2277 | return -EIO; | 2285 | return -EIO; |
2278 | } | 2286 | } |
2279 | 2287 | ||
2280 | return ioctl_common(info, cmd, arg); | ||
2281 | } | ||
2282 | |||
2283 | static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg) | ||
2284 | { | ||
2285 | int error; | ||
2286 | struct mgsl_icount cnow; /* kernel counter temps */ | ||
2287 | struct serial_icounter_struct __user *p_cuser; /* user space */ | ||
2288 | void __user *argp = (void __user *)arg; | ||
2289 | unsigned long flags; | ||
2290 | |||
2291 | switch (cmd) { | 2288 | switch (cmd) { |
2292 | case MGSL_IOCGPARAMS: | 2289 | case MGSL_IOCGPARAMS: |
2293 | return get_params(info, argp); | 2290 | return get_params(info, argp); |
2294 | case MGSL_IOCSPARAMS: | 2291 | case MGSL_IOCSPARAMS: |
2295 | return set_params(info, argp); | 2292 | return set_params(info, argp, tty); |
2296 | case MGSL_IOCGTXIDLE: | 2293 | case MGSL_IOCGTXIDLE: |
2297 | return get_txidle(info, argp); | 2294 | return get_txidle(info, argp); |
2298 | case MGSL_IOCSTXIDLE: | 2295 | case MGSL_IOCSTXIDLE: |
@@ -2302,7 +2299,7 @@ static int ioctl_common(MGSLPC_INFO *info, unsigned int cmd, unsigned long arg) | |||
2302 | case MGSL_IOCSIF: | 2299 | case MGSL_IOCSIF: |
2303 | return set_interface(info,(int)arg); | 2300 | return set_interface(info,(int)arg); |
2304 | case MGSL_IOCTXENABLE: | 2301 | case MGSL_IOCTXENABLE: |
2305 | return set_txenable(info,(int)arg); | 2302 | return set_txenable(info,(int)arg, tty); |
2306 | case MGSL_IOCRXENABLE: | 2303 | case MGSL_IOCRXENABLE: |
2307 | return set_rxenable(info,(int)arg); | 2304 | return set_rxenable(info,(int)arg); |
2308 | case MGSL_IOCTXABORT: | 2305 | case MGSL_IOCTXABORT: |
@@ -2369,7 +2366,7 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term | |||
2369 | == RELEVANT_IFLAG(old_termios->c_iflag))) | 2366 | == RELEVANT_IFLAG(old_termios->c_iflag))) |
2370 | return; | 2367 | return; |
2371 | 2368 | ||
2372 | mgslpc_change_params(info); | 2369 | mgslpc_change_params(info, tty); |
2373 | 2370 | ||
2374 | /* Handle transition to B0 status */ | 2371 | /* Handle transition to B0 status */ |
2375 | if (old_termios->c_cflag & CBAUD && | 2372 | if (old_termios->c_cflag & CBAUD && |
@@ -2404,81 +2401,34 @@ static void mgslpc_set_termios(struct tty_struct *tty, struct ktermios *old_term | |||
2404 | static void mgslpc_close(struct tty_struct *tty, struct file * filp) | 2401 | static void mgslpc_close(struct tty_struct *tty, struct file * filp) |
2405 | { | 2402 | { |
2406 | MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; | 2403 | MGSLPC_INFO * info = (MGSLPC_INFO *)tty->driver_data; |
2404 | struct tty_port *port = &info->port; | ||
2407 | 2405 | ||
2408 | if (mgslpc_paranoia_check(info, tty->name, "mgslpc_close")) | 2406 | if (mgslpc_paranoia_check(info, tty->name, "mgslpc_close")) |
2409 | return; | 2407 | return; |
2410 | 2408 | ||
2411 | if (debug_level >= DEBUG_LEVEL_INFO) | 2409 | if (debug_level >= DEBUG_LEVEL_INFO) |
2412 | printk("%s(%d):mgslpc_close(%s) entry, count=%d\n", | 2410 | printk("%s(%d):mgslpc_close(%s) entry, count=%d\n", |
2413 | __FILE__,__LINE__, info->device_name, info->count); | 2411 | __FILE__,__LINE__, info->device_name, port->count); |
2414 | |||
2415 | if (!info->count) | ||
2416 | return; | ||
2417 | 2412 | ||
2418 | if (tty_hung_up_p(filp)) | 2413 | WARN_ON(!port->count); |
2419 | goto cleanup; | ||
2420 | |||
2421 | if ((tty->count == 1) && (info->count != 1)) { | ||
2422 | /* | ||
2423 | * tty->count is 1 and the tty structure will be freed. | ||
2424 | * info->count should be one in this case. | ||
2425 | * if it's not, correct it so that the port is shutdown. | ||
2426 | */ | ||
2427 | printk("mgslpc_close: bad refcount; tty->count is 1, " | ||
2428 | "info->count is %d\n", info->count); | ||
2429 | info->count = 1; | ||
2430 | } | ||
2431 | 2414 | ||
2432 | info->count--; | 2415 | if (tty_port_close_start(port, tty, filp) == 0) |
2433 | |||
2434 | /* if at least one open remaining, leave hardware active */ | ||
2435 | if (info->count) | ||
2436 | goto cleanup; | 2416 | goto cleanup; |
2437 | 2417 | ||
2438 | info->flags |= ASYNC_CLOSING; | 2418 | if (port->flags & ASYNC_INITIALIZED) |
2439 | |||
2440 | /* set tty->closing to notify line discipline to | ||
2441 | * only process XON/XOFF characters. Only the N_TTY | ||
2442 | * discipline appears to use this (ppp does not). | ||
2443 | */ | ||
2444 | tty->closing = 1; | ||
2445 | |||
2446 | /* wait for transmit data to clear all layers */ | ||
2447 | |||
2448 | if (info->closing_wait != ASYNC_CLOSING_WAIT_NONE) { | ||
2449 | if (debug_level >= DEBUG_LEVEL_INFO) | ||
2450 | printk("%s(%d):mgslpc_close(%s) calling tty_wait_until_sent\n", | ||
2451 | __FILE__,__LINE__, info->device_name ); | ||
2452 | tty_wait_until_sent(tty, info->closing_wait); | ||
2453 | } | ||
2454 | |||
2455 | if (info->flags & ASYNC_INITIALIZED) | ||
2456 | mgslpc_wait_until_sent(tty, info->timeout); | 2419 | mgslpc_wait_until_sent(tty, info->timeout); |
2457 | 2420 | ||
2458 | mgslpc_flush_buffer(tty); | 2421 | mgslpc_flush_buffer(tty); |
2459 | 2422 | ||
2460 | tty_ldisc_flush(tty); | 2423 | tty_ldisc_flush(tty); |
2461 | 2424 | shutdown(info, tty); | |
2462 | shutdown(info); | 2425 | |
2463 | 2426 | tty_port_close_end(port, tty); | |
2464 | tty->closing = 0; | 2427 | tty_port_tty_set(port, NULL); |
2465 | info->tty = NULL; | ||
2466 | |||
2467 | if (info->blocked_open) { | ||
2468 | if (info->close_delay) { | ||
2469 | msleep_interruptible(jiffies_to_msecs(info->close_delay)); | ||
2470 | } | ||
2471 | wake_up_interruptible(&info->open_wait); | ||
2472 | } | ||
2473 | |||
2474 | info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); | ||
2475 | |||
2476 | wake_up_interruptible(&info->close_wait); | ||
2477 | |||
2478 | cleanup: | 2428 | cleanup: |
2479 | if (debug_level >= DEBUG_LEVEL_INFO) | 2429 | if (debug_level >= DEBUG_LEVEL_INFO) |
2480 | printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__, | 2430 | printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__,__LINE__, |
2481 | tty->driver->name, info->count); | 2431 | tty->driver->name, port->count); |
2482 | } | 2432 | } |
2483 | 2433 | ||
2484 | /* Wait until the transmitter is empty. | 2434 | /* Wait until the transmitter is empty. |
@@ -2498,7 +2448,7 @@ static void mgslpc_wait_until_sent(struct tty_struct *tty, int timeout) | |||
2498 | if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent")) | 2448 | if (mgslpc_paranoia_check(info, tty->name, "mgslpc_wait_until_sent")) |
2499 | return; | 2449 | return; |
2500 | 2450 | ||
2501 | if (!(info->flags & ASYNC_INITIALIZED)) | 2451 | if (!(info->port.flags & ASYNC_INITIALIZED)) |
2502 | goto exit; | 2452 | goto exit; |
2503 | 2453 | ||
2504 | orig_jiffies = jiffies; | 2454 | orig_jiffies = jiffies; |
@@ -2559,120 +2509,40 @@ static void mgslpc_hangup(struct tty_struct *tty) | |||
2559 | return; | 2509 | return; |
2560 | 2510 | ||
2561 | mgslpc_flush_buffer(tty); | 2511 | mgslpc_flush_buffer(tty); |
2562 | shutdown(info); | 2512 | shutdown(info, tty); |
2563 | 2513 | tty_port_hangup(&info->port); | |
2564 | info->count = 0; | ||
2565 | info->flags &= ~ASYNC_NORMAL_ACTIVE; | ||
2566 | info->tty = NULL; | ||
2567 | |||
2568 | wake_up_interruptible(&info->open_wait); | ||
2569 | } | 2514 | } |
2570 | 2515 | ||
2571 | /* Block the current process until the specified port | 2516 | static int carrier_raised(struct tty_port *port) |
2572 | * is ready to be opened. | ||
2573 | */ | ||
2574 | static int block_til_ready(struct tty_struct *tty, struct file *filp, | ||
2575 | MGSLPC_INFO *info) | ||
2576 | { | 2517 | { |
2577 | DECLARE_WAITQUEUE(wait, current); | 2518 | MGSLPC_INFO *info = container_of(port, MGSLPC_INFO, port); |
2578 | int retval; | 2519 | unsigned long flags; |
2579 | bool do_clocal = false; | ||
2580 | bool extra_count = false; | ||
2581 | unsigned long flags; | ||
2582 | |||
2583 | if (debug_level >= DEBUG_LEVEL_INFO) | ||
2584 | printk("%s(%d):block_til_ready on %s\n", | ||
2585 | __FILE__,__LINE__, tty->driver->name ); | ||
2586 | |||
2587 | if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ | ||
2588 | /* nonblock mode is set or port is not enabled */ | ||
2589 | /* just verify that callout device is not active */ | ||
2590 | info->flags |= ASYNC_NORMAL_ACTIVE; | ||
2591 | return 0; | ||
2592 | } | ||
2593 | |||
2594 | if (tty->termios->c_cflag & CLOCAL) | ||
2595 | do_clocal = true; | ||
2596 | |||
2597 | /* Wait for carrier detect and the line to become | ||
2598 | * free (i.e., not in use by the callout). While we are in | ||
2599 | * this loop, info->count is dropped by one, so that | ||
2600 | * mgslpc_close() knows when to free things. We restore it upon | ||
2601 | * exit, either normal or abnormal. | ||
2602 | */ | ||
2603 | |||
2604 | retval = 0; | ||
2605 | add_wait_queue(&info->open_wait, &wait); | ||
2606 | |||
2607 | if (debug_level >= DEBUG_LEVEL_INFO) | ||
2608 | printk("%s(%d):block_til_ready before block on %s count=%d\n", | ||
2609 | __FILE__,__LINE__, tty->driver->name, info->count ); | ||
2610 | |||
2611 | spin_lock_irqsave(&info->lock, flags); | ||
2612 | if (!tty_hung_up_p(filp)) { | ||
2613 | extra_count = true; | ||
2614 | info->count--; | ||
2615 | } | ||
2616 | spin_unlock_irqrestore(&info->lock, flags); | ||
2617 | info->blocked_open++; | ||
2618 | |||
2619 | while (1) { | ||
2620 | if ((tty->termios->c_cflag & CBAUD)) { | ||
2621 | spin_lock_irqsave(&info->lock,flags); | ||
2622 | info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; | ||
2623 | set_signals(info); | ||
2624 | spin_unlock_irqrestore(&info->lock,flags); | ||
2625 | } | ||
2626 | |||
2627 | set_current_state(TASK_INTERRUPTIBLE); | ||
2628 | |||
2629 | if (tty_hung_up_p(filp) || !(info->flags & ASYNC_INITIALIZED)){ | ||
2630 | retval = (info->flags & ASYNC_HUP_NOTIFY) ? | ||
2631 | -EAGAIN : -ERESTARTSYS; | ||
2632 | break; | ||
2633 | } | ||
2634 | |||
2635 | spin_lock_irqsave(&info->lock,flags); | ||
2636 | get_signals(info); | ||
2637 | spin_unlock_irqrestore(&info->lock,flags); | ||
2638 | |||
2639 | if (!(info->flags & ASYNC_CLOSING) && | ||
2640 | (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) { | ||
2641 | break; | ||
2642 | } | ||
2643 | |||
2644 | if (signal_pending(current)) { | ||
2645 | retval = -ERESTARTSYS; | ||
2646 | break; | ||
2647 | } | ||
2648 | |||
2649 | if (debug_level >= DEBUG_LEVEL_INFO) | ||
2650 | printk("%s(%d):block_til_ready blocking on %s count=%d\n", | ||
2651 | __FILE__,__LINE__, tty->driver->name, info->count ); | ||
2652 | |||
2653 | schedule(); | ||
2654 | } | ||
2655 | |||
2656 | set_current_state(TASK_RUNNING); | ||
2657 | remove_wait_queue(&info->open_wait, &wait); | ||
2658 | 2520 | ||
2659 | if (extra_count) | 2521 | spin_lock_irqsave(&info->lock,flags); |
2660 | info->count++; | 2522 | get_signals(info); |
2661 | info->blocked_open--; | 2523 | spin_unlock_irqrestore(&info->lock,flags); |
2662 | 2524 | ||
2663 | if (debug_level >= DEBUG_LEVEL_INFO) | 2525 | if (info->serial_signals & SerialSignal_DCD) |
2664 | printk("%s(%d):block_til_ready after blocking on %s count=%d\n", | 2526 | return 1; |
2665 | __FILE__,__LINE__, tty->driver->name, info->count ); | 2527 | return 0; |
2528 | } | ||
2666 | 2529 | ||
2667 | if (!retval) | 2530 | static void raise_dtr_rts(struct tty_port *port) |
2668 | info->flags |= ASYNC_NORMAL_ACTIVE; | 2531 | { |
2532 | MGSLPC_INFO *info = container_of(port, MGSLPC_INFO, port); | ||
2533 | unsigned long flags; | ||
2669 | 2534 | ||
2670 | return retval; | 2535 | spin_lock_irqsave(&info->lock,flags); |
2536 | info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; | ||
2537 | set_signals(info); | ||
2538 | spin_unlock_irqrestore(&info->lock,flags); | ||
2671 | } | 2539 | } |
2672 | 2540 | ||
2541 | |||
2673 | static int mgslpc_open(struct tty_struct *tty, struct file * filp) | 2542 | static int mgslpc_open(struct tty_struct *tty, struct file * filp) |
2674 | { | 2543 | { |
2675 | MGSLPC_INFO *info; | 2544 | MGSLPC_INFO *info; |
2545 | struct tty_port *port; | ||
2676 | int retval, line; | 2546 | int retval, line; |
2677 | unsigned long flags; | 2547 | unsigned long flags; |
2678 | 2548 | ||
@@ -2691,23 +2561,24 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) | |||
2691 | if (mgslpc_paranoia_check(info, tty->name, "mgslpc_open")) | 2561 | if (mgslpc_paranoia_check(info, tty->name, "mgslpc_open")) |
2692 | return -ENODEV; | 2562 | return -ENODEV; |
2693 | 2563 | ||
2564 | port = &info->port; | ||
2694 | tty->driver_data = info; | 2565 | tty->driver_data = info; |
2695 | info->tty = tty; | 2566 | tty_port_tty_set(port, tty); |
2696 | 2567 | ||
2697 | if (debug_level >= DEBUG_LEVEL_INFO) | 2568 | if (debug_level >= DEBUG_LEVEL_INFO) |
2698 | printk("%s(%d):mgslpc_open(%s), old ref count = %d\n", | 2569 | printk("%s(%d):mgslpc_open(%s), old ref count = %d\n", |
2699 | __FILE__,__LINE__,tty->driver->name, info->count); | 2570 | __FILE__,__LINE__,tty->driver->name, port->count); |
2700 | 2571 | ||
2701 | /* If port is closing, signal caller to try again */ | 2572 | /* If port is closing, signal caller to try again */ |
2702 | if (tty_hung_up_p(filp) || info->flags & ASYNC_CLOSING){ | 2573 | if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){ |
2703 | if (info->flags & ASYNC_CLOSING) | 2574 | if (port->flags & ASYNC_CLOSING) |
2704 | interruptible_sleep_on(&info->close_wait); | 2575 | interruptible_sleep_on(&port->close_wait); |
2705 | retval = ((info->flags & ASYNC_HUP_NOTIFY) ? | 2576 | retval = ((port->flags & ASYNC_HUP_NOTIFY) ? |
2706 | -EAGAIN : -ERESTARTSYS); | 2577 | -EAGAIN : -ERESTARTSYS); |
2707 | goto cleanup; | 2578 | goto cleanup; |
2708 | } | 2579 | } |
2709 | 2580 | ||
2710 | info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0; | 2581 | tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; |
2711 | 2582 | ||
2712 | spin_lock_irqsave(&info->netlock, flags); | 2583 | spin_lock_irqsave(&info->netlock, flags); |
2713 | if (info->netcount) { | 2584 | if (info->netcount) { |
@@ -2715,17 +2586,19 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) | |||
2715 | spin_unlock_irqrestore(&info->netlock, flags); | 2586 | spin_unlock_irqrestore(&info->netlock, flags); |
2716 | goto cleanup; | 2587 | goto cleanup; |
2717 | } | 2588 | } |
2718 | info->count++; | 2589 | spin_lock(&port->lock); |
2590 | port->count++; | ||
2591 | spin_unlock(&port->lock); | ||
2719 | spin_unlock_irqrestore(&info->netlock, flags); | 2592 | spin_unlock_irqrestore(&info->netlock, flags); |
2720 | 2593 | ||
2721 | if (info->count == 1) { | 2594 | if (port->count == 1) { |
2722 | /* 1st open on this device, init hardware */ | 2595 | /* 1st open on this device, init hardware */ |
2723 | retval = startup(info); | 2596 | retval = startup(info, tty); |
2724 | if (retval < 0) | 2597 | if (retval < 0) |
2725 | goto cleanup; | 2598 | goto cleanup; |
2726 | } | 2599 | } |
2727 | 2600 | ||
2728 | retval = block_til_ready(tty, filp, info); | 2601 | retval = tty_port_block_til_ready(&info->port, tty, filp); |
2729 | if (retval) { | 2602 | if (retval) { |
2730 | if (debug_level >= DEBUG_LEVEL_INFO) | 2603 | if (debug_level >= DEBUG_LEVEL_INFO) |
2731 | printk("%s(%d):block_til_ready(%s) returned %d\n", | 2604 | printk("%s(%d):block_til_ready(%s) returned %d\n", |
@@ -2739,13 +2612,6 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp) | |||
2739 | retval = 0; | 2612 | retval = 0; |
2740 | 2613 | ||
2741 | cleanup: | 2614 | cleanup: |
2742 | if (retval) { | ||
2743 | if (tty->count == 1) | ||
2744 | info->tty = NULL; /* tty layer will release tty struct */ | ||
2745 | if(info->count) | ||
2746 | info->count--; | ||
2747 | } | ||
2748 | |||
2749 | return retval; | 2615 | return retval; |
2750 | } | 2616 | } |
2751 | 2617 | ||
@@ -3500,7 +3366,7 @@ static void rx_start(MGSLPC_INFO *info) | |||
3500 | info->rx_enabled = true; | 3366 | info->rx_enabled = true; |
3501 | } | 3367 | } |
3502 | 3368 | ||
3503 | static void tx_start(MGSLPC_INFO *info) | 3369 | static void tx_start(MGSLPC_INFO *info, struct tty_struct *tty) |
3504 | { | 3370 | { |
3505 | if (debug_level >= DEBUG_LEVEL_ISR) | 3371 | if (debug_level >= DEBUG_LEVEL_ISR) |
3506 | printk("%s(%d):tx_start(%s)\n", | 3372 | printk("%s(%d):tx_start(%s)\n", |
@@ -3524,11 +3390,11 @@ static void tx_start(MGSLPC_INFO *info) | |||
3524 | if (info->params.mode == MGSL_MODE_ASYNC) { | 3390 | if (info->params.mode == MGSL_MODE_ASYNC) { |
3525 | if (!info->tx_active) { | 3391 | if (!info->tx_active) { |
3526 | info->tx_active = true; | 3392 | info->tx_active = true; |
3527 | tx_ready(info); | 3393 | tx_ready(info, tty); |
3528 | } | 3394 | } |
3529 | } else { | 3395 | } else { |
3530 | info->tx_active = true; | 3396 | info->tx_active = true; |
3531 | tx_ready(info); | 3397 | tx_ready(info, tty); |
3532 | mod_timer(&info->tx_timer, jiffies + | 3398 | mod_timer(&info->tx_timer, jiffies + |
3533 | msecs_to_jiffies(5000)); | 3399 | msecs_to_jiffies(5000)); |
3534 | } | 3400 | } |
@@ -3849,13 +3715,12 @@ static void rx_reset_buffers(MGSLPC_INFO *info) | |||
3849 | * | 3715 | * |
3850 | * Returns true if frame returned, otherwise false | 3716 | * Returns true if frame returned, otherwise false |
3851 | */ | 3717 | */ |
3852 | static bool rx_get_frame(MGSLPC_INFO *info) | 3718 | static bool rx_get_frame(MGSLPC_INFO *info, struct tty_struct *tty) |
3853 | { | 3719 | { |
3854 | unsigned short status; | 3720 | unsigned short status; |
3855 | RXBUF *buf; | 3721 | RXBUF *buf; |
3856 | unsigned int framesize = 0; | 3722 | unsigned int framesize = 0; |
3857 | unsigned long flags; | 3723 | unsigned long flags; |
3858 | struct tty_struct *tty = info->tty; | ||
3859 | bool return_frame = false; | 3724 | bool return_frame = false; |
3860 | 3725 | ||
3861 | if (info->rx_frame_count == 0) | 3726 | if (info->rx_frame_count == 0) |
@@ -4075,7 +3940,11 @@ static void tx_timeout(unsigned long context) | |||
4075 | hdlcdev_tx_done(info); | 3940 | hdlcdev_tx_done(info); |
4076 | else | 3941 | else |
4077 | #endif | 3942 | #endif |
4078 | bh_transmit(info); | 3943 | { |
3944 | struct tty_struct *tty = tty_port_tty_get(&info->port); | ||
3945 | bh_transmit(info, tty); | ||
3946 | tty_kref_put(tty); | ||
3947 | } | ||
4079 | } | 3948 | } |
4080 | 3949 | ||
4081 | #if SYNCLINK_GENERIC_HDLC | 3950 | #if SYNCLINK_GENERIC_HDLC |
@@ -4094,11 +3963,12 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding, | |||
4094 | unsigned short parity) | 3963 | unsigned short parity) |
4095 | { | 3964 | { |
4096 | MGSLPC_INFO *info = dev_to_port(dev); | 3965 | MGSLPC_INFO *info = dev_to_port(dev); |
3966 | struct tty_struct *tty; | ||
4097 | unsigned char new_encoding; | 3967 | unsigned char new_encoding; |
4098 | unsigned short new_crctype; | 3968 | unsigned short new_crctype; |
4099 | 3969 | ||
4100 | /* return error if TTY interface open */ | 3970 | /* return error if TTY interface open */ |
4101 | if (info->count) | 3971 | if (info->port.count) |
4102 | return -EBUSY; | 3972 | return -EBUSY; |
4103 | 3973 | ||
4104 | switch (encoding) | 3974 | switch (encoding) |
@@ -4123,8 +3993,11 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding, | |||
4123 | info->params.crc_type = new_crctype; | 3993 | info->params.crc_type = new_crctype; |
4124 | 3994 | ||
4125 | /* if network interface up, reprogram hardware */ | 3995 | /* if network interface up, reprogram hardware */ |
4126 | if (info->netcount) | 3996 | if (info->netcount) { |
4127 | mgslpc_program_hw(info); | 3997 | tty = tty_port_tty_get(&info->port); |
3998 | mgslpc_program_hw(info, tty); | ||
3999 | tty_kref_put(tty); | ||
4000 | } | ||
4128 | 4001 | ||
4129 | return 0; | 4002 | return 0; |
4130 | } | 4003 | } |
@@ -4165,8 +4038,11 @@ static int hdlcdev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
4165 | 4038 | ||
4166 | /* start hardware transmitter if necessary */ | 4039 | /* start hardware transmitter if necessary */ |
4167 | spin_lock_irqsave(&info->lock,flags); | 4040 | spin_lock_irqsave(&info->lock,flags); |
4168 | if (!info->tx_active) | 4041 | if (!info->tx_active) { |
4169 | tx_start(info); | 4042 | struct tty_struct *tty = tty_port_tty_get(&info->port); |
4043 | tx_start(info, tty); | ||
4044 | tty_kref_put(tty); | ||
4045 | } | ||
4170 | spin_unlock_irqrestore(&info->lock,flags); | 4046 | spin_unlock_irqrestore(&info->lock,flags); |
4171 | 4047 | ||
4172 | return 0; | 4048 | return 0; |
@@ -4183,6 +4059,7 @@ static int hdlcdev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
4183 | static int hdlcdev_open(struct net_device *dev) | 4059 | static int hdlcdev_open(struct net_device *dev) |
4184 | { | 4060 | { |
4185 | MGSLPC_INFO *info = dev_to_port(dev); | 4061 | MGSLPC_INFO *info = dev_to_port(dev); |
4062 | struct tty_struct *tty; | ||
4186 | int rc; | 4063 | int rc; |
4187 | unsigned long flags; | 4064 | unsigned long flags; |
4188 | 4065 | ||
@@ -4195,7 +4072,7 @@ static int hdlcdev_open(struct net_device *dev) | |||
4195 | 4072 | ||
4196 | /* arbitrate between network and tty opens */ | 4073 | /* arbitrate between network and tty opens */ |
4197 | spin_lock_irqsave(&info->netlock, flags); | 4074 | spin_lock_irqsave(&info->netlock, flags); |
4198 | if (info->count != 0 || info->netcount != 0) { | 4075 | if (info->port.count != 0 || info->netcount != 0) { |
4199 | printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name); | 4076 | printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name); |
4200 | spin_unlock_irqrestore(&info->netlock, flags); | 4077 | spin_unlock_irqrestore(&info->netlock, flags); |
4201 | return -EBUSY; | 4078 | return -EBUSY; |
@@ -4203,17 +4080,19 @@ static int hdlcdev_open(struct net_device *dev) | |||
4203 | info->netcount=1; | 4080 | info->netcount=1; |
4204 | spin_unlock_irqrestore(&info->netlock, flags); | 4081 | spin_unlock_irqrestore(&info->netlock, flags); |
4205 | 4082 | ||
4083 | tty = tty_port_tty_get(&info->port); | ||
4206 | /* claim resources and init adapter */ | 4084 | /* claim resources and init adapter */ |
4207 | if ((rc = startup(info)) != 0) { | 4085 | if ((rc = startup(info, tty)) != 0) { |
4086 | tty_kref_put(tty); | ||
4208 | spin_lock_irqsave(&info->netlock, flags); | 4087 | spin_lock_irqsave(&info->netlock, flags); |
4209 | info->netcount=0; | 4088 | info->netcount=0; |
4210 | spin_unlock_irqrestore(&info->netlock, flags); | 4089 | spin_unlock_irqrestore(&info->netlock, flags); |
4211 | return rc; | 4090 | return rc; |
4212 | } | 4091 | } |
4213 | |||
4214 | /* assert DTR and RTS, apply hardware settings */ | 4092 | /* assert DTR and RTS, apply hardware settings */ |
4215 | info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; | 4093 | info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; |
4216 | mgslpc_program_hw(info); | 4094 | mgslpc_program_hw(info, tty); |
4095 | tty_kref_put(tty); | ||
4217 | 4096 | ||
4218 | /* enable network layer transmit */ | 4097 | /* enable network layer transmit */ |
4219 | dev->trans_start = jiffies; | 4098 | dev->trans_start = jiffies; |
@@ -4241,6 +4120,7 @@ static int hdlcdev_open(struct net_device *dev) | |||
4241 | static int hdlcdev_close(struct net_device *dev) | 4120 | static int hdlcdev_close(struct net_device *dev) |
4242 | { | 4121 | { |
4243 | MGSLPC_INFO *info = dev_to_port(dev); | 4122 | MGSLPC_INFO *info = dev_to_port(dev); |
4123 | struct tty_struct *tty = tty_port_tty_get(&info->port); | ||
4244 | unsigned long flags; | 4124 | unsigned long flags; |
4245 | 4125 | ||
4246 | if (debug_level >= DEBUG_LEVEL_INFO) | 4126 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -4249,8 +4129,8 @@ static int hdlcdev_close(struct net_device *dev) | |||
4249 | netif_stop_queue(dev); | 4129 | netif_stop_queue(dev); |
4250 | 4130 | ||
4251 | /* shutdown adapter and release resources */ | 4131 | /* shutdown adapter and release resources */ |
4252 | shutdown(info); | 4132 | shutdown(info, tty); |
4253 | 4133 | tty_kref_put(tty); | |
4254 | hdlc_close(dev); | 4134 | hdlc_close(dev); |
4255 | 4135 | ||
4256 | spin_lock_irqsave(&info->netlock, flags); | 4136 | spin_lock_irqsave(&info->netlock, flags); |
@@ -4281,7 +4161,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
4281 | printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name); | 4161 | printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name); |
4282 | 4162 | ||
4283 | /* return error if TTY interface open */ | 4163 | /* return error if TTY interface open */ |
4284 | if (info->count) | 4164 | if (info->port.count) |
4285 | return -EBUSY; | 4165 | return -EBUSY; |
4286 | 4166 | ||
4287 | if (cmd != SIOCWANDEV) | 4167 | if (cmd != SIOCWANDEV) |
@@ -4354,8 +4234,11 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) | |||
4354 | info->params.clock_speed = 0; | 4234 | info->params.clock_speed = 0; |
4355 | 4235 | ||
4356 | /* if network interface up, reprogram hardware */ | 4236 | /* if network interface up, reprogram hardware */ |
4357 | if (info->netcount) | 4237 | if (info->netcount) { |
4358 | mgslpc_program_hw(info); | 4238 | struct tty_struct *tty = tty_port_tty_get(&info->port); |
4239 | mgslpc_program_hw(info, tty); | ||
4240 | tty_kref_put(tty); | ||
4241 | } | ||
4359 | return 0; | 4242 | return 0; |
4360 | 4243 | ||
4361 | default: | 4244 | default: |
diff --git a/drivers/char/pty.c b/drivers/char/pty.c index 6d4582712b1f..146c97613da0 100644 --- a/drivers/char/pty.c +++ b/drivers/char/pty.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * | 5 | * |
6 | * Added support for a Unix98-style ptmx device. | 6 | * Added support for a Unix98-style ptmx device. |
7 | * -- C. Scott Ananian <cananian@alumni.princeton.edu>, 14-Jan-1998 | 7 | * -- C. Scott Ananian <cananian@alumni.princeton.edu>, 14-Jan-1998 |
8 | * Added TTY_DO_WRITE_WAKEUP to enable n_tty to send POLL_OUT to | ||
9 | * waiting writers -- Sapan Bhatia <sapan@corewars.org> | ||
10 | * | 8 | * |
11 | * When reading this code see also fs/devpts. In particular note that the | 9 | * When reading this code see also fs/devpts. In particular note that the |
12 | * driver_data field is used by the devpts side as a binding to the devpts | 10 | * driver_data field is used by the devpts side as a binding to the devpts |
@@ -34,7 +32,7 @@ | |||
34 | 32 | ||
35 | /* These are global because they are accessed in tty_io.c */ | 33 | /* These are global because they are accessed in tty_io.c */ |
36 | #ifdef CONFIG_UNIX98_PTYS | 34 | #ifdef CONFIG_UNIX98_PTYS |
37 | struct tty_driver *ptm_driver; | 35 | static struct tty_driver *ptm_driver; |
38 | static struct tty_driver *pts_driver; | 36 | static struct tty_driver *pts_driver; |
39 | #endif | 37 | #endif |
40 | 38 | ||
@@ -217,7 +215,6 @@ static int pty_open(struct tty_struct *tty, struct file *filp) | |||
217 | 215 | ||
218 | clear_bit(TTY_OTHER_CLOSED, &tty->link->flags); | 216 | clear_bit(TTY_OTHER_CLOSED, &tty->link->flags); |
219 | set_bit(TTY_THROTTLED, &tty->flags); | 217 | set_bit(TTY_THROTTLED, &tty->flags); |
220 | set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); | ||
221 | retval = 0; | 218 | retval = 0; |
222 | out: | 219 | out: |
223 | return retval; | 220 | return retval; |
@@ -230,6 +227,55 @@ static void pty_set_termios(struct tty_struct *tty, | |||
230 | tty->termios->c_cflag |= (CS8 | CREAD); | 227 | tty->termios->c_cflag |= (CS8 | CREAD); |
231 | } | 228 | } |
232 | 229 | ||
230 | /** | ||
231 | * pty_do_resize - resize event | ||
232 | * @tty: tty being resized | ||
233 | * @real_tty: real tty (not the same as tty if using a pty/tty pair) | ||
234 | * @rows: rows (character) | ||
235 | * @cols: cols (character) | ||
236 | * | ||
237 | * Update the termios variables and send the neccessary signals to | ||
238 | * peform a terminal resize correctly | ||
239 | */ | ||
240 | |||
241 | int pty_resize(struct tty_struct *tty, struct winsize *ws) | ||
242 | { | ||
243 | struct pid *pgrp, *rpgrp; | ||
244 | unsigned long flags; | ||
245 | struct tty_struct *pty = tty->link; | ||
246 | |||
247 | /* For a PTY we need to lock the tty side */ | ||
248 | mutex_lock(&tty->termios_mutex); | ||
249 | if (!memcmp(ws, &tty->winsize, sizeof(*ws))) | ||
250 | goto done; | ||
251 | |||
252 | /* Get the PID values and reference them so we can | ||
253 | avoid holding the tty ctrl lock while sending signals. | ||
254 | We need to lock these individually however. */ | ||
255 | |||
256 | spin_lock_irqsave(&tty->ctrl_lock, flags); | ||
257 | pgrp = get_pid(tty->pgrp); | ||
258 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | ||
259 | |||
260 | spin_lock_irqsave(&pty->ctrl_lock, flags); | ||
261 | rpgrp = get_pid(pty->pgrp); | ||
262 | spin_unlock_irqrestore(&pty->ctrl_lock, flags); | ||
263 | |||
264 | if (pgrp) | ||
265 | kill_pgrp(pgrp, SIGWINCH, 1); | ||
266 | if (rpgrp != pgrp && rpgrp) | ||
267 | kill_pgrp(rpgrp, SIGWINCH, 1); | ||
268 | |||
269 | put_pid(pgrp); | ||
270 | put_pid(rpgrp); | ||
271 | |||
272 | tty->winsize = *ws; | ||
273 | pty->winsize = *ws; /* Never used so will go away soon */ | ||
274 | done: | ||
275 | mutex_unlock(&tty->termios_mutex); | ||
276 | return 0; | ||
277 | } | ||
278 | |||
233 | static int pty_install(struct tty_driver *driver, struct tty_struct *tty) | 279 | static int pty_install(struct tty_driver *driver, struct tty_struct *tty) |
234 | { | 280 | { |
235 | struct tty_struct *o_tty; | 281 | struct tty_struct *o_tty; |
@@ -290,6 +336,7 @@ static const struct tty_operations pty_ops = { | |||
290 | .chars_in_buffer = pty_chars_in_buffer, | 336 | .chars_in_buffer = pty_chars_in_buffer, |
291 | .unthrottle = pty_unthrottle, | 337 | .unthrottle = pty_unthrottle, |
292 | .set_termios = pty_set_termios, | 338 | .set_termios = pty_set_termios, |
339 | .resize = pty_resize | ||
293 | }; | 340 | }; |
294 | 341 | ||
295 | /* Traditional BSD devices */ | 342 | /* Traditional BSD devices */ |
@@ -319,6 +366,7 @@ static const struct tty_operations pty_ops_bsd = { | |||
319 | .unthrottle = pty_unthrottle, | 366 | .unthrottle = pty_unthrottle, |
320 | .set_termios = pty_set_termios, | 367 | .set_termios = pty_set_termios, |
321 | .ioctl = pty_bsd_ioctl, | 368 | .ioctl = pty_bsd_ioctl, |
369 | .resize = pty_resize | ||
322 | }; | 370 | }; |
323 | 371 | ||
324 | static void __init legacy_pty_init(void) | 372 | static void __init legacy_pty_init(void) |
@@ -561,7 +609,8 @@ static const struct tty_operations ptm_unix98_ops = { | |||
561 | .unthrottle = pty_unthrottle, | 609 | .unthrottle = pty_unthrottle, |
562 | .set_termios = pty_set_termios, | 610 | .set_termios = pty_set_termios, |
563 | .ioctl = pty_unix98_ioctl, | 611 | .ioctl = pty_unix98_ioctl, |
564 | .shutdown = pty_unix98_shutdown | 612 | .shutdown = pty_unix98_shutdown, |
613 | .resize = pty_resize | ||
565 | }; | 614 | }; |
566 | 615 | ||
567 | static const struct tty_operations pty_unix98_ops = { | 616 | static const struct tty_operations pty_unix98_ops = { |
diff --git a/drivers/char/random.c b/drivers/char/random.c index 675076f5fca8..7c13581ca9cd 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
@@ -407,7 +407,7 @@ struct entropy_store { | |||
407 | /* read-write data: */ | 407 | /* read-write data: */ |
408 | spinlock_t lock; | 408 | spinlock_t lock; |
409 | unsigned add_ptr; | 409 | unsigned add_ptr; |
410 | int entropy_count; /* Must at no time exceed ->POOLBITS! */ | 410 | int entropy_count; |
411 | int input_rotate; | 411 | int input_rotate; |
412 | }; | 412 | }; |
413 | 413 | ||
@@ -558,24 +558,43 @@ struct timer_rand_state { | |||
558 | unsigned dont_count_entropy:1; | 558 | unsigned dont_count_entropy:1; |
559 | }; | 559 | }; |
560 | 560 | ||
561 | #ifndef CONFIG_SPARSE_IRQ | ||
562 | |||
561 | static struct timer_rand_state *irq_timer_state[NR_IRQS]; | 563 | static struct timer_rand_state *irq_timer_state[NR_IRQS]; |
562 | 564 | ||
563 | static struct timer_rand_state *get_timer_rand_state(unsigned int irq) | 565 | static struct timer_rand_state *get_timer_rand_state(unsigned int irq) |
564 | { | 566 | { |
565 | if (irq >= nr_irqs) | ||
566 | return NULL; | ||
567 | |||
568 | return irq_timer_state[irq]; | 567 | return irq_timer_state[irq]; |
569 | } | 568 | } |
570 | 569 | ||
571 | static void set_timer_rand_state(unsigned int irq, struct timer_rand_state *state) | 570 | static void set_timer_rand_state(unsigned int irq, |
571 | struct timer_rand_state *state) | ||
572 | { | 572 | { |
573 | if (irq >= nr_irqs) | ||
574 | return; | ||
575 | |||
576 | irq_timer_state[irq] = state; | 573 | irq_timer_state[irq] = state; |
577 | } | 574 | } |
578 | 575 | ||
576 | #else | ||
577 | |||
578 | static struct timer_rand_state *get_timer_rand_state(unsigned int irq) | ||
579 | { | ||
580 | struct irq_desc *desc; | ||
581 | |||
582 | desc = irq_to_desc(irq); | ||
583 | |||
584 | return desc->timer_rand_state; | ||
585 | } | ||
586 | |||
587 | static void set_timer_rand_state(unsigned int irq, | ||
588 | struct timer_rand_state *state) | ||
589 | { | ||
590 | struct irq_desc *desc; | ||
591 | |||
592 | desc = irq_to_desc(irq); | ||
593 | |||
594 | desc->timer_rand_state = state; | ||
595 | } | ||
596 | #endif | ||
597 | |||
579 | static struct timer_rand_state input_timer_state; | 598 | static struct timer_rand_state input_timer_state; |
580 | 599 | ||
581 | /* | 600 | /* |
@@ -748,11 +767,10 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, | |||
748 | { | 767 | { |
749 | unsigned long flags; | 768 | unsigned long flags; |
750 | 769 | ||
751 | BUG_ON(r->entropy_count > r->poolinfo->POOLBITS); | ||
752 | |||
753 | /* Hold lock while accounting */ | 770 | /* Hold lock while accounting */ |
754 | spin_lock_irqsave(&r->lock, flags); | 771 | spin_lock_irqsave(&r->lock, flags); |
755 | 772 | ||
773 | BUG_ON(r->entropy_count > r->poolinfo->POOLBITS); | ||
756 | DEBUG_ENT("trying to extract %d bits from %s\n", | 774 | DEBUG_ENT("trying to extract %d bits from %s\n", |
757 | nbytes * 8, r->name); | 775 | nbytes * 8, r->name); |
758 | 776 | ||
@@ -933,9 +951,6 @@ void rand_initialize_irq(int irq) | |||
933 | { | 951 | { |
934 | struct timer_rand_state *state; | 952 | struct timer_rand_state *state; |
935 | 953 | ||
936 | if (irq >= nr_irqs) | ||
937 | return; | ||
938 | |||
939 | state = get_timer_rand_state(irq); | 954 | state = get_timer_rand_state(irq); |
940 | 955 | ||
941 | if (state) | 956 | if (state) |
diff --git a/drivers/char/rio/rio_linux.c b/drivers/char/rio/rio_linux.c index a8f68a3f14dd..2e8a6eed34be 100644 --- a/drivers/char/rio/rio_linux.c +++ b/drivers/char/rio/rio_linux.c | |||
@@ -173,7 +173,7 @@ static void rio_disable_tx_interrupts(void *ptr); | |||
173 | static void rio_enable_tx_interrupts(void *ptr); | 173 | static void rio_enable_tx_interrupts(void *ptr); |
174 | static void rio_disable_rx_interrupts(void *ptr); | 174 | static void rio_disable_rx_interrupts(void *ptr); |
175 | static void rio_enable_rx_interrupts(void *ptr); | 175 | static void rio_enable_rx_interrupts(void *ptr); |
176 | static int rio_get_CD(void *ptr); | 176 | static int rio_carrier_raised(struct tty_port *port); |
177 | static void rio_shutdown_port(void *ptr); | 177 | static void rio_shutdown_port(void *ptr); |
178 | static int rio_set_real_termios(void *ptr); | 178 | static int rio_set_real_termios(void *ptr); |
179 | static void rio_hungup(void *ptr); | 179 | static void rio_hungup(void *ptr); |
@@ -224,7 +224,6 @@ static struct real_driver rio_real_driver = { | |||
224 | rio_enable_tx_interrupts, | 224 | rio_enable_tx_interrupts, |
225 | rio_disable_rx_interrupts, | 225 | rio_disable_rx_interrupts, |
226 | rio_enable_rx_interrupts, | 226 | rio_enable_rx_interrupts, |
227 | rio_get_CD, | ||
228 | rio_shutdown_port, | 227 | rio_shutdown_port, |
229 | rio_set_real_termios, | 228 | rio_set_real_termios, |
230 | rio_chars_in_buffer, | 229 | rio_chars_in_buffer, |
@@ -476,9 +475,9 @@ static void rio_enable_rx_interrupts(void *ptr) | |||
476 | 475 | ||
477 | 476 | ||
478 | /* Jeez. Isn't this simple? */ | 477 | /* Jeez. Isn't this simple? */ |
479 | static int rio_get_CD(void *ptr) | 478 | static int rio_carrier_raised(struct tty_port *port) |
480 | { | 479 | { |
481 | struct Port *PortP = ptr; | 480 | struct Port *PortP = container_of(port, struct Port, gs.port); |
482 | int rv; | 481 | int rv; |
483 | 482 | ||
484 | func_enter(); | 483 | func_enter(); |
@@ -797,16 +796,9 @@ static int rio_init_drivers(void) | |||
797 | return 1; | 796 | return 1; |
798 | } | 797 | } |
799 | 798 | ||
800 | 799 | static const struct tty_port_operations rio_port_ops = { | |
801 | static void *ckmalloc(int size) | 800 | .carrier_raised = rio_carrier_raised, |
802 | { | 801 | }; |
803 | void *p; | ||
804 | |||
805 | p = kzalloc(size, GFP_KERNEL); | ||
806 | return p; | ||
807 | } | ||
808 | |||
809 | |||
810 | 802 | ||
811 | static int rio_init_datastructures(void) | 803 | static int rio_init_datastructures(void) |
812 | { | 804 | { |
@@ -826,33 +818,30 @@ static int rio_init_datastructures(void) | |||
826 | #define TMIO_SZ sizeof(struct termios *) | 818 | #define TMIO_SZ sizeof(struct termios *) |
827 | rio_dprintk(RIO_DEBUG_INIT, "getting : %Zd %Zd %Zd %Zd %Zd bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ); | 819 | rio_dprintk(RIO_DEBUG_INIT, "getting : %Zd %Zd %Zd %Zd %Zd bytes\n", RI_SZ, RIO_HOSTS * HOST_SZ, RIO_PORTS * PORT_SZ, RIO_PORTS * TMIO_SZ, RIO_PORTS * TMIO_SZ); |
828 | 820 | ||
829 | if (!(p = ckmalloc(RI_SZ))) | 821 | if (!(p = kzalloc(RI_SZ, GFP_KERNEL))) |
830 | goto free0; | 822 | goto free0; |
831 | if (!(p->RIOHosts = ckmalloc(RIO_HOSTS * HOST_SZ))) | 823 | if (!(p->RIOHosts = kzalloc(RIO_HOSTS * HOST_SZ, GFP_KERNEL))) |
832 | goto free1; | 824 | goto free1; |
833 | if (!(p->RIOPortp = ckmalloc(RIO_PORTS * PORT_SZ))) | 825 | if (!(p->RIOPortp = kzalloc(RIO_PORTS * PORT_SZ, GFP_KERNEL))) |
834 | goto free2; | 826 | goto free2; |
835 | p->RIOConf = RIOConf; | 827 | p->RIOConf = RIOConf; |
836 | rio_dprintk(RIO_DEBUG_INIT, "Got : %p %p %p\n", p, p->RIOHosts, p->RIOPortp); | 828 | rio_dprintk(RIO_DEBUG_INIT, "Got : %p %p %p\n", p, p->RIOHosts, p->RIOPortp); |
837 | 829 | ||
838 | #if 1 | 830 | #if 1 |
839 | for (i = 0; i < RIO_PORTS; i++) { | 831 | for (i = 0; i < RIO_PORTS; i++) { |
840 | port = p->RIOPortp[i] = ckmalloc(sizeof(struct Port)); | 832 | port = p->RIOPortp[i] = kzalloc(sizeof(struct Port), GFP_KERNEL); |
841 | if (!port) { | 833 | if (!port) { |
842 | goto free6; | 834 | goto free6; |
843 | } | 835 | } |
844 | rio_dprintk(RIO_DEBUG_INIT, "initing port %d (%d)\n", i, port->Mapped); | 836 | rio_dprintk(RIO_DEBUG_INIT, "initing port %d (%d)\n", i, port->Mapped); |
837 | tty_port_init(&port->gs.port); | ||
838 | port->gs.port.ops = &rio_port_ops; | ||
845 | port->PortNum = i; | 839 | port->PortNum = i; |
846 | port->gs.magic = RIO_MAGIC; | 840 | port->gs.magic = RIO_MAGIC; |
847 | port->gs.close_delay = HZ / 2; | 841 | port->gs.close_delay = HZ / 2; |
848 | port->gs.closing_wait = 30 * HZ; | 842 | port->gs.closing_wait = 30 * HZ; |
849 | port->gs.rd = &rio_real_driver; | 843 | port->gs.rd = &rio_real_driver; |
850 | spin_lock_init(&port->portSem); | 844 | spin_lock_init(&port->portSem); |
851 | /* | ||
852 | * Initializing wait queue | ||
853 | */ | ||
854 | init_waitqueue_head(&port->gs.port.open_wait); | ||
855 | init_waitqueue_head(&port->gs.port.close_wait); | ||
856 | } | 845 | } |
857 | #else | 846 | #else |
858 | /* We could postpone initializing them to when they are configured. */ | 847 | /* We could postpone initializing them to when they are configured. */ |
diff --git a/drivers/char/riscom8.c b/drivers/char/riscom8.c index 2c6c8f33d6b4..9af8d74875bc 100644 --- a/drivers/char/riscom8.c +++ b/drivers/char/riscom8.c | |||
@@ -857,98 +857,21 @@ static void rc_shutdown_port(struct tty_struct *tty, | |||
857 | rc_shutdown_board(bp); | 857 | rc_shutdown_board(bp); |
858 | } | 858 | } |
859 | 859 | ||
860 | static int block_til_ready(struct tty_struct *tty, struct file *filp, | 860 | static int carrier_raised(struct tty_port *port) |
861 | struct riscom_port *port) | ||
862 | { | 861 | { |
863 | DECLARE_WAITQUEUE(wait, current); | 862 | struct riscom_port *p = container_of(port, struct riscom_port, port); |
864 | struct riscom_board *bp = port_Board(port); | 863 | struct riscom_board *bp = port_Board(p); |
865 | int retval; | ||
866 | int do_clocal = 0; | ||
867 | int CD; | ||
868 | unsigned long flags; | 864 | unsigned long flags; |
869 | 865 | int CD; | |
870 | /* | 866 | |
871 | * If the device is in the middle of being closed, then block | ||
872 | * until it's done, and then try again. | ||
873 | */ | ||
874 | if (tty_hung_up_p(filp) || port->port.flags & ASYNC_CLOSING) { | ||
875 | interruptible_sleep_on(&port->port.close_wait); | ||
876 | if (port->port.flags & ASYNC_HUP_NOTIFY) | ||
877 | return -EAGAIN; | ||
878 | else | ||
879 | return -ERESTARTSYS; | ||
880 | } | ||
881 | |||
882 | /* | ||
883 | * If non-blocking mode is set, or the port is not enabled, | ||
884 | * then make the check up front and then exit. | ||
885 | */ | ||
886 | if ((filp->f_flags & O_NONBLOCK) || | ||
887 | (tty->flags & (1 << TTY_IO_ERROR))) { | ||
888 | port->port.flags |= ASYNC_NORMAL_ACTIVE; | ||
889 | return 0; | ||
890 | } | ||
891 | |||
892 | if (C_CLOCAL(tty)) | ||
893 | do_clocal = 1; | ||
894 | |||
895 | /* | ||
896 | * Block waiting for the carrier detect and the line to become | ||
897 | * free (i.e., not in use by the callout). While we are in | ||
898 | * this loop, info->count is dropped by one, so that | ||
899 | * rs_close() knows when to free things. We restore it upon | ||
900 | * exit, either normal or abnormal. | ||
901 | */ | ||
902 | retval = 0; | ||
903 | add_wait_queue(&port->port.open_wait, &wait); | ||
904 | |||
905 | spin_lock_irqsave(&riscom_lock, flags); | 867 | spin_lock_irqsave(&riscom_lock, flags); |
906 | 868 | rc_out(bp, CD180_CAR, port_No(p)); | |
907 | if (!tty_hung_up_p(filp)) | 869 | CD = rc_in(bp, CD180_MSVR) & MSVR_CD; |
908 | port->port.count--; | 870 | rc_out(bp, CD180_MSVR, MSVR_RTS); |
909 | 871 | bp->DTR &= ~(1u << port_No(p)); | |
872 | rc_out(bp, RC_DTR, bp->DTR); | ||
910 | spin_unlock_irqrestore(&riscom_lock, flags); | 873 | spin_unlock_irqrestore(&riscom_lock, flags); |
911 | 874 | return CD; | |
912 | port->port.blocked_open++; | ||
913 | while (1) { | ||
914 | spin_lock_irqsave(&riscom_lock, flags); | ||
915 | |||
916 | rc_out(bp, CD180_CAR, port_No(port)); | ||
917 | CD = rc_in(bp, CD180_MSVR) & MSVR_CD; | ||
918 | rc_out(bp, CD180_MSVR, MSVR_RTS); | ||
919 | bp->DTR &= ~(1u << port_No(port)); | ||
920 | rc_out(bp, RC_DTR, bp->DTR); | ||
921 | |||
922 | spin_unlock_irqrestore(&riscom_lock, flags); | ||
923 | |||
924 | set_current_state(TASK_INTERRUPTIBLE); | ||
925 | if (tty_hung_up_p(filp) || | ||
926 | !(port->port.flags & ASYNC_INITIALIZED)) { | ||
927 | if (port->port.flags & ASYNC_HUP_NOTIFY) | ||
928 | retval = -EAGAIN; | ||
929 | else | ||
930 | retval = -ERESTARTSYS; | ||
931 | break; | ||
932 | } | ||
933 | if (!(port->port.flags & ASYNC_CLOSING) && | ||
934 | (do_clocal || CD)) | ||
935 | break; | ||
936 | if (signal_pending(current)) { | ||
937 | retval = -ERESTARTSYS; | ||
938 | break; | ||
939 | } | ||
940 | schedule(); | ||
941 | } | ||
942 | __set_current_state(TASK_RUNNING); | ||
943 | remove_wait_queue(&port->port.open_wait, &wait); | ||
944 | if (!tty_hung_up_p(filp)) | ||
945 | port->port.count++; | ||
946 | port->port.blocked_open--; | ||
947 | if (retval) | ||
948 | return retval; | ||
949 | |||
950 | port->port.flags |= ASYNC_NORMAL_ACTIVE; | ||
951 | return 0; | ||
952 | } | 875 | } |
953 | 876 | ||
954 | static int rc_open(struct tty_struct *tty, struct file *filp) | 877 | static int rc_open(struct tty_struct *tty, struct file *filp) |
@@ -977,13 +900,13 @@ static int rc_open(struct tty_struct *tty, struct file *filp) | |||
977 | 900 | ||
978 | error = rc_setup_port(bp, port); | 901 | error = rc_setup_port(bp, port); |
979 | if (error == 0) | 902 | if (error == 0) |
980 | error = block_til_ready(tty, filp, port); | 903 | error = tty_port_block_til_ready(&port->port, tty, filp); |
981 | return error; | 904 | return error; |
982 | } | 905 | } |
983 | 906 | ||
984 | static void rc_flush_buffer(struct tty_struct *tty) | 907 | static void rc_flush_buffer(struct tty_struct *tty) |
985 | { | 908 | { |
986 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 909 | struct riscom_port *port = tty->driver_data; |
987 | unsigned long flags; | 910 | unsigned long flags; |
988 | 911 | ||
989 | if (rc_paranoia_check(port, tty->name, "rc_flush_buffer")) | 912 | if (rc_paranoia_check(port, tty->name, "rc_flush_buffer")) |
@@ -998,7 +921,7 @@ static void rc_flush_buffer(struct tty_struct *tty) | |||
998 | 921 | ||
999 | static void rc_close(struct tty_struct *tty, struct file *filp) | 922 | static void rc_close(struct tty_struct *tty, struct file *filp) |
1000 | { | 923 | { |
1001 | struct riscom_port *port = (struct riscom_port *) tty->driver_data; | 924 | struct riscom_port *port = tty->driver_data; |
1002 | struct riscom_board *bp; | 925 | struct riscom_board *bp; |
1003 | unsigned long flags; | 926 | unsigned long flags; |
1004 | unsigned long timeout; | 927 | unsigned long timeout; |
@@ -1006,40 +929,19 @@ static void rc_close(struct tty_struct *tty, struct file *filp) | |||
1006 | if (!port || rc_paranoia_check(port, tty->name, "close")) | 929 | if (!port || rc_paranoia_check(port, tty->name, "close")) |
1007 | return; | 930 | return; |
1008 | 931 | ||
1009 | spin_lock_irqsave(&riscom_lock, flags); | ||
1010 | |||
1011 | if (tty_hung_up_p(filp)) | ||
1012 | goto out; | ||
1013 | |||
1014 | bp = port_Board(port); | 932 | bp = port_Board(port); |
1015 | if ((tty->count == 1) && (port->port.count != 1)) { | 933 | |
1016 | printk(KERN_INFO "rc%d: rc_close: bad port count;" | 934 | if (tty_port_close_start(&port->port, tty, filp) == 0) |
1017 | " tty->count is 1, port count is %d\n", | 935 | return; |
1018 | board_No(bp), port->port.count); | 936 | |
1019 | port->port.count = 1; | ||
1020 | } | ||
1021 | if (--port->port.count < 0) { | ||
1022 | printk(KERN_INFO "rc%d: rc_close: bad port count " | ||
1023 | "for tty%d: %d\n", | ||
1024 | board_No(bp), port_No(port), port->port.count); | ||
1025 | port->port.count = 0; | ||
1026 | } | ||
1027 | if (port->port.count) | ||
1028 | goto out; | ||
1029 | port->port.flags |= ASYNC_CLOSING; | ||
1030 | /* | ||
1031 | * Now we wait for the transmit buffer to clear; and we notify | ||
1032 | * the line discipline to only process XON/XOFF characters. | ||
1033 | */ | ||
1034 | tty->closing = 1; | ||
1035 | if (port->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) | ||
1036 | tty_wait_until_sent(tty, port->port.closing_wait); | ||
1037 | /* | 937 | /* |
1038 | * At this point we stop accepting input. To do this, we | 938 | * At this point we stop accepting input. To do this, we |
1039 | * disable the receive line status interrupts, and tell the | 939 | * disable the receive line status interrupts, and tell the |
1040 | * interrupt driver to stop checking the data ready bit in the | 940 | * interrupt driver to stop checking the data ready bit in the |
1041 | * line status register. | 941 | * line status register. |
1042 | */ | 942 | */ |
943 | |||
944 | spin_lock_irqsave(&riscom_lock, flags); | ||
1043 | port->IER &= ~IER_RXD; | 945 | port->IER &= ~IER_RXD; |
1044 | if (port->port.flags & ASYNC_INITIALIZED) { | 946 | if (port->port.flags & ASYNC_INITIALIZED) { |
1045 | port->IER &= ~IER_TXRDY; | 947 | port->IER &= ~IER_TXRDY; |
@@ -1053,33 +955,24 @@ static void rc_close(struct tty_struct *tty, struct file *filp) | |||
1053 | */ | 955 | */ |
1054 | timeout = jiffies + HZ; | 956 | timeout = jiffies + HZ; |
1055 | while (port->IER & IER_TXEMPTY) { | 957 | while (port->IER & IER_TXEMPTY) { |
958 | spin_unlock_irqrestore(&riscom_lock, flags); | ||
1056 | msleep_interruptible(jiffies_to_msecs(port->timeout)); | 959 | msleep_interruptible(jiffies_to_msecs(port->timeout)); |
960 | spin_lock_irqsave(&riscom_lock, flags); | ||
1057 | if (time_after(jiffies, timeout)) | 961 | if (time_after(jiffies, timeout)) |
1058 | break; | 962 | break; |
1059 | } | 963 | } |
1060 | } | 964 | } |
1061 | rc_shutdown_port(tty, bp, port); | 965 | rc_shutdown_port(tty, bp, port); |
1062 | rc_flush_buffer(tty); | 966 | rc_flush_buffer(tty); |
1063 | tty_ldisc_flush(tty); | ||
1064 | |||
1065 | tty->closing = 0; | ||
1066 | port->port.tty = NULL; | ||
1067 | if (port->port.blocked_open) { | ||
1068 | if (port->port.close_delay) | ||
1069 | msleep_interruptible(jiffies_to_msecs(port->port.close_delay)); | ||
1070 | wake_up_interruptible(&port->port.open_wait); | ||
1071 | } | ||
1072 | port->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); | ||
1073 | wake_up_interruptible(&port->port.close_wait); | ||
1074 | |||
1075 | out: | ||
1076 | spin_unlock_irqrestore(&riscom_lock, flags); | 967 | spin_unlock_irqrestore(&riscom_lock, flags); |
968 | |||
969 | tty_port_close_end(&port->port, tty); | ||
1077 | } | 970 | } |
1078 | 971 | ||
1079 | static int rc_write(struct tty_struct *tty, | 972 | static int rc_write(struct tty_struct *tty, |
1080 | const unsigned char *buf, int count) | 973 | const unsigned char *buf, int count) |
1081 | { | 974 | { |
1082 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 975 | struct riscom_port *port = tty->driver_data; |
1083 | struct riscom_board *bp; | 976 | struct riscom_board *bp; |
1084 | int c, total = 0; | 977 | int c, total = 0; |
1085 | unsigned long flags; | 978 | unsigned long flags; |
@@ -1122,7 +1015,7 @@ static int rc_write(struct tty_struct *tty, | |||
1122 | 1015 | ||
1123 | static int rc_put_char(struct tty_struct *tty, unsigned char ch) | 1016 | static int rc_put_char(struct tty_struct *tty, unsigned char ch) |
1124 | { | 1017 | { |
1125 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1018 | struct riscom_port *port = tty->driver_data; |
1126 | unsigned long flags; | 1019 | unsigned long flags; |
1127 | int ret = 0; | 1020 | int ret = 0; |
1128 | 1021 | ||
@@ -1146,7 +1039,7 @@ out: | |||
1146 | 1039 | ||
1147 | static void rc_flush_chars(struct tty_struct *tty) | 1040 | static void rc_flush_chars(struct tty_struct *tty) |
1148 | { | 1041 | { |
1149 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1042 | struct riscom_port *port = tty->driver_data; |
1150 | unsigned long flags; | 1043 | unsigned long flags; |
1151 | 1044 | ||
1152 | if (rc_paranoia_check(port, tty->name, "rc_flush_chars")) | 1045 | if (rc_paranoia_check(port, tty->name, "rc_flush_chars")) |
@@ -1166,7 +1059,7 @@ static void rc_flush_chars(struct tty_struct *tty) | |||
1166 | 1059 | ||
1167 | static int rc_write_room(struct tty_struct *tty) | 1060 | static int rc_write_room(struct tty_struct *tty) |
1168 | { | 1061 | { |
1169 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1062 | struct riscom_port *port = tty->driver_data; |
1170 | int ret; | 1063 | int ret; |
1171 | 1064 | ||
1172 | if (rc_paranoia_check(port, tty->name, "rc_write_room")) | 1065 | if (rc_paranoia_check(port, tty->name, "rc_write_room")) |
@@ -1180,7 +1073,7 @@ static int rc_write_room(struct tty_struct *tty) | |||
1180 | 1073 | ||
1181 | static int rc_chars_in_buffer(struct tty_struct *tty) | 1074 | static int rc_chars_in_buffer(struct tty_struct *tty) |
1182 | { | 1075 | { |
1183 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1076 | struct riscom_port *port = tty->driver_data; |
1184 | 1077 | ||
1185 | if (rc_paranoia_check(port, tty->name, "rc_chars_in_buffer")) | 1078 | if (rc_paranoia_check(port, tty->name, "rc_chars_in_buffer")) |
1186 | return 0; | 1079 | return 0; |
@@ -1190,7 +1083,7 @@ static int rc_chars_in_buffer(struct tty_struct *tty) | |||
1190 | 1083 | ||
1191 | static int rc_tiocmget(struct tty_struct *tty, struct file *file) | 1084 | static int rc_tiocmget(struct tty_struct *tty, struct file *file) |
1192 | { | 1085 | { |
1193 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1086 | struct riscom_port *port = tty->driver_data; |
1194 | struct riscom_board *bp; | 1087 | struct riscom_board *bp; |
1195 | unsigned char status; | 1088 | unsigned char status; |
1196 | unsigned int result; | 1089 | unsigned int result; |
@@ -1220,7 +1113,7 @@ static int rc_tiocmget(struct tty_struct *tty, struct file *file) | |||
1220 | static int rc_tiocmset(struct tty_struct *tty, struct file *file, | 1113 | static int rc_tiocmset(struct tty_struct *tty, struct file *file, |
1221 | unsigned int set, unsigned int clear) | 1114 | unsigned int set, unsigned int clear) |
1222 | { | 1115 | { |
1223 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1116 | struct riscom_port *port = tty->driver_data; |
1224 | unsigned long flags; | 1117 | unsigned long flags; |
1225 | struct riscom_board *bp; | 1118 | struct riscom_board *bp; |
1226 | 1119 | ||
@@ -1252,7 +1145,7 @@ static int rc_tiocmset(struct tty_struct *tty, struct file *file, | |||
1252 | 1145 | ||
1253 | static int rc_send_break(struct tty_struct *tty, int length) | 1146 | static int rc_send_break(struct tty_struct *tty, int length) |
1254 | { | 1147 | { |
1255 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1148 | struct riscom_port *port = tty->driver_data; |
1256 | struct riscom_board *bp = port_Board(port); | 1149 | struct riscom_board *bp = port_Board(port); |
1257 | unsigned long flags; | 1150 | unsigned long flags; |
1258 | 1151 | ||
@@ -1345,7 +1238,7 @@ static int rc_get_serial_info(struct riscom_port *port, | |||
1345 | static int rc_ioctl(struct tty_struct *tty, struct file *filp, | 1238 | static int rc_ioctl(struct tty_struct *tty, struct file *filp, |
1346 | unsigned int cmd, unsigned long arg) | 1239 | unsigned int cmd, unsigned long arg) |
1347 | { | 1240 | { |
1348 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1241 | struct riscom_port *port = tty->driver_data; |
1349 | void __user *argp = (void __user *)arg; | 1242 | void __user *argp = (void __user *)arg; |
1350 | int retval; | 1243 | int retval; |
1351 | 1244 | ||
@@ -1371,7 +1264,7 @@ static int rc_ioctl(struct tty_struct *tty, struct file *filp, | |||
1371 | 1264 | ||
1372 | static void rc_throttle(struct tty_struct *tty) | 1265 | static void rc_throttle(struct tty_struct *tty) |
1373 | { | 1266 | { |
1374 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1267 | struct riscom_port *port = tty->driver_data; |
1375 | struct riscom_board *bp; | 1268 | struct riscom_board *bp; |
1376 | unsigned long flags; | 1269 | unsigned long flags; |
1377 | 1270 | ||
@@ -1393,7 +1286,7 @@ static void rc_throttle(struct tty_struct *tty) | |||
1393 | 1286 | ||
1394 | static void rc_unthrottle(struct tty_struct *tty) | 1287 | static void rc_unthrottle(struct tty_struct *tty) |
1395 | { | 1288 | { |
1396 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1289 | struct riscom_port *port = tty->driver_data; |
1397 | struct riscom_board *bp; | 1290 | struct riscom_board *bp; |
1398 | unsigned long flags; | 1291 | unsigned long flags; |
1399 | 1292 | ||
@@ -1415,7 +1308,7 @@ static void rc_unthrottle(struct tty_struct *tty) | |||
1415 | 1308 | ||
1416 | static void rc_stop(struct tty_struct *tty) | 1309 | static void rc_stop(struct tty_struct *tty) |
1417 | { | 1310 | { |
1418 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1311 | struct riscom_port *port = tty->driver_data; |
1419 | struct riscom_board *bp; | 1312 | struct riscom_board *bp; |
1420 | unsigned long flags; | 1313 | unsigned long flags; |
1421 | 1314 | ||
@@ -1433,7 +1326,7 @@ static void rc_stop(struct tty_struct *tty) | |||
1433 | 1326 | ||
1434 | static void rc_start(struct tty_struct *tty) | 1327 | static void rc_start(struct tty_struct *tty) |
1435 | { | 1328 | { |
1436 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1329 | struct riscom_port *port = tty->driver_data; |
1437 | struct riscom_board *bp; | 1330 | struct riscom_board *bp; |
1438 | unsigned long flags; | 1331 | unsigned long flags; |
1439 | 1332 | ||
@@ -1454,8 +1347,9 @@ static void rc_start(struct tty_struct *tty) | |||
1454 | 1347 | ||
1455 | static void rc_hangup(struct tty_struct *tty) | 1348 | static void rc_hangup(struct tty_struct *tty) |
1456 | { | 1349 | { |
1457 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1350 | struct riscom_port *port = tty->driver_data; |
1458 | struct riscom_board *bp; | 1351 | struct riscom_board *bp; |
1352 | unsigned long flags; | ||
1459 | 1353 | ||
1460 | if (rc_paranoia_check(port, tty->name, "rc_hangup")) | 1354 | if (rc_paranoia_check(port, tty->name, "rc_hangup")) |
1461 | return; | 1355 | return; |
@@ -1463,16 +1357,18 @@ static void rc_hangup(struct tty_struct *tty) | |||
1463 | bp = port_Board(port); | 1357 | bp = port_Board(port); |
1464 | 1358 | ||
1465 | rc_shutdown_port(tty, bp, port); | 1359 | rc_shutdown_port(tty, bp, port); |
1360 | spin_lock_irqsave(&port->port.lock, flags); | ||
1466 | port->port.count = 0; | 1361 | port->port.count = 0; |
1467 | port->port.flags &= ~ASYNC_NORMAL_ACTIVE; | 1362 | port->port.flags &= ~ASYNC_NORMAL_ACTIVE; |
1468 | port->port.tty = NULL; | 1363 | port->port.tty = NULL; |
1469 | wake_up_interruptible(&port->port.open_wait); | 1364 | wake_up_interruptible(&port->port.open_wait); |
1365 | spin_unlock_irqrestore(&port->port.lock, flags); | ||
1470 | } | 1366 | } |
1471 | 1367 | ||
1472 | static void rc_set_termios(struct tty_struct *tty, | 1368 | static void rc_set_termios(struct tty_struct *tty, |
1473 | struct ktermios *old_termios) | 1369 | struct ktermios *old_termios) |
1474 | { | 1370 | { |
1475 | struct riscom_port *port = (struct riscom_port *)tty->driver_data; | 1371 | struct riscom_port *port = tty->driver_data; |
1476 | unsigned long flags; | 1372 | unsigned long flags; |
1477 | 1373 | ||
1478 | if (rc_paranoia_check(port, tty->name, "rc_set_termios")) | 1374 | if (rc_paranoia_check(port, tty->name, "rc_set_termios")) |
@@ -1510,6 +1406,11 @@ static const struct tty_operations riscom_ops = { | |||
1510 | .break_ctl = rc_send_break, | 1406 | .break_ctl = rc_send_break, |
1511 | }; | 1407 | }; |
1512 | 1408 | ||
1409 | static const struct tty_port_operations riscom_port_ops = { | ||
1410 | .carrier_raised = carrier_raised, | ||
1411 | }; | ||
1412 | |||
1413 | |||
1513 | static int __init rc_init_drivers(void) | 1414 | static int __init rc_init_drivers(void) |
1514 | { | 1415 | { |
1515 | int error; | 1416 | int error; |
@@ -1541,6 +1442,7 @@ static int __init rc_init_drivers(void) | |||
1541 | memset(rc_port, 0, sizeof(rc_port)); | 1442 | memset(rc_port, 0, sizeof(rc_port)); |
1542 | for (i = 0; i < RC_NPORT * RC_NBOARD; i++) { | 1443 | for (i = 0; i < RC_NPORT * RC_NBOARD; i++) { |
1543 | tty_port_init(&rc_port[i].port); | 1444 | tty_port_init(&rc_port[i].port); |
1445 | rc_port[i].port.ops = &riscom_port_ops; | ||
1544 | rc_port[i].magic = RISCOM8_MAGIC; | 1446 | rc_port[i].magic = RISCOM8_MAGIC; |
1545 | } | 1447 | } |
1546 | return 0; | 1448 | return 0; |
diff --git a/drivers/char/rocket.c b/drivers/char/rocket.c index 584d791e84a6..f59fc5cea067 100644 --- a/drivers/char/rocket.c +++ b/drivers/char/rocket.c | |||
@@ -135,6 +135,7 @@ static int rcktpt_type[NUM_BOARDS]; | |||
135 | static int is_PCI[NUM_BOARDS]; | 135 | static int is_PCI[NUM_BOARDS]; |
136 | static rocketModel_t rocketModel[NUM_BOARDS]; | 136 | static rocketModel_t rocketModel[NUM_BOARDS]; |
137 | static int max_board; | 137 | static int max_board; |
138 | static const struct tty_port_operations rocket_port_ops; | ||
138 | 139 | ||
139 | /* | 140 | /* |
140 | * The following arrays define the interrupt bits corresponding to each AIOP. | 141 | * The following arrays define the interrupt bits corresponding to each AIOP. |
@@ -435,15 +436,15 @@ static void rp_do_transmit(struct r_port *info) | |||
435 | #endif | 436 | #endif |
436 | if (!info) | 437 | if (!info) |
437 | return; | 438 | return; |
438 | if (!info->port.tty) { | 439 | tty = tty_port_tty_get(&info->port); |
439 | printk(KERN_WARNING "rp: WARNING %s called with " | 440 | |
440 | "info->port.tty==NULL\n", __func__); | 441 | if (tty == NULL) { |
442 | printk(KERN_WARNING "rp: WARNING %s called with tty==NULL\n", __func__); | ||
441 | clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); | 443 | clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); |
442 | return; | 444 | return; |
443 | } | 445 | } |
444 | 446 | ||
445 | spin_lock_irqsave(&info->slock, flags); | 447 | spin_lock_irqsave(&info->slock, flags); |
446 | tty = info->port.tty; | ||
447 | info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp); | 448 | info->xmit_fifo_room = TXFIFO_SIZE - sGetTxCnt(cp); |
448 | 449 | ||
449 | /* Loop sending data to FIFO until done or FIFO full */ | 450 | /* Loop sending data to FIFO until done or FIFO full */ |
@@ -477,6 +478,7 @@ static void rp_do_transmit(struct r_port *info) | |||
477 | } | 478 | } |
478 | 479 | ||
479 | spin_unlock_irqrestore(&info->slock, flags); | 480 | spin_unlock_irqrestore(&info->slock, flags); |
481 | tty_kref_put(tty); | ||
480 | 482 | ||
481 | #ifdef ROCKET_DEBUG_INTR | 483 | #ifdef ROCKET_DEBUG_INTR |
482 | printk(KERN_DEBUG "(%d,%d,%d,%d)...\n", info->xmit_cnt, info->xmit_head, | 484 | printk(KERN_DEBUG "(%d,%d,%d,%d)...\n", info->xmit_cnt, info->xmit_head, |
@@ -498,18 +500,18 @@ static void rp_handle_port(struct r_port *info) | |||
498 | if (!info) | 500 | if (!info) |
499 | return; | 501 | return; |
500 | 502 | ||
501 | if ((info->flags & ROCKET_INITIALIZED) == 0) { | 503 | if ((info->port.flags & ASYNC_INITIALIZED) == 0) { |
502 | printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " | 504 | printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " |
503 | "info->flags & NOT_INIT\n"); | 505 | "info->flags & NOT_INIT\n"); |
504 | return; | 506 | return; |
505 | } | 507 | } |
506 | if (!info->port.tty) { | 508 | tty = tty_port_tty_get(&info->port); |
509 | if (!tty) { | ||
507 | printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " | 510 | printk(KERN_WARNING "rp: WARNING: rp_handle_port called with " |
508 | "info->port.tty==NULL\n"); | 511 | "tty==NULL\n"); |
509 | return; | 512 | return; |
510 | } | 513 | } |
511 | cp = &info->channel; | 514 | cp = &info->channel; |
512 | tty = info->port.tty; | ||
513 | 515 | ||
514 | IntMask = sGetChanIntID(cp) & info->intmask; | 516 | IntMask = sGetChanIntID(cp) & info->intmask; |
515 | #ifdef ROCKET_DEBUG_INTR | 517 | #ifdef ROCKET_DEBUG_INTR |
@@ -541,6 +543,7 @@ static void rp_handle_port(struct r_port *info) | |||
541 | printk(KERN_INFO "DSR change...\n"); | 543 | printk(KERN_INFO "DSR change...\n"); |
542 | } | 544 | } |
543 | #endif | 545 | #endif |
546 | tty_kref_put(tty); | ||
544 | } | 547 | } |
545 | 548 | ||
546 | /* | 549 | /* |
@@ -649,9 +652,8 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) | |||
649 | info->board = board; | 652 | info->board = board; |
650 | info->aiop = aiop; | 653 | info->aiop = aiop; |
651 | info->chan = chan; | 654 | info->chan = chan; |
652 | info->port.closing_wait = 3000; | 655 | tty_port_init(&info->port); |
653 | info->port.close_delay = 50; | 656 | info->port.ops = &rocket_port_ops; |
654 | init_waitqueue_head(&info->port.open_wait); | ||
655 | init_completion(&info->close_wait); | 657 | init_completion(&info->close_wait); |
656 | info->flags &= ~ROCKET_MODE_MASK; | 658 | info->flags &= ~ROCKET_MODE_MASK; |
657 | switch (pc104[board][line]) { | 659 | switch (pc104[board][line]) { |
@@ -710,7 +712,7 @@ static void init_r_port(int board, int aiop, int chan, struct pci_dev *pci_dev) | |||
710 | * Configures a rocketport port according to its termio settings. Called from | 712 | * Configures a rocketport port according to its termio settings. Called from |
711 | * user mode into the driver (exception handler). *info CD manipulation is spinlock protected. | 713 | * user mode into the driver (exception handler). *info CD manipulation is spinlock protected. |
712 | */ | 714 | */ |
713 | static void configure_r_port(struct r_port *info, | 715 | static void configure_r_port(struct tty_struct *tty, struct r_port *info, |
714 | struct ktermios *old_termios) | 716 | struct ktermios *old_termios) |
715 | { | 717 | { |
716 | unsigned cflag; | 718 | unsigned cflag; |
@@ -718,7 +720,7 @@ static void configure_r_port(struct r_port *info, | |||
718 | unsigned rocketMode; | 720 | unsigned rocketMode; |
719 | int bits, baud, divisor; | 721 | int bits, baud, divisor; |
720 | CHANNEL_t *cp; | 722 | CHANNEL_t *cp; |
721 | struct ktermios *t = info->port.tty->termios; | 723 | struct ktermios *t = tty->termios; |
722 | 724 | ||
723 | cp = &info->channel; | 725 | cp = &info->channel; |
724 | cflag = t->c_cflag; | 726 | cflag = t->c_cflag; |
@@ -751,7 +753,7 @@ static void configure_r_port(struct r_port *info, | |||
751 | } | 753 | } |
752 | 754 | ||
753 | /* baud rate */ | 755 | /* baud rate */ |
754 | baud = tty_get_baud_rate(info->port.tty); | 756 | baud = tty_get_baud_rate(tty); |
755 | if (!baud) | 757 | if (!baud) |
756 | baud = 9600; | 758 | baud = 9600; |
757 | divisor = ((rp_baud_base[info->board] + (baud >> 1)) / baud) - 1; | 759 | divisor = ((rp_baud_base[info->board] + (baud >> 1)) / baud) - 1; |
@@ -769,7 +771,7 @@ static void configure_r_port(struct r_port *info, | |||
769 | sSetBaud(cp, divisor); | 771 | sSetBaud(cp, divisor); |
770 | 772 | ||
771 | /* FIXME: Should really back compute a baud rate from the divisor */ | 773 | /* FIXME: Should really back compute a baud rate from the divisor */ |
772 | tty_encode_baud_rate(info->port.tty, baud, baud); | 774 | tty_encode_baud_rate(tty, baud, baud); |
773 | 775 | ||
774 | if (cflag & CRTSCTS) { | 776 | if (cflag & CRTSCTS) { |
775 | info->intmask |= DELTA_CTS; | 777 | info->intmask |= DELTA_CTS; |
@@ -794,15 +796,15 @@ static void configure_r_port(struct r_port *info, | |||
794 | * Handle software flow control in the board | 796 | * Handle software flow control in the board |
795 | */ | 797 | */ |
796 | #ifdef ROCKET_SOFT_FLOW | 798 | #ifdef ROCKET_SOFT_FLOW |
797 | if (I_IXON(info->port.tty)) { | 799 | if (I_IXON(tty)) { |
798 | sEnTxSoftFlowCtl(cp); | 800 | sEnTxSoftFlowCtl(cp); |
799 | if (I_IXANY(info->port.tty)) { | 801 | if (I_IXANY(tty)) { |
800 | sEnIXANY(cp); | 802 | sEnIXANY(cp); |
801 | } else { | 803 | } else { |
802 | sDisIXANY(cp); | 804 | sDisIXANY(cp); |
803 | } | 805 | } |
804 | sSetTxXONChar(cp, START_CHAR(info->port.tty)); | 806 | sSetTxXONChar(cp, START_CHAR(tty)); |
805 | sSetTxXOFFChar(cp, STOP_CHAR(info->port.tty)); | 807 | sSetTxXOFFChar(cp, STOP_CHAR(tty)); |
806 | } else { | 808 | } else { |
807 | sDisTxSoftFlowCtl(cp); | 809 | sDisTxSoftFlowCtl(cp); |
808 | sDisIXANY(cp); | 810 | sDisIXANY(cp); |
@@ -814,24 +816,24 @@ static void configure_r_port(struct r_port *info, | |||
814 | * Set up ignore/read mask words | 816 | * Set up ignore/read mask words |
815 | */ | 817 | */ |
816 | info->read_status_mask = STMRCVROVRH | 0xFF; | 818 | info->read_status_mask = STMRCVROVRH | 0xFF; |
817 | if (I_INPCK(info->port.tty)) | 819 | if (I_INPCK(tty)) |
818 | info->read_status_mask |= STMFRAMEH | STMPARITYH; | 820 | info->read_status_mask |= STMFRAMEH | STMPARITYH; |
819 | if (I_BRKINT(info->port.tty) || I_PARMRK(info->port.tty)) | 821 | if (I_BRKINT(tty) || I_PARMRK(tty)) |
820 | info->read_status_mask |= STMBREAKH; | 822 | info->read_status_mask |= STMBREAKH; |
821 | 823 | ||
822 | /* | 824 | /* |
823 | * Characters to ignore | 825 | * Characters to ignore |
824 | */ | 826 | */ |
825 | info->ignore_status_mask = 0; | 827 | info->ignore_status_mask = 0; |
826 | if (I_IGNPAR(info->port.tty)) | 828 | if (I_IGNPAR(tty)) |
827 | info->ignore_status_mask |= STMFRAMEH | STMPARITYH; | 829 | info->ignore_status_mask |= STMFRAMEH | STMPARITYH; |
828 | if (I_IGNBRK(info->port.tty)) { | 830 | if (I_IGNBRK(tty)) { |
829 | info->ignore_status_mask |= STMBREAKH; | 831 | info->ignore_status_mask |= STMBREAKH; |
830 | /* | 832 | /* |
831 | * If we're ignoring parity and break indicators, | 833 | * If we're ignoring parity and break indicators, |
832 | * ignore overruns too. (For real raw support). | 834 | * ignore overruns too. (For real raw support). |
833 | */ | 835 | */ |
834 | if (I_IGNPAR(info->port.tty)) | 836 | if (I_IGNPAR(tty)) |
835 | info->ignore_status_mask |= STMRCVROVRH; | 837 | info->ignore_status_mask |= STMRCVROVRH; |
836 | } | 838 | } |
837 | 839 | ||
@@ -864,106 +866,17 @@ static void configure_r_port(struct r_port *info, | |||
864 | } | 866 | } |
865 | } | 867 | } |
866 | 868 | ||
867 | /* info->port.count is considered critical, protected by spinlocks. */ | 869 | static int carrier_raised(struct tty_port *port) |
868 | static int block_til_ready(struct tty_struct *tty, struct file *filp, | ||
869 | struct r_port *info) | ||
870 | { | 870 | { |
871 | DECLARE_WAITQUEUE(wait, current); | 871 | struct r_port *info = container_of(port, struct r_port, port); |
872 | int retval; | 872 | return (sGetChanStatusLo(&info->channel) & CD_ACT) ? 1 : 0; |
873 | int do_clocal = 0, extra_count = 0; | 873 | } |
874 | unsigned long flags; | ||
875 | |||
876 | /* | ||
877 | * If the device is in the middle of being closed, then block | ||
878 | * until it's done, and then try again. | ||
879 | */ | ||
880 | if (tty_hung_up_p(filp)) | ||
881 | return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); | ||
882 | if (info->flags & ROCKET_CLOSING) { | ||
883 | if (wait_for_completion_interruptible(&info->close_wait)) | ||
884 | return -ERESTARTSYS; | ||
885 | return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); | ||
886 | } | ||
887 | |||
888 | /* | ||
889 | * If non-blocking mode is set, or the port is not enabled, | ||
890 | * then make the check up front and then exit. | ||
891 | */ | ||
892 | if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { | ||
893 | info->flags |= ROCKET_NORMAL_ACTIVE; | ||
894 | return 0; | ||
895 | } | ||
896 | if (tty->termios->c_cflag & CLOCAL) | ||
897 | do_clocal = 1; | ||
898 | |||
899 | /* | ||
900 | * Block waiting for the carrier detect and the line to become free. While we are in | ||
901 | * this loop, info->port.count is dropped by one, so that rp_close() knows when to free things. | ||
902 | * We restore it upon exit, either normal or abnormal. | ||
903 | */ | ||
904 | retval = 0; | ||
905 | add_wait_queue(&info->port.open_wait, &wait); | ||
906 | #ifdef ROCKET_DEBUG_OPEN | ||
907 | printk(KERN_INFO "block_til_ready before block: ttyR%d, count = %d\n", info->line, info->port.count); | ||
908 | #endif | ||
909 | spin_lock_irqsave(&info->slock, flags); | ||
910 | |||
911 | #ifdef ROCKET_DISABLE_SIMUSAGE | ||
912 | info->flags |= ROCKET_NORMAL_ACTIVE; | ||
913 | #else | ||
914 | if (!tty_hung_up_p(filp)) { | ||
915 | extra_count = 1; | ||
916 | info->port.count--; | ||
917 | } | ||
918 | #endif | ||
919 | info->port.blocked_open++; | ||
920 | |||
921 | spin_unlock_irqrestore(&info->slock, flags); | ||
922 | |||
923 | while (1) { | ||
924 | if (tty->termios->c_cflag & CBAUD) { | ||
925 | sSetDTR(&info->channel); | ||
926 | sSetRTS(&info->channel); | ||
927 | } | ||
928 | set_current_state(TASK_INTERRUPTIBLE); | ||
929 | if (tty_hung_up_p(filp) || !(info->flags & ROCKET_INITIALIZED)) { | ||
930 | if (info->flags & ROCKET_HUP_NOTIFY) | ||
931 | retval = -EAGAIN; | ||
932 | else | ||
933 | retval = -ERESTARTSYS; | ||
934 | break; | ||
935 | } | ||
936 | if (!(info->flags & ROCKET_CLOSING) && (do_clocal || (sGetChanStatusLo(&info->channel) & CD_ACT))) | ||
937 | break; | ||
938 | if (signal_pending(current)) { | ||
939 | retval = -ERESTARTSYS; | ||
940 | break; | ||
941 | } | ||
942 | #ifdef ROCKET_DEBUG_OPEN | ||
943 | printk(KERN_INFO "block_til_ready blocking: ttyR%d, count = %d, flags=0x%0x\n", | ||
944 | info->line, info->port.count, info->flags); | ||
945 | #endif | ||
946 | schedule(); /* Don't hold spinlock here, will hang PC */ | ||
947 | } | ||
948 | __set_current_state(TASK_RUNNING); | ||
949 | remove_wait_queue(&info->port.open_wait, &wait); | ||
950 | |||
951 | spin_lock_irqsave(&info->slock, flags); | ||
952 | |||
953 | if (extra_count) | ||
954 | info->port.count++; | ||
955 | info->port.blocked_open--; | ||
956 | |||
957 | spin_unlock_irqrestore(&info->slock, flags); | ||
958 | 874 | ||
959 | #ifdef ROCKET_DEBUG_OPEN | 875 | static void raise_dtr_rts(struct tty_port *port) |
960 | printk(KERN_INFO "block_til_ready after blocking: ttyR%d, count = %d\n", | 876 | { |
961 | info->line, info->port.count); | 877 | struct r_port *info = container_of(port, struct r_port, port); |
962 | #endif | 878 | sSetDTR(&info->channel); |
963 | if (retval) | 879 | sSetRTS(&info->channel); |
964 | return retval; | ||
965 | info->flags |= ROCKET_NORMAL_ACTIVE; | ||
966 | return 0; | ||
967 | } | 880 | } |
968 | 881 | ||
969 | /* | 882 | /* |
@@ -973,24 +886,26 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
973 | static int rp_open(struct tty_struct *tty, struct file *filp) | 886 | static int rp_open(struct tty_struct *tty, struct file *filp) |
974 | { | 887 | { |
975 | struct r_port *info; | 888 | struct r_port *info; |
889 | struct tty_port *port; | ||
976 | int line = 0, retval; | 890 | int line = 0, retval; |
977 | CHANNEL_t *cp; | 891 | CHANNEL_t *cp; |
978 | unsigned long page; | 892 | unsigned long page; |
979 | 893 | ||
980 | line = tty->index; | 894 | line = tty->index; |
981 | if ((line < 0) || (line >= MAX_RP_PORTS) || ((info = rp_table[line]) == NULL)) | 895 | if (line < 0 || line >= MAX_RP_PORTS || ((info = rp_table[line]) == NULL)) |
982 | return -ENXIO; | 896 | return -ENXIO; |
983 | 897 | port = &info->port; | |
898 | |||
984 | page = __get_free_page(GFP_KERNEL); | 899 | page = __get_free_page(GFP_KERNEL); |
985 | if (!page) | 900 | if (!page) |
986 | return -ENOMEM; | 901 | return -ENOMEM; |
987 | 902 | ||
988 | if (info->flags & ROCKET_CLOSING) { | 903 | if (port->flags & ASYNC_CLOSING) { |
989 | retval = wait_for_completion_interruptible(&info->close_wait); | 904 | retval = wait_for_completion_interruptible(&info->close_wait); |
990 | free_page(page); | 905 | free_page(page); |
991 | if (retval) | 906 | if (retval) |
992 | return retval; | 907 | return retval; |
993 | return ((info->flags & ROCKET_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); | 908 | return ((port->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); |
994 | } | 909 | } |
995 | 910 | ||
996 | /* | 911 | /* |
@@ -1002,9 +917,9 @@ static int rp_open(struct tty_struct *tty, struct file *filp) | |||
1002 | info->xmit_buf = (unsigned char *) page; | 917 | info->xmit_buf = (unsigned char *) page; |
1003 | 918 | ||
1004 | tty->driver_data = info; | 919 | tty->driver_data = info; |
1005 | info->port.tty = tty; | 920 | tty_port_tty_set(port, tty); |
1006 | 921 | ||
1007 | if (info->port.count++ == 0) { | 922 | if (port->count++ == 0) { |
1008 | atomic_inc(&rp_num_ports_open); | 923 | atomic_inc(&rp_num_ports_open); |
1009 | 924 | ||
1010 | #ifdef ROCKET_DEBUG_OPEN | 925 | #ifdef ROCKET_DEBUG_OPEN |
@@ -1019,7 +934,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp) | |||
1019 | /* | 934 | /* |
1020 | * Info->count is now 1; so it's safe to sleep now. | 935 | * Info->count is now 1; so it's safe to sleep now. |
1021 | */ | 936 | */ |
1022 | if ((info->flags & ROCKET_INITIALIZED) == 0) { | 937 | if (!test_bit(ASYNC_INITIALIZED, &port->flags)) { |
1023 | cp = &info->channel; | 938 | cp = &info->channel; |
1024 | sSetRxTrigger(cp, TRIG_1); | 939 | sSetRxTrigger(cp, TRIG_1); |
1025 | if (sGetChanStatus(cp) & CD_ACT) | 940 | if (sGetChanStatus(cp) & CD_ACT) |
@@ -1043,21 +958,21 @@ static int rp_open(struct tty_struct *tty, struct file *filp) | |||
1043 | sEnRxFIFO(cp); | 958 | sEnRxFIFO(cp); |
1044 | sEnTransmit(cp); | 959 | sEnTransmit(cp); |
1045 | 960 | ||
1046 | info->flags |= ROCKET_INITIALIZED; | 961 | set_bit(ASYNC_INITIALIZED, &info->port.flags); |
1047 | 962 | ||
1048 | /* | 963 | /* |
1049 | * Set up the tty->alt_speed kludge | 964 | * Set up the tty->alt_speed kludge |
1050 | */ | 965 | */ |
1051 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI) | 966 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI) |
1052 | info->port.tty->alt_speed = 57600; | 967 | tty->alt_speed = 57600; |
1053 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI) | 968 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI) |
1054 | info->port.tty->alt_speed = 115200; | 969 | tty->alt_speed = 115200; |
1055 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI) | 970 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI) |
1056 | info->port.tty->alt_speed = 230400; | 971 | tty->alt_speed = 230400; |
1057 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP) | 972 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP) |
1058 | info->port.tty->alt_speed = 460800; | 973 | tty->alt_speed = 460800; |
1059 | 974 | ||
1060 | configure_r_port(info, NULL); | 975 | configure_r_port(tty, info, NULL); |
1061 | if (tty->termios->c_cflag & CBAUD) { | 976 | if (tty->termios->c_cflag & CBAUD) { |
1062 | sSetDTR(cp); | 977 | sSetDTR(cp); |
1063 | sSetRTS(cp); | 978 | sSetRTS(cp); |
@@ -1066,7 +981,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp) | |||
1066 | /* Starts (or resets) the maint polling loop */ | 981 | /* Starts (or resets) the maint polling loop */ |
1067 | mod_timer(&rocket_timer, jiffies + POLL_PERIOD); | 982 | mod_timer(&rocket_timer, jiffies + POLL_PERIOD); |
1068 | 983 | ||
1069 | retval = block_til_ready(tty, filp, info); | 984 | retval = tty_port_block_til_ready(port, tty, filp); |
1070 | if (retval) { | 985 | if (retval) { |
1071 | #ifdef ROCKET_DEBUG_OPEN | 986 | #ifdef ROCKET_DEBUG_OPEN |
1072 | printk(KERN_INFO "rp_open returning after block_til_ready with %d\n", retval); | 987 | printk(KERN_INFO "rp_open returning after block_til_ready with %d\n", retval); |
@@ -1081,8 +996,8 @@ static int rp_open(struct tty_struct *tty, struct file *filp) | |||
1081 | */ | 996 | */ |
1082 | static void rp_close(struct tty_struct *tty, struct file *filp) | 997 | static void rp_close(struct tty_struct *tty, struct file *filp) |
1083 | { | 998 | { |
1084 | struct r_port *info = (struct r_port *) tty->driver_data; | 999 | struct r_port *info = tty->driver_data; |
1085 | unsigned long flags; | 1000 | struct tty_port *port = &info->port; |
1086 | int timeout; | 1001 | int timeout; |
1087 | CHANNEL_t *cp; | 1002 | CHANNEL_t *cp; |
1088 | 1003 | ||
@@ -1093,53 +1008,10 @@ static void rp_close(struct tty_struct *tty, struct file *filp) | |||
1093 | printk(KERN_INFO "rp_close ttyR%d, count = %d\n", info->line, info->port.count); | 1008 | printk(KERN_INFO "rp_close ttyR%d, count = %d\n", info->line, info->port.count); |
1094 | #endif | 1009 | #endif |
1095 | 1010 | ||
1096 | if (tty_hung_up_p(filp)) | 1011 | if (tty_port_close_start(port, tty, filp) == 0) |
1097 | return; | ||
1098 | spin_lock_irqsave(&info->slock, flags); | ||
1099 | |||
1100 | if ((tty->count == 1) && (info->port.count != 1)) { | ||
1101 | /* | ||
1102 | * Uh, oh. tty->count is 1, which means that the tty | ||
1103 | * structure will be freed. Info->count should always | ||
1104 | * be one in these conditions. If it's greater than | ||
1105 | * one, we've got real problems, since it means the | ||
1106 | * serial port won't be shutdown. | ||
1107 | */ | ||
1108 | printk(KERN_WARNING "rp_close: bad serial port count; " | ||
1109 | "tty->count is 1, info->port.count is %d\n", info->port.count); | ||
1110 | info->port.count = 1; | ||
1111 | } | ||
1112 | if (--info->port.count < 0) { | ||
1113 | printk(KERN_WARNING "rp_close: bad serial port count for " | ||
1114 | "ttyR%d: %d\n", info->line, info->port.count); | ||
1115 | info->port.count = 0; | ||
1116 | } | ||
1117 | if (info->port.count) { | ||
1118 | spin_unlock_irqrestore(&info->slock, flags); | ||
1119 | return; | 1012 | return; |
1120 | } | ||
1121 | info->flags |= ROCKET_CLOSING; | ||
1122 | spin_unlock_irqrestore(&info->slock, flags); | ||
1123 | 1013 | ||
1124 | cp = &info->channel; | 1014 | cp = &info->channel; |
1125 | |||
1126 | /* | ||
1127 | * Notify the line discpline to only process XON/XOFF characters | ||
1128 | */ | ||
1129 | tty->closing = 1; | ||
1130 | |||
1131 | /* | ||
1132 | * If transmission was throttled by the application request, | ||
1133 | * just flush the xmit buffer. | ||
1134 | */ | ||
1135 | if (tty->flow_stopped) | ||
1136 | rp_flush_buffer(tty); | ||
1137 | |||
1138 | /* | ||
1139 | * Wait for the transmit buffer to clear | ||
1140 | */ | ||
1141 | if (info->port.closing_wait != ROCKET_CLOSING_WAIT_NONE) | ||
1142 | tty_wait_until_sent(tty, info->port.closing_wait); | ||
1143 | /* | 1015 | /* |
1144 | * Before we drop DTR, make sure the UART transmitter | 1016 | * Before we drop DTR, make sure the UART transmitter |
1145 | * has completely drained; this is especially | 1017 | * has completely drained; this is especially |
@@ -1168,19 +1040,24 @@ static void rp_close(struct tty_struct *tty, struct file *filp) | |||
1168 | 1040 | ||
1169 | clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); | 1041 | clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); |
1170 | 1042 | ||
1171 | if (info->port.blocked_open) { | 1043 | /* We can't yet use tty_port_close_end as the buffer handling in this |
1172 | if (info->port.close_delay) { | 1044 | driver is a bit different to the usual */ |
1173 | msleep_interruptible(jiffies_to_msecs(info->port.close_delay)); | 1045 | |
1046 | if (port->blocked_open) { | ||
1047 | if (port->close_delay) { | ||
1048 | msleep_interruptible(jiffies_to_msecs(port->close_delay)); | ||
1174 | } | 1049 | } |
1175 | wake_up_interruptible(&info->port.open_wait); | 1050 | wake_up_interruptible(&port->open_wait); |
1176 | } else { | 1051 | } else { |
1177 | if (info->xmit_buf) { | 1052 | if (info->xmit_buf) { |
1178 | free_page((unsigned long) info->xmit_buf); | 1053 | free_page((unsigned long) info->xmit_buf); |
1179 | info->xmit_buf = NULL; | 1054 | info->xmit_buf = NULL; |
1180 | } | 1055 | } |
1181 | } | 1056 | } |
1182 | info->flags &= ~(ROCKET_INITIALIZED | ROCKET_CLOSING | ROCKET_NORMAL_ACTIVE); | 1057 | info->port.flags &= ~(ASYNC_INITIALIZED | ASYNC_CLOSING | ASYNC_NORMAL_ACTIVE); |
1183 | tty->closing = 0; | 1058 | tty->closing = 0; |
1059 | tty_port_tty_set(port, NULL); | ||
1060 | wake_up_interruptible(&port->close_wait); | ||
1184 | complete_all(&info->close_wait); | 1061 | complete_all(&info->close_wait); |
1185 | atomic_dec(&rp_num_ports_open); | 1062 | atomic_dec(&rp_num_ports_open); |
1186 | 1063 | ||
@@ -1195,7 +1072,7 @@ static void rp_close(struct tty_struct *tty, struct file *filp) | |||
1195 | static void rp_set_termios(struct tty_struct *tty, | 1072 | static void rp_set_termios(struct tty_struct *tty, |
1196 | struct ktermios *old_termios) | 1073 | struct ktermios *old_termios) |
1197 | { | 1074 | { |
1198 | struct r_port *info = (struct r_port *) tty->driver_data; | 1075 | struct r_port *info = tty->driver_data; |
1199 | CHANNEL_t *cp; | 1076 | CHANNEL_t *cp; |
1200 | unsigned cflag; | 1077 | unsigned cflag; |
1201 | 1078 | ||
@@ -1213,7 +1090,7 @@ static void rp_set_termios(struct tty_struct *tty, | |||
1213 | /* Or CMSPAR */ | 1090 | /* Or CMSPAR */ |
1214 | tty->termios->c_cflag &= ~CMSPAR; | 1091 | tty->termios->c_cflag &= ~CMSPAR; |
1215 | 1092 | ||
1216 | configure_r_port(info, old_termios); | 1093 | configure_r_port(tty, info, old_termios); |
1217 | 1094 | ||
1218 | cp = &info->channel; | 1095 | cp = &info->channel; |
1219 | 1096 | ||
@@ -1238,7 +1115,7 @@ static void rp_set_termios(struct tty_struct *tty, | |||
1238 | 1115 | ||
1239 | static int rp_break(struct tty_struct *tty, int break_state) | 1116 | static int rp_break(struct tty_struct *tty, int break_state) |
1240 | { | 1117 | { |
1241 | struct r_port *info = (struct r_port *) tty->driver_data; | 1118 | struct r_port *info = tty->driver_data; |
1242 | unsigned long flags; | 1119 | unsigned long flags; |
1243 | 1120 | ||
1244 | if (rocket_paranoia_check(info, "rp_break")) | 1121 | if (rocket_paranoia_check(info, "rp_break")) |
@@ -1284,7 +1161,7 @@ static int sGetChanRI(CHANNEL_T * ChP) | |||
1284 | */ | 1161 | */ |
1285 | static int rp_tiocmget(struct tty_struct *tty, struct file *file) | 1162 | static int rp_tiocmget(struct tty_struct *tty, struct file *file) |
1286 | { | 1163 | { |
1287 | struct r_port *info = (struct r_port *)tty->driver_data; | 1164 | struct r_port *info = tty->driver_data; |
1288 | unsigned int control, result, ChanStatus; | 1165 | unsigned int control, result, ChanStatus; |
1289 | 1166 | ||
1290 | ChanStatus = sGetChanStatusLo(&info->channel); | 1167 | ChanStatus = sGetChanStatusLo(&info->channel); |
@@ -1305,7 +1182,7 @@ static int rp_tiocmget(struct tty_struct *tty, struct file *file) | |||
1305 | static int rp_tiocmset(struct tty_struct *tty, struct file *file, | 1182 | static int rp_tiocmset(struct tty_struct *tty, struct file *file, |
1306 | unsigned int set, unsigned int clear) | 1183 | unsigned int set, unsigned int clear) |
1307 | { | 1184 | { |
1308 | struct r_port *info = (struct r_port *)tty->driver_data; | 1185 | struct r_port *info = tty->driver_data; |
1309 | 1186 | ||
1310 | if (set & TIOCM_RTS) | 1187 | if (set & TIOCM_RTS) |
1311 | info->channel.TxControl[3] |= SET_RTS; | 1188 | info->channel.TxControl[3] |= SET_RTS; |
@@ -1338,7 +1215,8 @@ static int get_config(struct r_port *info, struct rocket_config __user *retinfo) | |||
1338 | return 0; | 1215 | return 0; |
1339 | } | 1216 | } |
1340 | 1217 | ||
1341 | static int set_config(struct r_port *info, struct rocket_config __user *new_info) | 1218 | static int set_config(struct tty_struct *tty, struct r_port *info, |
1219 | struct rocket_config __user *new_info) | ||
1342 | { | 1220 | { |
1343 | struct rocket_config new_serial; | 1221 | struct rocket_config new_serial; |
1344 | 1222 | ||
@@ -1350,7 +1228,7 @@ static int set_config(struct r_port *info, struct rocket_config __user *new_info | |||
1350 | if ((new_serial.flags & ~ROCKET_USR_MASK) != (info->flags & ~ROCKET_USR_MASK)) | 1228 | if ((new_serial.flags & ~ROCKET_USR_MASK) != (info->flags & ~ROCKET_USR_MASK)) |
1351 | return -EPERM; | 1229 | return -EPERM; |
1352 | info->flags = ((info->flags & ~ROCKET_USR_MASK) | (new_serial.flags & ROCKET_USR_MASK)); | 1230 | info->flags = ((info->flags & ~ROCKET_USR_MASK) | (new_serial.flags & ROCKET_USR_MASK)); |
1353 | configure_r_port(info, NULL); | 1231 | configure_r_port(tty, info, NULL); |
1354 | return 0; | 1232 | return 0; |
1355 | } | 1233 | } |
1356 | 1234 | ||
@@ -1359,15 +1237,15 @@ static int set_config(struct r_port *info, struct rocket_config __user *new_info | |||
1359 | info->port.closing_wait = new_serial.closing_wait; | 1237 | info->port.closing_wait = new_serial.closing_wait; |
1360 | 1238 | ||
1361 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI) | 1239 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_HI) |
1362 | info->port.tty->alt_speed = 57600; | 1240 | tty->alt_speed = 57600; |
1363 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI) | 1241 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_VHI) |
1364 | info->port.tty->alt_speed = 115200; | 1242 | tty->alt_speed = 115200; |
1365 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI) | 1243 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_SHI) |
1366 | info->port.tty->alt_speed = 230400; | 1244 | tty->alt_speed = 230400; |
1367 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP) | 1245 | if ((info->flags & ROCKET_SPD_MASK) == ROCKET_SPD_WARP) |
1368 | info->port.tty->alt_speed = 460800; | 1246 | tty->alt_speed = 460800; |
1369 | 1247 | ||
1370 | configure_r_port(info, NULL); | 1248 | configure_r_port(tty, info, NULL); |
1371 | return 0; | 1249 | return 0; |
1372 | } | 1250 | } |
1373 | 1251 | ||
@@ -1434,7 +1312,7 @@ static int get_version(struct r_port *info, struct rocket_version __user *retver | |||
1434 | static int rp_ioctl(struct tty_struct *tty, struct file *file, | 1312 | static int rp_ioctl(struct tty_struct *tty, struct file *file, |
1435 | unsigned int cmd, unsigned long arg) | 1313 | unsigned int cmd, unsigned long arg) |
1436 | { | 1314 | { |
1437 | struct r_port *info = (struct r_port *) tty->driver_data; | 1315 | struct r_port *info = tty->driver_data; |
1438 | void __user *argp = (void __user *)arg; | 1316 | void __user *argp = (void __user *)arg; |
1439 | int ret = 0; | 1317 | int ret = 0; |
1440 | 1318 | ||
@@ -1452,7 +1330,7 @@ static int rp_ioctl(struct tty_struct *tty, struct file *file, | |||
1452 | ret = get_config(info, argp); | 1330 | ret = get_config(info, argp); |
1453 | break; | 1331 | break; |
1454 | case RCKP_SET_CONFIG: | 1332 | case RCKP_SET_CONFIG: |
1455 | ret = set_config(info, argp); | 1333 | ret = set_config(tty, info, argp); |
1456 | break; | 1334 | break; |
1457 | case RCKP_GET_PORTS: | 1335 | case RCKP_GET_PORTS: |
1458 | ret = get_ports(info, argp); | 1336 | ret = get_ports(info, argp); |
@@ -1472,7 +1350,7 @@ static int rp_ioctl(struct tty_struct *tty, struct file *file, | |||
1472 | 1350 | ||
1473 | static void rp_send_xchar(struct tty_struct *tty, char ch) | 1351 | static void rp_send_xchar(struct tty_struct *tty, char ch) |
1474 | { | 1352 | { |
1475 | struct r_port *info = (struct r_port *) tty->driver_data; | 1353 | struct r_port *info = tty->driver_data; |
1476 | CHANNEL_t *cp; | 1354 | CHANNEL_t *cp; |
1477 | 1355 | ||
1478 | if (rocket_paranoia_check(info, "rp_send_xchar")) | 1356 | if (rocket_paranoia_check(info, "rp_send_xchar")) |
@@ -1487,7 +1365,7 @@ static void rp_send_xchar(struct tty_struct *tty, char ch) | |||
1487 | 1365 | ||
1488 | static void rp_throttle(struct tty_struct *tty) | 1366 | static void rp_throttle(struct tty_struct *tty) |
1489 | { | 1367 | { |
1490 | struct r_port *info = (struct r_port *) tty->driver_data; | 1368 | struct r_port *info = tty->driver_data; |
1491 | CHANNEL_t *cp; | 1369 | CHANNEL_t *cp; |
1492 | 1370 | ||
1493 | #ifdef ROCKET_DEBUG_THROTTLE | 1371 | #ifdef ROCKET_DEBUG_THROTTLE |
@@ -1507,7 +1385,7 @@ static void rp_throttle(struct tty_struct *tty) | |||
1507 | 1385 | ||
1508 | static void rp_unthrottle(struct tty_struct *tty) | 1386 | static void rp_unthrottle(struct tty_struct *tty) |
1509 | { | 1387 | { |
1510 | struct r_port *info = (struct r_port *) tty->driver_data; | 1388 | struct r_port *info = tty->driver_data; |
1511 | CHANNEL_t *cp; | 1389 | CHANNEL_t *cp; |
1512 | #ifdef ROCKET_DEBUG_THROTTLE | 1390 | #ifdef ROCKET_DEBUG_THROTTLE |
1513 | printk(KERN_INFO "unthrottle %s: %d....\n", tty->name, | 1391 | printk(KERN_INFO "unthrottle %s: %d....\n", tty->name, |
@@ -1534,7 +1412,7 @@ static void rp_unthrottle(struct tty_struct *tty) | |||
1534 | */ | 1412 | */ |
1535 | static void rp_stop(struct tty_struct *tty) | 1413 | static void rp_stop(struct tty_struct *tty) |
1536 | { | 1414 | { |
1537 | struct r_port *info = (struct r_port *) tty->driver_data; | 1415 | struct r_port *info = tty->driver_data; |
1538 | 1416 | ||
1539 | #ifdef ROCKET_DEBUG_FLOW | 1417 | #ifdef ROCKET_DEBUG_FLOW |
1540 | printk(KERN_INFO "stop %s: %d %d....\n", tty->name, | 1418 | printk(KERN_INFO "stop %s: %d %d....\n", tty->name, |
@@ -1550,7 +1428,7 @@ static void rp_stop(struct tty_struct *tty) | |||
1550 | 1428 | ||
1551 | static void rp_start(struct tty_struct *tty) | 1429 | static void rp_start(struct tty_struct *tty) |
1552 | { | 1430 | { |
1553 | struct r_port *info = (struct r_port *) tty->driver_data; | 1431 | struct r_port *info = tty->driver_data; |
1554 | 1432 | ||
1555 | #ifdef ROCKET_DEBUG_FLOW | 1433 | #ifdef ROCKET_DEBUG_FLOW |
1556 | printk(KERN_INFO "start %s: %d %d....\n", tty->name, | 1434 | printk(KERN_INFO "start %s: %d %d....\n", tty->name, |
@@ -1570,7 +1448,7 @@ static void rp_start(struct tty_struct *tty) | |||
1570 | */ | 1448 | */ |
1571 | static void rp_wait_until_sent(struct tty_struct *tty, int timeout) | 1449 | static void rp_wait_until_sent(struct tty_struct *tty, int timeout) |
1572 | { | 1450 | { |
1573 | struct r_port *info = (struct r_port *) tty->driver_data; | 1451 | struct r_port *info = tty->driver_data; |
1574 | CHANNEL_t *cp; | 1452 | CHANNEL_t *cp; |
1575 | unsigned long orig_jiffies; | 1453 | unsigned long orig_jiffies; |
1576 | int check_time, exit_time; | 1454 | int check_time, exit_time; |
@@ -1627,7 +1505,7 @@ static void rp_wait_until_sent(struct tty_struct *tty, int timeout) | |||
1627 | static void rp_hangup(struct tty_struct *tty) | 1505 | static void rp_hangup(struct tty_struct *tty) |
1628 | { | 1506 | { |
1629 | CHANNEL_t *cp; | 1507 | CHANNEL_t *cp; |
1630 | struct r_port *info = (struct r_port *) tty->driver_data; | 1508 | struct r_port *info = tty->driver_data; |
1631 | 1509 | ||
1632 | if (rocket_paranoia_check(info, "rp_hangup")) | 1510 | if (rocket_paranoia_check(info, "rp_hangup")) |
1633 | return; | 1511 | return; |
@@ -1636,15 +1514,13 @@ static void rp_hangup(struct tty_struct *tty) | |||
1636 | printk(KERN_INFO "rp_hangup of ttyR%d...\n", info->line); | 1514 | printk(KERN_INFO "rp_hangup of ttyR%d...\n", info->line); |
1637 | #endif | 1515 | #endif |
1638 | rp_flush_buffer(tty); | 1516 | rp_flush_buffer(tty); |
1639 | if (info->flags & ROCKET_CLOSING) | 1517 | if (info->port.flags & ASYNC_CLOSING) |
1640 | return; | 1518 | return; |
1641 | if (info->port.count) | 1519 | if (info->port.count) |
1642 | atomic_dec(&rp_num_ports_open); | 1520 | atomic_dec(&rp_num_ports_open); |
1643 | clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); | 1521 | clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]); |
1644 | 1522 | ||
1645 | info->port.count = 0; | 1523 | tty_port_hangup(&info->port); |
1646 | info->flags &= ~ROCKET_NORMAL_ACTIVE; | ||
1647 | info->port.tty = NULL; | ||
1648 | 1524 | ||
1649 | cp = &info->channel; | 1525 | cp = &info->channel; |
1650 | sDisRxFIFO(cp); | 1526 | sDisRxFIFO(cp); |
@@ -1653,7 +1529,7 @@ static void rp_hangup(struct tty_struct *tty) | |||
1653 | sDisCTSFlowCtl(cp); | 1529 | sDisCTSFlowCtl(cp); |
1654 | sDisTxSoftFlowCtl(cp); | 1530 | sDisTxSoftFlowCtl(cp); |
1655 | sClrTxXOFF(cp); | 1531 | sClrTxXOFF(cp); |
1656 | info->flags &= ~ROCKET_INITIALIZED; | 1532 | info->port.flags &= ~ASYNC_INITIALIZED; |
1657 | 1533 | ||
1658 | wake_up_interruptible(&info->port.open_wait); | 1534 | wake_up_interruptible(&info->port.open_wait); |
1659 | } | 1535 | } |
@@ -1667,7 +1543,7 @@ static void rp_hangup(struct tty_struct *tty) | |||
1667 | */ | 1543 | */ |
1668 | static int rp_put_char(struct tty_struct *tty, unsigned char ch) | 1544 | static int rp_put_char(struct tty_struct *tty, unsigned char ch) |
1669 | { | 1545 | { |
1670 | struct r_port *info = (struct r_port *) tty->driver_data; | 1546 | struct r_port *info = tty->driver_data; |
1671 | CHANNEL_t *cp; | 1547 | CHANNEL_t *cp; |
1672 | unsigned long flags; | 1548 | unsigned long flags; |
1673 | 1549 | ||
@@ -1714,7 +1590,7 @@ static int rp_put_char(struct tty_struct *tty, unsigned char ch) | |||
1714 | static int rp_write(struct tty_struct *tty, | 1590 | static int rp_write(struct tty_struct *tty, |
1715 | const unsigned char *buf, int count) | 1591 | const unsigned char *buf, int count) |
1716 | { | 1592 | { |
1717 | struct r_port *info = (struct r_port *) tty->driver_data; | 1593 | struct r_port *info = tty->driver_data; |
1718 | CHANNEL_t *cp; | 1594 | CHANNEL_t *cp; |
1719 | const unsigned char *b; | 1595 | const unsigned char *b; |
1720 | int c, retval = 0; | 1596 | int c, retval = 0; |
@@ -1764,7 +1640,8 @@ static int rp_write(struct tty_struct *tty, | |||
1764 | 1640 | ||
1765 | /* Write remaining data into the port's xmit_buf */ | 1641 | /* Write remaining data into the port's xmit_buf */ |
1766 | while (1) { | 1642 | while (1) { |
1767 | if (!info->port.tty) /* Seemingly obligatory check... */ | 1643 | /* Hung up ? */ |
1644 | if (!test_bit(ASYNC_NORMAL_ACTIVE, &info->port.flags)) | ||
1768 | goto end; | 1645 | goto end; |
1769 | c = min(count, XMIT_BUF_SIZE - info->xmit_cnt - 1); | 1646 | c = min(count, XMIT_BUF_SIZE - info->xmit_cnt - 1); |
1770 | c = min(c, XMIT_BUF_SIZE - info->xmit_head); | 1647 | c = min(c, XMIT_BUF_SIZE - info->xmit_head); |
@@ -1806,7 +1683,7 @@ end: | |||
1806 | */ | 1683 | */ |
1807 | static int rp_write_room(struct tty_struct *tty) | 1684 | static int rp_write_room(struct tty_struct *tty) |
1808 | { | 1685 | { |
1809 | struct r_port *info = (struct r_port *) tty->driver_data; | 1686 | struct r_port *info = tty->driver_data; |
1810 | int ret; | 1687 | int ret; |
1811 | 1688 | ||
1812 | if (rocket_paranoia_check(info, "rp_write_room")) | 1689 | if (rocket_paranoia_check(info, "rp_write_room")) |
@@ -1827,7 +1704,7 @@ static int rp_write_room(struct tty_struct *tty) | |||
1827 | */ | 1704 | */ |
1828 | static int rp_chars_in_buffer(struct tty_struct *tty) | 1705 | static int rp_chars_in_buffer(struct tty_struct *tty) |
1829 | { | 1706 | { |
1830 | struct r_port *info = (struct r_port *) tty->driver_data; | 1707 | struct r_port *info = tty->driver_data; |
1831 | CHANNEL_t *cp; | 1708 | CHANNEL_t *cp; |
1832 | 1709 | ||
1833 | if (rocket_paranoia_check(info, "rp_chars_in_buffer")) | 1710 | if (rocket_paranoia_check(info, "rp_chars_in_buffer")) |
@@ -1848,7 +1725,7 @@ static int rp_chars_in_buffer(struct tty_struct *tty) | |||
1848 | */ | 1725 | */ |
1849 | static void rp_flush_buffer(struct tty_struct *tty) | 1726 | static void rp_flush_buffer(struct tty_struct *tty) |
1850 | { | 1727 | { |
1851 | struct r_port *info = (struct r_port *) tty->driver_data; | 1728 | struct r_port *info = tty->driver_data; |
1852 | CHANNEL_t *cp; | 1729 | CHANNEL_t *cp; |
1853 | unsigned long flags; | 1730 | unsigned long flags; |
1854 | 1731 | ||
@@ -2371,6 +2248,11 @@ static const struct tty_operations rocket_ops = { | |||
2371 | .tiocmset = rp_tiocmset, | 2248 | .tiocmset = rp_tiocmset, |
2372 | }; | 2249 | }; |
2373 | 2250 | ||
2251 | static const struct tty_port_operations rocket_port_ops = { | ||
2252 | .carrier_raised = carrier_raised, | ||
2253 | .raise_dtr_rts = raise_dtr_rts, | ||
2254 | }; | ||
2255 | |||
2374 | /* | 2256 | /* |
2375 | * The module "startup" routine; it's run when the module is loaded. | 2257 | * The module "startup" routine; it's run when the module is loaded. |
2376 | */ | 2258 | */ |
diff --git a/drivers/char/rocket.h b/drivers/char/rocket.h index a8b09195ebba..ec863f35f1a9 100644 --- a/drivers/char/rocket.h +++ b/drivers/char/rocket.h | |||
@@ -39,7 +39,7 @@ struct rocket_version { | |||
39 | /* | 39 | /* |
40 | * Rocketport flags | 40 | * Rocketport flags |
41 | */ | 41 | */ |
42 | #define ROCKET_CALLOUT_NOHUP 0x00000001 | 42 | /*#define ROCKET_CALLOUT_NOHUP 0x00000001 */ |
43 | #define ROCKET_FORCE_CD 0x00000002 | 43 | #define ROCKET_FORCE_CD 0x00000002 |
44 | #define ROCKET_HUP_NOTIFY 0x00000004 | 44 | #define ROCKET_HUP_NOTIFY 0x00000004 |
45 | #define ROCKET_SPLIT_TERMIOS 0x00000008 | 45 | #define ROCKET_SPLIT_TERMIOS 0x00000008 |
diff --git a/drivers/char/rocket_int.h b/drivers/char/rocket_int.h index 21f3ff53ba32..67e0f1e778a2 100644 --- a/drivers/char/rocket_int.h +++ b/drivers/char/rocket_int.h | |||
@@ -1162,11 +1162,6 @@ struct r_port { | |||
1162 | /* number of characters left in xmit buffer before we ask for more */ | 1162 | /* number of characters left in xmit buffer before we ask for more */ |
1163 | #define WAKEUP_CHARS 256 | 1163 | #define WAKEUP_CHARS 256 |
1164 | 1164 | ||
1165 | /* Internal flags used only by the rocketport driver */ | ||
1166 | #define ROCKET_INITIALIZED 0x80000000 /* Port is active */ | ||
1167 | #define ROCKET_CLOSING 0x40000000 /* Serial port is closing */ | ||
1168 | #define ROCKET_NORMAL_ACTIVE 0x20000000 /* Normal port is active */ | ||
1169 | |||
1170 | /* | 1165 | /* |
1171 | * Assigned major numbers for the Comtrol Rocketport | 1166 | * Assigned major numbers for the Comtrol Rocketport |
1172 | */ | 1167 | */ |
diff --git a/drivers/char/selection.c b/drivers/char/selection.c index 2978a49a172b..f29fbe9b8ed7 100644 --- a/drivers/char/selection.c +++ b/drivers/char/selection.c | |||
@@ -306,7 +306,7 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t | |||
306 | */ | 306 | */ |
307 | int paste_selection(struct tty_struct *tty) | 307 | int paste_selection(struct tty_struct *tty) |
308 | { | 308 | { |
309 | struct vc_data *vc = (struct vc_data *)tty->driver_data; | 309 | struct vc_data *vc = tty->driver_data; |
310 | int pasted = 0; | 310 | int pasted = 0; |
311 | unsigned int count; | 311 | unsigned int count; |
312 | struct tty_ldisc *ld; | 312 | struct tty_ldisc *ld; |
diff --git a/drivers/char/ser_a2232.c b/drivers/char/ser_a2232.c index 7b0c35207d9b..33872a219df6 100644 --- a/drivers/char/ser_a2232.c +++ b/drivers/char/ser_a2232.c | |||
@@ -122,7 +122,7 @@ static void a2232_disable_tx_interrupts(void *ptr); | |||
122 | static void a2232_enable_tx_interrupts(void *ptr); | 122 | static void a2232_enable_tx_interrupts(void *ptr); |
123 | static void a2232_disable_rx_interrupts(void *ptr); | 123 | static void a2232_disable_rx_interrupts(void *ptr); |
124 | static void a2232_enable_rx_interrupts(void *ptr); | 124 | static void a2232_enable_rx_interrupts(void *ptr); |
125 | static int a2232_get_CD(void *ptr); | 125 | static int a2232_carrier_raised(struct tty_port *port); |
126 | static void a2232_shutdown_port(void *ptr); | 126 | static void a2232_shutdown_port(void *ptr); |
127 | static int a2232_set_real_termios(void *ptr); | 127 | static int a2232_set_real_termios(void *ptr); |
128 | static int a2232_chars_in_buffer(void *ptr); | 128 | static int a2232_chars_in_buffer(void *ptr); |
@@ -148,7 +148,6 @@ static struct real_driver a2232_real_driver = { | |||
148 | a2232_enable_tx_interrupts, | 148 | a2232_enable_tx_interrupts, |
149 | a2232_disable_rx_interrupts, | 149 | a2232_disable_rx_interrupts, |
150 | a2232_enable_rx_interrupts, | 150 | a2232_enable_rx_interrupts, |
151 | a2232_get_CD, | ||
152 | a2232_shutdown_port, | 151 | a2232_shutdown_port, |
153 | a2232_set_real_termios, | 152 | a2232_set_real_termios, |
154 | a2232_chars_in_buffer, | 153 | a2232_chars_in_buffer, |
@@ -260,9 +259,10 @@ static void a2232_enable_rx_interrupts(void *ptr) | |||
260 | port->disable_rx = 0; | 259 | port->disable_rx = 0; |
261 | } | 260 | } |
262 | 261 | ||
263 | static int a2232_get_CD(void *ptr) | 262 | static int a2232_carrier_raised(struct tty_port *port) |
264 | { | 263 | { |
265 | return ((struct a2232_port *) ptr)->cd_status; | 264 | struct a2232_port *ap = container_of(port, struct a2232_port, gs.port); |
265 | return ap->cd_status; | ||
266 | } | 266 | } |
267 | 267 | ||
268 | static void a2232_shutdown_port(void *ptr) | 268 | static void a2232_shutdown_port(void *ptr) |
@@ -460,14 +460,14 @@ static void a2232_throttle(struct tty_struct *tty) | |||
460 | if switched on. So the only thing we can do at this | 460 | if switched on. So the only thing we can do at this |
461 | layer here is not taking any characters out of the | 461 | layer here is not taking any characters out of the |
462 | A2232 buffer any more. */ | 462 | A2232 buffer any more. */ |
463 | struct a2232_port *port = (struct a2232_port *) tty->driver_data; | 463 | struct a2232_port *port = tty->driver_data; |
464 | port->throttle_input = -1; | 464 | port->throttle_input = -1; |
465 | } | 465 | } |
466 | 466 | ||
467 | static void a2232_unthrottle(struct tty_struct *tty) | 467 | static void a2232_unthrottle(struct tty_struct *tty) |
468 | { | 468 | { |
469 | /* Unthrottle: dual to "throttle()" above. */ | 469 | /* Unthrottle: dual to "throttle()" above. */ |
470 | struct a2232_port *port = (struct a2232_port *) tty->driver_data; | 470 | struct a2232_port *port = tty->driver_data; |
471 | port->throttle_input = 0; | 471 | port->throttle_input = 0; |
472 | } | 472 | } |
473 | 473 | ||
@@ -638,6 +638,10 @@ int ch, err, n, p; | |||
638 | return IRQ_HANDLED; | 638 | return IRQ_HANDLED; |
639 | } | 639 | } |
640 | 640 | ||
641 | static const struct tty_port_operations a2232_port_ops = { | ||
642 | .carrier_raised = a2232_carrier_raised, | ||
643 | }; | ||
644 | |||
641 | static void a2232_init_portstructs(void) | 645 | static void a2232_init_portstructs(void) |
642 | { | 646 | { |
643 | struct a2232_port *port; | 647 | struct a2232_port *port; |
@@ -645,6 +649,8 @@ static void a2232_init_portstructs(void) | |||
645 | 649 | ||
646 | for (i = 0; i < MAX_A2232_BOARDS*NUMLINES; i++) { | 650 | for (i = 0; i < MAX_A2232_BOARDS*NUMLINES; i++) { |
647 | port = a2232_ports + i; | 651 | port = a2232_ports + i; |
652 | tty_port_init(&port->gs.port); | ||
653 | port->gs.port.ops = &a2232_port_ops; | ||
648 | port->which_a2232 = i/NUMLINES; | 654 | port->which_a2232 = i/NUMLINES; |
649 | port->which_port_on_a2232 = i%NUMLINES; | 655 | port->which_port_on_a2232 = i%NUMLINES; |
650 | port->disable_rx = port->throttle_input = port->cd_status = 0; | 656 | port->disable_rx = port->throttle_input = port->cd_status = 0; |
@@ -652,11 +658,6 @@ static void a2232_init_portstructs(void) | |||
652 | port->gs.close_delay = HZ/2; | 658 | port->gs.close_delay = HZ/2; |
653 | port->gs.closing_wait = 30 * HZ; | 659 | port->gs.closing_wait = 30 * HZ; |
654 | port->gs.rd = &a2232_real_driver; | 660 | port->gs.rd = &a2232_real_driver; |
655 | #ifdef NEW_WRITE_LOCKING | ||
656 | mutex_init(&(port->gs.port_write_mutex)); | ||
657 | #endif | ||
658 | init_waitqueue_head(&port->gs.port.open_wait); | ||
659 | init_waitqueue_head(&port->gs.port.close_wait); | ||
660 | } | 661 | } |
661 | } | 662 | } |
662 | 663 | ||
diff --git a/drivers/char/serial167.c b/drivers/char/serial167.c index a8f15e6be594..f1f24f0ee26f 100644 --- a/drivers/char/serial167.c +++ b/drivers/char/serial167.c | |||
@@ -315,7 +315,7 @@ u_short write_cy_cmd(volatile u_char * base_addr, u_char cmd) | |||
315 | 315 | ||
316 | static void cy_stop(struct tty_struct *tty) | 316 | static void cy_stop(struct tty_struct *tty) |
317 | { | 317 | { |
318 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 318 | struct cyclades_port *info = tty->driver_data; |
319 | volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; | 319 | volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; |
320 | int channel; | 320 | int channel; |
321 | unsigned long flags; | 321 | unsigned long flags; |
@@ -337,7 +337,7 @@ static void cy_stop(struct tty_struct *tty) | |||
337 | 337 | ||
338 | static void cy_start(struct tty_struct *tty) | 338 | static void cy_start(struct tty_struct *tty) |
339 | { | 339 | { |
340 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 340 | struct cyclades_port *info = tty->driver_data; |
341 | volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; | 341 | volatile unsigned char *base_addr = (unsigned char *)BASE_ADDR; |
342 | int channel; | 342 | int channel; |
343 | unsigned long flags; | 343 | unsigned long flags; |
@@ -1062,7 +1062,7 @@ static void config_setup(struct cyclades_port *info) | |||
1062 | 1062 | ||
1063 | static int cy_put_char(struct tty_struct *tty, unsigned char ch) | 1063 | static int cy_put_char(struct tty_struct *tty, unsigned char ch) |
1064 | { | 1064 | { |
1065 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1065 | struct cyclades_port *info = tty->driver_data; |
1066 | unsigned long flags; | 1066 | unsigned long flags; |
1067 | 1067 | ||
1068 | #ifdef SERIAL_DEBUG_IO | 1068 | #ifdef SERIAL_DEBUG_IO |
@@ -1090,7 +1090,7 @@ static int cy_put_char(struct tty_struct *tty, unsigned char ch) | |||
1090 | 1090 | ||
1091 | static void cy_flush_chars(struct tty_struct *tty) | 1091 | static void cy_flush_chars(struct tty_struct *tty) |
1092 | { | 1092 | { |
1093 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1093 | struct cyclades_port *info = tty->driver_data; |
1094 | unsigned long flags; | 1094 | unsigned long flags; |
1095 | volatile unsigned char *base_addr = (u_char *) BASE_ADDR; | 1095 | volatile unsigned char *base_addr = (u_char *) BASE_ADDR; |
1096 | int channel; | 1096 | int channel; |
@@ -1122,7 +1122,7 @@ static void cy_flush_chars(struct tty_struct *tty) | |||
1122 | */ | 1122 | */ |
1123 | static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count) | 1123 | static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count) |
1124 | { | 1124 | { |
1125 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1125 | struct cyclades_port *info = tty->driver_data; |
1126 | unsigned long flags; | 1126 | unsigned long flags; |
1127 | int c, total = 0; | 1127 | int c, total = 0; |
1128 | 1128 | ||
@@ -1166,7 +1166,7 @@ static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count) | |||
1166 | 1166 | ||
1167 | static int cy_write_room(struct tty_struct *tty) | 1167 | static int cy_write_room(struct tty_struct *tty) |
1168 | { | 1168 | { |
1169 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1169 | struct cyclades_port *info = tty->driver_data; |
1170 | int ret; | 1170 | int ret; |
1171 | 1171 | ||
1172 | #ifdef SERIAL_DEBUG_IO | 1172 | #ifdef SERIAL_DEBUG_IO |
@@ -1183,7 +1183,7 @@ static int cy_write_room(struct tty_struct *tty) | |||
1183 | 1183 | ||
1184 | static int cy_chars_in_buffer(struct tty_struct *tty) | 1184 | static int cy_chars_in_buffer(struct tty_struct *tty) |
1185 | { | 1185 | { |
1186 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1186 | struct cyclades_port *info = tty->driver_data; |
1187 | 1187 | ||
1188 | #ifdef SERIAL_DEBUG_IO | 1188 | #ifdef SERIAL_DEBUG_IO |
1189 | printk("cy_chars_in_buffer %s %d\n", tty->name, info->xmit_cnt); /* */ | 1189 | printk("cy_chars_in_buffer %s %d\n", tty->name, info->xmit_cnt); /* */ |
@@ -1197,7 +1197,7 @@ static int cy_chars_in_buffer(struct tty_struct *tty) | |||
1197 | 1197 | ||
1198 | static void cy_flush_buffer(struct tty_struct *tty) | 1198 | static void cy_flush_buffer(struct tty_struct *tty) |
1199 | { | 1199 | { |
1200 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1200 | struct cyclades_port *info = tty->driver_data; |
1201 | unsigned long flags; | 1201 | unsigned long flags; |
1202 | 1202 | ||
1203 | #ifdef SERIAL_DEBUG_IO | 1203 | #ifdef SERIAL_DEBUG_IO |
@@ -1218,7 +1218,7 @@ static void cy_flush_buffer(struct tty_struct *tty) | |||
1218 | */ | 1218 | */ |
1219 | static void cy_throttle(struct tty_struct *tty) | 1219 | static void cy_throttle(struct tty_struct *tty) |
1220 | { | 1220 | { |
1221 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1221 | struct cyclades_port *info = tty->driver_data; |
1222 | unsigned long flags; | 1222 | unsigned long flags; |
1223 | volatile unsigned char *base_addr = (u_char *) BASE_ADDR; | 1223 | volatile unsigned char *base_addr = (u_char *) BASE_ADDR; |
1224 | int channel; | 1224 | int channel; |
@@ -1250,7 +1250,7 @@ static void cy_throttle(struct tty_struct *tty) | |||
1250 | 1250 | ||
1251 | static void cy_unthrottle(struct tty_struct *tty) | 1251 | static void cy_unthrottle(struct tty_struct *tty) |
1252 | { | 1252 | { |
1253 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1253 | struct cyclades_port *info = tty->driver_data; |
1254 | unsigned long flags; | 1254 | unsigned long flags; |
1255 | volatile unsigned char *base_addr = (u_char *) BASE_ADDR; | 1255 | volatile unsigned char *base_addr = (u_char *) BASE_ADDR; |
1256 | int channel; | 1256 | int channel; |
@@ -1345,7 +1345,7 @@ check_and_exit: | |||
1345 | 1345 | ||
1346 | static int cy_tiocmget(struct tty_struct *tty, struct file *file) | 1346 | static int cy_tiocmget(struct tty_struct *tty, struct file *file) |
1347 | { | 1347 | { |
1348 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1348 | struct cyclades_port *info = tty->driver_data; |
1349 | int channel; | 1349 | int channel; |
1350 | volatile unsigned char *base_addr = (u_char *) BASE_ADDR; | 1350 | volatile unsigned char *base_addr = (u_char *) BASE_ADDR; |
1351 | unsigned long flags; | 1351 | unsigned long flags; |
@@ -1369,7 +1369,7 @@ static int | |||
1369 | cy_tiocmset(struct tty_struct *tty, struct file *file, | 1369 | cy_tiocmset(struct tty_struct *tty, struct file *file, |
1370 | unsigned int set, unsigned int clear) | 1370 | unsigned int set, unsigned int clear) |
1371 | { | 1371 | { |
1372 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1372 | struct cyclades_port *info = tty->driver_data; |
1373 | int channel; | 1373 | int channel; |
1374 | volatile unsigned char *base_addr = (u_char *) BASE_ADDR; | 1374 | volatile unsigned char *base_addr = (u_char *) BASE_ADDR; |
1375 | unsigned long flags; | 1375 | unsigned long flags; |
@@ -1532,7 +1532,7 @@ cy_ioctl(struct tty_struct *tty, struct file *file, | |||
1532 | unsigned int cmd, unsigned long arg) | 1532 | unsigned int cmd, unsigned long arg) |
1533 | { | 1533 | { |
1534 | unsigned long val; | 1534 | unsigned long val; |
1535 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1535 | struct cyclades_port *info = tty->driver_data; |
1536 | int ret_val = 0; | 1536 | int ret_val = 0; |
1537 | void __user *argp = (void __user *)arg; | 1537 | void __user *argp = (void __user *)arg; |
1538 | 1538 | ||
@@ -1607,7 +1607,7 @@ cy_ioctl(struct tty_struct *tty, struct file *file, | |||
1607 | 1607 | ||
1608 | static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | 1608 | static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios) |
1609 | { | 1609 | { |
1610 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1610 | struct cyclades_port *info = tty->driver_data; |
1611 | 1611 | ||
1612 | #ifdef SERIAL_DEBUG_OTHER | 1612 | #ifdef SERIAL_DEBUG_OTHER |
1613 | printk("cy_set_termios %s\n", tty->name); | 1613 | printk("cy_set_termios %s\n", tty->name); |
@@ -1631,7 +1631,7 @@ static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
1631 | 1631 | ||
1632 | static void cy_close(struct tty_struct *tty, struct file *filp) | 1632 | static void cy_close(struct tty_struct *tty, struct file *filp) |
1633 | { | 1633 | { |
1634 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1634 | struct cyclades_port *info = tty->driver_data; |
1635 | 1635 | ||
1636 | /* CP('C'); */ | 1636 | /* CP('C'); */ |
1637 | #ifdef SERIAL_DEBUG_OTHER | 1637 | #ifdef SERIAL_DEBUG_OTHER |
@@ -1698,7 +1698,7 @@ static void cy_close(struct tty_struct *tty, struct file *filp) | |||
1698 | */ | 1698 | */ |
1699 | void cy_hangup(struct tty_struct *tty) | 1699 | void cy_hangup(struct tty_struct *tty) |
1700 | { | 1700 | { |
1701 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 1701 | struct cyclades_port *info = tty->driver_data; |
1702 | 1702 | ||
1703 | #ifdef SERIAL_DEBUG_OTHER | 1703 | #ifdef SERIAL_DEBUG_OTHER |
1704 | printk("cy_hangup %s\n", tty->name); /* */ | 1704 | printk("cy_hangup %s\n", tty->name); /* */ |
diff --git a/drivers/char/specialix.c b/drivers/char/specialix.c index a16b94f12eb2..3c67c3d83de9 100644 --- a/drivers/char/specialix.c +++ b/drivers/char/specialix.c | |||
@@ -1450,7 +1450,7 @@ static int sx_open(struct tty_struct *tty, struct file *filp) | |||
1450 | 1450 | ||
1451 | static void sx_flush_buffer(struct tty_struct *tty) | 1451 | static void sx_flush_buffer(struct tty_struct *tty) |
1452 | { | 1452 | { |
1453 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 1453 | struct specialix_port *port = tty->driver_data; |
1454 | unsigned long flags; | 1454 | unsigned long flags; |
1455 | struct specialix_board *bp; | 1455 | struct specialix_board *bp; |
1456 | 1456 | ||
@@ -1472,7 +1472,7 @@ static void sx_flush_buffer(struct tty_struct *tty) | |||
1472 | 1472 | ||
1473 | static void sx_close(struct tty_struct *tty, struct file *filp) | 1473 | static void sx_close(struct tty_struct *tty, struct file *filp) |
1474 | { | 1474 | { |
1475 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 1475 | struct specialix_port *port = tty->driver_data; |
1476 | struct specialix_board *bp; | 1476 | struct specialix_board *bp; |
1477 | unsigned long flags; | 1477 | unsigned long flags; |
1478 | unsigned long timeout; | 1478 | unsigned long timeout; |
@@ -1585,7 +1585,7 @@ static void sx_close(struct tty_struct *tty, struct file *filp) | |||
1585 | static int sx_write(struct tty_struct *tty, | 1585 | static int sx_write(struct tty_struct *tty, |
1586 | const unsigned char *buf, int count) | 1586 | const unsigned char *buf, int count) |
1587 | { | 1587 | { |
1588 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 1588 | struct specialix_port *port = tty->driver_data; |
1589 | struct specialix_board *bp; | 1589 | struct specialix_board *bp; |
1590 | int c, total = 0; | 1590 | int c, total = 0; |
1591 | unsigned long flags; | 1591 | unsigned long flags; |
@@ -1637,7 +1637,7 @@ static int sx_write(struct tty_struct *tty, | |||
1637 | 1637 | ||
1638 | static int sx_put_char(struct tty_struct *tty, unsigned char ch) | 1638 | static int sx_put_char(struct tty_struct *tty, unsigned char ch) |
1639 | { | 1639 | { |
1640 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 1640 | struct specialix_port *port = tty->driver_data; |
1641 | unsigned long flags; | 1641 | unsigned long flags; |
1642 | struct specialix_board *bp; | 1642 | struct specialix_board *bp; |
1643 | 1643 | ||
@@ -1676,7 +1676,7 @@ static int sx_put_char(struct tty_struct *tty, unsigned char ch) | |||
1676 | 1676 | ||
1677 | static void sx_flush_chars(struct tty_struct *tty) | 1677 | static void sx_flush_chars(struct tty_struct *tty) |
1678 | { | 1678 | { |
1679 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 1679 | struct specialix_port *port = tty->driver_data; |
1680 | unsigned long flags; | 1680 | unsigned long flags; |
1681 | struct specialix_board *bp = port_Board(port); | 1681 | struct specialix_board *bp = port_Board(port); |
1682 | 1682 | ||
@@ -1703,7 +1703,7 @@ static void sx_flush_chars(struct tty_struct *tty) | |||
1703 | 1703 | ||
1704 | static int sx_write_room(struct tty_struct *tty) | 1704 | static int sx_write_room(struct tty_struct *tty) |
1705 | { | 1705 | { |
1706 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 1706 | struct specialix_port *port = tty->driver_data; |
1707 | int ret; | 1707 | int ret; |
1708 | 1708 | ||
1709 | func_enter(); | 1709 | func_enter(); |
@@ -1724,7 +1724,7 @@ static int sx_write_room(struct tty_struct *tty) | |||
1724 | 1724 | ||
1725 | static int sx_chars_in_buffer(struct tty_struct *tty) | 1725 | static int sx_chars_in_buffer(struct tty_struct *tty) |
1726 | { | 1726 | { |
1727 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 1727 | struct specialix_port *port = tty->driver_data; |
1728 | 1728 | ||
1729 | func_enter(); | 1729 | func_enter(); |
1730 | 1730 | ||
@@ -1738,7 +1738,7 @@ static int sx_chars_in_buffer(struct tty_struct *tty) | |||
1738 | 1738 | ||
1739 | static int sx_tiocmget(struct tty_struct *tty, struct file *file) | 1739 | static int sx_tiocmget(struct tty_struct *tty, struct file *file) |
1740 | { | 1740 | { |
1741 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 1741 | struct specialix_port *port = tty->driver_data; |
1742 | struct specialix_board *bp; | 1742 | struct specialix_board *bp; |
1743 | unsigned char status; | 1743 | unsigned char status; |
1744 | unsigned int result; | 1744 | unsigned int result; |
@@ -1780,7 +1780,7 @@ static int sx_tiocmget(struct tty_struct *tty, struct file *file) | |||
1780 | static int sx_tiocmset(struct tty_struct *tty, struct file *file, | 1780 | static int sx_tiocmset(struct tty_struct *tty, struct file *file, |
1781 | unsigned int set, unsigned int clear) | 1781 | unsigned int set, unsigned int clear) |
1782 | { | 1782 | { |
1783 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 1783 | struct specialix_port *port = tty->driver_data; |
1784 | unsigned long flags; | 1784 | unsigned long flags; |
1785 | struct specialix_board *bp; | 1785 | struct specialix_board *bp; |
1786 | 1786 | ||
@@ -1820,7 +1820,7 @@ static int sx_tiocmset(struct tty_struct *tty, struct file *file, | |||
1820 | 1820 | ||
1821 | static int sx_send_break(struct tty_struct *tty, int length) | 1821 | static int sx_send_break(struct tty_struct *tty, int length) |
1822 | { | 1822 | { |
1823 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 1823 | struct specialix_port *port = tty->driver_data; |
1824 | struct specialix_board *bp = port_Board(port); | 1824 | struct specialix_board *bp = port_Board(port); |
1825 | unsigned long flags; | 1825 | unsigned long flags; |
1826 | 1826 | ||
@@ -1931,7 +1931,7 @@ static int sx_get_serial_info(struct specialix_port *port, | |||
1931 | static int sx_ioctl(struct tty_struct *tty, struct file *filp, | 1931 | static int sx_ioctl(struct tty_struct *tty, struct file *filp, |
1932 | unsigned int cmd, unsigned long arg) | 1932 | unsigned int cmd, unsigned long arg) |
1933 | { | 1933 | { |
1934 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 1934 | struct specialix_port *port = tty->driver_data; |
1935 | void __user *argp = (void __user *)arg; | 1935 | void __user *argp = (void __user *)arg; |
1936 | 1936 | ||
1937 | func_enter(); | 1937 | func_enter(); |
@@ -1959,7 +1959,7 @@ static int sx_ioctl(struct tty_struct *tty, struct file *filp, | |||
1959 | 1959 | ||
1960 | static void sx_throttle(struct tty_struct *tty) | 1960 | static void sx_throttle(struct tty_struct *tty) |
1961 | { | 1961 | { |
1962 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 1962 | struct specialix_port *port = tty->driver_data; |
1963 | struct specialix_board *bp; | 1963 | struct specialix_board *bp; |
1964 | unsigned long flags; | 1964 | unsigned long flags; |
1965 | 1965 | ||
@@ -2004,7 +2004,7 @@ static void sx_throttle(struct tty_struct *tty) | |||
2004 | 2004 | ||
2005 | static void sx_unthrottle(struct tty_struct *tty) | 2005 | static void sx_unthrottle(struct tty_struct *tty) |
2006 | { | 2006 | { |
2007 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 2007 | struct specialix_port *port = tty->driver_data; |
2008 | struct specialix_board *bp; | 2008 | struct specialix_board *bp; |
2009 | unsigned long flags; | 2009 | unsigned long flags; |
2010 | 2010 | ||
@@ -2045,7 +2045,7 @@ static void sx_unthrottle(struct tty_struct *tty) | |||
2045 | 2045 | ||
2046 | static void sx_stop(struct tty_struct *tty) | 2046 | static void sx_stop(struct tty_struct *tty) |
2047 | { | 2047 | { |
2048 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 2048 | struct specialix_port *port = tty->driver_data; |
2049 | struct specialix_board *bp; | 2049 | struct specialix_board *bp; |
2050 | unsigned long flags; | 2050 | unsigned long flags; |
2051 | 2051 | ||
@@ -2072,7 +2072,7 @@ static void sx_stop(struct tty_struct *tty) | |||
2072 | 2072 | ||
2073 | static void sx_start(struct tty_struct *tty) | 2073 | static void sx_start(struct tty_struct *tty) |
2074 | { | 2074 | { |
2075 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 2075 | struct specialix_port *port = tty->driver_data; |
2076 | struct specialix_board *bp; | 2076 | struct specialix_board *bp; |
2077 | unsigned long flags; | 2077 | unsigned long flags; |
2078 | 2078 | ||
@@ -2100,7 +2100,7 @@ static void sx_start(struct tty_struct *tty) | |||
2100 | 2100 | ||
2101 | static void sx_hangup(struct tty_struct *tty) | 2101 | static void sx_hangup(struct tty_struct *tty) |
2102 | { | 2102 | { |
2103 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 2103 | struct specialix_port *port = tty->driver_data; |
2104 | struct specialix_board *bp; | 2104 | struct specialix_board *bp; |
2105 | unsigned long flags; | 2105 | unsigned long flags; |
2106 | 2106 | ||
@@ -2135,7 +2135,7 @@ static void sx_hangup(struct tty_struct *tty) | |||
2135 | static void sx_set_termios(struct tty_struct *tty, | 2135 | static void sx_set_termios(struct tty_struct *tty, |
2136 | struct ktermios *old_termios) | 2136 | struct ktermios *old_termios) |
2137 | { | 2137 | { |
2138 | struct specialix_port *port = (struct specialix_port *)tty->driver_data; | 2138 | struct specialix_port *port = tty->driver_data; |
2139 | unsigned long flags; | 2139 | unsigned long flags; |
2140 | struct specialix_board *bp; | 2140 | struct specialix_board *bp; |
2141 | 2141 | ||
diff --git a/drivers/char/stallion.c b/drivers/char/stallion.c index 963b03fb29e5..e1e0dd89ac9a 100644 --- a/drivers/char/stallion.c +++ b/drivers/char/stallion.c | |||
@@ -130,6 +130,8 @@ static char stl_unwanted[SC26198_RXFIFOSIZE]; | |||
130 | static DEFINE_MUTEX(stl_brdslock); | 130 | static DEFINE_MUTEX(stl_brdslock); |
131 | static struct stlbrd *stl_brds[STL_MAXBRDS]; | 131 | static struct stlbrd *stl_brds[STL_MAXBRDS]; |
132 | 132 | ||
133 | static const struct tty_port_operations stl_port_ops; | ||
134 | |||
133 | /* | 135 | /* |
134 | * Per board state flags. Used with the state field of the board struct. | 136 | * Per board state flags. Used with the state field of the board struct. |
135 | * Not really much here! | 137 | * Not really much here! |
@@ -407,7 +409,6 @@ static int stl_memioctl(struct inode *ip, struct file *fp, unsigned int cmd, uns | |||
407 | static int stl_brdinit(struct stlbrd *brdp); | 409 | static int stl_brdinit(struct stlbrd *brdp); |
408 | static int stl_getportstats(struct tty_struct *tty, struct stlport *portp, comstats_t __user *cp); | 410 | static int stl_getportstats(struct tty_struct *tty, struct stlport *portp, comstats_t __user *cp); |
409 | static int stl_clrportstats(struct stlport *portp, comstats_t __user *cp); | 411 | static int stl_clrportstats(struct stlport *portp, comstats_t __user *cp); |
410 | static int stl_waitcarrier(struct tty_struct *tty, struct stlport *portp, struct file *filp); | ||
411 | 412 | ||
412 | /* | 413 | /* |
413 | * CD1400 uart specific handling functions. | 414 | * CD1400 uart specific handling functions. |
@@ -703,8 +704,9 @@ static int stl_open(struct tty_struct *tty, struct file *filp) | |||
703 | { | 704 | { |
704 | struct stlport *portp; | 705 | struct stlport *portp; |
705 | struct stlbrd *brdp; | 706 | struct stlbrd *brdp; |
707 | struct tty_port *port; | ||
706 | unsigned int minordev, brdnr, panelnr; | 708 | unsigned int minordev, brdnr, panelnr; |
707 | int portnr, rc; | 709 | int portnr; |
708 | 710 | ||
709 | pr_debug("stl_open(tty=%p,filp=%p): device=%s\n", tty, filp, tty->name); | 711 | pr_debug("stl_open(tty=%p,filp=%p): device=%s\n", tty, filp, tty->name); |
710 | 712 | ||
@@ -715,6 +717,7 @@ static int stl_open(struct tty_struct *tty, struct file *filp) | |||
715 | brdp = stl_brds[brdnr]; | 717 | brdp = stl_brds[brdnr]; |
716 | if (brdp == NULL) | 718 | if (brdp == NULL) |
717 | return -ENODEV; | 719 | return -ENODEV; |
720 | |||
718 | minordev = MINOR2PORT(minordev); | 721 | minordev = MINOR2PORT(minordev); |
719 | for (portnr = -1, panelnr = 0; panelnr < STL_MAXPANELS; panelnr++) { | 722 | for (portnr = -1, panelnr = 0; panelnr < STL_MAXPANELS; panelnr++) { |
720 | if (brdp->panels[panelnr] == NULL) | 723 | if (brdp->panels[panelnr] == NULL) |
@@ -731,16 +734,17 @@ static int stl_open(struct tty_struct *tty, struct file *filp) | |||
731 | portp = brdp->panels[panelnr]->ports[portnr]; | 734 | portp = brdp->panels[panelnr]->ports[portnr]; |
732 | if (portp == NULL) | 735 | if (portp == NULL) |
733 | return -ENODEV; | 736 | return -ENODEV; |
737 | port = &portp->port; | ||
734 | 738 | ||
735 | /* | 739 | /* |
736 | * On the first open of the device setup the port hardware, and | 740 | * On the first open of the device setup the port hardware, and |
737 | * initialize the per port data structure. | 741 | * initialize the per port data structure. |
738 | */ | 742 | */ |
739 | tty_port_tty_set(&portp->port, tty); | 743 | tty_port_tty_set(port, tty); |
740 | tty->driver_data = portp; | 744 | tty->driver_data = portp; |
741 | portp->port.count++; | 745 | port->count++; |
742 | 746 | ||
743 | if ((portp->port.flags & ASYNC_INITIALIZED) == 0) { | 747 | if ((port->flags & ASYNC_INITIALIZED) == 0) { |
744 | if (!portp->tx.buf) { | 748 | if (!portp->tx.buf) { |
745 | portp->tx.buf = kmalloc(STL_TXBUFSIZE, GFP_KERNEL); | 749 | portp->tx.buf = kmalloc(STL_TXBUFSIZE, GFP_KERNEL); |
746 | if (!portp->tx.buf) | 750 | if (!portp->tx.buf) |
@@ -754,91 +758,24 @@ static int stl_open(struct tty_struct *tty, struct file *filp) | |||
754 | stl_enablerxtx(portp, 1, 1); | 758 | stl_enablerxtx(portp, 1, 1); |
755 | stl_startrxtx(portp, 1, 0); | 759 | stl_startrxtx(portp, 1, 0); |
756 | clear_bit(TTY_IO_ERROR, &tty->flags); | 760 | clear_bit(TTY_IO_ERROR, &tty->flags); |
757 | portp->port.flags |= ASYNC_INITIALIZED; | 761 | port->flags |= ASYNC_INITIALIZED; |
758 | } | ||
759 | |||
760 | /* | ||
761 | * Check if this port is in the middle of closing. If so then wait | ||
762 | * until it is closed then return error status, based on flag settings. | ||
763 | * The sleep here does not need interrupt protection since the wakeup | ||
764 | * for it is done with the same context. | ||
765 | */ | ||
766 | if (portp->port.flags & ASYNC_CLOSING) { | ||
767 | interruptible_sleep_on(&portp->port.close_wait); | ||
768 | if (portp->port.flags & ASYNC_HUP_NOTIFY) | ||
769 | return -EAGAIN; | ||
770 | return -ERESTARTSYS; | ||
771 | } | 762 | } |
772 | 763 | return tty_port_block_til_ready(port, tty, filp); | |
773 | /* | ||
774 | * Based on type of open being done check if it can overlap with any | ||
775 | * previous opens still in effect. If we are a normal serial device | ||
776 | * then also we might have to wait for carrier. | ||
777 | */ | ||
778 | if (!(filp->f_flags & O_NONBLOCK)) | ||
779 | if ((rc = stl_waitcarrier(tty, portp, filp)) != 0) | ||
780 | return rc; | ||
781 | |||
782 | portp->port.flags |= ASYNC_NORMAL_ACTIVE; | ||
783 | |||
784 | return 0; | ||
785 | } | 764 | } |
786 | 765 | ||
787 | /*****************************************************************************/ | 766 | /*****************************************************************************/ |
788 | 767 | ||
789 | /* | 768 | static int stl_carrier_raised(struct tty_port *port) |
790 | * Possibly need to wait for carrier (DCD signal) to come high. Say | ||
791 | * maybe because if we are clocal then we don't need to wait... | ||
792 | */ | ||
793 | |||
794 | static int stl_waitcarrier(struct tty_struct *tty, struct stlport *portp, | ||
795 | struct file *filp) | ||
796 | { | 769 | { |
797 | unsigned long flags; | 770 | struct stlport *portp = container_of(port, struct stlport, port); |
798 | int rc, doclocal; | 771 | return (portp->sigs & TIOCM_CD) ? 1 : 0; |
799 | 772 | } | |
800 | pr_debug("stl_waitcarrier(portp=%p,filp=%p)\n", portp, filp); | ||
801 | |||
802 | rc = 0; | ||
803 | doclocal = 0; | ||
804 | |||
805 | spin_lock_irqsave(&stallion_lock, flags); | ||
806 | |||
807 | if (tty->termios->c_cflag & CLOCAL) | ||
808 | doclocal++; | ||
809 | |||
810 | portp->openwaitcnt++; | ||
811 | if (! tty_hung_up_p(filp)) | ||
812 | portp->port.count--; | ||
813 | |||
814 | for (;;) { | ||
815 | /* Takes brd_lock internally */ | ||
816 | stl_setsignals(portp, 1, 1); | ||
817 | if (tty_hung_up_p(filp) || | ||
818 | ((portp->port.flags & ASYNC_INITIALIZED) == 0)) { | ||
819 | if (portp->port.flags & ASYNC_HUP_NOTIFY) | ||
820 | rc = -EBUSY; | ||
821 | else | ||
822 | rc = -ERESTARTSYS; | ||
823 | break; | ||
824 | } | ||
825 | if (((portp->port.flags & ASYNC_CLOSING) == 0) && | ||
826 | (doclocal || (portp->sigs & TIOCM_CD))) | ||
827 | break; | ||
828 | if (signal_pending(current)) { | ||
829 | rc = -ERESTARTSYS; | ||
830 | break; | ||
831 | } | ||
832 | /* FIXME */ | ||
833 | interruptible_sleep_on(&portp->port.open_wait); | ||
834 | } | ||
835 | |||
836 | if (! tty_hung_up_p(filp)) | ||
837 | portp->port.count++; | ||
838 | portp->openwaitcnt--; | ||
839 | spin_unlock_irqrestore(&stallion_lock, flags); | ||
840 | 773 | ||
841 | return rc; | 774 | static void stl_raise_dtr_rts(struct tty_port *port) |
775 | { | ||
776 | struct stlport *portp = container_of(port, struct stlport, port); | ||
777 | /* Takes brd_lock internally */ | ||
778 | stl_setsignals(portp, 1, 1); | ||
842 | } | 779 | } |
843 | 780 | ||
844 | /*****************************************************************************/ | 781 | /*****************************************************************************/ |
@@ -890,47 +827,29 @@ static void stl_waituntilsent(struct tty_struct *tty, int timeout) | |||
890 | static void stl_close(struct tty_struct *tty, struct file *filp) | 827 | static void stl_close(struct tty_struct *tty, struct file *filp) |
891 | { | 828 | { |
892 | struct stlport *portp; | 829 | struct stlport *portp; |
830 | struct tty_port *port; | ||
893 | unsigned long flags; | 831 | unsigned long flags; |
894 | 832 | ||
895 | pr_debug("stl_close(tty=%p,filp=%p)\n", tty, filp); | 833 | pr_debug("stl_close(tty=%p,filp=%p)\n", tty, filp); |
896 | 834 | ||
897 | portp = tty->driver_data; | 835 | portp = tty->driver_data; |
898 | if (portp == NULL) | 836 | BUG_ON(portp == NULL); |
899 | return; | ||
900 | 837 | ||
901 | spin_lock_irqsave(&stallion_lock, flags); | 838 | port = &portp->port; |
902 | if (tty_hung_up_p(filp)) { | ||
903 | spin_unlock_irqrestore(&stallion_lock, flags); | ||
904 | return; | ||
905 | } | ||
906 | if ((tty->count == 1) && (portp->port.count != 1)) | ||
907 | portp->port.count = 1; | ||
908 | if (portp->port.count-- > 1) { | ||
909 | spin_unlock_irqrestore(&stallion_lock, flags); | ||
910 | return; | ||
911 | } | ||
912 | |||
913 | portp->port.count = 0; | ||
914 | portp->port.flags |= ASYNC_CLOSING; | ||
915 | 839 | ||
840 | if (tty_port_close_start(port, tty, filp) == 0) | ||
841 | return; | ||
916 | /* | 842 | /* |
917 | * May want to wait for any data to drain before closing. The BUSY | 843 | * May want to wait for any data to drain before closing. The BUSY |
918 | * flag keeps track of whether we are still sending or not - it is | 844 | * flag keeps track of whether we are still sending or not - it is |
919 | * very accurate for the cd1400, not quite so for the sc26198. | 845 | * very accurate for the cd1400, not quite so for the sc26198. |
920 | * (The sc26198 has no "end-of-data" interrupt only empty FIFO) | 846 | * (The sc26198 has no "end-of-data" interrupt only empty FIFO) |
921 | */ | 847 | */ |
922 | tty->closing = 1; | ||
923 | |||
924 | spin_unlock_irqrestore(&stallion_lock, flags); | ||
925 | |||
926 | if (portp->closing_wait != ASYNC_CLOSING_WAIT_NONE) | ||
927 | tty_wait_until_sent(tty, portp->closing_wait); | ||
928 | stl_waituntilsent(tty, (HZ / 2)); | 848 | stl_waituntilsent(tty, (HZ / 2)); |
929 | 849 | ||
930 | 850 | spin_lock_irqsave(&port->lock, flags); | |
931 | spin_lock_irqsave(&stallion_lock, flags); | ||
932 | portp->port.flags &= ~ASYNC_INITIALIZED; | 851 | portp->port.flags &= ~ASYNC_INITIALIZED; |
933 | spin_unlock_irqrestore(&stallion_lock, flags); | 852 | spin_unlock_irqrestore(&port->lock, flags); |
934 | 853 | ||
935 | stl_disableintrs(portp); | 854 | stl_disableintrs(portp); |
936 | if (tty->termios->c_cflag & HUPCL) | 855 | if (tty->termios->c_cflag & HUPCL) |
@@ -944,20 +863,9 @@ static void stl_close(struct tty_struct *tty, struct file *filp) | |||
944 | portp->tx.head = NULL; | 863 | portp->tx.head = NULL; |
945 | portp->tx.tail = NULL; | 864 | portp->tx.tail = NULL; |
946 | } | 865 | } |
947 | set_bit(TTY_IO_ERROR, &tty->flags); | ||
948 | tty_ldisc_flush(tty); | ||
949 | 866 | ||
950 | tty->closing = 0; | 867 | tty_port_close_end(port, tty); |
951 | tty_port_tty_set(&portp->port, NULL); | 868 | tty_port_tty_set(port, NULL); |
952 | |||
953 | if (portp->openwaitcnt) { | ||
954 | if (portp->close_delay) | ||
955 | msleep_interruptible(jiffies_to_msecs(portp->close_delay)); | ||
956 | wake_up_interruptible(&portp->port.open_wait); | ||
957 | } | ||
958 | |||
959 | portp->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); | ||
960 | wake_up_interruptible(&portp->port.close_wait); | ||
961 | } | 869 | } |
962 | 870 | ||
963 | /*****************************************************************************/ | 871 | /*****************************************************************************/ |
@@ -1405,14 +1313,20 @@ static void stl_stop(struct tty_struct *tty) | |||
1405 | static void stl_hangup(struct tty_struct *tty) | 1313 | static void stl_hangup(struct tty_struct *tty) |
1406 | { | 1314 | { |
1407 | struct stlport *portp; | 1315 | struct stlport *portp; |
1316 | struct tty_port *port; | ||
1317 | unsigned long flags; | ||
1408 | 1318 | ||
1409 | pr_debug("stl_hangup(tty=%p)\n", tty); | 1319 | pr_debug("stl_hangup(tty=%p)\n", tty); |
1410 | 1320 | ||
1411 | portp = tty->driver_data; | 1321 | portp = tty->driver_data; |
1412 | if (portp == NULL) | 1322 | if (portp == NULL) |
1413 | return; | 1323 | return; |
1324 | port = &portp->port; | ||
1325 | |||
1326 | spin_lock_irqsave(&port->lock, flags); | ||
1327 | port->flags &= ~ASYNC_INITIALIZED; | ||
1328 | spin_unlock_irqrestore(&port->lock, flags); | ||
1414 | 1329 | ||
1415 | portp->port.flags &= ~ASYNC_INITIALIZED; | ||
1416 | stl_disableintrs(portp); | 1330 | stl_disableintrs(portp); |
1417 | if (tty->termios->c_cflag & HUPCL) | 1331 | if (tty->termios->c_cflag & HUPCL) |
1418 | stl_setsignals(portp, 0, 0); | 1332 | stl_setsignals(portp, 0, 0); |
@@ -1426,10 +1340,7 @@ static void stl_hangup(struct tty_struct *tty) | |||
1426 | portp->tx.head = NULL; | 1340 | portp->tx.head = NULL; |
1427 | portp->tx.tail = NULL; | 1341 | portp->tx.tail = NULL; |
1428 | } | 1342 | } |
1429 | tty_port_tty_set(&portp->port, NULL); | 1343 | tty_port_hangup(port); |
1430 | portp->port.flags &= ~ASYNC_NORMAL_ACTIVE; | ||
1431 | portp->port.count = 0; | ||
1432 | wake_up_interruptible(&portp->port.open_wait); | ||
1433 | } | 1344 | } |
1434 | 1345 | ||
1435 | /*****************************************************************************/ | 1346 | /*****************************************************************************/ |
@@ -1776,6 +1687,7 @@ static int __devinit stl_initports(struct stlbrd *brdp, struct stlpanel *panelp) | |||
1776 | break; | 1687 | break; |
1777 | } | 1688 | } |
1778 | tty_port_init(&portp->port); | 1689 | tty_port_init(&portp->port); |
1690 | portp->port.ops = &stl_port_ops; | ||
1779 | portp->magic = STL_PORTMAGIC; | 1691 | portp->magic = STL_PORTMAGIC; |
1780 | portp->portnr = i; | 1692 | portp->portnr = i; |
1781 | portp->brdnr = panelp->brdnr; | 1693 | portp->brdnr = panelp->brdnr; |
@@ -2659,6 +2571,11 @@ static const struct tty_operations stl_ops = { | |||
2659 | .tiocmset = stl_tiocmset, | 2571 | .tiocmset = stl_tiocmset, |
2660 | }; | 2572 | }; |
2661 | 2573 | ||
2574 | static const struct tty_port_operations stl_port_ops = { | ||
2575 | .carrier_raised = stl_carrier_raised, | ||
2576 | .raise_dtr_rts = stl_raise_dtr_rts, | ||
2577 | }; | ||
2578 | |||
2662 | /*****************************************************************************/ | 2579 | /*****************************************************************************/ |
2663 | /* CD1400 HARDWARE FUNCTIONS */ | 2580 | /* CD1400 HARDWARE FUNCTIONS */ |
2664 | /*****************************************************************************/ | 2581 | /*****************************************************************************/ |
diff --git a/drivers/char/sx.c b/drivers/char/sx.c index ba4e86281fbf..b60be7b0decf 100644 --- a/drivers/char/sx.c +++ b/drivers/char/sx.c | |||
@@ -279,7 +279,7 @@ static void sx_disable_tx_interrupts(void *ptr); | |||
279 | static void sx_enable_tx_interrupts(void *ptr); | 279 | static void sx_enable_tx_interrupts(void *ptr); |
280 | static void sx_disable_rx_interrupts(void *ptr); | 280 | static void sx_disable_rx_interrupts(void *ptr); |
281 | static void sx_enable_rx_interrupts(void *ptr); | 281 | static void sx_enable_rx_interrupts(void *ptr); |
282 | static int sx_get_CD(void *ptr); | 282 | static int sx_carrier_raised(struct tty_port *port); |
283 | static void sx_shutdown_port(void *ptr); | 283 | static void sx_shutdown_port(void *ptr); |
284 | static int sx_set_real_termios(void *ptr); | 284 | static int sx_set_real_termios(void *ptr); |
285 | static void sx_close(void *ptr); | 285 | static void sx_close(void *ptr); |
@@ -360,7 +360,6 @@ static struct real_driver sx_real_driver = { | |||
360 | sx_enable_tx_interrupts, | 360 | sx_enable_tx_interrupts, |
361 | sx_disable_rx_interrupts, | 361 | sx_disable_rx_interrupts, |
362 | sx_enable_rx_interrupts, | 362 | sx_enable_rx_interrupts, |
363 | sx_get_CD, | ||
364 | sx_shutdown_port, | 363 | sx_shutdown_port, |
365 | sx_set_real_termios, | 364 | sx_set_real_termios, |
366 | sx_chars_in_buffer, | 365 | sx_chars_in_buffer, |
@@ -791,7 +790,7 @@ static int sx_getsignals(struct sx_port *port) | |||
791 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "getsignals: %d/%d (%d/%d) " | 790 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "getsignals: %d/%d (%d/%d) " |
792 | "%02x/%02x\n", | 791 | "%02x/%02x\n", |
793 | (o_stat & OP_DTR) != 0, (o_stat & OP_RTS) != 0, | 792 | (o_stat & OP_DTR) != 0, (o_stat & OP_RTS) != 0, |
794 | port->c_dcd, sx_get_CD(port), | 793 | port->c_dcd, tty_port_carrier_raised(&port->gs.port), |
795 | sx_read_channel_byte(port, hi_ip), | 794 | sx_read_channel_byte(port, hi_ip), |
796 | sx_read_channel_byte(port, hi_state)); | 795 | sx_read_channel_byte(port, hi_state)); |
797 | 796 | ||
@@ -1190,7 +1189,7 @@ static inline void sx_check_modem_signals(struct sx_port *port) | |||
1190 | 1189 | ||
1191 | hi_state = sx_read_channel_byte(port, hi_state); | 1190 | hi_state = sx_read_channel_byte(port, hi_state); |
1192 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "Checking modem signals (%d/%d)\n", | 1191 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "Checking modem signals (%d/%d)\n", |
1193 | port->c_dcd, sx_get_CD(port)); | 1192 | port->c_dcd, tty_port_carrier_raised(&port->gs.port)); |
1194 | 1193 | ||
1195 | if (hi_state & ST_BREAK) { | 1194 | if (hi_state & ST_BREAK) { |
1196 | hi_state &= ~ST_BREAK; | 1195 | hi_state &= ~ST_BREAK; |
@@ -1202,11 +1201,11 @@ static inline void sx_check_modem_signals(struct sx_port *port) | |||
1202 | hi_state &= ~ST_DCD; | 1201 | hi_state &= ~ST_DCD; |
1203 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "got a DCD change.\n"); | 1202 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "got a DCD change.\n"); |
1204 | sx_write_channel_byte(port, hi_state, hi_state); | 1203 | sx_write_channel_byte(port, hi_state, hi_state); |
1205 | c_dcd = sx_get_CD(port); | 1204 | c_dcd = tty_port_carrier_raised(&port->gs.port); |
1206 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD is now %d\n", c_dcd); | 1205 | sx_dprintk(SX_DEBUG_MODEMSIGNALS, "DCD is now %d\n", c_dcd); |
1207 | if (c_dcd != port->c_dcd) { | 1206 | if (c_dcd != port->c_dcd) { |
1208 | port->c_dcd = c_dcd; | 1207 | port->c_dcd = c_dcd; |
1209 | if (sx_get_CD(port)) { | 1208 | if (tty_port_carrier_raised(&port->gs.port)) { |
1210 | /* DCD went UP */ | 1209 | /* DCD went UP */ |
1211 | if ((sx_read_channel_byte(port, hi_hstat) != | 1210 | if ((sx_read_channel_byte(port, hi_hstat) != |
1212 | HS_IDLE_CLOSED) && | 1211 | HS_IDLE_CLOSED) && |
@@ -1415,13 +1414,10 @@ static void sx_enable_rx_interrupts(void *ptr) | |||
1415 | } | 1414 | } |
1416 | 1415 | ||
1417 | /* Jeez. Isn't this simple? */ | 1416 | /* Jeez. Isn't this simple? */ |
1418 | static int sx_get_CD(void *ptr) | 1417 | static int sx_carrier_raised(struct tty_port *port) |
1419 | { | 1418 | { |
1420 | struct sx_port *port = ptr; | 1419 | struct sx_port *sp = container_of(port, struct sx_port, gs.port); |
1421 | func_enter2(); | 1420 | return ((sx_read_channel_byte(sp, hi_ip) & IP_DCD) != 0); |
1422 | |||
1423 | func_exit(); | ||
1424 | return ((sx_read_channel_byte(port, hi_ip) & IP_DCD) != 0); | ||
1425 | } | 1421 | } |
1426 | 1422 | ||
1427 | /* Jeez. Isn't this simple? */ | 1423 | /* Jeez. Isn't this simple? */ |
@@ -1536,7 +1532,7 @@ static int sx_open(struct tty_struct *tty, struct file *filp) | |||
1536 | } | 1532 | } |
1537 | /* tty->low_latency = 1; */ | 1533 | /* tty->low_latency = 1; */ |
1538 | 1534 | ||
1539 | port->c_dcd = sx_get_CD(port); | 1535 | port->c_dcd = sx_carrier_raised(&port->gs.port); |
1540 | sx_dprintk(SX_DEBUG_OPEN, "at open: cd=%d\n", port->c_dcd); | 1536 | sx_dprintk(SX_DEBUG_OPEN, "at open: cd=%d\n", port->c_dcd); |
1541 | 1537 | ||
1542 | func_exit(); | 1538 | func_exit(); |
@@ -1945,7 +1941,7 @@ static int sx_ioctl(struct tty_struct *tty, struct file *filp, | |||
1945 | 1941 | ||
1946 | static void sx_throttle(struct tty_struct *tty) | 1942 | static void sx_throttle(struct tty_struct *tty) |
1947 | { | 1943 | { |
1948 | struct sx_port *port = (struct sx_port *)tty->driver_data; | 1944 | struct sx_port *port = tty->driver_data; |
1949 | 1945 | ||
1950 | func_enter2(); | 1946 | func_enter2(); |
1951 | /* If the port is using any type of input flow | 1947 | /* If the port is using any type of input flow |
@@ -1959,7 +1955,7 @@ static void sx_throttle(struct tty_struct *tty) | |||
1959 | 1955 | ||
1960 | static void sx_unthrottle(struct tty_struct *tty) | 1956 | static void sx_unthrottle(struct tty_struct *tty) |
1961 | { | 1957 | { |
1962 | struct sx_port *port = (struct sx_port *)tty->driver_data; | 1958 | struct sx_port *port = tty->driver_data; |
1963 | 1959 | ||
1964 | func_enter2(); | 1960 | func_enter2(); |
1965 | /* Always unthrottle even if flow control is not enabled on | 1961 | /* Always unthrottle even if flow control is not enabled on |
@@ -2354,6 +2350,10 @@ static const struct tty_operations sx_ops = { | |||
2354 | .tiocmset = sx_tiocmset, | 2350 | .tiocmset = sx_tiocmset, |
2355 | }; | 2351 | }; |
2356 | 2352 | ||
2353 | static const struct tty_port_operations sx_port_ops = { | ||
2354 | .carrier_raised = sx_carrier_raised, | ||
2355 | }; | ||
2356 | |||
2357 | static int sx_init_drivers(void) | 2357 | static int sx_init_drivers(void) |
2358 | { | 2358 | { |
2359 | int error; | 2359 | int error; |
@@ -2410,6 +2410,7 @@ static int sx_init_portstructs(int nboards, int nports) | |||
2410 | for (j = 0; j < boards[i].nports; j++) { | 2410 | for (j = 0; j < boards[i].nports; j++) { |
2411 | sx_dprintk(SX_DEBUG_INIT, "initing port %d\n", j); | 2411 | sx_dprintk(SX_DEBUG_INIT, "initing port %d\n", j); |
2412 | tty_port_init(&port->gs.port); | 2412 | tty_port_init(&port->gs.port); |
2413 | port->gs.port.ops = &sx_port_ops; | ||
2413 | port->gs.magic = SX_MAGIC; | 2414 | port->gs.magic = SX_MAGIC; |
2414 | port->gs.close_delay = HZ / 2; | 2415 | port->gs.close_delay = HZ / 2; |
2415 | port->gs.closing_wait = 30 * HZ; | 2416 | port->gs.closing_wait = 30 * HZ; |
diff --git a/drivers/char/synclink.c b/drivers/char/synclink.c index 500f5176b6ba..b8063d4cad32 100644 --- a/drivers/char/synclink.c +++ b/drivers/char/synclink.c | |||
@@ -977,7 +977,7 @@ static void ldisc_receive_buf(struct tty_struct *tty, | |||
977 | */ | 977 | */ |
978 | static void mgsl_stop(struct tty_struct *tty) | 978 | static void mgsl_stop(struct tty_struct *tty) |
979 | { | 979 | { |
980 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 980 | struct mgsl_struct *info = tty->driver_data; |
981 | unsigned long flags; | 981 | unsigned long flags; |
982 | 982 | ||
983 | if (mgsl_paranoia_check(info, tty->name, "mgsl_stop")) | 983 | if (mgsl_paranoia_check(info, tty->name, "mgsl_stop")) |
@@ -1000,7 +1000,7 @@ static void mgsl_stop(struct tty_struct *tty) | |||
1000 | */ | 1000 | */ |
1001 | static void mgsl_start(struct tty_struct *tty) | 1001 | static void mgsl_start(struct tty_struct *tty) |
1002 | { | 1002 | { |
1003 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 1003 | struct mgsl_struct *info = tty->driver_data; |
1004 | unsigned long flags; | 1004 | unsigned long flags; |
1005 | 1005 | ||
1006 | if (mgsl_paranoia_check(info, tty->name, "mgsl_start")) | 1006 | if (mgsl_paranoia_check(info, tty->name, "mgsl_start")) |
@@ -2057,7 +2057,7 @@ static int mgsl_put_char(struct tty_struct *tty, unsigned char ch) | |||
2057 | */ | 2057 | */ |
2058 | static void mgsl_flush_chars(struct tty_struct *tty) | 2058 | static void mgsl_flush_chars(struct tty_struct *tty) |
2059 | { | 2059 | { |
2060 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 2060 | struct mgsl_struct *info = tty->driver_data; |
2061 | unsigned long flags; | 2061 | unsigned long flags; |
2062 | 2062 | ||
2063 | if ( debug_level >= DEBUG_LEVEL_INFO ) | 2063 | if ( debug_level >= DEBUG_LEVEL_INFO ) |
@@ -2109,7 +2109,7 @@ static int mgsl_write(struct tty_struct * tty, | |||
2109 | const unsigned char *buf, int count) | 2109 | const unsigned char *buf, int count) |
2110 | { | 2110 | { |
2111 | int c, ret = 0; | 2111 | int c, ret = 0; |
2112 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 2112 | struct mgsl_struct *info = tty->driver_data; |
2113 | unsigned long flags; | 2113 | unsigned long flags; |
2114 | 2114 | ||
2115 | if ( debug_level >= DEBUG_LEVEL_INFO ) | 2115 | if ( debug_level >= DEBUG_LEVEL_INFO ) |
@@ -2232,7 +2232,7 @@ cleanup: | |||
2232 | */ | 2232 | */ |
2233 | static int mgsl_write_room(struct tty_struct *tty) | 2233 | static int mgsl_write_room(struct tty_struct *tty) |
2234 | { | 2234 | { |
2235 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 2235 | struct mgsl_struct *info = tty->driver_data; |
2236 | int ret; | 2236 | int ret; |
2237 | 2237 | ||
2238 | if (mgsl_paranoia_check(info, tty->name, "mgsl_write_room")) | 2238 | if (mgsl_paranoia_check(info, tty->name, "mgsl_write_room")) |
@@ -2267,7 +2267,7 @@ static int mgsl_write_room(struct tty_struct *tty) | |||
2267 | */ | 2267 | */ |
2268 | static int mgsl_chars_in_buffer(struct tty_struct *tty) | 2268 | static int mgsl_chars_in_buffer(struct tty_struct *tty) |
2269 | { | 2269 | { |
2270 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 2270 | struct mgsl_struct *info = tty->driver_data; |
2271 | 2271 | ||
2272 | if (debug_level >= DEBUG_LEVEL_INFO) | 2272 | if (debug_level >= DEBUG_LEVEL_INFO) |
2273 | printk("%s(%d):mgsl_chars_in_buffer(%s)\n", | 2273 | printk("%s(%d):mgsl_chars_in_buffer(%s)\n", |
@@ -2301,7 +2301,7 @@ static int mgsl_chars_in_buffer(struct tty_struct *tty) | |||
2301 | */ | 2301 | */ |
2302 | static void mgsl_flush_buffer(struct tty_struct *tty) | 2302 | static void mgsl_flush_buffer(struct tty_struct *tty) |
2303 | { | 2303 | { |
2304 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 2304 | struct mgsl_struct *info = tty->driver_data; |
2305 | unsigned long flags; | 2305 | unsigned long flags; |
2306 | 2306 | ||
2307 | if (debug_level >= DEBUG_LEVEL_INFO) | 2307 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -2329,7 +2329,7 @@ static void mgsl_flush_buffer(struct tty_struct *tty) | |||
2329 | */ | 2329 | */ |
2330 | static void mgsl_send_xchar(struct tty_struct *tty, char ch) | 2330 | static void mgsl_send_xchar(struct tty_struct *tty, char ch) |
2331 | { | 2331 | { |
2332 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 2332 | struct mgsl_struct *info = tty->driver_data; |
2333 | unsigned long flags; | 2333 | unsigned long flags; |
2334 | 2334 | ||
2335 | if (debug_level >= DEBUG_LEVEL_INFO) | 2335 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -2358,7 +2358,7 @@ static void mgsl_send_xchar(struct tty_struct *tty, char ch) | |||
2358 | */ | 2358 | */ |
2359 | static void mgsl_throttle(struct tty_struct * tty) | 2359 | static void mgsl_throttle(struct tty_struct * tty) |
2360 | { | 2360 | { |
2361 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 2361 | struct mgsl_struct *info = tty->driver_data; |
2362 | unsigned long flags; | 2362 | unsigned long flags; |
2363 | 2363 | ||
2364 | if (debug_level >= DEBUG_LEVEL_INFO) | 2364 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -2388,7 +2388,7 @@ static void mgsl_throttle(struct tty_struct * tty) | |||
2388 | */ | 2388 | */ |
2389 | static void mgsl_unthrottle(struct tty_struct * tty) | 2389 | static void mgsl_unthrottle(struct tty_struct * tty) |
2390 | { | 2390 | { |
2391 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 2391 | struct mgsl_struct *info = tty->driver_data; |
2392 | unsigned long flags; | 2392 | unsigned long flags; |
2393 | 2393 | ||
2394 | if (debug_level >= DEBUG_LEVEL_INFO) | 2394 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -2841,7 +2841,7 @@ static int modem_input_wait(struct mgsl_struct *info,int arg) | |||
2841 | */ | 2841 | */ |
2842 | static int tiocmget(struct tty_struct *tty, struct file *file) | 2842 | static int tiocmget(struct tty_struct *tty, struct file *file) |
2843 | { | 2843 | { |
2844 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 2844 | struct mgsl_struct *info = tty->driver_data; |
2845 | unsigned int result; | 2845 | unsigned int result; |
2846 | unsigned long flags; | 2846 | unsigned long flags; |
2847 | 2847 | ||
@@ -2867,7 +2867,7 @@ static int tiocmget(struct tty_struct *tty, struct file *file) | |||
2867 | static int tiocmset(struct tty_struct *tty, struct file *file, | 2867 | static int tiocmset(struct tty_struct *tty, struct file *file, |
2868 | unsigned int set, unsigned int clear) | 2868 | unsigned int set, unsigned int clear) |
2869 | { | 2869 | { |
2870 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 2870 | struct mgsl_struct *info = tty->driver_data; |
2871 | unsigned long flags; | 2871 | unsigned long flags; |
2872 | 2872 | ||
2873 | if (debug_level >= DEBUG_LEVEL_INFO) | 2873 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -2898,7 +2898,7 @@ static int tiocmset(struct tty_struct *tty, struct file *file, | |||
2898 | */ | 2898 | */ |
2899 | static int mgsl_break(struct tty_struct *tty, int break_state) | 2899 | static int mgsl_break(struct tty_struct *tty, int break_state) |
2900 | { | 2900 | { |
2901 | struct mgsl_struct * info = (struct mgsl_struct *)tty->driver_data; | 2901 | struct mgsl_struct * info = tty->driver_data; |
2902 | unsigned long flags; | 2902 | unsigned long flags; |
2903 | 2903 | ||
2904 | if (debug_level >= DEBUG_LEVEL_INFO) | 2904 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -2932,7 +2932,7 @@ static int mgsl_break(struct tty_struct *tty, int break_state) | |||
2932 | static int mgsl_ioctl(struct tty_struct *tty, struct file * file, | 2932 | static int mgsl_ioctl(struct tty_struct *tty, struct file * file, |
2933 | unsigned int cmd, unsigned long arg) | 2933 | unsigned int cmd, unsigned long arg) |
2934 | { | 2934 | { |
2935 | struct mgsl_struct * info = (struct mgsl_struct *)tty->driver_data; | 2935 | struct mgsl_struct * info = tty->driver_data; |
2936 | int ret; | 2936 | int ret; |
2937 | 2937 | ||
2938 | if (debug_level >= DEBUG_LEVEL_INFO) | 2938 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -3042,7 +3042,7 @@ static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigne | |||
3042 | */ | 3042 | */ |
3043 | static void mgsl_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | 3043 | static void mgsl_set_termios(struct tty_struct *tty, struct ktermios *old_termios) |
3044 | { | 3044 | { |
3045 | struct mgsl_struct *info = (struct mgsl_struct *)tty->driver_data; | 3045 | struct mgsl_struct *info = tty->driver_data; |
3046 | unsigned long flags; | 3046 | unsigned long flags; |
3047 | 3047 | ||
3048 | if (debug_level >= DEBUG_LEVEL_INFO) | 3048 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -3096,7 +3096,7 @@ static void mgsl_set_termios(struct tty_struct *tty, struct ktermios *old_termio | |||
3096 | */ | 3096 | */ |
3097 | static void mgsl_close(struct tty_struct *tty, struct file * filp) | 3097 | static void mgsl_close(struct tty_struct *tty, struct file * filp) |
3098 | { | 3098 | { |
3099 | struct mgsl_struct * info = (struct mgsl_struct *)tty->driver_data; | 3099 | struct mgsl_struct * info = tty->driver_data; |
3100 | 3100 | ||
3101 | if (mgsl_paranoia_check(info, tty->name, "mgsl_close")) | 3101 | if (mgsl_paranoia_check(info, tty->name, "mgsl_close")) |
3102 | return; | 3102 | return; |
@@ -3104,70 +3104,18 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp) | |||
3104 | if (debug_level >= DEBUG_LEVEL_INFO) | 3104 | if (debug_level >= DEBUG_LEVEL_INFO) |
3105 | printk("%s(%d):mgsl_close(%s) entry, count=%d\n", | 3105 | printk("%s(%d):mgsl_close(%s) entry, count=%d\n", |
3106 | __FILE__,__LINE__, info->device_name, info->port.count); | 3106 | __FILE__,__LINE__, info->device_name, info->port.count); |
3107 | |||
3108 | if (!info->port.count) | ||
3109 | return; | ||
3110 | 3107 | ||
3111 | if (tty_hung_up_p(filp)) | 3108 | if (tty_port_close_start(&info->port, tty, filp) == 0) |
3112 | goto cleanup; | 3109 | goto cleanup; |
3113 | 3110 | ||
3114 | if ((tty->count == 1) && (info->port.count != 1)) { | ||
3115 | /* | ||
3116 | * tty->count is 1 and the tty structure will be freed. | ||
3117 | * info->port.count should be one in this case. | ||
3118 | * if it's not, correct it so that the port is shutdown. | ||
3119 | */ | ||
3120 | printk("mgsl_close: bad refcount; tty->count is 1, " | ||
3121 | "info->port.count is %d\n", info->port.count); | ||
3122 | info->port.count = 1; | ||
3123 | } | ||
3124 | |||
3125 | info->port.count--; | ||
3126 | |||
3127 | /* if at least one open remaining, leave hardware active */ | ||
3128 | if (info->port.count) | ||
3129 | goto cleanup; | ||
3130 | |||
3131 | info->port.flags |= ASYNC_CLOSING; | ||
3132 | |||
3133 | /* set tty->closing to notify line discipline to | ||
3134 | * only process XON/XOFF characters. Only the N_TTY | ||
3135 | * discipline appears to use this (ppp does not). | ||
3136 | */ | ||
3137 | tty->closing = 1; | ||
3138 | |||
3139 | /* wait for transmit data to clear all layers */ | ||
3140 | |||
3141 | if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) { | ||
3142 | if (debug_level >= DEBUG_LEVEL_INFO) | ||
3143 | printk("%s(%d):mgsl_close(%s) calling tty_wait_until_sent\n", | ||
3144 | __FILE__,__LINE__, info->device_name ); | ||
3145 | tty_wait_until_sent(tty, info->port.closing_wait); | ||
3146 | } | ||
3147 | |||
3148 | if (info->port.flags & ASYNC_INITIALIZED) | 3111 | if (info->port.flags & ASYNC_INITIALIZED) |
3149 | mgsl_wait_until_sent(tty, info->timeout); | 3112 | mgsl_wait_until_sent(tty, info->timeout); |
3150 | |||
3151 | mgsl_flush_buffer(tty); | 3113 | mgsl_flush_buffer(tty); |
3152 | |||
3153 | tty_ldisc_flush(tty); | 3114 | tty_ldisc_flush(tty); |
3154 | |||
3155 | shutdown(info); | 3115 | shutdown(info); |
3156 | 3116 | ||
3157 | tty->closing = 0; | 3117 | tty_port_close_end(&info->port, tty); |
3158 | info->port.tty = NULL; | 3118 | info->port.tty = NULL; |
3159 | |||
3160 | if (info->port.blocked_open) { | ||
3161 | if (info->port.close_delay) { | ||
3162 | msleep_interruptible(jiffies_to_msecs(info->port.close_delay)); | ||
3163 | } | ||
3164 | wake_up_interruptible(&info->port.open_wait); | ||
3165 | } | ||
3166 | |||
3167 | info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); | ||
3168 | |||
3169 | wake_up_interruptible(&info->port.close_wait); | ||
3170 | |||
3171 | cleanup: | 3119 | cleanup: |
3172 | if (debug_level >= DEBUG_LEVEL_INFO) | 3120 | if (debug_level >= DEBUG_LEVEL_INFO) |
3173 | printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__, | 3121 | printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__, |
@@ -3188,7 +3136,7 @@ cleanup: | |||
3188 | */ | 3136 | */ |
3189 | static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout) | 3137 | static void mgsl_wait_until_sent(struct tty_struct *tty, int timeout) |
3190 | { | 3138 | { |
3191 | struct mgsl_struct * info = (struct mgsl_struct *)tty->driver_data; | 3139 | struct mgsl_struct * info = tty->driver_data; |
3192 | unsigned long orig_jiffies, char_time; | 3140 | unsigned long orig_jiffies, char_time; |
3193 | 3141 | ||
3194 | if (!info ) | 3142 | if (!info ) |
@@ -3261,7 +3209,7 @@ exit: | |||
3261 | */ | 3209 | */ |
3262 | static void mgsl_hangup(struct tty_struct *tty) | 3210 | static void mgsl_hangup(struct tty_struct *tty) |
3263 | { | 3211 | { |
3264 | struct mgsl_struct * info = (struct mgsl_struct *)tty->driver_data; | 3212 | struct mgsl_struct * info = tty->driver_data; |
3265 | 3213 | ||
3266 | if (debug_level >= DEBUG_LEVEL_INFO) | 3214 | if (debug_level >= DEBUG_LEVEL_INFO) |
3267 | printk("%s(%d):mgsl_hangup(%s)\n", | 3215 | printk("%s(%d):mgsl_hangup(%s)\n", |
@@ -3281,6 +3229,35 @@ static void mgsl_hangup(struct tty_struct *tty) | |||
3281 | 3229 | ||
3282 | } /* end of mgsl_hangup() */ | 3230 | } /* end of mgsl_hangup() */ |
3283 | 3231 | ||
3232 | /* | ||
3233 | * carrier_raised() | ||
3234 | * | ||
3235 | * Return true if carrier is raised | ||
3236 | */ | ||
3237 | |||
3238 | static int carrier_raised(struct tty_port *port) | ||
3239 | { | ||
3240 | unsigned long flags; | ||
3241 | struct mgsl_struct *info = container_of(port, struct mgsl_struct, port); | ||
3242 | |||
3243 | spin_lock_irqsave(&info->irq_spinlock, flags); | ||
3244 | usc_get_serial_signals(info); | ||
3245 | spin_unlock_irqrestore(&info->irq_spinlock, flags); | ||
3246 | return (info->serial_signals & SerialSignal_DCD) ? 1 : 0; | ||
3247 | } | ||
3248 | |||
3249 | static void raise_dtr_rts(struct tty_port *port) | ||
3250 | { | ||
3251 | struct mgsl_struct *info = container_of(port, struct mgsl_struct, port); | ||
3252 | unsigned long flags; | ||
3253 | |||
3254 | spin_lock_irqsave(&info->irq_spinlock,flags); | ||
3255 | info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; | ||
3256 | usc_set_serial_signals(info); | ||
3257 | spin_unlock_irqrestore(&info->irq_spinlock,flags); | ||
3258 | } | ||
3259 | |||
3260 | |||
3284 | /* block_til_ready() | 3261 | /* block_til_ready() |
3285 | * | 3262 | * |
3286 | * Block the current process until the specified port | 3263 | * Block the current process until the specified port |
@@ -3302,6 +3279,8 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3302 | bool do_clocal = false; | 3279 | bool do_clocal = false; |
3303 | bool extra_count = false; | 3280 | bool extra_count = false; |
3304 | unsigned long flags; | 3281 | unsigned long flags; |
3282 | int dcd; | ||
3283 | struct tty_port *port = &info->port; | ||
3305 | 3284 | ||
3306 | if (debug_level >= DEBUG_LEVEL_INFO) | 3285 | if (debug_level >= DEBUG_LEVEL_INFO) |
3307 | printk("%s(%d):block_til_ready on %s\n", | 3286 | printk("%s(%d):block_til_ready on %s\n", |
@@ -3309,7 +3288,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3309 | 3288 | ||
3310 | if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ | 3289 | if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ |
3311 | /* nonblock mode is set or port is not enabled */ | 3290 | /* nonblock mode is set or port is not enabled */ |
3312 | info->port.flags |= ASYNC_NORMAL_ACTIVE; | 3291 | port->flags |= ASYNC_NORMAL_ACTIVE; |
3313 | return 0; | 3292 | return 0; |
3314 | } | 3293 | } |
3315 | 3294 | ||
@@ -3318,50 +3297,42 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3318 | 3297 | ||
3319 | /* Wait for carrier detect and the line to become | 3298 | /* Wait for carrier detect and the line to become |
3320 | * free (i.e., not in use by the callout). While we are in | 3299 | * free (i.e., not in use by the callout). While we are in |
3321 | * this loop, info->port.count is dropped by one, so that | 3300 | * this loop, port->count is dropped by one, so that |
3322 | * mgsl_close() knows when to free things. We restore it upon | 3301 | * mgsl_close() knows when to free things. We restore it upon |
3323 | * exit, either normal or abnormal. | 3302 | * exit, either normal or abnormal. |
3324 | */ | 3303 | */ |
3325 | 3304 | ||
3326 | retval = 0; | 3305 | retval = 0; |
3327 | add_wait_queue(&info->port.open_wait, &wait); | 3306 | add_wait_queue(&port->open_wait, &wait); |
3328 | 3307 | ||
3329 | if (debug_level >= DEBUG_LEVEL_INFO) | 3308 | if (debug_level >= DEBUG_LEVEL_INFO) |
3330 | printk("%s(%d):block_til_ready before block on %s count=%d\n", | 3309 | printk("%s(%d):block_til_ready before block on %s count=%d\n", |
3331 | __FILE__,__LINE__, tty->driver->name, info->port.count ); | 3310 | __FILE__,__LINE__, tty->driver->name, port->count ); |
3332 | 3311 | ||
3333 | spin_lock_irqsave(&info->irq_spinlock, flags); | 3312 | spin_lock_irqsave(&info->irq_spinlock, flags); |
3334 | if (!tty_hung_up_p(filp)) { | 3313 | if (!tty_hung_up_p(filp)) { |
3335 | extra_count = true; | 3314 | extra_count = true; |
3336 | info->port.count--; | 3315 | port->count--; |
3337 | } | 3316 | } |
3338 | spin_unlock_irqrestore(&info->irq_spinlock, flags); | 3317 | spin_unlock_irqrestore(&info->irq_spinlock, flags); |
3339 | info->port.blocked_open++; | 3318 | port->blocked_open++; |
3340 | 3319 | ||
3341 | while (1) { | 3320 | while (1) { |
3342 | if (tty->termios->c_cflag & CBAUD) { | 3321 | if (tty->termios->c_cflag & CBAUD) |
3343 | spin_lock_irqsave(&info->irq_spinlock,flags); | 3322 | tty_port_raise_dtr_rts(port); |
3344 | info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; | ||
3345 | usc_set_serial_signals(info); | ||
3346 | spin_unlock_irqrestore(&info->irq_spinlock,flags); | ||
3347 | } | ||
3348 | 3323 | ||
3349 | set_current_state(TASK_INTERRUPTIBLE); | 3324 | set_current_state(TASK_INTERRUPTIBLE); |
3350 | 3325 | ||
3351 | if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){ | 3326 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)){ |
3352 | retval = (info->port.flags & ASYNC_HUP_NOTIFY) ? | 3327 | retval = (port->flags & ASYNC_HUP_NOTIFY) ? |
3353 | -EAGAIN : -ERESTARTSYS; | 3328 | -EAGAIN : -ERESTARTSYS; |
3354 | break; | 3329 | break; |
3355 | } | 3330 | } |
3356 | 3331 | ||
3357 | spin_lock_irqsave(&info->irq_spinlock,flags); | 3332 | dcd = tty_port_carrier_raised(&info->port); |
3358 | usc_get_serial_signals(info); | ||
3359 | spin_unlock_irqrestore(&info->irq_spinlock,flags); | ||
3360 | 3333 | ||
3361 | if (!(info->port.flags & ASYNC_CLOSING) && | 3334 | if (!(port->flags & ASYNC_CLOSING) && (do_clocal || dcd)) |
3362 | (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) { | ||
3363 | break; | 3335 | break; |
3364 | } | ||
3365 | 3336 | ||
3366 | if (signal_pending(current)) { | 3337 | if (signal_pending(current)) { |
3367 | retval = -ERESTARTSYS; | 3338 | retval = -ERESTARTSYS; |
@@ -3370,24 +3341,25 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp, | |||
3370 | 3341 | ||
3371 | if (debug_level >= DEBUG_LEVEL_INFO) | 3342 | if (debug_level >= DEBUG_LEVEL_INFO) |
3372 | printk("%s(%d):block_til_ready blocking on %s count=%d\n", | 3343 | printk("%s(%d):block_til_ready blocking on %s count=%d\n", |
3373 | __FILE__,__LINE__, tty->driver->name, info->port.count ); | 3344 | __FILE__,__LINE__, tty->driver->name, port->count ); |
3374 | 3345 | ||
3375 | schedule(); | 3346 | schedule(); |
3376 | } | 3347 | } |
3377 | 3348 | ||
3378 | set_current_state(TASK_RUNNING); | 3349 | set_current_state(TASK_RUNNING); |
3379 | remove_wait_queue(&info->port.open_wait, &wait); | 3350 | remove_wait_queue(&port->open_wait, &wait); |
3380 | 3351 | ||
3352 | /* FIXME: Racy on hangup during close wait */ | ||
3381 | if (extra_count) | 3353 | if (extra_count) |
3382 | info->port.count++; | 3354 | port->count++; |
3383 | info->port.blocked_open--; | 3355 | port->blocked_open--; |
3384 | 3356 | ||
3385 | if (debug_level >= DEBUG_LEVEL_INFO) | 3357 | if (debug_level >= DEBUG_LEVEL_INFO) |
3386 | printk("%s(%d):block_til_ready after blocking on %s count=%d\n", | 3358 | printk("%s(%d):block_til_ready after blocking on %s count=%d\n", |
3387 | __FILE__,__LINE__, tty->driver->name, info->port.count ); | 3359 | __FILE__,__LINE__, tty->driver->name, port->count ); |
3388 | 3360 | ||
3389 | if (!retval) | 3361 | if (!retval) |
3390 | info->port.flags |= ASYNC_NORMAL_ACTIVE; | 3362 | port->flags |= ASYNC_NORMAL_ACTIVE; |
3391 | 3363 | ||
3392 | return retval; | 3364 | return retval; |
3393 | 3365 | ||
@@ -4304,6 +4276,12 @@ static void mgsl_add_device( struct mgsl_struct *info ) | |||
4304 | 4276 | ||
4305 | } /* end of mgsl_add_device() */ | 4277 | } /* end of mgsl_add_device() */ |
4306 | 4278 | ||
4279 | static const struct tty_port_operations mgsl_port_ops = { | ||
4280 | .carrier_raised = carrier_raised, | ||
4281 | .raise_dtr_rts = raise_dtr_rts, | ||
4282 | }; | ||
4283 | |||
4284 | |||
4307 | /* mgsl_allocate_device() | 4285 | /* mgsl_allocate_device() |
4308 | * | 4286 | * |
4309 | * Allocate and initialize a device instance structure | 4287 | * Allocate and initialize a device instance structure |
@@ -4322,6 +4300,7 @@ static struct mgsl_struct* mgsl_allocate_device(void) | |||
4322 | printk("Error can't allocate device instance data\n"); | 4300 | printk("Error can't allocate device instance data\n"); |
4323 | } else { | 4301 | } else { |
4324 | tty_port_init(&info->port); | 4302 | tty_port_init(&info->port); |
4303 | info->port.ops = &mgsl_port_ops; | ||
4325 | info->magic = MGSL_MAGIC; | 4304 | info->magic = MGSL_MAGIC; |
4326 | INIT_WORK(&info->task, mgsl_bh_handler); | 4305 | INIT_WORK(&info->task, mgsl_bh_handler); |
4327 | info->max_frame_size = 4096; | 4306 | info->max_frame_size = 4096; |
diff --git a/drivers/char/synclink_gt.c b/drivers/char/synclink_gt.c index 08911ed66494..53544e21f191 100644 --- a/drivers/char/synclink_gt.c +++ b/drivers/char/synclink_gt.c | |||
@@ -720,44 +720,9 @@ static void close(struct tty_struct *tty, struct file *filp) | |||
720 | return; | 720 | return; |
721 | DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count)); | 721 | DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count)); |
722 | 722 | ||
723 | if (!info->port.count) | 723 | if (tty_port_close_start(&info->port, tty, filp) == 0) |
724 | return; | ||
725 | |||
726 | if (tty_hung_up_p(filp)) | ||
727 | goto cleanup; | ||
728 | |||
729 | if ((tty->count == 1) && (info->port.count != 1)) { | ||
730 | /* | ||
731 | * tty->count is 1 and the tty structure will be freed. | ||
732 | * info->port.count should be one in this case. | ||
733 | * if it's not, correct it so that the port is shutdown. | ||
734 | */ | ||
735 | DBGERR(("%s close: bad refcount; tty->count=1, " | ||
736 | "info->port.count=%d\n", info->device_name, info->port.count)); | ||
737 | info->port.count = 1; | ||
738 | } | ||
739 | |||
740 | info->port.count--; | ||
741 | |||
742 | /* if at least one open remaining, leave hardware active */ | ||
743 | if (info->port.count) | ||
744 | goto cleanup; | 724 | goto cleanup; |
745 | 725 | ||
746 | info->port.flags |= ASYNC_CLOSING; | ||
747 | |||
748 | /* set tty->closing to notify line discipline to | ||
749 | * only process XON/XOFF characters. Only the N_TTY | ||
750 | * discipline appears to use this (ppp does not). | ||
751 | */ | ||
752 | tty->closing = 1; | ||
753 | |||
754 | /* wait for transmit data to clear all layers */ | ||
755 | |||
756 | if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) { | ||
757 | DBGINFO(("%s call tty_wait_until_sent\n", info->device_name)); | ||
758 | tty_wait_until_sent(tty, info->port.closing_wait); | ||
759 | } | ||
760 | |||
761 | if (info->port.flags & ASYNC_INITIALIZED) | 726 | if (info->port.flags & ASYNC_INITIALIZED) |
762 | wait_until_sent(tty, info->timeout); | 727 | wait_until_sent(tty, info->timeout); |
763 | flush_buffer(tty); | 728 | flush_buffer(tty); |
@@ -765,20 +730,8 @@ static void close(struct tty_struct *tty, struct file *filp) | |||
765 | 730 | ||
766 | shutdown(info); | 731 | shutdown(info); |
767 | 732 | ||
768 | tty->closing = 0; | 733 | tty_port_close_end(&info->port, tty); |
769 | info->port.tty = NULL; | 734 | info->port.tty = NULL; |
770 | |||
771 | if (info->port.blocked_open) { | ||
772 | if (info->port.close_delay) { | ||
773 | msleep_interruptible(jiffies_to_msecs(info->port.close_delay)); | ||
774 | } | ||
775 | wake_up_interruptible(&info->port.open_wait); | ||
776 | } | ||
777 | |||
778 | info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); | ||
779 | |||
780 | wake_up_interruptible(&info->port.close_wait); | ||
781 | |||
782 | cleanup: | 735 | cleanup: |
783 | DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count)); | 736 | DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count)); |
784 | } | 737 | } |
@@ -3132,6 +3085,29 @@ static int tiocmset(struct tty_struct *tty, struct file *file, | |||
3132 | return 0; | 3085 | return 0; |
3133 | } | 3086 | } |
3134 | 3087 | ||
3088 | static int carrier_raised(struct tty_port *port) | ||
3089 | { | ||
3090 | unsigned long flags; | ||
3091 | struct slgt_info *info = container_of(port, struct slgt_info, port); | ||
3092 | |||
3093 | spin_lock_irqsave(&info->lock,flags); | ||
3094 | get_signals(info); | ||
3095 | spin_unlock_irqrestore(&info->lock,flags); | ||
3096 | return (info->signals & SerialSignal_DCD) ? 1 : 0; | ||
3097 | } | ||
3098 | |||
3099 | static void raise_dtr_rts(struct tty_port *port) | ||
3100 | { | ||
3101 | unsigned long flags; | ||
3102 | struct slgt_info *info = container_of(port, struct slgt_info, port); | ||
3103 | |||
3104 | spin_lock_irqsave(&info->lock,flags); | ||
3105 | info->signals |= SerialSignal_RTS + SerialSignal_DTR; | ||
3106 | set_signals(info); | ||
3107 | spin_unlock_irqrestore(&info->lock,flags); | ||
3108 | } | ||
3109 | |||
3110 | |||
3135 | /* | 3111 | /* |
3136 | * block current process until the device is ready to open | 3112 | * block current process until the device is ready to open |
3137 | */ | 3113 | */ |
@@ -3143,12 +3119,14 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3143 | bool do_clocal = false; | 3119 | bool do_clocal = false; |
3144 | bool extra_count = false; | 3120 | bool extra_count = false; |
3145 | unsigned long flags; | 3121 | unsigned long flags; |
3122 | int cd; | ||
3123 | struct tty_port *port = &info->port; | ||
3146 | 3124 | ||
3147 | DBGINFO(("%s block_til_ready\n", tty->driver->name)); | 3125 | DBGINFO(("%s block_til_ready\n", tty->driver->name)); |
3148 | 3126 | ||
3149 | if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ | 3127 | if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ |
3150 | /* nonblock mode is set or port is not enabled */ | 3128 | /* nonblock mode is set or port is not enabled */ |
3151 | info->port.flags |= ASYNC_NORMAL_ACTIVE; | 3129 | port->flags |= ASYNC_NORMAL_ACTIVE; |
3152 | return 0; | 3130 | return 0; |
3153 | } | 3131 | } |
3154 | 3132 | ||
@@ -3157,46 +3135,38 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3157 | 3135 | ||
3158 | /* Wait for carrier detect and the line to become | 3136 | /* Wait for carrier detect and the line to become |
3159 | * free (i.e., not in use by the callout). While we are in | 3137 | * free (i.e., not in use by the callout). While we are in |
3160 | * this loop, info->port.count is dropped by one, so that | 3138 | * this loop, port->count is dropped by one, so that |
3161 | * close() knows when to free things. We restore it upon | 3139 | * close() knows when to free things. We restore it upon |
3162 | * exit, either normal or abnormal. | 3140 | * exit, either normal or abnormal. |
3163 | */ | 3141 | */ |
3164 | 3142 | ||
3165 | retval = 0; | 3143 | retval = 0; |
3166 | add_wait_queue(&info->port.open_wait, &wait); | 3144 | add_wait_queue(&port->open_wait, &wait); |
3167 | 3145 | ||
3168 | spin_lock_irqsave(&info->lock, flags); | 3146 | spin_lock_irqsave(&info->lock, flags); |
3169 | if (!tty_hung_up_p(filp)) { | 3147 | if (!tty_hung_up_p(filp)) { |
3170 | extra_count = true; | 3148 | extra_count = true; |
3171 | info->port.count--; | 3149 | port->count--; |
3172 | } | 3150 | } |
3173 | spin_unlock_irqrestore(&info->lock, flags); | 3151 | spin_unlock_irqrestore(&info->lock, flags); |
3174 | info->port.blocked_open++; | 3152 | port->blocked_open++; |
3175 | 3153 | ||
3176 | while (1) { | 3154 | while (1) { |
3177 | if ((tty->termios->c_cflag & CBAUD)) { | 3155 | if ((tty->termios->c_cflag & CBAUD)) |
3178 | spin_lock_irqsave(&info->lock,flags); | 3156 | tty_port_raise_dtr_rts(port); |
3179 | info->signals |= SerialSignal_RTS + SerialSignal_DTR; | ||
3180 | set_signals(info); | ||
3181 | spin_unlock_irqrestore(&info->lock,flags); | ||
3182 | } | ||
3183 | 3157 | ||
3184 | set_current_state(TASK_INTERRUPTIBLE); | 3158 | set_current_state(TASK_INTERRUPTIBLE); |
3185 | 3159 | ||
3186 | if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){ | 3160 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)){ |
3187 | retval = (info->port.flags & ASYNC_HUP_NOTIFY) ? | 3161 | retval = (port->flags & ASYNC_HUP_NOTIFY) ? |
3188 | -EAGAIN : -ERESTARTSYS; | 3162 | -EAGAIN : -ERESTARTSYS; |
3189 | break; | 3163 | break; |
3190 | } | 3164 | } |
3191 | 3165 | ||
3192 | spin_lock_irqsave(&info->lock,flags); | 3166 | cd = tty_port_carrier_raised(port); |
3193 | get_signals(info); | ||
3194 | spin_unlock_irqrestore(&info->lock,flags); | ||
3195 | 3167 | ||
3196 | if (!(info->port.flags & ASYNC_CLOSING) && | 3168 | if (!(port->flags & ASYNC_CLOSING) && (do_clocal || cd )) |
3197 | (do_clocal || (info->signals & SerialSignal_DCD)) ) { | ||
3198 | break; | 3169 | break; |
3199 | } | ||
3200 | 3170 | ||
3201 | if (signal_pending(current)) { | 3171 | if (signal_pending(current)) { |
3202 | retval = -ERESTARTSYS; | 3172 | retval = -ERESTARTSYS; |
@@ -3208,14 +3178,14 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3208 | } | 3178 | } |
3209 | 3179 | ||
3210 | set_current_state(TASK_RUNNING); | 3180 | set_current_state(TASK_RUNNING); |
3211 | remove_wait_queue(&info->port.open_wait, &wait); | 3181 | remove_wait_queue(&port->open_wait, &wait); |
3212 | 3182 | ||
3213 | if (extra_count) | 3183 | if (extra_count) |
3214 | info->port.count++; | 3184 | port->count++; |
3215 | info->port.blocked_open--; | 3185 | port->blocked_open--; |
3216 | 3186 | ||
3217 | if (!retval) | 3187 | if (!retval) |
3218 | info->port.flags |= ASYNC_NORMAL_ACTIVE; | 3188 | port->flags |= ASYNC_NORMAL_ACTIVE; |
3219 | 3189 | ||
3220 | DBGINFO(("%s block_til_ready ready, rc=%d\n", tty->driver->name, retval)); | 3190 | DBGINFO(("%s block_til_ready ready, rc=%d\n", tty->driver->name, retval)); |
3221 | return retval; | 3191 | return retval; |
@@ -3444,6 +3414,11 @@ static void add_device(struct slgt_info *info) | |||
3444 | #endif | 3414 | #endif |
3445 | } | 3415 | } |
3446 | 3416 | ||
3417 | static const struct tty_port_operations slgt_port_ops = { | ||
3418 | .carrier_raised = carrier_raised, | ||
3419 | .raise_dtr_rts = raise_dtr_rts, | ||
3420 | }; | ||
3421 | |||
3447 | /* | 3422 | /* |
3448 | * allocate device instance structure, return NULL on failure | 3423 | * allocate device instance structure, return NULL on failure |
3449 | */ | 3424 | */ |
@@ -3458,6 +3433,7 @@ static struct slgt_info *alloc_dev(int adapter_num, int port_num, struct pci_dev | |||
3458 | driver_name, adapter_num, port_num)); | 3433 | driver_name, adapter_num, port_num)); |
3459 | } else { | 3434 | } else { |
3460 | tty_port_init(&info->port); | 3435 | tty_port_init(&info->port); |
3436 | info->port.ops = &slgt_port_ops; | ||
3461 | info->magic = MGSL_MAGIC; | 3437 | info->magic = MGSL_MAGIC; |
3462 | INIT_WORK(&info->task, bh_handler); | 3438 | INIT_WORK(&info->task, bh_handler); |
3463 | info->max_frame_size = 4096; | 3439 | info->max_frame_size = 4096; |
diff --git a/drivers/char/synclinkmp.c b/drivers/char/synclinkmp.c index 6bdb44f7bec2..7b0c5b2dd263 100644 --- a/drivers/char/synclinkmp.c +++ b/drivers/char/synclinkmp.c | |||
@@ -558,6 +558,7 @@ static void release_resources(SLMP_INFO *info); | |||
558 | 558 | ||
559 | static int startup(SLMP_INFO *info); | 559 | static int startup(SLMP_INFO *info); |
560 | static int block_til_ready(struct tty_struct *tty, struct file * filp,SLMP_INFO *info); | 560 | static int block_til_ready(struct tty_struct *tty, struct file * filp,SLMP_INFO *info); |
561 | static int carrier_raised(struct tty_port *port); | ||
561 | static void shutdown(SLMP_INFO *info); | 562 | static void shutdown(SLMP_INFO *info); |
562 | static void program_hw(SLMP_INFO *info); | 563 | static void program_hw(SLMP_INFO *info); |
563 | static void change_params(SLMP_INFO *info); | 564 | static void change_params(SLMP_INFO *info); |
@@ -800,7 +801,7 @@ cleanup: | |||
800 | */ | 801 | */ |
801 | static void close(struct tty_struct *tty, struct file *filp) | 802 | static void close(struct tty_struct *tty, struct file *filp) |
802 | { | 803 | { |
803 | SLMP_INFO * info = (SLMP_INFO *)tty->driver_data; | 804 | SLMP_INFO * info = tty->driver_data; |
804 | 805 | ||
805 | if (sanity_check(info, tty->name, "close")) | 806 | if (sanity_check(info, tty->name, "close")) |
806 | return; | 807 | return; |
@@ -809,70 +810,18 @@ static void close(struct tty_struct *tty, struct file *filp) | |||
809 | printk("%s(%d):%s close() entry, count=%d\n", | 810 | printk("%s(%d):%s close() entry, count=%d\n", |
810 | __FILE__,__LINE__, info->device_name, info->port.count); | 811 | __FILE__,__LINE__, info->device_name, info->port.count); |
811 | 812 | ||
812 | if (!info->port.count) | 813 | if (tty_port_close_start(&info->port, tty, filp) == 0) |
813 | return; | ||
814 | |||
815 | if (tty_hung_up_p(filp)) | ||
816 | goto cleanup; | ||
817 | |||
818 | if ((tty->count == 1) && (info->port.count != 1)) { | ||
819 | /* | ||
820 | * tty->count is 1 and the tty structure will be freed. | ||
821 | * info->port.count should be one in this case. | ||
822 | * if it's not, correct it so that the port is shutdown. | ||
823 | */ | ||
824 | printk("%s(%d):%s close: bad refcount; tty->count is 1, " | ||
825 | "info->port.count is %d\n", | ||
826 | __FILE__,__LINE__, info->device_name, info->port.count); | ||
827 | info->port.count = 1; | ||
828 | } | ||
829 | |||
830 | info->port.count--; | ||
831 | |||
832 | /* if at least one open remaining, leave hardware active */ | ||
833 | if (info->port.count) | ||
834 | goto cleanup; | 814 | goto cleanup; |
835 | 815 | ||
836 | info->port.flags |= ASYNC_CLOSING; | ||
837 | |||
838 | /* set tty->closing to notify line discipline to | ||
839 | * only process XON/XOFF characters. Only the N_TTY | ||
840 | * discipline appears to use this (ppp does not). | ||
841 | */ | ||
842 | tty->closing = 1; | ||
843 | |||
844 | /* wait for transmit data to clear all layers */ | ||
845 | |||
846 | if (info->port.closing_wait != ASYNC_CLOSING_WAIT_NONE) { | ||
847 | if (debug_level >= DEBUG_LEVEL_INFO) | ||
848 | printk("%s(%d):%s close() calling tty_wait_until_sent\n", | ||
849 | __FILE__,__LINE__, info->device_name ); | ||
850 | tty_wait_until_sent(tty, info->port.closing_wait); | ||
851 | } | ||
852 | |||
853 | if (info->port.flags & ASYNC_INITIALIZED) | 816 | if (info->port.flags & ASYNC_INITIALIZED) |
854 | wait_until_sent(tty, info->timeout); | 817 | wait_until_sent(tty, info->timeout); |
855 | 818 | ||
856 | flush_buffer(tty); | 819 | flush_buffer(tty); |
857 | |||
858 | tty_ldisc_flush(tty); | 820 | tty_ldisc_flush(tty); |
859 | |||
860 | shutdown(info); | 821 | shutdown(info); |
861 | 822 | ||
862 | tty->closing = 0; | 823 | tty_port_close_end(&info->port, tty); |
863 | info->port.tty = NULL; | 824 | info->port.tty = NULL; |
864 | |||
865 | if (info->port.blocked_open) { | ||
866 | if (info->port.close_delay) { | ||
867 | msleep_interruptible(jiffies_to_msecs(info->port.close_delay)); | ||
868 | } | ||
869 | wake_up_interruptible(&info->port.open_wait); | ||
870 | } | ||
871 | |||
872 | info->port.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); | ||
873 | |||
874 | wake_up_interruptible(&info->port.close_wait); | ||
875 | |||
876 | cleanup: | 825 | cleanup: |
877 | if (debug_level >= DEBUG_LEVEL_INFO) | 826 | if (debug_level >= DEBUG_LEVEL_INFO) |
878 | printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__, | 827 | printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__, |
@@ -884,7 +833,7 @@ cleanup: | |||
884 | */ | 833 | */ |
885 | static void hangup(struct tty_struct *tty) | 834 | static void hangup(struct tty_struct *tty) |
886 | { | 835 | { |
887 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 836 | SLMP_INFO *info = tty->driver_data; |
888 | 837 | ||
889 | if (debug_level >= DEBUG_LEVEL_INFO) | 838 | if (debug_level >= DEBUG_LEVEL_INFO) |
890 | printk("%s(%d):%s hangup()\n", | 839 | printk("%s(%d):%s hangup()\n", |
@@ -907,7 +856,7 @@ static void hangup(struct tty_struct *tty) | |||
907 | */ | 856 | */ |
908 | static void set_termios(struct tty_struct *tty, struct ktermios *old_termios) | 857 | static void set_termios(struct tty_struct *tty, struct ktermios *old_termios) |
909 | { | 858 | { |
910 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 859 | SLMP_INFO *info = tty->driver_data; |
911 | unsigned long flags; | 860 | unsigned long flags; |
912 | 861 | ||
913 | if (debug_level >= DEBUG_LEVEL_INFO) | 862 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -960,7 +909,7 @@ static int write(struct tty_struct *tty, | |||
960 | const unsigned char *buf, int count) | 909 | const unsigned char *buf, int count) |
961 | { | 910 | { |
962 | int c, ret = 0; | 911 | int c, ret = 0; |
963 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 912 | SLMP_INFO *info = tty->driver_data; |
964 | unsigned long flags; | 913 | unsigned long flags; |
965 | 914 | ||
966 | if (debug_level >= DEBUG_LEVEL_INFO) | 915 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -1038,7 +987,7 @@ cleanup: | |||
1038 | */ | 987 | */ |
1039 | static int put_char(struct tty_struct *tty, unsigned char ch) | 988 | static int put_char(struct tty_struct *tty, unsigned char ch) |
1040 | { | 989 | { |
1041 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 990 | SLMP_INFO *info = tty->driver_data; |
1042 | unsigned long flags; | 991 | unsigned long flags; |
1043 | int ret = 0; | 992 | int ret = 0; |
1044 | 993 | ||
@@ -1075,7 +1024,7 @@ static int put_char(struct tty_struct *tty, unsigned char ch) | |||
1075 | */ | 1024 | */ |
1076 | static void send_xchar(struct tty_struct *tty, char ch) | 1025 | static void send_xchar(struct tty_struct *tty, char ch) |
1077 | { | 1026 | { |
1078 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 1027 | SLMP_INFO *info = tty->driver_data; |
1079 | unsigned long flags; | 1028 | unsigned long flags; |
1080 | 1029 | ||
1081 | if (debug_level >= DEBUG_LEVEL_INFO) | 1030 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -1099,7 +1048,7 @@ static void send_xchar(struct tty_struct *tty, char ch) | |||
1099 | */ | 1048 | */ |
1100 | static void wait_until_sent(struct tty_struct *tty, int timeout) | 1049 | static void wait_until_sent(struct tty_struct *tty, int timeout) |
1101 | { | 1050 | { |
1102 | SLMP_INFO * info = (SLMP_INFO *)tty->driver_data; | 1051 | SLMP_INFO * info = tty->driver_data; |
1103 | unsigned long orig_jiffies, char_time; | 1052 | unsigned long orig_jiffies, char_time; |
1104 | 1053 | ||
1105 | if (!info ) | 1054 | if (!info ) |
@@ -1166,7 +1115,7 @@ exit: | |||
1166 | */ | 1115 | */ |
1167 | static int write_room(struct tty_struct *tty) | 1116 | static int write_room(struct tty_struct *tty) |
1168 | { | 1117 | { |
1169 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 1118 | SLMP_INFO *info = tty->driver_data; |
1170 | int ret; | 1119 | int ret; |
1171 | 1120 | ||
1172 | if (sanity_check(info, tty->name, "write_room")) | 1121 | if (sanity_check(info, tty->name, "write_room")) |
@@ -1193,7 +1142,7 @@ static int write_room(struct tty_struct *tty) | |||
1193 | */ | 1142 | */ |
1194 | static void flush_chars(struct tty_struct *tty) | 1143 | static void flush_chars(struct tty_struct *tty) |
1195 | { | 1144 | { |
1196 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 1145 | SLMP_INFO *info = tty->driver_data; |
1197 | unsigned long flags; | 1146 | unsigned long flags; |
1198 | 1147 | ||
1199 | if ( debug_level >= DEBUG_LEVEL_INFO ) | 1148 | if ( debug_level >= DEBUG_LEVEL_INFO ) |
@@ -1232,7 +1181,7 @@ static void flush_chars(struct tty_struct *tty) | |||
1232 | */ | 1181 | */ |
1233 | static void flush_buffer(struct tty_struct *tty) | 1182 | static void flush_buffer(struct tty_struct *tty) |
1234 | { | 1183 | { |
1235 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 1184 | SLMP_INFO *info = tty->driver_data; |
1236 | unsigned long flags; | 1185 | unsigned long flags; |
1237 | 1186 | ||
1238 | if (debug_level >= DEBUG_LEVEL_INFO) | 1187 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -1254,7 +1203,7 @@ static void flush_buffer(struct tty_struct *tty) | |||
1254 | */ | 1203 | */ |
1255 | static void tx_hold(struct tty_struct *tty) | 1204 | static void tx_hold(struct tty_struct *tty) |
1256 | { | 1205 | { |
1257 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 1206 | SLMP_INFO *info = tty->driver_data; |
1258 | unsigned long flags; | 1207 | unsigned long flags; |
1259 | 1208 | ||
1260 | if (sanity_check(info, tty->name, "tx_hold")) | 1209 | if (sanity_check(info, tty->name, "tx_hold")) |
@@ -1274,7 +1223,7 @@ static void tx_hold(struct tty_struct *tty) | |||
1274 | */ | 1223 | */ |
1275 | static void tx_release(struct tty_struct *tty) | 1224 | static void tx_release(struct tty_struct *tty) |
1276 | { | 1225 | { |
1277 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 1226 | SLMP_INFO *info = tty->driver_data; |
1278 | unsigned long flags; | 1227 | unsigned long flags; |
1279 | 1228 | ||
1280 | if (sanity_check(info, tty->name, "tx_release")) | 1229 | if (sanity_check(info, tty->name, "tx_release")) |
@@ -1304,7 +1253,7 @@ static void tx_release(struct tty_struct *tty) | |||
1304 | static int do_ioctl(struct tty_struct *tty, struct file *file, | 1253 | static int do_ioctl(struct tty_struct *tty, struct file *file, |
1305 | unsigned int cmd, unsigned long arg) | 1254 | unsigned int cmd, unsigned long arg) |
1306 | { | 1255 | { |
1307 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 1256 | SLMP_INFO *info = tty->driver_data; |
1308 | int error; | 1257 | int error; |
1309 | struct mgsl_icount cnow; /* kernel counter temps */ | 1258 | struct mgsl_icount cnow; /* kernel counter temps */ |
1310 | struct serial_icounter_struct __user *p_cuser; /* user space */ | 1259 | struct serial_icounter_struct __user *p_cuser; /* user space */ |
@@ -1515,7 +1464,7 @@ done: | |||
1515 | */ | 1464 | */ |
1516 | static int chars_in_buffer(struct tty_struct *tty) | 1465 | static int chars_in_buffer(struct tty_struct *tty) |
1517 | { | 1466 | { |
1518 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 1467 | SLMP_INFO *info = tty->driver_data; |
1519 | 1468 | ||
1520 | if (sanity_check(info, tty->name, "chars_in_buffer")) | 1469 | if (sanity_check(info, tty->name, "chars_in_buffer")) |
1521 | return 0; | 1470 | return 0; |
@@ -1531,7 +1480,7 @@ static int chars_in_buffer(struct tty_struct *tty) | |||
1531 | */ | 1480 | */ |
1532 | static void throttle(struct tty_struct * tty) | 1481 | static void throttle(struct tty_struct * tty) |
1533 | { | 1482 | { |
1534 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 1483 | SLMP_INFO *info = tty->driver_data; |
1535 | unsigned long flags; | 1484 | unsigned long flags; |
1536 | 1485 | ||
1537 | if (debug_level >= DEBUG_LEVEL_INFO) | 1486 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -1556,7 +1505,7 @@ static void throttle(struct tty_struct * tty) | |||
1556 | */ | 1505 | */ |
1557 | static void unthrottle(struct tty_struct * tty) | 1506 | static void unthrottle(struct tty_struct * tty) |
1558 | { | 1507 | { |
1559 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 1508 | SLMP_INFO *info = tty->driver_data; |
1560 | unsigned long flags; | 1509 | unsigned long flags; |
1561 | 1510 | ||
1562 | if (debug_level >= DEBUG_LEVEL_INFO) | 1511 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -1587,7 +1536,7 @@ static void unthrottle(struct tty_struct * tty) | |||
1587 | static int set_break(struct tty_struct *tty, int break_state) | 1536 | static int set_break(struct tty_struct *tty, int break_state) |
1588 | { | 1537 | { |
1589 | unsigned char RegValue; | 1538 | unsigned char RegValue; |
1590 | SLMP_INFO * info = (SLMP_INFO *)tty->driver_data; | 1539 | SLMP_INFO * info = tty->driver_data; |
1591 | unsigned long flags; | 1540 | unsigned long flags; |
1592 | 1541 | ||
1593 | if (debug_level >= DEBUG_LEVEL_INFO) | 1542 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -3269,7 +3218,7 @@ static int modem_input_wait(SLMP_INFO *info,int arg) | |||
3269 | */ | 3218 | */ |
3270 | static int tiocmget(struct tty_struct *tty, struct file *file) | 3219 | static int tiocmget(struct tty_struct *tty, struct file *file) |
3271 | { | 3220 | { |
3272 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 3221 | SLMP_INFO *info = tty->driver_data; |
3273 | unsigned int result; | 3222 | unsigned int result; |
3274 | unsigned long flags; | 3223 | unsigned long flags; |
3275 | 3224 | ||
@@ -3295,7 +3244,7 @@ static int tiocmget(struct tty_struct *tty, struct file *file) | |||
3295 | static int tiocmset(struct tty_struct *tty, struct file *file, | 3244 | static int tiocmset(struct tty_struct *tty, struct file *file, |
3296 | unsigned int set, unsigned int clear) | 3245 | unsigned int set, unsigned int clear) |
3297 | { | 3246 | { |
3298 | SLMP_INFO *info = (SLMP_INFO *)tty->driver_data; | 3247 | SLMP_INFO *info = tty->driver_data; |
3299 | unsigned long flags; | 3248 | unsigned long flags; |
3300 | 3249 | ||
3301 | if (debug_level >= DEBUG_LEVEL_INFO) | 3250 | if (debug_level >= DEBUG_LEVEL_INFO) |
@@ -3318,7 +3267,28 @@ static int tiocmset(struct tty_struct *tty, struct file *file, | |||
3318 | return 0; | 3267 | return 0; |
3319 | } | 3268 | } |
3320 | 3269 | ||
3270 | static int carrier_raised(struct tty_port *port) | ||
3271 | { | ||
3272 | SLMP_INFO *info = container_of(port, SLMP_INFO, port); | ||
3273 | unsigned long flags; | ||
3274 | |||
3275 | spin_lock_irqsave(&info->lock,flags); | ||
3276 | get_signals(info); | ||
3277 | spin_unlock_irqrestore(&info->lock,flags); | ||
3321 | 3278 | ||
3279 | return (info->serial_signals & SerialSignal_DCD) ? 1 : 0; | ||
3280 | } | ||
3281 | |||
3282 | static void raise_dtr_rts(struct tty_port *port) | ||
3283 | { | ||
3284 | SLMP_INFO *info = container_of(port, SLMP_INFO, port); | ||
3285 | unsigned long flags; | ||
3286 | |||
3287 | spin_lock_irqsave(&info->lock,flags); | ||
3288 | info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; | ||
3289 | set_signals(info); | ||
3290 | spin_unlock_irqrestore(&info->lock,flags); | ||
3291 | } | ||
3322 | 3292 | ||
3323 | /* Block the current process until the specified port is ready to open. | 3293 | /* Block the current process until the specified port is ready to open. |
3324 | */ | 3294 | */ |
@@ -3330,6 +3300,8 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3330 | bool do_clocal = false; | 3300 | bool do_clocal = false; |
3331 | bool extra_count = false; | 3301 | bool extra_count = false; |
3332 | unsigned long flags; | 3302 | unsigned long flags; |
3303 | int cd; | ||
3304 | struct tty_port *port = &info->port; | ||
3333 | 3305 | ||
3334 | if (debug_level >= DEBUG_LEVEL_INFO) | 3306 | if (debug_level >= DEBUG_LEVEL_INFO) |
3335 | printk("%s(%d):%s block_til_ready()\n", | 3307 | printk("%s(%d):%s block_til_ready()\n", |
@@ -3338,7 +3310,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3338 | if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ | 3310 | if (filp->f_flags & O_NONBLOCK || tty->flags & (1 << TTY_IO_ERROR)){ |
3339 | /* nonblock mode is set or port is not enabled */ | 3311 | /* nonblock mode is set or port is not enabled */ |
3340 | /* just verify that callout device is not active */ | 3312 | /* just verify that callout device is not active */ |
3341 | info->port.flags |= ASYNC_NORMAL_ACTIVE; | 3313 | port->flags |= ASYNC_NORMAL_ACTIVE; |
3342 | return 0; | 3314 | return 0; |
3343 | } | 3315 | } |
3344 | 3316 | ||
@@ -3347,50 +3319,42 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3347 | 3319 | ||
3348 | /* Wait for carrier detect and the line to become | 3320 | /* Wait for carrier detect and the line to become |
3349 | * free (i.e., not in use by the callout). While we are in | 3321 | * free (i.e., not in use by the callout). While we are in |
3350 | * this loop, info->port.count is dropped by one, so that | 3322 | * this loop, port->count is dropped by one, so that |
3351 | * close() knows when to free things. We restore it upon | 3323 | * close() knows when to free things. We restore it upon |
3352 | * exit, either normal or abnormal. | 3324 | * exit, either normal or abnormal. |
3353 | */ | 3325 | */ |
3354 | 3326 | ||
3355 | retval = 0; | 3327 | retval = 0; |
3356 | add_wait_queue(&info->port.open_wait, &wait); | 3328 | add_wait_queue(&port->open_wait, &wait); |
3357 | 3329 | ||
3358 | if (debug_level >= DEBUG_LEVEL_INFO) | 3330 | if (debug_level >= DEBUG_LEVEL_INFO) |
3359 | printk("%s(%d):%s block_til_ready() before block, count=%d\n", | 3331 | printk("%s(%d):%s block_til_ready() before block, count=%d\n", |
3360 | __FILE__,__LINE__, tty->driver->name, info->port.count ); | 3332 | __FILE__,__LINE__, tty->driver->name, port->count ); |
3361 | 3333 | ||
3362 | spin_lock_irqsave(&info->lock, flags); | 3334 | spin_lock_irqsave(&info->lock, flags); |
3363 | if (!tty_hung_up_p(filp)) { | 3335 | if (!tty_hung_up_p(filp)) { |
3364 | extra_count = true; | 3336 | extra_count = true; |
3365 | info->port.count--; | 3337 | port->count--; |
3366 | } | 3338 | } |
3367 | spin_unlock_irqrestore(&info->lock, flags); | 3339 | spin_unlock_irqrestore(&info->lock, flags); |
3368 | info->port.blocked_open++; | 3340 | port->blocked_open++; |
3369 | 3341 | ||
3370 | while (1) { | 3342 | while (1) { |
3371 | if ((tty->termios->c_cflag & CBAUD)) { | 3343 | if (tty->termios->c_cflag & CBAUD) |
3372 | spin_lock_irqsave(&info->lock,flags); | 3344 | tty_port_raise_dtr_rts(port); |
3373 | info->serial_signals |= SerialSignal_RTS + SerialSignal_DTR; | ||
3374 | set_signals(info); | ||
3375 | spin_unlock_irqrestore(&info->lock,flags); | ||
3376 | } | ||
3377 | 3345 | ||
3378 | set_current_state(TASK_INTERRUPTIBLE); | 3346 | set_current_state(TASK_INTERRUPTIBLE); |
3379 | 3347 | ||
3380 | if (tty_hung_up_p(filp) || !(info->port.flags & ASYNC_INITIALIZED)){ | 3348 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)){ |
3381 | retval = (info->port.flags & ASYNC_HUP_NOTIFY) ? | 3349 | retval = (port->flags & ASYNC_HUP_NOTIFY) ? |
3382 | -EAGAIN : -ERESTARTSYS; | 3350 | -EAGAIN : -ERESTARTSYS; |
3383 | break; | 3351 | break; |
3384 | } | 3352 | } |
3385 | 3353 | ||
3386 | spin_lock_irqsave(&info->lock,flags); | 3354 | cd = tty_port_carrier_raised(port); |
3387 | get_signals(info); | ||
3388 | spin_unlock_irqrestore(&info->lock,flags); | ||
3389 | 3355 | ||
3390 | if (!(info->port.flags & ASYNC_CLOSING) && | 3356 | if (!(port->flags & ASYNC_CLOSING) && (do_clocal || cd)) |
3391 | (do_clocal || (info->serial_signals & SerialSignal_DCD)) ) { | ||
3392 | break; | 3357 | break; |
3393 | } | ||
3394 | 3358 | ||
3395 | if (signal_pending(current)) { | 3359 | if (signal_pending(current)) { |
3396 | retval = -ERESTARTSYS; | 3360 | retval = -ERESTARTSYS; |
@@ -3399,24 +3363,24 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp, | |||
3399 | 3363 | ||
3400 | if (debug_level >= DEBUG_LEVEL_INFO) | 3364 | if (debug_level >= DEBUG_LEVEL_INFO) |
3401 | printk("%s(%d):%s block_til_ready() count=%d\n", | 3365 | printk("%s(%d):%s block_til_ready() count=%d\n", |
3402 | __FILE__,__LINE__, tty->driver->name, info->port.count ); | 3366 | __FILE__,__LINE__, tty->driver->name, port->count ); |
3403 | 3367 | ||
3404 | schedule(); | 3368 | schedule(); |
3405 | } | 3369 | } |
3406 | 3370 | ||
3407 | set_current_state(TASK_RUNNING); | 3371 | set_current_state(TASK_RUNNING); |
3408 | remove_wait_queue(&info->port.open_wait, &wait); | 3372 | remove_wait_queue(&port->open_wait, &wait); |
3409 | 3373 | ||
3410 | if (extra_count) | 3374 | if (extra_count) |
3411 | info->port.count++; | 3375 | port->count++; |
3412 | info->port.blocked_open--; | 3376 | port->blocked_open--; |
3413 | 3377 | ||
3414 | if (debug_level >= DEBUG_LEVEL_INFO) | 3378 | if (debug_level >= DEBUG_LEVEL_INFO) |
3415 | printk("%s(%d):%s block_til_ready() after, count=%d\n", | 3379 | printk("%s(%d):%s block_til_ready() after, count=%d\n", |
3416 | __FILE__,__LINE__, tty->driver->name, info->port.count ); | 3380 | __FILE__,__LINE__, tty->driver->name, port->count ); |
3417 | 3381 | ||
3418 | if (!retval) | 3382 | if (!retval) |
3419 | info->port.flags |= ASYNC_NORMAL_ACTIVE; | 3383 | port->flags |= ASYNC_NORMAL_ACTIVE; |
3420 | 3384 | ||
3421 | return retval; | 3385 | return retval; |
3422 | } | 3386 | } |
@@ -3782,6 +3746,11 @@ static void add_device(SLMP_INFO *info) | |||
3782 | #endif | 3746 | #endif |
3783 | } | 3747 | } |
3784 | 3748 | ||
3749 | static const struct tty_port_operations port_ops = { | ||
3750 | .carrier_raised = carrier_raised, | ||
3751 | .raise_dtr_rts = raise_dtr_rts, | ||
3752 | }; | ||
3753 | |||
3785 | /* Allocate and initialize a device instance structure | 3754 | /* Allocate and initialize a device instance structure |
3786 | * | 3755 | * |
3787 | * Return Value: pointer to SLMP_INFO if success, otherwise NULL | 3756 | * Return Value: pointer to SLMP_INFO if success, otherwise NULL |
@@ -3798,6 +3767,7 @@ static SLMP_INFO *alloc_dev(int adapter_num, int port_num, struct pci_dev *pdev) | |||
3798 | __FILE__,__LINE__, adapter_num, port_num); | 3767 | __FILE__,__LINE__, adapter_num, port_num); |
3799 | } else { | 3768 | } else { |
3800 | tty_port_init(&info->port); | 3769 | tty_port_init(&info->port); |
3770 | info->port.ops = &port_ops; | ||
3801 | info->magic = MGSL_MAGIC; | 3771 | info->magic = MGSL_MAGIC; |
3802 | INIT_WORK(&info->task, bh_handler); | 3772 | INIT_WORK(&info->task, bh_handler); |
3803 | info->max_frame_size = 4096; | 3773 | info->max_frame_size = 4096; |
@@ -3940,6 +3910,7 @@ static const struct tty_operations ops = { | |||
3940 | .tiocmset = tiocmset, | 3910 | .tiocmset = tiocmset, |
3941 | }; | 3911 | }; |
3942 | 3912 | ||
3913 | |||
3943 | static void synclinkmp_cleanup(void) | 3914 | static void synclinkmp_cleanup(void) |
3944 | { | 3915 | { |
3945 | int rc; | 3916 | int rc; |
diff --git a/drivers/char/sysrq.c b/drivers/char/sysrq.c index ce0d9da52a8a..d41b9f6f7903 100644 --- a/drivers/char/sysrq.c +++ b/drivers/char/sysrq.c | |||
@@ -82,7 +82,7 @@ static void sysrq_handle_loglevel(int key, struct tty_struct *tty) | |||
82 | } | 82 | } |
83 | static struct sysrq_key_op sysrq_loglevel_op = { | 83 | static struct sysrq_key_op sysrq_loglevel_op = { |
84 | .handler = sysrq_handle_loglevel, | 84 | .handler = sysrq_handle_loglevel, |
85 | .help_msg = "loglevel0-8", | 85 | .help_msg = "loglevel(0-9)", |
86 | .action_msg = "Changing Loglevel", | 86 | .action_msg = "Changing Loglevel", |
87 | .enable_mask = SYSRQ_ENABLE_LOG, | 87 | .enable_mask = SYSRQ_ENABLE_LOG, |
88 | }; | 88 | }; |
@@ -233,7 +233,7 @@ static void sysrq_handle_showallcpus(int key, struct tty_struct *tty) | |||
233 | 233 | ||
234 | static struct sysrq_key_op sysrq_showallcpus_op = { | 234 | static struct sysrq_key_op sysrq_showallcpus_op = { |
235 | .handler = sysrq_handle_showallcpus, | 235 | .handler = sysrq_handle_showallcpus, |
236 | .help_msg = "aLlcpus", | 236 | .help_msg = "show-backtrace-all-active-cpus(L)", |
237 | .action_msg = "Show backtrace of all active CPUs", | 237 | .action_msg = "Show backtrace of all active CPUs", |
238 | .enable_mask = SYSRQ_ENABLE_DUMP, | 238 | .enable_mask = SYSRQ_ENABLE_DUMP, |
239 | }; | 239 | }; |
@@ -247,7 +247,7 @@ static void sysrq_handle_showregs(int key, struct tty_struct *tty) | |||
247 | } | 247 | } |
248 | static struct sysrq_key_op sysrq_showregs_op = { | 248 | static struct sysrq_key_op sysrq_showregs_op = { |
249 | .handler = sysrq_handle_showregs, | 249 | .handler = sysrq_handle_showregs, |
250 | .help_msg = "showPc", | 250 | .help_msg = "show-registers(P)", |
251 | .action_msg = "Show Regs", | 251 | .action_msg = "Show Regs", |
252 | .enable_mask = SYSRQ_ENABLE_DUMP, | 252 | .enable_mask = SYSRQ_ENABLE_DUMP, |
253 | }; | 253 | }; |
@@ -258,7 +258,7 @@ static void sysrq_handle_showstate(int key, struct tty_struct *tty) | |||
258 | } | 258 | } |
259 | static struct sysrq_key_op sysrq_showstate_op = { | 259 | static struct sysrq_key_op sysrq_showstate_op = { |
260 | .handler = sysrq_handle_showstate, | 260 | .handler = sysrq_handle_showstate, |
261 | .help_msg = "showTasks", | 261 | .help_msg = "show-task-states(T)", |
262 | .action_msg = "Show State", | 262 | .action_msg = "Show State", |
263 | .enable_mask = SYSRQ_ENABLE_DUMP, | 263 | .enable_mask = SYSRQ_ENABLE_DUMP, |
264 | }; | 264 | }; |
@@ -269,11 +269,27 @@ static void sysrq_handle_showstate_blocked(int key, struct tty_struct *tty) | |||
269 | } | 269 | } |
270 | static struct sysrq_key_op sysrq_showstate_blocked_op = { | 270 | static struct sysrq_key_op sysrq_showstate_blocked_op = { |
271 | .handler = sysrq_handle_showstate_blocked, | 271 | .handler = sysrq_handle_showstate_blocked, |
272 | .help_msg = "shoW-blocked-tasks", | 272 | .help_msg = "show-blocked-tasks(W)", |
273 | .action_msg = "Show Blocked State", | 273 | .action_msg = "Show Blocked State", |
274 | .enable_mask = SYSRQ_ENABLE_DUMP, | 274 | .enable_mask = SYSRQ_ENABLE_DUMP, |
275 | }; | 275 | }; |
276 | 276 | ||
277 | #ifdef CONFIG_TRACING | ||
278 | #include <linux/ftrace.h> | ||
279 | |||
280 | static void sysrq_ftrace_dump(int key, struct tty_struct *tty) | ||
281 | { | ||
282 | ftrace_dump(); | ||
283 | } | ||
284 | static struct sysrq_key_op sysrq_ftrace_dump_op = { | ||
285 | .handler = sysrq_ftrace_dump, | ||
286 | .help_msg = "dumpZ-ftrace-buffer", | ||
287 | .action_msg = "Dump ftrace buffer", | ||
288 | .enable_mask = SYSRQ_ENABLE_DUMP, | ||
289 | }; | ||
290 | #else | ||
291 | #define sysrq_ftrace_dump_op (*(struct sysrq_key_op *)0) | ||
292 | #endif | ||
277 | 293 | ||
278 | static void sysrq_handle_showmem(int key, struct tty_struct *tty) | 294 | static void sysrq_handle_showmem(int key, struct tty_struct *tty) |
279 | { | 295 | { |
@@ -281,7 +297,7 @@ static void sysrq_handle_showmem(int key, struct tty_struct *tty) | |||
281 | } | 297 | } |
282 | static struct sysrq_key_op sysrq_showmem_op = { | 298 | static struct sysrq_key_op sysrq_showmem_op = { |
283 | .handler = sysrq_handle_showmem, | 299 | .handler = sysrq_handle_showmem, |
284 | .help_msg = "showMem", | 300 | .help_msg = "show-memory-usage(M)", |
285 | .action_msg = "Show Memory", | 301 | .action_msg = "Show Memory", |
286 | .enable_mask = SYSRQ_ENABLE_DUMP, | 302 | .enable_mask = SYSRQ_ENABLE_DUMP, |
287 | }; | 303 | }; |
@@ -307,7 +323,7 @@ static void sysrq_handle_term(int key, struct tty_struct *tty) | |||
307 | } | 323 | } |
308 | static struct sysrq_key_op sysrq_term_op = { | 324 | static struct sysrq_key_op sysrq_term_op = { |
309 | .handler = sysrq_handle_term, | 325 | .handler = sysrq_handle_term, |
310 | .help_msg = "tErm", | 326 | .help_msg = "terminate-all-tasks(E)", |
311 | .action_msg = "Terminate All Tasks", | 327 | .action_msg = "Terminate All Tasks", |
312 | .enable_mask = SYSRQ_ENABLE_SIGNAL, | 328 | .enable_mask = SYSRQ_ENABLE_SIGNAL, |
313 | }; | 329 | }; |
@@ -325,7 +341,7 @@ static void sysrq_handle_moom(int key, struct tty_struct *tty) | |||
325 | } | 341 | } |
326 | static struct sysrq_key_op sysrq_moom_op = { | 342 | static struct sysrq_key_op sysrq_moom_op = { |
327 | .handler = sysrq_handle_moom, | 343 | .handler = sysrq_handle_moom, |
328 | .help_msg = "Full", | 344 | .help_msg = "memory-full-oom-kill(F)", |
329 | .action_msg = "Manual OOM execution", | 345 | .action_msg = "Manual OOM execution", |
330 | .enable_mask = SYSRQ_ENABLE_SIGNAL, | 346 | .enable_mask = SYSRQ_ENABLE_SIGNAL, |
331 | }; | 347 | }; |
@@ -337,7 +353,7 @@ static void sysrq_handle_kill(int key, struct tty_struct *tty) | |||
337 | } | 353 | } |
338 | static struct sysrq_key_op sysrq_kill_op = { | 354 | static struct sysrq_key_op sysrq_kill_op = { |
339 | .handler = sysrq_handle_kill, | 355 | .handler = sysrq_handle_kill, |
340 | .help_msg = "kIll", | 356 | .help_msg = "kill-all-tasks(I)", |
341 | .action_msg = "Kill All Tasks", | 357 | .action_msg = "Kill All Tasks", |
342 | .enable_mask = SYSRQ_ENABLE_SIGNAL, | 358 | .enable_mask = SYSRQ_ENABLE_SIGNAL, |
343 | }; | 359 | }; |
@@ -348,7 +364,7 @@ static void sysrq_handle_unrt(int key, struct tty_struct *tty) | |||
348 | } | 364 | } |
349 | static struct sysrq_key_op sysrq_unrt_op = { | 365 | static struct sysrq_key_op sysrq_unrt_op = { |
350 | .handler = sysrq_handle_unrt, | 366 | .handler = sysrq_handle_unrt, |
351 | .help_msg = "Nice", | 367 | .help_msg = "nice-all-RT-tasks(N)", |
352 | .action_msg = "Nice All RT Tasks", | 368 | .action_msg = "Nice All RT Tasks", |
353 | .enable_mask = SYSRQ_ENABLE_RTNICE, | 369 | .enable_mask = SYSRQ_ENABLE_RTNICE, |
354 | }; | 370 | }; |
@@ -406,7 +422,7 @@ static struct sysrq_key_op *sysrq_key_table[36] = { | |||
406 | NULL, /* x */ | 422 | NULL, /* x */ |
407 | /* y: May be registered on sparc64 for global register dump */ | 423 | /* y: May be registered on sparc64 for global register dump */ |
408 | NULL, /* y */ | 424 | NULL, /* y */ |
409 | NULL /* z */ | 425 | &sysrq_ftrace_dump_op, /* z */ |
410 | }; | 426 | }; |
411 | 427 | ||
412 | /* key2index calculation, -1 on invalid index */ | 428 | /* key2index calculation, -1 on invalid index */ |
diff --git a/drivers/char/tpm/tpm_nsc.c b/drivers/char/tpm/tpm_nsc.c index ab18c1e7b115..70efba2ee053 100644 --- a/drivers/char/tpm/tpm_nsc.c +++ b/drivers/char/tpm/tpm_nsc.c | |||
@@ -273,12 +273,23 @@ static void tpm_nsc_remove(struct device *dev) | |||
273 | } | 273 | } |
274 | } | 274 | } |
275 | 275 | ||
276 | static struct device_driver nsc_drv = { | 276 | static int tpm_nsc_suspend(struct platform_device *dev, pm_message_t msg) |
277 | .name = "tpm_nsc", | 277 | { |
278 | .bus = &platform_bus_type, | 278 | return tpm_pm_suspend(&dev->dev, msg); |
279 | .owner = THIS_MODULE, | 279 | } |
280 | .suspend = tpm_pm_suspend, | 280 | |
281 | .resume = tpm_pm_resume, | 281 | static int tpm_nsc_resume(struct platform_device *dev) |
282 | { | ||
283 | return tpm_pm_resume(&dev->dev); | ||
284 | } | ||
285 | |||
286 | static struct platform_driver nsc_drv = { | ||
287 | .suspend = tpm_nsc_suspend, | ||
288 | .resume = tpm_nsc_resume, | ||
289 | .driver = { | ||
290 | .name = "tpm_nsc", | ||
291 | .owner = THIS_MODULE, | ||
292 | }, | ||
282 | }; | 293 | }; |
283 | 294 | ||
284 | static int __init init_nsc(void) | 295 | static int __init init_nsc(void) |
@@ -297,7 +308,7 @@ static int __init init_nsc(void) | |||
297 | return -ENODEV; | 308 | return -ENODEV; |
298 | } | 309 | } |
299 | 310 | ||
300 | err = driver_register(&nsc_drv); | 311 | err = platform_driver_register(&nsc_drv); |
301 | if (err) | 312 | if (err) |
302 | return err; | 313 | return err; |
303 | 314 | ||
@@ -308,17 +319,15 @@ static int __init init_nsc(void) | |||
308 | /* enable the DPM module */ | 319 | /* enable the DPM module */ |
309 | tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01); | 320 | tpm_write_index(nscAddrBase, NSC_LDC_INDEX, 0x01); |
310 | 321 | ||
311 | pdev = kzalloc(sizeof(struct platform_device), GFP_KERNEL); | 322 | pdev = platform_device_alloc("tpm_nscl0", -1); |
312 | if (!pdev) { | 323 | if (!pdev) { |
313 | rc = -ENOMEM; | 324 | rc = -ENOMEM; |
314 | goto err_unreg_drv; | 325 | goto err_unreg_drv; |
315 | } | 326 | } |
316 | 327 | ||
317 | pdev->name = "tpm_nscl0"; | ||
318 | pdev->id = -1; | ||
319 | pdev->num_resources = 0; | 328 | pdev->num_resources = 0; |
329 | pdev->dev.driver = &nsc_drv.driver; | ||
320 | pdev->dev.release = tpm_nsc_remove; | 330 | pdev->dev.release = tpm_nsc_remove; |
321 | pdev->dev.driver = &nsc_drv; | ||
322 | 331 | ||
323 | if ((rc = platform_device_register(pdev)) < 0) | 332 | if ((rc = platform_device_register(pdev)) < 0) |
324 | goto err_free_dev; | 333 | goto err_free_dev; |
@@ -377,7 +386,7 @@ err_unreg_dev: | |||
377 | err_free_dev: | 386 | err_free_dev: |
378 | kfree(pdev); | 387 | kfree(pdev); |
379 | err_unreg_drv: | 388 | err_unreg_drv: |
380 | driver_unregister(&nsc_drv); | 389 | platform_driver_unregister(&nsc_drv); |
381 | return rc; | 390 | return rc; |
382 | } | 391 | } |
383 | 392 | ||
@@ -390,7 +399,7 @@ static void __exit cleanup_nsc(void) | |||
390 | pdev = NULL; | 399 | pdev = NULL; |
391 | } | 400 | } |
392 | 401 | ||
393 | driver_unregister(&nsc_drv); | 402 | platform_driver_unregister(&nsc_drv); |
394 | } | 403 | } |
395 | 404 | ||
396 | module_init(init_nsc); | 405 | module_init(init_nsc); |
diff --git a/drivers/char/tty_audit.c b/drivers/char/tty_audit.c index 5787249934c8..34ab6d798f81 100644 --- a/drivers/char/tty_audit.c +++ b/drivers/char/tty_audit.c | |||
@@ -67,6 +67,29 @@ static void tty_audit_buf_put(struct tty_audit_buf *buf) | |||
67 | tty_audit_buf_free(buf); | 67 | tty_audit_buf_free(buf); |
68 | } | 68 | } |
69 | 69 | ||
70 | static void tty_audit_log(const char *description, struct task_struct *tsk, | ||
71 | uid_t loginuid, unsigned sessionid, int major, | ||
72 | int minor, unsigned char *data, size_t size) | ||
73 | { | ||
74 | struct audit_buffer *ab; | ||
75 | |||
76 | ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_TTY); | ||
77 | if (ab) { | ||
78 | char name[sizeof(tsk->comm)]; | ||
79 | uid_t uid = task_uid(tsk); | ||
80 | |||
81 | audit_log_format(ab, "%s pid=%u uid=%u auid=%u ses=%u " | ||
82 | "major=%d minor=%d comm=", description, | ||
83 | tsk->pid, uid, loginuid, sessionid, | ||
84 | major, minor); | ||
85 | get_task_comm(name, tsk); | ||
86 | audit_log_untrustedstring(ab, name); | ||
87 | audit_log_format(ab, " data="); | ||
88 | audit_log_n_hex(ab, data, size); | ||
89 | audit_log_end(ab); | ||
90 | } | ||
91 | } | ||
92 | |||
70 | /** | 93 | /** |
71 | * tty_audit_buf_push - Push buffered data out | 94 | * tty_audit_buf_push - Push buffered data out |
72 | * | 95 | * |
@@ -77,25 +100,12 @@ static void tty_audit_buf_push(struct task_struct *tsk, uid_t loginuid, | |||
77 | unsigned int sessionid, | 100 | unsigned int sessionid, |
78 | struct tty_audit_buf *buf) | 101 | struct tty_audit_buf *buf) |
79 | { | 102 | { |
80 | struct audit_buffer *ab; | ||
81 | |||
82 | if (buf->valid == 0) | 103 | if (buf->valid == 0) |
83 | return; | 104 | return; |
84 | if (audit_enabled == 0) | 105 | if (audit_enabled == 0) |
85 | return; | 106 | return; |
86 | ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_TTY); | 107 | tty_audit_log("tty", tsk, loginuid, sessionid, buf->major, buf->minor, |
87 | if (ab) { | 108 | buf->data, buf->valid); |
88 | char name[sizeof(tsk->comm)]; | ||
89 | |||
90 | audit_log_format(ab, "tty pid=%u uid=%u auid=%u ses=%u " | ||
91 | "major=%d minor=%d comm=", tsk->pid, tsk->uid, | ||
92 | loginuid, sessionid, buf->major, buf->minor); | ||
93 | get_task_comm(name, tsk); | ||
94 | audit_log_untrustedstring(ab, name); | ||
95 | audit_log_format(ab, " data="); | ||
96 | audit_log_n_hex(ab, buf->data, buf->valid); | ||
97 | audit_log_end(ab); | ||
98 | } | ||
99 | buf->valid = 0; | 109 | buf->valid = 0; |
100 | } | 110 | } |
101 | 111 | ||
@@ -150,6 +160,42 @@ void tty_audit_fork(struct signal_struct *sig) | |||
150 | } | 160 | } |
151 | 161 | ||
152 | /** | 162 | /** |
163 | * tty_audit_tiocsti - Log TIOCSTI | ||
164 | */ | ||
165 | void tty_audit_tiocsti(struct tty_struct *tty, char ch) | ||
166 | { | ||
167 | struct tty_audit_buf *buf; | ||
168 | int major, minor, should_audit; | ||
169 | |||
170 | spin_lock_irq(¤t->sighand->siglock); | ||
171 | should_audit = current->signal->audit_tty; | ||
172 | buf = current->signal->tty_audit_buf; | ||
173 | if (buf) | ||
174 | atomic_inc(&buf->count); | ||
175 | spin_unlock_irq(¤t->sighand->siglock); | ||
176 | |||
177 | major = tty->driver->major; | ||
178 | minor = tty->driver->minor_start + tty->index; | ||
179 | if (buf) { | ||
180 | mutex_lock(&buf->mutex); | ||
181 | if (buf->major == major && buf->minor == minor) | ||
182 | tty_audit_buf_push_current(buf); | ||
183 | mutex_unlock(&buf->mutex); | ||
184 | tty_audit_buf_put(buf); | ||
185 | } | ||
186 | |||
187 | if (should_audit && audit_enabled) { | ||
188 | uid_t auid; | ||
189 | unsigned int sessionid; | ||
190 | |||
191 | auid = audit_get_loginuid(current); | ||
192 | sessionid = audit_get_sessionid(current); | ||
193 | tty_audit_log("ioctl=TIOCSTI", current, auid, sessionid, major, | ||
194 | minor, &ch, 1); | ||
195 | } | ||
196 | } | ||
197 | |||
198 | /** | ||
153 | * tty_audit_push_task - Flush task's pending audit data | 199 | * tty_audit_push_task - Flush task's pending audit data |
154 | */ | 200 | */ |
155 | void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid) | 201 | void tty_audit_push_task(struct task_struct *tsk, uid_t loginuid, u32 sessionid) |
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c index 1412a8d1e58d..d33e5ab06177 100644 --- a/drivers/char/tty_io.c +++ b/drivers/char/tty_io.c | |||
@@ -1111,9 +1111,7 @@ void tty_write_message(struct tty_struct *tty, char *msg) | |||
1111 | * Locks the line discipline as required | 1111 | * Locks the line discipline as required |
1112 | * Writes to the tty driver are serialized by the atomic_write_lock | 1112 | * Writes to the tty driver are serialized by the atomic_write_lock |
1113 | * and are then processed in chunks to the device. The line discipline | 1113 | * and are then processed in chunks to the device. The line discipline |
1114 | * write method will not be involked in parallel for each device | 1114 | * write method will not be invoked in parallel for each device. |
1115 | * The line discipline write method is called under the big | ||
1116 | * kernel lock for historical reasons. New code should not rely on this. | ||
1117 | */ | 1115 | */ |
1118 | 1116 | ||
1119 | static ssize_t tty_write(struct file *file, const char __user *buf, | 1117 | static ssize_t tty_write(struct file *file, const char __user *buf, |
@@ -1213,7 +1211,7 @@ static void tty_line_name(struct tty_driver *driver, int index, char *p) | |||
1213 | * be held until the 'fast-open' is also done. Will change once we | 1211 | * be held until the 'fast-open' is also done. Will change once we |
1214 | * have refcounting in the driver and per driver locking | 1212 | * have refcounting in the driver and per driver locking |
1215 | */ | 1213 | */ |
1216 | struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver, | 1214 | static struct tty_struct *tty_driver_lookup_tty(struct tty_driver *driver, |
1217 | struct inode *inode, int idx) | 1215 | struct inode *inode, int idx) |
1218 | { | 1216 | { |
1219 | struct tty_struct *tty; | 1217 | struct tty_struct *tty; |
@@ -2018,6 +2016,7 @@ static int tiocsti(struct tty_struct *tty, char __user *p) | |||
2018 | return -EPERM; | 2016 | return -EPERM; |
2019 | if (get_user(ch, p)) | 2017 | if (get_user(ch, p)) |
2020 | return -EFAULT; | 2018 | return -EFAULT; |
2019 | tty_audit_tiocsti(tty, ch); | ||
2021 | ld = tty_ldisc_ref_wait(tty); | 2020 | ld = tty_ldisc_ref_wait(tty); |
2022 | ld->ops->receive_buf(tty, &ch, &mbz, 1); | 2021 | ld->ops->receive_buf(tty, &ch, &mbz, 1); |
2023 | tty_ldisc_deref(ld); | 2022 | tty_ldisc_deref(ld); |
@@ -2049,7 +2048,6 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg) | |||
2049 | /** | 2048 | /** |
2050 | * tty_do_resize - resize event | 2049 | * tty_do_resize - resize event |
2051 | * @tty: tty being resized | 2050 | * @tty: tty being resized |
2052 | * @real_tty: real tty (not the same as tty if using a pty/tty pair) | ||
2053 | * @rows: rows (character) | 2051 | * @rows: rows (character) |
2054 | * @cols: cols (character) | 2052 | * @cols: cols (character) |
2055 | * | 2053 | * |
@@ -2057,41 +2055,34 @@ static int tiocgwinsz(struct tty_struct *tty, struct winsize __user *arg) | |||
2057 | * peform a terminal resize correctly | 2055 | * peform a terminal resize correctly |
2058 | */ | 2056 | */ |
2059 | 2057 | ||
2060 | int tty_do_resize(struct tty_struct *tty, struct tty_struct *real_tty, | 2058 | int tty_do_resize(struct tty_struct *tty, struct winsize *ws) |
2061 | struct winsize *ws) | ||
2062 | { | 2059 | { |
2063 | struct pid *pgrp, *rpgrp; | 2060 | struct pid *pgrp; |
2064 | unsigned long flags; | 2061 | unsigned long flags; |
2065 | 2062 | ||
2066 | /* For a PTY we need to lock the tty side */ | 2063 | /* Lock the tty */ |
2067 | mutex_lock(&real_tty->termios_mutex); | 2064 | mutex_lock(&tty->termios_mutex); |
2068 | if (!memcmp(ws, &real_tty->winsize, sizeof(*ws))) | 2065 | if (!memcmp(ws, &tty->winsize, sizeof(*ws))) |
2069 | goto done; | 2066 | goto done; |
2070 | /* Get the PID values and reference them so we can | 2067 | /* Get the PID values and reference them so we can |
2071 | avoid holding the tty ctrl lock while sending signals */ | 2068 | avoid holding the tty ctrl lock while sending signals */ |
2072 | spin_lock_irqsave(&tty->ctrl_lock, flags); | 2069 | spin_lock_irqsave(&tty->ctrl_lock, flags); |
2073 | pgrp = get_pid(tty->pgrp); | 2070 | pgrp = get_pid(tty->pgrp); |
2074 | rpgrp = get_pid(real_tty->pgrp); | ||
2075 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); | 2071 | spin_unlock_irqrestore(&tty->ctrl_lock, flags); |
2076 | 2072 | ||
2077 | if (pgrp) | 2073 | if (pgrp) |
2078 | kill_pgrp(pgrp, SIGWINCH, 1); | 2074 | kill_pgrp(pgrp, SIGWINCH, 1); |
2079 | if (rpgrp != pgrp && rpgrp) | ||
2080 | kill_pgrp(rpgrp, SIGWINCH, 1); | ||
2081 | |||
2082 | put_pid(pgrp); | 2075 | put_pid(pgrp); |
2083 | put_pid(rpgrp); | ||
2084 | 2076 | ||
2085 | tty->winsize = *ws; | 2077 | tty->winsize = *ws; |
2086 | real_tty->winsize = *ws; | ||
2087 | done: | 2078 | done: |
2088 | mutex_unlock(&real_tty->termios_mutex); | 2079 | mutex_unlock(&tty->termios_mutex); |
2089 | return 0; | 2080 | return 0; |
2090 | } | 2081 | } |
2091 | 2082 | ||
2092 | /** | 2083 | /** |
2093 | * tiocswinsz - implement window size set ioctl | 2084 | * tiocswinsz - implement window size set ioctl |
2094 | * @tty; tty | 2085 | * @tty; tty side of tty |
2095 | * @arg: user buffer for result | 2086 | * @arg: user buffer for result |
2096 | * | 2087 | * |
2097 | * Copies the user idea of the window size to the kernel. Traditionally | 2088 | * Copies the user idea of the window size to the kernel. Traditionally |
@@ -2104,17 +2095,16 @@ done: | |||
2104 | * then calls into the default method. | 2095 | * then calls into the default method. |
2105 | */ | 2096 | */ |
2106 | 2097 | ||
2107 | static int tiocswinsz(struct tty_struct *tty, struct tty_struct *real_tty, | 2098 | static int tiocswinsz(struct tty_struct *tty, struct winsize __user *arg) |
2108 | struct winsize __user *arg) | ||
2109 | { | 2099 | { |
2110 | struct winsize tmp_ws; | 2100 | struct winsize tmp_ws; |
2111 | if (copy_from_user(&tmp_ws, arg, sizeof(*arg))) | 2101 | if (copy_from_user(&tmp_ws, arg, sizeof(*arg))) |
2112 | return -EFAULT; | 2102 | return -EFAULT; |
2113 | 2103 | ||
2114 | if (tty->ops->resize) | 2104 | if (tty->ops->resize) |
2115 | return tty->ops->resize(tty, real_tty, &tmp_ws); | 2105 | return tty->ops->resize(tty, &tmp_ws); |
2116 | else | 2106 | else |
2117 | return tty_do_resize(tty, real_tty, &tmp_ws); | 2107 | return tty_do_resize(tty, &tmp_ws); |
2118 | } | 2108 | } |
2119 | 2109 | ||
2120 | /** | 2110 | /** |
@@ -2539,7 +2529,7 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
2539 | case TIOCGWINSZ: | 2529 | case TIOCGWINSZ: |
2540 | return tiocgwinsz(real_tty, p); | 2530 | return tiocgwinsz(real_tty, p); |
2541 | case TIOCSWINSZ: | 2531 | case TIOCSWINSZ: |
2542 | return tiocswinsz(tty, real_tty, p); | 2532 | return tiocswinsz(real_tty, p); |
2543 | case TIOCCONS: | 2533 | case TIOCCONS: |
2544 | return real_tty != tty ? -EINVAL : tioccons(file); | 2534 | return real_tty != tty ? -EINVAL : tioccons(file); |
2545 | case FIONBIO: | 2535 | case FIONBIO: |
@@ -2784,6 +2774,8 @@ void initialize_tty_struct(struct tty_struct *tty, | |||
2784 | INIT_WORK(&tty->hangup_work, do_tty_hangup); | 2774 | INIT_WORK(&tty->hangup_work, do_tty_hangup); |
2785 | mutex_init(&tty->atomic_read_lock); | 2775 | mutex_init(&tty->atomic_read_lock); |
2786 | mutex_init(&tty->atomic_write_lock); | 2776 | mutex_init(&tty->atomic_write_lock); |
2777 | mutex_init(&tty->output_lock); | ||
2778 | mutex_init(&tty->echo_lock); | ||
2787 | spin_lock_init(&tty->read_lock); | 2779 | spin_lock_init(&tty->read_lock); |
2788 | spin_lock_init(&tty->ctrl_lock); | 2780 | spin_lock_init(&tty->ctrl_lock); |
2789 | INIT_LIST_HEAD(&tty->tty_files); | 2781 | INIT_LIST_HEAD(&tty->tty_files); |
diff --git a/drivers/char/tty_ldisc.c b/drivers/char/tty_ldisc.c index f307f135cbfb..7a84b406a952 100644 --- a/drivers/char/tty_ldisc.c +++ b/drivers/char/tty_ldisc.c | |||
@@ -316,8 +316,7 @@ struct tty_ldisc *tty_ldisc_ref_wait(struct tty_struct *tty) | |||
316 | { | 316 | { |
317 | /* wait_event is a macro */ | 317 | /* wait_event is a macro */ |
318 | wait_event(tty_ldisc_wait, tty_ldisc_try(tty)); | 318 | wait_event(tty_ldisc_wait, tty_ldisc_try(tty)); |
319 | if (tty->ldisc.refcount == 0) | 319 | WARN_ON(tty->ldisc.refcount == 0); |
320 | printk(KERN_ERR "tty_ldisc_ref_wait\n"); | ||
321 | return &tty->ldisc; | 320 | return &tty->ldisc; |
322 | } | 321 | } |
323 | 322 | ||
@@ -376,15 +375,17 @@ EXPORT_SYMBOL_GPL(tty_ldisc_deref); | |||
376 | * @tty: terminal to activate ldisc on | 375 | * @tty: terminal to activate ldisc on |
377 | * | 376 | * |
378 | * Set the TTY_LDISC flag when the line discipline can be called | 377 | * Set the TTY_LDISC flag when the line discipline can be called |
379 | * again. Do necessary wakeups for existing sleepers. | 378 | * again. Do necessary wakeups for existing sleepers. Clear the LDISC |
379 | * changing flag to indicate any ldisc change is now over. | ||
380 | * | 380 | * |
381 | * Note: nobody should set this bit except via this function. Clearing | 381 | * Note: nobody should set the TTY_LDISC bit except via this function. |
382 | * directly is allowed. | 382 | * Clearing directly is allowed. |
383 | */ | 383 | */ |
384 | 384 | ||
385 | void tty_ldisc_enable(struct tty_struct *tty) | 385 | void tty_ldisc_enable(struct tty_struct *tty) |
386 | { | 386 | { |
387 | set_bit(TTY_LDISC, &tty->flags); | 387 | set_bit(TTY_LDISC, &tty->flags); |
388 | clear_bit(TTY_LDISC_CHANGING, &tty->flags); | ||
388 | wake_up(&tty_ldisc_wait); | 389 | wake_up(&tty_ldisc_wait); |
389 | } | 390 | } |
390 | 391 | ||
@@ -496,7 +497,14 @@ restart: | |||
496 | * reference to the line discipline. The TTY_LDISC bit | 497 | * reference to the line discipline. The TTY_LDISC bit |
497 | * prevents anyone taking a reference once it is clear. | 498 | * prevents anyone taking a reference once it is clear. |
498 | * We need the lock to avoid racing reference takers. | 499 | * We need the lock to avoid racing reference takers. |
500 | * | ||
501 | * We must clear the TTY_LDISC bit here to avoid a livelock | ||
502 | * with a userspace app continually trying to use the tty in | ||
503 | * parallel to the change and re-referencing the tty. | ||
499 | */ | 504 | */ |
505 | clear_bit(TTY_LDISC, &tty->flags); | ||
506 | if (o_tty) | ||
507 | clear_bit(TTY_LDISC, &o_tty->flags); | ||
500 | 508 | ||
501 | spin_lock_irqsave(&tty_ldisc_lock, flags); | 509 | spin_lock_irqsave(&tty_ldisc_lock, flags); |
502 | if (tty->ldisc.refcount || (o_tty && o_tty->ldisc.refcount)) { | 510 | if (tty->ldisc.refcount || (o_tty && o_tty->ldisc.refcount)) { |
@@ -528,7 +536,7 @@ restart: | |||
528 | * If the TTY_LDISC bit is set, then we are racing against | 536 | * If the TTY_LDISC bit is set, then we are racing against |
529 | * another ldisc change | 537 | * another ldisc change |
530 | */ | 538 | */ |
531 | if (!test_bit(TTY_LDISC, &tty->flags)) { | 539 | if (test_bit(TTY_LDISC_CHANGING, &tty->flags)) { |
532 | struct tty_ldisc *ld; | 540 | struct tty_ldisc *ld; |
533 | spin_unlock_irqrestore(&tty_ldisc_lock, flags); | 541 | spin_unlock_irqrestore(&tty_ldisc_lock, flags); |
534 | tty_ldisc_put(new_ldisc.ops); | 542 | tty_ldisc_put(new_ldisc.ops); |
@@ -536,10 +544,14 @@ restart: | |||
536 | tty_ldisc_deref(ld); | 544 | tty_ldisc_deref(ld); |
537 | goto restart; | 545 | goto restart; |
538 | } | 546 | } |
539 | 547 | /* | |
540 | clear_bit(TTY_LDISC, &tty->flags); | 548 | * This flag is used to avoid two parallel ldisc changes. Once |
549 | * open and close are fine grained locked this may work better | ||
550 | * as a mutex shared with the open/close/hup paths | ||
551 | */ | ||
552 | set_bit(TTY_LDISC_CHANGING, &tty->flags); | ||
541 | if (o_tty) | 553 | if (o_tty) |
542 | clear_bit(TTY_LDISC, &o_tty->flags); | 554 | set_bit(TTY_LDISC_CHANGING, &o_tty->flags); |
543 | spin_unlock_irqrestore(&tty_ldisc_lock, flags); | 555 | spin_unlock_irqrestore(&tty_ldisc_lock, flags); |
544 | 556 | ||
545 | /* | 557 | /* |
diff --git a/drivers/char/tty_port.c b/drivers/char/tty_port.c index c8f8024cb40e..9b8004c72686 100644 --- a/drivers/char/tty_port.c +++ b/drivers/char/tty_port.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/tty.h> | 7 | #include <linux/tty.h> |
8 | #include <linux/tty_driver.h> | 8 | #include <linux/tty_driver.h> |
9 | #include <linux/tty_flip.h> | 9 | #include <linux/tty_flip.h> |
10 | #include <linux/serial.h> | ||
10 | #include <linux/timer.h> | 11 | #include <linux/timer.h> |
11 | #include <linux/string.h> | 12 | #include <linux/string.h> |
12 | #include <linux/slab.h> | 13 | #include <linux/slab.h> |
@@ -94,3 +95,227 @@ void tty_port_tty_set(struct tty_port *port, struct tty_struct *tty) | |||
94 | spin_unlock_irqrestore(&port->lock, flags); | 95 | spin_unlock_irqrestore(&port->lock, flags); |
95 | } | 96 | } |
96 | EXPORT_SYMBOL(tty_port_tty_set); | 97 | EXPORT_SYMBOL(tty_port_tty_set); |
98 | |||
99 | /** | ||
100 | * tty_port_hangup - hangup helper | ||
101 | * @port: tty port | ||
102 | * | ||
103 | * Perform port level tty hangup flag and count changes. Drop the tty | ||
104 | * reference. | ||
105 | */ | ||
106 | |||
107 | void tty_port_hangup(struct tty_port *port) | ||
108 | { | ||
109 | unsigned long flags; | ||
110 | |||
111 | spin_lock_irqsave(&port->lock, flags); | ||
112 | port->count = 0; | ||
113 | port->flags &= ~ASYNC_NORMAL_ACTIVE; | ||
114 | if (port->tty) | ||
115 | tty_kref_put(port->tty); | ||
116 | port->tty = NULL; | ||
117 | spin_unlock_irqrestore(&port->lock, flags); | ||
118 | wake_up_interruptible(&port->open_wait); | ||
119 | } | ||
120 | EXPORT_SYMBOL(tty_port_hangup); | ||
121 | |||
122 | /** | ||
123 | * tty_port_carrier_raised - carrier raised check | ||
124 | * @port: tty port | ||
125 | * | ||
126 | * Wrapper for the carrier detect logic. For the moment this is used | ||
127 | * to hide some internal details. This will eventually become entirely | ||
128 | * internal to the tty port. | ||
129 | */ | ||
130 | |||
131 | int tty_port_carrier_raised(struct tty_port *port) | ||
132 | { | ||
133 | if (port->ops->carrier_raised == NULL) | ||
134 | return 1; | ||
135 | return port->ops->carrier_raised(port); | ||
136 | } | ||
137 | EXPORT_SYMBOL(tty_port_carrier_raised); | ||
138 | |||
139 | /** | ||
140 | * tty_port_raise_dtr_rts - Riase DTR/RTS | ||
141 | * @port: tty port | ||
142 | * | ||
143 | * Wrapper for the DTR/RTS raise logic. For the moment this is used | ||
144 | * to hide some internal details. This will eventually become entirely | ||
145 | * internal to the tty port. | ||
146 | */ | ||
147 | |||
148 | void tty_port_raise_dtr_rts(struct tty_port *port) | ||
149 | { | ||
150 | if (port->ops->raise_dtr_rts) | ||
151 | port->ops->raise_dtr_rts(port); | ||
152 | } | ||
153 | EXPORT_SYMBOL(tty_port_raise_dtr_rts); | ||
154 | |||
155 | /** | ||
156 | * tty_port_block_til_ready - Waiting logic for tty open | ||
157 | * @port: the tty port being opened | ||
158 | * @tty: the tty device being bound | ||
159 | * @filp: the file pointer of the opener | ||
160 | * | ||
161 | * Implement the core POSIX/SuS tty behaviour when opening a tty device. | ||
162 | * Handles: | ||
163 | * - hangup (both before and during) | ||
164 | * - non blocking open | ||
165 | * - rts/dtr/dcd | ||
166 | * - signals | ||
167 | * - port flags and counts | ||
168 | * | ||
169 | * The passed tty_port must implement the carrier_raised method if it can | ||
170 | * do carrier detect and the raise_dtr_rts method if it supports software | ||
171 | * management of these lines. Note that the dtr/rts raise is done each | ||
172 | * iteration as a hangup may have previously dropped them while we wait. | ||
173 | */ | ||
174 | |||
175 | int tty_port_block_til_ready(struct tty_port *port, | ||
176 | struct tty_struct *tty, struct file *filp) | ||
177 | { | ||
178 | int do_clocal = 0, retval; | ||
179 | unsigned long flags; | ||
180 | DECLARE_WAITQUEUE(wait, current); | ||
181 | int cd; | ||
182 | |||
183 | /* block if port is in the process of being closed */ | ||
184 | if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING) { | ||
185 | interruptible_sleep_on(&port->close_wait); | ||
186 | if (port->flags & ASYNC_HUP_NOTIFY) | ||
187 | return -EAGAIN; | ||
188 | else | ||
189 | return -ERESTARTSYS; | ||
190 | } | ||
191 | |||
192 | /* if non-blocking mode is set we can pass directly to open unless | ||
193 | the port has just hung up or is in another error state */ | ||
194 | if ((filp->f_flags & O_NONBLOCK) || | ||
195 | (tty->flags & (1 << TTY_IO_ERROR))) { | ||
196 | port->flags |= ASYNC_NORMAL_ACTIVE; | ||
197 | return 0; | ||
198 | } | ||
199 | |||
200 | if (C_CLOCAL(tty)) | ||
201 | do_clocal = 1; | ||
202 | |||
203 | /* Block waiting until we can proceed. We may need to wait for the | ||
204 | carrier, but we must also wait for any close that is in progress | ||
205 | before the next open may complete */ | ||
206 | |||
207 | retval = 0; | ||
208 | add_wait_queue(&port->open_wait, &wait); | ||
209 | |||
210 | /* The port lock protects the port counts */ | ||
211 | spin_lock_irqsave(&port->lock, flags); | ||
212 | if (!tty_hung_up_p(filp)) | ||
213 | port->count--; | ||
214 | port->blocked_open++; | ||
215 | spin_unlock_irqrestore(&port->lock, flags); | ||
216 | |||
217 | while (1) { | ||
218 | /* Indicate we are open */ | ||
219 | if (tty->termios->c_cflag & CBAUD) | ||
220 | tty_port_raise_dtr_rts(port); | ||
221 | |||
222 | set_current_state(TASK_INTERRUPTIBLE); | ||
223 | /* Check for a hangup or uninitialised port. Return accordingly */ | ||
224 | if (tty_hung_up_p(filp) || !(port->flags & ASYNC_INITIALIZED)) { | ||
225 | if (port->flags & ASYNC_HUP_NOTIFY) | ||
226 | retval = -EAGAIN; | ||
227 | else | ||
228 | retval = -ERESTARTSYS; | ||
229 | break; | ||
230 | } | ||
231 | /* Probe the carrier. For devices with no carrier detect this | ||
232 | will always return true */ | ||
233 | cd = tty_port_carrier_raised(port); | ||
234 | if (!(port->flags & ASYNC_CLOSING) && | ||
235 | (do_clocal || cd)) | ||
236 | break; | ||
237 | if (signal_pending(current)) { | ||
238 | retval = -ERESTARTSYS; | ||
239 | break; | ||
240 | } | ||
241 | schedule(); | ||
242 | } | ||
243 | set_current_state(TASK_RUNNING); | ||
244 | remove_wait_queue(&port->open_wait, &wait); | ||
245 | |||
246 | /* Update counts. A parallel hangup will have set count to zero and | ||
247 | we must not mess that up further */ | ||
248 | spin_lock_irqsave(&port->lock, flags); | ||
249 | if (!tty_hung_up_p(filp)) | ||
250 | port->count++; | ||
251 | port->blocked_open--; | ||
252 | if (retval == 0) | ||
253 | port->flags |= ASYNC_NORMAL_ACTIVE; | ||
254 | spin_unlock_irqrestore(&port->lock, flags); | ||
255 | return 0; | ||
256 | |||
257 | } | ||
258 | EXPORT_SYMBOL(tty_port_block_til_ready); | ||
259 | |||
260 | int tty_port_close_start(struct tty_port *port, struct tty_struct *tty, struct file *filp) | ||
261 | { | ||
262 | unsigned long flags; | ||
263 | |||
264 | spin_lock_irqsave(&port->lock, flags); | ||
265 | if (tty_hung_up_p(filp)) { | ||
266 | spin_unlock_irqrestore(&port->lock, flags); | ||
267 | return 0; | ||
268 | } | ||
269 | |||
270 | if( tty->count == 1 && port->count != 1) { | ||
271 | printk(KERN_WARNING | ||
272 | "tty_port_close_start: tty->count = 1 port count = %d.\n", | ||
273 | port->count); | ||
274 | port->count = 1; | ||
275 | } | ||
276 | if (--port->count < 0) { | ||
277 | printk(KERN_WARNING "tty_port_close_start: count = %d\n", | ||
278 | port->count); | ||
279 | port->count = 0; | ||
280 | } | ||
281 | |||
282 | if (port->count) { | ||
283 | spin_unlock_irqrestore(&port->lock, flags); | ||
284 | return 0; | ||
285 | } | ||
286 | port->flags |= ASYNC_CLOSING; | ||
287 | tty->closing = 1; | ||
288 | spin_unlock_irqrestore(&port->lock, flags); | ||
289 | /* Don't block on a stalled port, just pull the chain */ | ||
290 | if (tty->flow_stopped) | ||
291 | tty_driver_flush_buffer(tty); | ||
292 | if (port->flags & ASYNC_INITIALIZED && | ||
293 | port->closing_wait != ASYNC_CLOSING_WAIT_NONE) | ||
294 | tty_wait_until_sent(tty, port->closing_wait); | ||
295 | return 1; | ||
296 | } | ||
297 | EXPORT_SYMBOL(tty_port_close_start); | ||
298 | |||
299 | void tty_port_close_end(struct tty_port *port, struct tty_struct *tty) | ||
300 | { | ||
301 | unsigned long flags; | ||
302 | |||
303 | tty_ldisc_flush(tty); | ||
304 | |||
305 | spin_lock_irqsave(&port->lock, flags); | ||
306 | tty->closing = 0; | ||
307 | |||
308 | if (port->blocked_open) { | ||
309 | spin_unlock_irqrestore(&port->lock, flags); | ||
310 | if (port->close_delay) { | ||
311 | msleep_interruptible( | ||
312 | jiffies_to_msecs(port->close_delay)); | ||
313 | } | ||
314 | spin_lock_irqsave(&port->lock, flags); | ||
315 | wake_up_interruptible(&port->open_wait); | ||
316 | } | ||
317 | port->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); | ||
318 | wake_up_interruptible(&port->close_wait); | ||
319 | spin_unlock_irqrestore(&port->lock, flags); | ||
320 | } | ||
321 | EXPORT_SYMBOL(tty_port_close_end); | ||
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 3fb0d2c88ba5..ff6f5a4b58fb 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
@@ -138,12 +138,33 @@ int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int)) | |||
138 | } | 138 | } |
139 | 139 | ||
140 | /* | 140 | /* |
141 | * virtio console configuration. This supports: | ||
142 | * - console resize | ||
143 | */ | ||
144 | static void virtcons_apply_config(struct virtio_device *dev) | ||
145 | { | ||
146 | struct winsize ws; | ||
147 | |||
148 | if (virtio_has_feature(dev, VIRTIO_CONSOLE_F_SIZE)) { | ||
149 | dev->config->get(dev, | ||
150 | offsetof(struct virtio_console_config, cols), | ||
151 | &ws.ws_col, sizeof(u16)); | ||
152 | dev->config->get(dev, | ||
153 | offsetof(struct virtio_console_config, rows), | ||
154 | &ws.ws_row, sizeof(u16)); | ||
155 | hvc_resize(hvc, ws); | ||
156 | } | ||
157 | } | ||
158 | |||
159 | /* | ||
141 | * we support only one console, the hvc struct is a global var | 160 | * we support only one console, the hvc struct is a global var |
142 | * There is no need to do anything | 161 | * We set the configuration at this point, since we now have a tty |
143 | */ | 162 | */ |
144 | static int notifier_add_vio(struct hvc_struct *hp, int data) | 163 | static int notifier_add_vio(struct hvc_struct *hp, int data) |
145 | { | 164 | { |
146 | hp->irq_requested = 1; | 165 | hp->irq_requested = 1; |
166 | virtcons_apply_config(vdev); | ||
167 | |||
147 | return 0; | 168 | return 0; |
148 | } | 169 | } |
149 | 170 | ||
@@ -234,11 +255,18 @@ static struct virtio_device_id id_table[] = { | |||
234 | { 0 }, | 255 | { 0 }, |
235 | }; | 256 | }; |
236 | 257 | ||
258 | static unsigned int features[] = { | ||
259 | VIRTIO_CONSOLE_F_SIZE, | ||
260 | }; | ||
261 | |||
237 | static struct virtio_driver virtio_console = { | 262 | static struct virtio_driver virtio_console = { |
263 | .feature_table = features, | ||
264 | .feature_table_size = ARRAY_SIZE(features), | ||
238 | .driver.name = KBUILD_MODNAME, | 265 | .driver.name = KBUILD_MODNAME, |
239 | .driver.owner = THIS_MODULE, | 266 | .driver.owner = THIS_MODULE, |
240 | .id_table = id_table, | 267 | .id_table = id_table, |
241 | .probe = virtcons_probe, | 268 | .probe = virtcons_probe, |
269 | .config_changed = virtcons_apply_config, | ||
242 | }; | 270 | }; |
243 | 271 | ||
244 | static int __init init(void) | 272 | static int __init init(void) |
diff --git a/drivers/char/vme_scc.c b/drivers/char/vme_scc.c index 1718b3c481db..0e8234bd0e19 100644 --- a/drivers/char/vme_scc.c +++ b/drivers/char/vme_scc.c | |||
@@ -69,7 +69,7 @@ static void scc_disable_tx_interrupts(void * ptr); | |||
69 | static void scc_enable_tx_interrupts(void * ptr); | 69 | static void scc_enable_tx_interrupts(void * ptr); |
70 | static void scc_disable_rx_interrupts(void * ptr); | 70 | static void scc_disable_rx_interrupts(void * ptr); |
71 | static void scc_enable_rx_interrupts(void * ptr); | 71 | static void scc_enable_rx_interrupts(void * ptr); |
72 | static int scc_get_CD(void * ptr); | 72 | static int scc_carrier_raised(struct tty_port *port); |
73 | static void scc_shutdown_port(void * ptr); | 73 | static void scc_shutdown_port(void * ptr); |
74 | static int scc_set_real_termios(void *ptr); | 74 | static int scc_set_real_termios(void *ptr); |
75 | static void scc_hungup(void *ptr); | 75 | static void scc_hungup(void *ptr); |
@@ -100,7 +100,6 @@ static struct real_driver scc_real_driver = { | |||
100 | scc_enable_tx_interrupts, | 100 | scc_enable_tx_interrupts, |
101 | scc_disable_rx_interrupts, | 101 | scc_disable_rx_interrupts, |
102 | scc_enable_rx_interrupts, | 102 | scc_enable_rx_interrupts, |
103 | scc_get_CD, | ||
104 | scc_shutdown_port, | 103 | scc_shutdown_port, |
105 | scc_set_real_termios, | 104 | scc_set_real_termios, |
106 | scc_chars_in_buffer, | 105 | scc_chars_in_buffer, |
@@ -129,6 +128,10 @@ static const struct tty_operations scc_ops = { | |||
129 | .break_ctl = scc_break_ctl, | 128 | .break_ctl = scc_break_ctl, |
130 | }; | 129 | }; |
131 | 130 | ||
131 | static const struct tty_port_operations scc_port_ops = { | ||
132 | .carrier_raised = scc_carrier_raised, | ||
133 | }; | ||
134 | |||
132 | /*---------------------------------------------------------------------------- | 135 | /*---------------------------------------------------------------------------- |
133 | * vme_scc_init() and support functions | 136 | * vme_scc_init() and support functions |
134 | *---------------------------------------------------------------------------*/ | 137 | *---------------------------------------------------------------------------*/ |
@@ -176,6 +179,8 @@ static void scc_init_portstructs(void) | |||
176 | 179 | ||
177 | for (i = 0; i < 2; i++) { | 180 | for (i = 0; i < 2; i++) { |
178 | port = scc_ports + i; | 181 | port = scc_ports + i; |
182 | tty_port_init(&port->gs.port); | ||
183 | port->gs.port.ops = &scc_port_ops; | ||
179 | port->gs.magic = SCC_MAGIC; | 184 | port->gs.magic = SCC_MAGIC; |
180 | port->gs.close_delay = HZ/2; | 185 | port->gs.close_delay = HZ/2; |
181 | port->gs.closing_wait = 30 * HZ; | 186 | port->gs.closing_wait = 30 * HZ; |
@@ -624,10 +629,10 @@ static void scc_enable_rx_interrupts(void *ptr) | |||
624 | } | 629 | } |
625 | 630 | ||
626 | 631 | ||
627 | static int scc_get_CD(void *ptr) | 632 | static int scc_carrier_raised(struct tty_port *port) |
628 | { | 633 | { |
629 | struct scc_port *port = ptr; | 634 | struct scc_port *sc = container_of(port, struct scc_port, gs.port); |
630 | unsigned channel = port->channel; | 635 | unsigned channel = sc->channel; |
631 | 636 | ||
632 | return !!(scc_last_status_reg[channel] & SR_DCD); | 637 | return !!(scc_last_status_reg[channel] & SR_DCD); |
633 | } | 638 | } |
@@ -638,7 +643,7 @@ static void scc_shutdown_port(void *ptr) | |||
638 | struct scc_port *port = ptr; | 643 | struct scc_port *port = ptr; |
639 | 644 | ||
640 | port->gs.port.flags &= ~ GS_ACTIVE; | 645 | port->gs.port.flags &= ~ GS_ACTIVE; |
641 | if (port->gs.port.tty && port->gs.port.tty->termios->c_cflag & HUPCL) { | 646 | if (port->gs.port.tty && (port->gs.port.tty->termios->c_cflag & HUPCL)) { |
642 | scc_setsignals (port, 0, 0); | 647 | scc_setsignals (port, 0, 0); |
643 | } | 648 | } |
644 | } | 649 | } |
@@ -779,7 +784,7 @@ static void scc_setsignals(struct scc_port *port, int dtr, int rts) | |||
779 | 784 | ||
780 | static void scc_send_xchar(struct tty_struct *tty, char ch) | 785 | static void scc_send_xchar(struct tty_struct *tty, char ch) |
781 | { | 786 | { |
782 | struct scc_port *port = (struct scc_port *)tty->driver_data; | 787 | struct scc_port *port = tty->driver_data; |
783 | 788 | ||
784 | port->x_char = ch; | 789 | port->x_char = ch; |
785 | if (ch) | 790 | if (ch) |
@@ -896,7 +901,7 @@ static int scc_open (struct tty_struct * tty, struct file * filp) | |||
896 | return retval; | 901 | return retval; |
897 | } | 902 | } |
898 | 903 | ||
899 | port->c_dcd = scc_get_CD (port); | 904 | port->c_dcd = tty_port_carrier_raised(&port->gs.port); |
900 | 905 | ||
901 | scc_enable_rx_interrupts(port); | 906 | scc_enable_rx_interrupts(port); |
902 | 907 | ||
@@ -906,7 +911,7 @@ static int scc_open (struct tty_struct * tty, struct file * filp) | |||
906 | 911 | ||
907 | static void scc_throttle (struct tty_struct * tty) | 912 | static void scc_throttle (struct tty_struct * tty) |
908 | { | 913 | { |
909 | struct scc_port *port = (struct scc_port *)tty->driver_data; | 914 | struct scc_port *port = tty->driver_data; |
910 | unsigned long flags; | 915 | unsigned long flags; |
911 | SCC_ACCESS_INIT(port); | 916 | SCC_ACCESS_INIT(port); |
912 | 917 | ||
@@ -922,7 +927,7 @@ static void scc_throttle (struct tty_struct * tty) | |||
922 | 927 | ||
923 | static void scc_unthrottle (struct tty_struct * tty) | 928 | static void scc_unthrottle (struct tty_struct * tty) |
924 | { | 929 | { |
925 | struct scc_port *port = (struct scc_port *)tty->driver_data; | 930 | struct scc_port *port = tty->driver_data; |
926 | unsigned long flags; | 931 | unsigned long flags; |
927 | SCC_ACCESS_INIT(port); | 932 | SCC_ACCESS_INIT(port); |
928 | 933 | ||
@@ -945,7 +950,7 @@ static int scc_ioctl(struct tty_struct *tty, struct file *file, | |||
945 | 950 | ||
946 | static int scc_break_ctl(struct tty_struct *tty, int break_state) | 951 | static int scc_break_ctl(struct tty_struct *tty, int break_state) |
947 | { | 952 | { |
948 | struct scc_port *port = (struct scc_port *)tty->driver_data; | 953 | struct scc_port *port = tty->driver_data; |
949 | unsigned long flags; | 954 | unsigned long flags; |
950 | SCC_ACCESS_INIT(port); | 955 | SCC_ACCESS_INIT(port); |
951 | 956 | ||
diff --git a/drivers/char/vt.c b/drivers/char/vt.c index 008176edbd64..7900bd63b36d 100644 --- a/drivers/char/vt.c +++ b/drivers/char/vt.c | |||
@@ -819,8 +819,8 @@ static inline int resize_screen(struct vc_data *vc, int width, int height, | |||
819 | * ctrl_lock of the tty IFF a tty is passed. | 819 | * ctrl_lock of the tty IFF a tty is passed. |
820 | */ | 820 | */ |
821 | 821 | ||
822 | static int vc_do_resize(struct tty_struct *tty, struct tty_struct *real_tty, | 822 | static int vc_do_resize(struct tty_struct *tty, struct vc_data *vc, |
823 | struct vc_data *vc, unsigned int cols, unsigned int lines) | 823 | unsigned int cols, unsigned int lines) |
824 | { | 824 | { |
825 | unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0; | 825 | unsigned long old_origin, new_origin, new_scr_end, rlth, rrem, err = 0; |
826 | unsigned int old_cols, old_rows, old_row_size, old_screen_size; | 826 | unsigned int old_cols, old_rows, old_row_size, old_screen_size; |
@@ -932,7 +932,7 @@ static int vc_do_resize(struct tty_struct *tty, struct tty_struct *real_tty, | |||
932 | ws.ws_row = vc->vc_rows; | 932 | ws.ws_row = vc->vc_rows; |
933 | ws.ws_col = vc->vc_cols; | 933 | ws.ws_col = vc->vc_cols; |
934 | ws.ws_ypixel = vc->vc_scan_lines; | 934 | ws.ws_ypixel = vc->vc_scan_lines; |
935 | tty_do_resize(tty, real_tty, &ws); | 935 | tty_do_resize(tty, &ws); |
936 | } | 936 | } |
937 | 937 | ||
938 | if (CON_IS_VISIBLE(vc)) | 938 | if (CON_IS_VISIBLE(vc)) |
@@ -954,13 +954,12 @@ static int vc_do_resize(struct tty_struct *tty, struct tty_struct *real_tty, | |||
954 | 954 | ||
955 | int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows) | 955 | int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows) |
956 | { | 956 | { |
957 | return vc_do_resize(vc->vc_tty, vc->vc_tty, vc, cols, rows); | 957 | return vc_do_resize(vc->vc_tty, vc, cols, rows); |
958 | } | 958 | } |
959 | 959 | ||
960 | /** | 960 | /** |
961 | * vt_resize - resize a VT | 961 | * vt_resize - resize a VT |
962 | * @tty: tty to resize | 962 | * @tty: tty to resize |
963 | * @real_tty: tty if a pty/tty pair | ||
964 | * @ws: winsize attributes | 963 | * @ws: winsize attributes |
965 | * | 964 | * |
966 | * Resize a virtual terminal. This is called by the tty layer as we | 965 | * Resize a virtual terminal. This is called by the tty layer as we |
@@ -970,15 +969,13 @@ int vc_resize(struct vc_data *vc, unsigned int cols, unsigned int rows) | |||
970 | * Takes the console sem and the called methods then take the tty | 969 | * Takes the console sem and the called methods then take the tty |
971 | * termios_mutex and the tty ctrl_lock in that order. | 970 | * termios_mutex and the tty ctrl_lock in that order. |
972 | */ | 971 | */ |
973 | 972 | static int vt_resize(struct tty_struct *tty, struct winsize *ws) | |
974 | int vt_resize(struct tty_struct *tty, struct tty_struct *real_tty, | ||
975 | struct winsize *ws) | ||
976 | { | 973 | { |
977 | struct vc_data *vc = tty->driver_data; | 974 | struct vc_data *vc = tty->driver_data; |
978 | int ret; | 975 | int ret; |
979 | 976 | ||
980 | acquire_console_sem(); | 977 | acquire_console_sem(); |
981 | ret = vc_do_resize(tty, real_tty, vc, ws->ws_col, ws->ws_row); | 978 | ret = vc_do_resize(tty, vc, ws->ws_col, ws->ws_row); |
982 | release_console_sem(); | 979 | release_console_sem(); |
983 | return ret; | 980 | return ret; |
984 | } | 981 | } |
@@ -2679,7 +2676,7 @@ static int con_write_room(struct tty_struct *tty) | |||
2679 | { | 2676 | { |
2680 | if (tty->stopped) | 2677 | if (tty->stopped) |
2681 | return 0; | 2678 | return 0; |
2682 | return 4096; /* No limit, really; we're not buffering */ | 2679 | return 32768; /* No limit, really; we're not buffering */ |
2683 | } | 2680 | } |
2684 | 2681 | ||
2685 | static int con_chars_in_buffer(struct tty_struct *tty) | 2682 | static int con_chars_in_buffer(struct tty_struct *tty) |
diff --git a/drivers/char/vt_ioctl.c b/drivers/char/vt_ioctl.c index 8944ce508e2f..a2dee0eb6dad 100644 --- a/drivers/char/vt_ioctl.c +++ b/drivers/char/vt_ioctl.c | |||
@@ -366,7 +366,7 @@ do_unimap_ioctl(int cmd, struct unimapdesc __user *user_ud, int perm, struct vc_ | |||
366 | int vt_ioctl(struct tty_struct *tty, struct file * file, | 366 | int vt_ioctl(struct tty_struct *tty, struct file * file, |
367 | unsigned int cmd, unsigned long arg) | 367 | unsigned int cmd, unsigned long arg) |
368 | { | 368 | { |
369 | struct vc_data *vc = (struct vc_data *)tty->driver_data; | 369 | struct vc_data *vc = tty->driver_data; |
370 | struct console_font_op op; /* used in multiple places here */ | 370 | struct console_font_op op; /* used in multiple places here */ |
371 | struct kbd_struct * kbd; | 371 | struct kbd_struct * kbd; |
372 | unsigned int console; | 372 | unsigned int console; |