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

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty-2.6: (49 commits)
serial8250: ratelimit "too much work" error
serial: bfin_sport_uart: speed up sport RX sample rate to be 3% faster
serial: abstraction for 8250 legacy ports
serial/imx: check that the buffer is non-empty before sending it out
serial: mfd: add more baud rates support
jsm: Remove the uart port on errors
Alchemy: Add UART PM methods.
8250: allow platforms to override PM hook.
altera_uart: Don't use plain integer as NULL pointer
altera_uart: Fix missing prototype for registering an early console
altera_uart: Fixup type usage of port flags
altera_uart: Make it possible to use Altera UART and 8250 ports together
altera_uart: Add support for different address strides
altera_uart: Add support for getting mapbase and IRQ from resources
altera_uart: Add support for polling mode (IRQ-less)
serial: Factor out uart_poll_timeout() from 8250 driver
serial: mark the 8250 driver as maintained
serial: 8250: Don't delay after transmitter is ready.
tty: MAINTAINERS: add drivers/serial/jsm/ as maintained driver
vcs: invoke the vt update callback when /dev/vcs* is written to
...

+1756 -1532
+1
Documentation/devices.txt
··· 239 239 0 = /dev/tty Current TTY device 240 240 1 = /dev/console System console 241 241 2 = /dev/ptmx PTY master multiplex 242 + 3 = /dev/ttyprintk User messages via printk TTY device 242 243 64 = /dev/cua0 Callout device for ttyS0 243 244 ... 244 245 255 = /dev/cua191 Callout device for ttyS191
+32
Documentation/filesystems/proc.txt
··· 1075 1075 drivers list of drivers and their usage 1076 1076 ldiscs registered line disciplines 1077 1077 driver/serial usage statistic and status of single tty lines 1078 + consoles registered system console lines 1078 1079 .............................................................................. 1079 1080 1080 1081 To see which tty's are currently in use, you can simply look into the file ··· 1093 1092 /dev/console /dev/console 5 1 system:console 1094 1093 /dev/tty /dev/tty 5 0 system:/dev/tty 1095 1094 unknown /dev/tty 4 1-63 console 1095 + 1096 + To see which character device lines are currently used for the system console 1097 + /dev/console, you may simply look into the file /proc/tty/consoles: 1098 + 1099 + > cat /proc/tty/consoles 1100 + tty0 -WU (ECp) 4:7 1101 + ttyS0 -W- (Ep) 4:64 1102 + 1103 + The columns are: 1104 + 1105 + device name of the device 1106 + operations R = can do read operations 1107 + W = can do write operations 1108 + U = can do unblank 1109 + flags E = it is enabled 1110 + C = it is prefered console 1111 + B = it is primary boot console 1112 + p = it is used for printk buffer 1113 + b = it is not a TTY but a Braille device 1114 + a = it is safe to use when cpu is offline 1115 + * = it is standard input of the reading process 1116 + major:minor major and minor number of the device separated by a colon 1117 + 1118 + If the reading process holds /dev/console open at the regular standard input 1119 + stream the active device will be marked by an asterisk: 1120 + 1121 + > cat /proc/tty/consoles < /dev/console 1122 + tty0 -WU (ECp*) 4:7 1123 + ttyS0 -W- (Ep) 4:64 1124 + > tty 1125 + /dev/pts/3 1096 1126 1097 1127 1098 1128 1.8 Miscellaneous kernel statistics in /proc/stat
+9 -1
MAINTAINERS
··· 157 157 F: drivers/net/r8169.c 158 158 159 159 8250/16?50 (AND CLONE UARTS) SERIAL DRIVER 160 + M: Greg Kroah-Hartman <gregkh@suse.de> 160 161 L: linux-serial@vger.kernel.org 161 162 W: http://serial.sourceforge.net 162 - S: Orphan 163 + S: Maintained 164 + T: quilt kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/ 163 165 F: drivers/serial/8250* 164 166 F: include/linux/serial_8250.h 165 167 ··· 3354 3352 F: fs/jbd*/ 3355 3353 F: include/linux/ext*jbd*.h 3356 3354 F: include/linux/jbd*.h 3355 + 3356 + JSM Neo PCI based serial card 3357 + M: Breno Leitao <leitao@linux.vnet.ibm.com> 3358 + L: linux-serial@vger.kernel.org 3359 + S: Maintained 3360 + F: drivers/serial/jsm/ 3357 3361 3358 3362 K8TEMP HARDWARE MONITORING DRIVER 3359 3363 M: Rudolf Marek <r.marek@assembler.cz>
+1 -82
arch/arm/include/asm/ioctls.h
··· 1 1 #ifndef __ASM_ARM_IOCTLS_H 2 2 #define __ASM_ARM_IOCTLS_H 3 3 4 - #include <asm/ioctl.h> 5 - 6 - /* 0x54 is just a magic number to make these relatively unique ('T') */ 7 - 8 - #define TCGETS 0x5401 9 - #define TCSETS 0x5402 10 - #define TCSETSW 0x5403 11 - #define TCSETSF 0x5404 12 - #define TCGETA 0x5405 13 - #define TCSETA 0x5406 14 - #define TCSETAW 0x5407 15 - #define TCSETAF 0x5408 16 - #define TCSBRK 0x5409 17 - #define TCXONC 0x540A 18 - #define TCFLSH 0x540B 19 - #define TIOCEXCL 0x540C 20 - #define TIOCNXCL 0x540D 21 - #define TIOCSCTTY 0x540E 22 - #define TIOCGPGRP 0x540F 23 - #define TIOCSPGRP 0x5410 24 - #define TIOCOUTQ 0x5411 25 - #define TIOCSTI 0x5412 26 - #define TIOCGWINSZ 0x5413 27 - #define TIOCSWINSZ 0x5414 28 - #define TIOCMGET 0x5415 29 - #define TIOCMBIS 0x5416 30 - #define TIOCMBIC 0x5417 31 - #define TIOCMSET 0x5418 32 - #define TIOCGSOFTCAR 0x5419 33 - #define TIOCSSOFTCAR 0x541A 34 - #define FIONREAD 0x541B 35 - #define TIOCINQ FIONREAD 36 - #define TIOCLINUX 0x541C 37 - #define TIOCCONS 0x541D 38 - #define TIOCGSERIAL 0x541E 39 - #define TIOCSSERIAL 0x541F 40 - #define TIOCPKT 0x5420 41 - #define FIONBIO 0x5421 42 - #define TIOCNOTTY 0x5422 43 - #define TIOCSETD 0x5423 44 - #define TIOCGETD 0x5424 45 - #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ 46 - #define TIOCSBRK 0x5427 /* BSD compatibility */ 47 - #define TIOCCBRK 0x5428 /* BSD compatibility */ 48 - #define TIOCGSID 0x5429 /* Return the session ID of FD */ 49 - #define TCGETS2 _IOR('T',0x2A, struct termios2) 50 - #define TCSETS2 _IOW('T',0x2B, struct termios2) 51 - #define TCSETSW2 _IOW('T',0x2C, struct termios2) 52 - #define TCSETSF2 _IOW('T',0x2D, struct termios2) 53 - #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 54 - #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 55 - #define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 56 - 57 - #define TIOCGRS485 0x542E 58 - #define TIOCSRS485 0x542F 59 - 60 - #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ 61 - #define FIOCLEX 0x5451 62 - #define FIOASYNC 0x5452 63 - #define TIOCSERCONFIG 0x5453 64 - #define TIOCSERGWILD 0x5454 65 - #define TIOCSERSWILD 0x5455 66 - #define TIOCGLCKTRMIOS 0x5456 67 - #define TIOCSLCKTRMIOS 0x5457 68 - #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ 69 - #define TIOCSERGETLSR 0x5459 /* Get line status register */ 70 - #define TIOCSERGETMULTI 0x545A /* Get multiport config */ 71 - #define TIOCSERSETMULTI 0x545B /* Set multiport config */ 72 - 73 - #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ 74 - #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ 75 4 #define FIOQSIZE 0x545E 76 5 77 - /* Used for packet mode */ 78 - #define TIOCPKT_DATA 0 79 - #define TIOCPKT_FLUSHREAD 1 80 - #define TIOCPKT_FLUSHWRITE 2 81 - #define TIOCPKT_STOP 4 82 - #define TIOCPKT_START 8 83 - #define TIOCPKT_NOSTOP 16 84 - #define TIOCPKT_DOSTOP 32 85 - #define TIOCPKT_IOCTL 64 86 - 87 - #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 6 + #include <asm-generic/ioctls.h> 88 7 89 8 #endif
+1 -85
arch/avr32/include/asm/ioctls.h
··· 1 1 #ifndef __ASM_AVR32_IOCTLS_H 2 2 #define __ASM_AVR32_IOCTLS_H 3 3 4 - #include <asm/ioctl.h> 5 - 6 - /* 0x54 is just a magic number to make these relatively unique ('T') */ 7 - 8 - #define TCGETS 0x5401 9 - #define TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */ 10 - #define TCSETSW 0x5403 11 - #define TCSETSF 0x5404 12 - #define TCGETA 0x5405 13 - #define TCSETA 0x5406 14 - #define TCSETAW 0x5407 15 - #define TCSETAF 0x5408 16 - #define TCSBRK 0x5409 17 - #define TCXONC 0x540A 18 - #define TCFLSH 0x540B 19 - #define TIOCEXCL 0x540C 20 - #define TIOCNXCL 0x540D 21 - #define TIOCSCTTY 0x540E 22 - #define TIOCGPGRP 0x540F 23 - #define TIOCSPGRP 0x5410 24 - #define TIOCOUTQ 0x5411 25 - #define TIOCSTI 0x5412 26 - #define TIOCGWINSZ 0x5413 27 - #define TIOCSWINSZ 0x5414 28 - #define TIOCMGET 0x5415 29 - #define TIOCMBIS 0x5416 30 - #define TIOCMBIC 0x5417 31 - #define TIOCMSET 0x5418 32 - #define TIOCGSOFTCAR 0x5419 33 - #define TIOCSSOFTCAR 0x541A 34 - #define FIONREAD 0x541B 35 - #define TIOCINQ FIONREAD 36 - #define TIOCLINUX 0x541C 37 - #define TIOCCONS 0x541D 38 - #define TIOCGSERIAL 0x541E 39 - #define TIOCSSERIAL 0x541F 40 - #define TIOCPKT 0x5420 41 - #define FIONBIO 0x5421 42 - #define TIOCNOTTY 0x5422 43 - #define TIOCSETD 0x5423 44 - #define TIOCGETD 0x5424 45 - #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ 46 - /* #define TIOCTTYGSTRUCT 0x5426 - Former debugging-only ioctl */ 47 - #define TIOCSBRK 0x5427 /* BSD compatibility */ 48 - #define TIOCCBRK 0x5428 /* BSD compatibility */ 49 - #define TIOCGSID 0x5429 /* Return the session ID of FD */ 50 - #define TCGETS2 _IOR('T',0x2A, struct termios2) 51 - #define TCSETS2 _IOW('T',0x2B, struct termios2) 52 - #define TCSETSW2 _IOW('T',0x2C, struct termios2) 53 - #define TCSETSF2 _IOW('T',0x2D, struct termios2) 54 - #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 55 - #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 56 - #define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 57 - 58 - #define TIOCGRS485 0x542E 59 - #define TIOCSRS485 0x542F 60 - 61 - #define FIONCLEX 0x5450 62 - #define FIOCLEX 0x5451 63 - #define FIOASYNC 0x5452 64 - #define TIOCSERCONFIG 0x5453 65 - #define TIOCSERGWILD 0x5454 66 - #define TIOCSERSWILD 0x5455 67 - #define TIOCGLCKTRMIOS 0x5456 68 - #define TIOCSLCKTRMIOS 0x5457 69 - #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ 70 - #define TIOCSERGETLSR 0x5459 /* Get line status register */ 71 - #define TIOCSERGETMULTI 0x545A /* Get multiport config */ 72 - #define TIOCSERSETMULTI 0x545B /* Set multiport config */ 73 - 74 - #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ 75 - #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ 76 - #define FIOQSIZE 0x5460 77 - 78 - /* Used for packet mode */ 79 - #define TIOCPKT_DATA 0 80 - #define TIOCPKT_FLUSHREAD 1 81 - #define TIOCPKT_FLUSHWRITE 2 82 - #define TIOCPKT_STOP 4 83 - #define TIOCPKT_START 8 84 - #define TIOCPKT_NOSTOP 16 85 - #define TIOCPKT_DOSTOP 32 86 - #define TIOCPKT_IOCTL 64 87 - 88 - #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 4 + #include <asm-generic/ioctls.h> 89 5 90 6 #endif /* __ASM_AVR32_IOCTLS_H */
+1 -83
arch/cris/include/asm/ioctls.h
··· 1 1 #ifndef __ARCH_CRIS_IOCTLS_H__ 2 2 #define __ARCH_CRIS_IOCTLS_H__ 3 3 4 - /* verbatim copy of asm-i386/ioctls.h */ 5 - 6 - #include <asm/ioctl.h> 7 - 8 - /* 0x54 is just a magic number to make these relatively unique ('T') */ 9 - 10 - #define TCGETS 0x5401 11 - #define TCSETS 0x5402 12 - #define TCSETSW 0x5403 13 - #define TCSETSF 0x5404 14 - #define TCGETA 0x5405 15 - #define TCSETA 0x5406 16 - #define TCSETAW 0x5407 17 - #define TCSETAF 0x5408 18 - #define TCSBRK 0x5409 19 - #define TCXONC 0x540A 20 - #define TCFLSH 0x540B 21 - #define TIOCEXCL 0x540C 22 - #define TIOCNXCL 0x540D 23 - #define TIOCSCTTY 0x540E 24 - #define TIOCGPGRP 0x540F 25 - #define TIOCSPGRP 0x5410 26 - #define TIOCOUTQ 0x5411 27 - #define TIOCSTI 0x5412 28 - #define TIOCGWINSZ 0x5413 29 - #define TIOCSWINSZ 0x5414 30 - #define TIOCMGET 0x5415 31 - #define TIOCMBIS 0x5416 32 - #define TIOCMBIC 0x5417 33 - #define TIOCMSET 0x5418 34 - #define TIOCGSOFTCAR 0x5419 35 - #define TIOCSSOFTCAR 0x541A 36 - #define FIONREAD 0x541B 37 - #define TIOCINQ FIONREAD 38 - #define TIOCLINUX 0x541C 39 - #define TIOCCONS 0x541D 40 - #define TIOCGSERIAL 0x541E 41 - #define TIOCSSERIAL 0x541F 42 - #define TIOCPKT 0x5420 43 - #define FIONBIO 0x5421 44 - #define TIOCNOTTY 0x5422 45 - #define TIOCSETD 0x5423 46 - #define TIOCGETD 0x5424 47 - #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ 48 - #define TIOCSBRK 0x5427 /* BSD compatibility */ 49 - #define TIOCCBRK 0x5428 /* BSD compatibility */ 50 - #define TIOCGSID 0x5429 /* Return the session ID of FD */ 51 - #define TCGETS2 _IOR('T',0x2A, struct termios2) 52 - #define TCSETS2 _IOW('T',0x2B, struct termios2) 53 - #define TCSETSW2 _IOW('T',0x2C, struct termios2) 54 - #define TCSETSF2 _IOW('T',0x2D, struct termios2) 55 - #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 56 - #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 57 - #define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 58 - 59 - #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ 60 - #define FIOCLEX 0x5451 61 - #define FIOASYNC 0x5452 62 - #define TIOCSERCONFIG 0x5453 63 - #define TIOCSERGWILD 0x5454 64 - #define TIOCSERSWILD 0x5455 65 - #define TIOCGLCKTRMIOS 0x5456 66 - #define TIOCSLCKTRMIOS 0x5457 67 4 #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ 68 - #define TIOCSERGETLSR 0x5459 /* Get line status register */ 69 - #define TIOCSERGETMULTI 0x545A /* Get multiport config */ 70 - #define TIOCSERSETMULTI 0x545B /* Set multiport config */ 71 - 72 - #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ 73 - #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ 74 - #define FIOQSIZE 0x5460 75 - 76 5 #define TIOCSERSETRS485 0x5461 /* enable rs-485 (deprecated) */ 77 6 #define TIOCSERWRRS485 0x5462 /* write rs-485 */ 78 7 #define TIOCSRS485 0x5463 /* enable rs-485 */ 79 - #define TIOCGRS485 0x542E /* get rs-485 */ 80 8 81 - /* Used for packet mode */ 82 - #define TIOCPKT_DATA 0 83 - #define TIOCPKT_FLUSHREAD 1 84 - #define TIOCPKT_FLUSHWRITE 2 85 - #define TIOCPKT_STOP 4 86 - #define TIOCPKT_START 8 87 - #define TIOCPKT_NOSTOP 16 88 - #define TIOCPKT_DOSTOP 32 89 - #define TIOCPKT_IOCTL 64 90 - 91 - #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 9 + #include <asm-generic/ioctls.h> 92 10 93 11 #endif
+1 -79
arch/frv/include/asm/ioctls.h
··· 1 1 #ifndef __ASM_IOCTLS_H__ 2 2 #define __ASM_IOCTLS_H__ 3 3 4 - #include <asm/ioctl.h> 5 - 6 - /* 0x54 is just a magic number to make these relatively unique ('T') */ 7 - 8 - #define TCGETS 0x5401 9 - #define TCSETS 0x5402 10 - #define TCSETSW 0x5403 11 - #define TCSETSF 0x5404 12 - #define TCGETA 0x5405 13 - #define TCSETA 0x5406 14 - #define TCSETAW 0x5407 15 - #define TCSETAF 0x5408 16 - #define TCSBRK 0x5409 17 - #define TCXONC 0x540A 18 - #define TCFLSH 0x540B 19 - #define TIOCEXCL 0x540C 20 - #define TIOCNXCL 0x540D 21 - #define TIOCSCTTY 0x540E 22 - #define TIOCGPGRP 0x540F 23 - #define TIOCSPGRP 0x5410 24 - #define TIOCOUTQ 0x5411 25 - #define TIOCSTI 0x5412 26 - #define TIOCGWINSZ 0x5413 27 - #define TIOCSWINSZ 0x5414 28 - #define TIOCMGET 0x5415 29 - #define TIOCMBIS 0x5416 30 - #define TIOCMBIC 0x5417 31 - #define TIOCMSET 0x5418 32 - #define TIOCGSOFTCAR 0x5419 33 - #define TIOCSSOFTCAR 0x541A 34 - #define FIONREAD 0x541B 35 - #define TIOCINQ FIONREAD 36 - #define TIOCLINUX 0x541C 37 - #define TIOCCONS 0x541D 38 - #define TIOCGSERIAL 0x541E 39 - #define TIOCSSERIAL 0x541F 40 - #define TIOCPKT 0x5420 41 - #define FIONBIO 0x5421 42 - #define TIOCNOTTY 0x5422 43 - #define TIOCSETD 0x5423 44 - #define TIOCGETD 0x5424 45 - #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ 46 4 #define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ 47 - #define TIOCSBRK 0x5427 /* BSD compatibility */ 48 - #define TIOCCBRK 0x5428 /* BSD compatibility */ 49 - #define TIOCGSID 0x5429 /* Return the session ID of FD */ 50 - #define TCGETS2 _IOR('T',0x2A, struct termios2) 51 - #define TCSETS2 _IOW('T',0x2B, struct termios2) 52 - #define TCSETSW2 _IOW('T',0x2C, struct termios2) 53 - #define TCSETSF2 _IOW('T',0x2D, struct termios2) 54 - #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 55 - #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 56 - #define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 57 - 58 - #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ 59 - #define FIOCLEX 0x5451 60 - #define FIOASYNC 0x5452 61 - #define TIOCSERCONFIG 0x5453 62 - #define TIOCSERGWILD 0x5454 63 - #define TIOCSERSWILD 0x5455 64 - #define TIOCGLCKTRMIOS 0x5456 65 - #define TIOCSLCKTRMIOS 0x5457 66 - #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ 67 - #define TIOCSERGETLSR 0x5459 /* Get line status register */ 68 - #define TIOCSERGETMULTI 0x545A /* Get multiport config */ 69 - #define TIOCSERSETMULTI 0x545B /* Set multiport config */ 70 - 71 - #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ 72 - #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ 73 5 #define FIOQSIZE 0x545E 74 6 75 - /* Used for packet mode */ 76 - #define TIOCPKT_DATA 0 77 - #define TIOCPKT_FLUSHREAD 1 78 - #define TIOCPKT_FLUSHWRITE 2 79 - #define TIOCPKT_STOP 4 80 - #define TIOCPKT_START 8 81 - #define TIOCPKT_NOSTOP 16 82 - #define TIOCPKT_DOSTOP 32 83 - #define TIOCPKT_IOCTL 64 84 - 85 - #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 7 + #include <asm-generic/ioctls.h> 86 8 87 9 #endif /* __ASM_IOCTLS_H__ */ 88 10
+1 -80
arch/h8300/include/asm/ioctls.h
··· 1 1 #ifndef __ARCH_H8300_IOCTLS_H__ 2 2 #define __ARCH_H8300_IOCTLS_H__ 3 3 4 - #include <asm/ioctl.h> 5 - 6 - /* 0x54 is just a magic number to make these relatively unique ('T') */ 7 - 8 - #define TCGETS 0x5401 9 - #define TCSETS 0x5402 10 - #define TCSETSW 0x5403 11 - #define TCSETSF 0x5404 12 - #define TCGETA 0x5405 13 - #define TCSETA 0x5406 14 - #define TCSETAW 0x5407 15 - #define TCSETAF 0x5408 16 - #define TCSBRK 0x5409 17 - #define TCXONC 0x540A 18 - #define TCFLSH 0x540B 19 - #define TIOCEXCL 0x540C 20 - #define TIOCNXCL 0x540D 21 - #define TIOCSCTTY 0x540E 22 - #define TIOCGPGRP 0x540F 23 - #define TIOCSPGRP 0x5410 24 - #define TIOCOUTQ 0x5411 25 - #define TIOCSTI 0x5412 26 - #define TIOCGWINSZ 0x5413 27 - #define TIOCSWINSZ 0x5414 28 - #define TIOCMGET 0x5415 29 - #define TIOCMBIS 0x5416 30 - #define TIOCMBIC 0x5417 31 - #define TIOCMSET 0x5418 32 - #define TIOCGSOFTCAR 0x5419 33 - #define TIOCSSOFTCAR 0x541A 34 - #define FIONREAD 0x541B 35 - #define TIOCINQ FIONREAD 36 - #define TIOCLINUX 0x541C 37 - #define TIOCCONS 0x541D 38 - #define TIOCGSERIAL 0x541E 39 - #define TIOCSSERIAL 0x541F 40 - #define TIOCPKT 0x5420 41 - #define FIONBIO 0x5421 42 - #define TIOCNOTTY 0x5422 43 - #define TIOCSETD 0x5423 44 - #define TIOCGETD 0x5424 45 - #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ 46 - #define TIOCTTYGSTRUCT 0x5426 /* For debugging only */ 47 - #define TIOCSBRK 0x5427 /* BSD compatibility */ 48 - #define TIOCCBRK 0x5428 /* BSD compatibility */ 49 - #define TIOCGSID 0x5429 /* Return the session ID of FD */ 50 - #define TCGETS2 _IOR('T',0x2A, struct termios2) 51 - #define TCSETS2 _IOW('T',0x2B, struct termios2) 52 - #define TCSETSW2 _IOW('T',0x2C, struct termios2) 53 - #define TCSETSF2 _IOW('T',0x2D, struct termios2) 54 - #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 55 - #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 56 - #define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 57 - 58 - #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ 59 - #define FIOCLEX 0x5451 60 - #define FIOASYNC 0x5452 61 - #define TIOCSERCONFIG 0x5453 62 - #define TIOCSERGWILD 0x5454 63 - #define TIOCSERSWILD 0x5455 64 - #define TIOCGLCKTRMIOS 0x5456 65 - #define TIOCSLCKTRMIOS 0x5457 66 - #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ 67 - #define TIOCSERGETLSR 0x5459 /* Get line status register */ 68 - #define TIOCSERGETMULTI 0x545A /* Get multiport config */ 69 - #define TIOCSERSETMULTI 0x545B /* Set multiport config */ 70 - 71 - #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ 72 - #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ 73 4 #define FIOQSIZE 0x545E 74 5 75 - /* Used for packet mode */ 76 - #define TIOCPKT_DATA 0 77 - #define TIOCPKT_FLUSHREAD 1 78 - #define TIOCPKT_FLUSHWRITE 2 79 - #define TIOCPKT_STOP 4 80 - #define TIOCPKT_START 8 81 - #define TIOCPKT_NOSTOP 16 82 - #define TIOCPKT_DOSTOP 32 83 - #define TIOCPKT_IOCTL 64 84 - 85 - #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 6 + #include <asm-generic/ioctls.h> 86 7 87 8 #endif /* __ARCH_H8300_IOCTLS_H__ */
+1 -11
arch/ia64/hp/sim/simserial.c
··· 395 395 { 396 396 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 397 397 (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) && 398 - (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { 398 + (cmd != TIOCMIWAIT)) { 399 399 if (tty->flags & (1 << TTY_IO_ERROR)) 400 400 return -EIO; 401 401 } ··· 433 433 case TIOCMIWAIT: 434 434 printk(KERN_INFO "rs_ioctl: TIOCMIWAIT: called\n"); 435 435 return 0; 436 - /* 437 - * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 438 - * Return: write counters to the user passed counter struct 439 - * NB: both 1->0 and 0->1 transitions are counted except for 440 - * RI where only 0->1 is counted. 441 - */ 442 - case TIOCGICOUNT: 443 - printk(KERN_INFO "rs_ioctl: TIOCGICOUNT called\n"); 444 - return 0; 445 - 446 436 case TIOCSERGWILD: 447 437 case TIOCSERSWILD: 448 438 /* "setserial -W" is called in Debian boot */
+1 -88
arch/ia64/include/asm/ioctls.h
··· 1 1 #ifndef _ASM_IA64_IOCTLS_H 2 2 #define _ASM_IA64_IOCTLS_H 3 3 4 - /* 5 - * Based on <asm-i386/ioctls.h> 6 - * 7 - * Modified 1998, 1999, 2002 8 - * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co 9 - */ 10 - 11 - #include <asm/ioctl.h> 12 - 13 - /* 0x54 is just a magic number to make these relatively unique ('T') */ 14 - 15 - #define TCGETS 0x5401 16 - #define TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */ 17 - #define TCSETSW 0x5403 18 - #define TCSETSF 0x5404 19 - #define TCGETA 0x5405 20 - #define TCSETA 0x5406 21 - #define TCSETAW 0x5407 22 - #define TCSETAF 0x5408 23 - #define TCSBRK 0x5409 24 - #define TCXONC 0x540A 25 - #define TCFLSH 0x540B 26 - #define TIOCEXCL 0x540C 27 - #define TIOCNXCL 0x540D 28 - #define TIOCSCTTY 0x540E 29 - #define TIOCGPGRP 0x540F 30 - #define TIOCSPGRP 0x5410 31 - #define TIOCOUTQ 0x5411 32 - #define TIOCSTI 0x5412 33 - #define TIOCGWINSZ 0x5413 34 - #define TIOCSWINSZ 0x5414 35 - #define TIOCMGET 0x5415 36 - #define TIOCMBIS 0x5416 37 - #define TIOCMBIC 0x5417 38 - #define TIOCMSET 0x5418 39 - #define TIOCGSOFTCAR 0x5419 40 - #define TIOCSSOFTCAR 0x541A 41 - #define FIONREAD 0x541B 42 - #define TIOCINQ FIONREAD 43 - #define TIOCLINUX 0x541C 44 - #define TIOCCONS 0x541D 45 - #define TIOCGSERIAL 0x541E 46 - #define TIOCSSERIAL 0x541F 47 - #define TIOCPKT 0x5420 48 - #define FIONBIO 0x5421 49 - #define TIOCNOTTY 0x5422 50 - #define TIOCSETD 0x5423 51 - #define TIOCGETD 0x5424 52 - #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ 53 - #define TIOCSBRK 0x5427 /* BSD compatibility */ 54 - #define TIOCCBRK 0x5428 /* BSD compatibility */ 55 - #define TIOCGSID 0x5429 /* Return the session ID of FD */ 56 - #define TCGETS2 _IOR('T',0x2A, struct termios2) 57 - #define TCSETS2 _IOW('T',0x2B, struct termios2) 58 - #define TCSETSW2 _IOW('T',0x2C, struct termios2) 59 - #define TCSETSF2 _IOW('T',0x2D, struct termios2) 60 - #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 61 - #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 62 - #define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 63 - 64 - #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ 65 - #define FIOCLEX 0x5451 66 - #define FIOASYNC 0x5452 67 - #define TIOCSERCONFIG 0x5453 68 - #define TIOCSERGWILD 0x5454 69 - #define TIOCSERSWILD 0x5455 70 - #define TIOCGLCKTRMIOS 0x5456 71 - #define TIOCSLCKTRMIOS 0x5457 72 - #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ 73 - #define TIOCSERGETLSR 0x5459 /* Get line status register */ 74 - #define TIOCSERGETMULTI 0x545A /* Get multiport config */ 75 - #define TIOCSERSETMULTI 0x545B /* Set multiport config */ 76 - 77 - #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ 78 - #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ 79 - #define FIOQSIZE 0x5460 80 - 81 - /* Used for packet mode */ 82 - #define TIOCPKT_DATA 0 83 - #define TIOCPKT_FLUSHREAD 1 84 - #define TIOCPKT_FLUSHWRITE 2 85 - #define TIOCPKT_STOP 4 86 - #define TIOCPKT_START 8 87 - #define TIOCPKT_NOSTOP 16 88 - #define TIOCPKT_DOSTOP 32 89 - #define TIOCPKT_IOCTL 64 90 - 91 - #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 4 + #include <asm-generic/ioctls.h> 92 5 93 6 #endif /* _ASM_IA64_IOCTLS_H */
+1 -82
arch/m32r/include/asm/ioctls.h
··· 1 1 #ifndef __ARCH_M32R_IOCTLS_H__ 2 2 #define __ARCH_M32R_IOCTLS_H__ 3 3 4 - #include <asm/ioctl.h> 5 - 6 - /* 0x54 is just a magic number to make these relatively unique ('T') */ 7 - 8 - #define TCGETS 0x5401 9 - #define TCSETS 0x5402 /* Clashes with SNDCTL_TMR_START sound ioctl */ 10 - #define TCSETSW 0x5403 11 - #define TCSETSF 0x5404 12 - #define TCGETA 0x5405 13 - #define TCSETA 0x5406 14 - #define TCSETAW 0x5407 15 - #define TCSETAF 0x5408 16 - #define TCSBRK 0x5409 17 - #define TCXONC 0x540A 18 - #define TCFLSH 0x540B 19 - #define TIOCEXCL 0x540C 20 - #define TIOCNXCL 0x540D 21 - #define TIOCSCTTY 0x540E 22 - #define TIOCGPGRP 0x540F 23 - #define TIOCSPGRP 0x5410 24 - #define TIOCOUTQ 0x5411 25 - #define TIOCSTI 0x5412 26 - #define TIOCGWINSZ 0x5413 27 - #define TIOCSWINSZ 0x5414 28 - #define TIOCMGET 0x5415 29 - #define TIOCMBIS 0x5416 30 - #define TIOCMBIC 0x5417 31 - #define TIOCMSET 0x5418 32 - #define TIOCGSOFTCAR 0x5419 33 - #define TIOCSSOFTCAR 0x541A 34 - #define FIONREAD 0x541B 35 - #define TIOCINQ FIONREAD 36 - #define TIOCLINUX 0x541C 37 - #define TIOCCONS 0x541D 38 - #define TIOCGSERIAL 0x541E 39 - #define TIOCSSERIAL 0x541F 40 - #define TIOCPKT 0x5420 41 - #define FIONBIO 0x5421 42 - #define TIOCNOTTY 0x5422 43 - #define TIOCSETD 0x5423 44 - #define TIOCGETD 0x5424 45 - #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ 46 - /* #define TIOCTTYGSTRUCT 0x5426 - Former debugging-only ioctl */ 47 - #define TIOCSBRK 0x5427 /* BSD compatibility */ 48 - #define TIOCCBRK 0x5428 /* BSD compatibility */ 49 - #define TIOCGSID 0x5429 /* Return the session ID of FD */ 50 - #define TCGETS2 _IOR('T',0x2A, struct termios2) 51 - #define TCSETS2 _IOW('T',0x2B, struct termios2) 52 - #define TCSETSW2 _IOW('T',0x2C, struct termios2) 53 - #define TCSETSF2 _IOW('T',0x2D, struct termios2) 54 - #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 55 - #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 56 - #define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 57 - 58 - #define FIONCLEX 0x5450 59 - #define FIOCLEX 0x5451 60 - #define FIOASYNC 0x5452 61 - #define TIOCSERCONFIG 0x5453 62 - #define TIOCSERGWILD 0x5454 63 - #define TIOCSERSWILD 0x5455 64 - #define TIOCGLCKTRMIOS 0x5456 65 - #define TIOCSLCKTRMIOS 0x5457 66 - #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ 67 - #define TIOCSERGETLSR 0x5459 /* Get line status register */ 68 - #define TIOCSERGETMULTI 0x545A /* Get multiport config */ 69 - #define TIOCSERSETMULTI 0x545B /* Set multiport config */ 70 - 71 - #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ 72 - #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ 73 - #define FIOQSIZE 0x5460 74 - 75 - /* Used for packet mode */ 76 - #define TIOCPKT_DATA 0 77 - #define TIOCPKT_FLUSHREAD 1 78 - #define TIOCPKT_FLUSHWRITE 2 79 - #define TIOCPKT_STOP 4 80 - #define TIOCPKT_START 8 81 - #define TIOCPKT_NOSTOP 16 82 - #define TIOCPKT_DOSTOP 32 83 - #define TIOCPKT_IOCTL 64 84 - 85 - #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 4 + #include <asm-generic/ioctls.h> 86 5 87 6 #endif /* __ARCH_M32R_IOCTLS_H__ */
+28
arch/mips/alchemy/common/platform.c
··· 24 24 25 25 #include <prom.h> 26 26 27 + static void alchemy_8250_pm(struct uart_port *port, unsigned int state, 28 + unsigned int old_state) 29 + { 30 + switch (state) { 31 + case 0: 32 + if ((__raw_readl(port->membase + UART_MOD_CNTRL) & 3) != 3) { 33 + /* power-on sequence as suggested in the databooks */ 34 + __raw_writel(0, port->membase + UART_MOD_CNTRL); 35 + wmb(); 36 + __raw_writel(1, port->membase + UART_MOD_CNTRL); 37 + wmb(); 38 + } 39 + __raw_writel(3, port->membase + UART_MOD_CNTRL); /* full on */ 40 + wmb(); 41 + serial8250_do_pm(port, state, old_state); 42 + break; 43 + case 3: /* power off */ 44 + serial8250_do_pm(port, state, old_state); 45 + __raw_writel(0, port->membase + UART_MOD_CNTRL); 46 + wmb(); 47 + break; 48 + default: 49 + serial8250_do_pm(port, state, old_state); 50 + break; 51 + } 52 + } 53 + 27 54 #define PORT(_base, _irq) \ 28 55 { \ 29 56 .mapbase = _base, \ ··· 60 33 .flags = UPF_SKIP_TEST | UPF_IOREMAP | \ 61 34 UPF_FIXED_TYPE, \ 62 35 .type = PORT_16550A, \ 36 + .pm = alchemy_8250_pm, \ 63 37 } 64 38 65 39 static struct plat_serial8250_port au1x00_uart_data[] = {
-35
arch/mips/alchemy/common/power.c
··· 49 49 * We only have to save/restore registers that aren't otherwise 50 50 * done as part of a driver pm_* function. 51 51 */ 52 - static unsigned int sleep_uart0_inten; 53 - static unsigned int sleep_uart0_fifoctl; 54 - static unsigned int sleep_uart0_linectl; 55 - static unsigned int sleep_uart0_clkdiv; 56 - static unsigned int sleep_uart0_enable; 57 52 static unsigned int sleep_usb[2]; 58 53 static unsigned int sleep_sys_clocks[5]; 59 54 static unsigned int sleep_sys_pinfunc; ··· 57 62 58 63 static void save_core_regs(void) 59 64 { 60 - extern void save_au1xxx_intctl(void); 61 - extern void pm_eth0_shutdown(void); 62 - 63 - /* 64 - * Do the serial ports.....these really should be a pm_* 65 - * registered function by the driver......but of course the 66 - * standard serial driver doesn't understand our Au1xxx 67 - * unique registers. 68 - */ 69 - sleep_uart0_inten = au_readl(UART0_ADDR + UART_IER); 70 - sleep_uart0_fifoctl = au_readl(UART0_ADDR + UART_FCR); 71 - sleep_uart0_linectl = au_readl(UART0_ADDR + UART_LCR); 72 - sleep_uart0_clkdiv = au_readl(UART0_ADDR + UART_CLK); 73 - sleep_uart0_enable = au_readl(UART0_ADDR + UART_MOD_CNTRL); 74 - au_sync(); 75 - 76 65 #ifndef CONFIG_SOC_AU1200 77 66 /* Shutdown USB host/device. */ 78 67 sleep_usb[0] = au_readl(USB_HOST_CONFIG); ··· 154 175 au_writel(sleep_static_memctlr[3][0], MEM_STCFG3); 155 176 au_writel(sleep_static_memctlr[3][1], MEM_STTIME3); 156 177 au_writel(sleep_static_memctlr[3][2], MEM_STADDR3); 157 - 158 - /* 159 - * Enable the UART if it was enabled before sleep. 160 - * I guess I should define module control bits........ 161 - */ 162 - if (sleep_uart0_enable & 0x02) { 163 - au_writel(0, UART0_ADDR + UART_MOD_CNTRL); au_sync(); 164 - au_writel(1, UART0_ADDR + UART_MOD_CNTRL); au_sync(); 165 - au_writel(3, UART0_ADDR + UART_MOD_CNTRL); au_sync(); 166 - au_writel(sleep_uart0_inten, UART0_ADDR + UART_IER); au_sync(); 167 - au_writel(sleep_uart0_fifoctl, UART0_ADDR + UART_FCR); au_sync(); 168 - au_writel(sleep_uart0_linectl, UART0_ADDR + UART_LCR); au_sync(); 169 - au_writel(sleep_uart0_clkdiv, UART0_ADDR + UART_CLK); au_sync(); 170 - } 171 178 } 172 179 173 180 void au_sleep(void)
+1 -83
arch/mn10300/include/asm/ioctls.h
··· 1 1 #ifndef _ASM_IOCTLS_H 2 2 #define _ASM_IOCTLS_H 3 3 4 - #include <asm/ioctl.h> 5 - 6 - /* 0x54 is just a magic number to make these relatively unique ('T') */ 7 - 8 - #define TCGETS 0x5401 9 - #define TCSETS 0x5402 10 - #define TCSETSW 0x5403 11 - #define TCSETSF 0x5404 12 - #define TCGETA 0x5405 13 - #define TCSETA 0x5406 14 - #define TCSETAW 0x5407 15 - #define TCSETAF 0x5408 16 - #define TCSBRK 0x5409 17 - #define TCXONC 0x540A 18 - #define TCFLSH 0x540B 19 - #define TIOCEXCL 0x540C 20 - #define TIOCNXCL 0x540D 21 - #define TIOCSCTTY 0x540E 22 - #define TIOCGPGRP 0x540F 23 - #define TIOCSPGRP 0x5410 24 - #define TIOCOUTQ 0x5411 25 - #define TIOCSTI 0x5412 26 - #define TIOCGWINSZ 0x5413 27 - #define TIOCSWINSZ 0x5414 28 - #define TIOCMGET 0x5415 29 - #define TIOCMBIS 0x5416 30 - #define TIOCMBIC 0x5417 31 - #define TIOCMSET 0x5418 32 - #define TIOCGSOFTCAR 0x5419 33 - #define TIOCSSOFTCAR 0x541A 34 - #define FIONREAD 0x541B 35 - #define TIOCINQ FIONREAD 36 - #define TIOCLINUX 0x541C 37 - #define TIOCCONS 0x541D 38 - #define TIOCGSERIAL 0x541E 39 - #define TIOCSSERIAL 0x541F 40 - #define TIOCPKT 0x5420 41 - #define FIONBIO 0x5421 42 - #define TIOCNOTTY 0x5422 43 - #define TIOCSETD 0x5423 44 - #define TIOCGETD 0x5424 45 - #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ 46 - /* #define TIOCTTYGSTRUCT 0x5426 - Former debugging-only ioctl */ 47 - #define TIOCSBRK 0x5427 /* BSD compatibility */ 48 - #define TIOCCBRK 0x5428 /* BSD compatibility */ 49 - #define TIOCGSID 0x5429 /* Return the session ID of FD */ 50 - #define TCGETS2 _IOR('T', 0x2A, struct termios2) 51 - #define TCSETS2 _IOW('T', 0x2B, struct termios2) 52 - #define TCSETSW2 _IOW('T', 0x2C, struct termios2) 53 - #define TCSETSF2 _IOW('T', 0x2D, struct termios2) 54 - #define TIOCGPTN _IOR('T', 0x30, unsigned int) /* Get Pty Number 55 - * (of pty-mux device) */ 56 - #define TIOCSPTLCK _IOW('T', 0x31, int) /* Lock/unlock Pty */ 57 - #define TIOCSIG _IOW('T', 0x36, int) /* Generate signal on Pty slave */ 58 - 59 - #define FIONCLEX 0x5450 60 - #define FIOCLEX 0x5451 61 - #define FIOASYNC 0x5452 62 - #define TIOCSERCONFIG 0x5453 63 - #define TIOCSERGWILD 0x5454 64 - #define TIOCSERSWILD 0x5455 65 - #define TIOCGLCKTRMIOS 0x5456 66 - #define TIOCSLCKTRMIOS 0x5457 67 - #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ 68 - #define TIOCSERGETLSR 0x5459 /* Get line status register */ 69 - #define TIOCSERGETMULTI 0x545A /* Get multiport config */ 70 - #define TIOCSERSETMULTI 0x545B /* Set multiport config */ 71 - 72 - #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ 73 - #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ 74 - #define FIOQSIZE 0x5460 75 - 76 - /* Used for packet mode */ 77 - #define TIOCPKT_DATA 0 78 - #define TIOCPKT_FLUSHREAD 1 79 - #define TIOCPKT_FLUSHWRITE 2 80 - #define TIOCPKT_STOP 4 81 - #define TIOCPKT_START 8 82 - #define TIOCPKT_NOSTOP 16 83 - #define TIOCPKT_DOSTOP 32 84 - #define TIOCPKT_IOCTL 64 85 - 86 - #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 4 + #include <asm-generic/ioctls.h> 87 5 88 6 #endif /* _ASM_IOCTLS_H */
+1 -87
arch/s390/include/asm/ioctls.h
··· 1 - /* 2 - * include/asm-s390/ioctls.h 3 - * 4 - * S390 version 5 - * 6 - * Derived from "include/asm-i386/ioctls.h" 7 - */ 8 - 9 1 #ifndef __ARCH_S390_IOCTLS_H__ 10 2 #define __ARCH_S390_IOCTLS_H__ 11 3 12 - #include <asm/ioctl.h> 13 - 14 - /* 0x54 is just a magic number to make these relatively unique ('T') */ 15 - 16 - #define TCGETS 0x5401 17 - #define TCSETS 0x5402 18 - #define TCSETSW 0x5403 19 - #define TCSETSF 0x5404 20 - #define TCGETA 0x5405 21 - #define TCSETA 0x5406 22 - #define TCSETAW 0x5407 23 - #define TCSETAF 0x5408 24 - #define TCSBRK 0x5409 25 - #define TCXONC 0x540A 26 - #define TCFLSH 0x540B 27 - #define TIOCEXCL 0x540C 28 - #define TIOCNXCL 0x540D 29 - #define TIOCSCTTY 0x540E 30 - #define TIOCGPGRP 0x540F 31 - #define TIOCSPGRP 0x5410 32 - #define TIOCOUTQ 0x5411 33 - #define TIOCSTI 0x5412 34 - #define TIOCGWINSZ 0x5413 35 - #define TIOCSWINSZ 0x5414 36 - #define TIOCMGET 0x5415 37 - #define TIOCMBIS 0x5416 38 - #define TIOCMBIC 0x5417 39 - #define TIOCMSET 0x5418 40 - #define TIOCGSOFTCAR 0x5419 41 - #define TIOCSSOFTCAR 0x541A 42 - #define FIONREAD 0x541B 43 - #define TIOCINQ FIONREAD 44 - #define TIOCLINUX 0x541C 45 - #define TIOCCONS 0x541D 46 - #define TIOCGSERIAL 0x541E 47 - #define TIOCSSERIAL 0x541F 48 - #define TIOCPKT 0x5420 49 - #define FIONBIO 0x5421 50 - #define TIOCNOTTY 0x5422 51 - #define TIOCSETD 0x5423 52 - #define TIOCGETD 0x5424 53 - #define TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */ 54 - #define TIOCSBRK 0x5427 /* BSD compatibility */ 55 - #define TIOCCBRK 0x5428 /* BSD compatibility */ 56 - #define TIOCGSID 0x5429 /* Return the session ID of FD */ 57 - #define TCGETS2 _IOR('T',0x2A, struct termios2) 58 - #define TCSETS2 _IOW('T',0x2B, struct termios2) 59 - #define TCSETSW2 _IOW('T',0x2C, struct termios2) 60 - #define TCSETSF2 _IOW('T',0x2D, struct termios2) 61 - #define TIOCGPTN _IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 62 - #define TIOCSPTLCK _IOW('T',0x31, int) /* Lock/unlock Pty */ 63 - #define TIOCSIG _IOW('T',0x36, int) /* Generate signal on Pty slave */ 64 - 65 - #define FIONCLEX 0x5450 /* these numbers need to be adjusted. */ 66 - #define FIOCLEX 0x5451 67 - #define FIOASYNC 0x5452 68 - #define TIOCSERCONFIG 0x5453 69 - #define TIOCSERGWILD 0x5454 70 - #define TIOCSERSWILD 0x5455 71 - #define TIOCGLCKTRMIOS 0x5456 72 - #define TIOCSLCKTRMIOS 0x5457 73 - #define TIOCSERGSTRUCT 0x5458 /* For debugging only */ 74 - #define TIOCSERGETLSR 0x5459 /* Get line status register */ 75 - #define TIOCSERGETMULTI 0x545A /* Get multiport config */ 76 - #define TIOCSERSETMULTI 0x545B /* Set multiport config */ 77 - 78 - #define TIOCMIWAIT 0x545C /* wait for a change on serial input line(s) */ 79 - #define TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */ 80 4 #define FIOQSIZE 0x545E 81 5 82 - /* Used for packet mode */ 83 - #define TIOCPKT_DATA 0 84 - #define TIOCPKT_FLUSHREAD 1 85 - #define TIOCPKT_FLUSHWRITE 2 86 - #define TIOCPKT_STOP 4 87 - #define TIOCPKT_START 8 88 - #define TIOCPKT_NOSTOP 16 89 - #define TIOCPKT_DOSTOP 32 90 - #define TIOCPKT_IOCTL 64 91 - 92 - #define TIOCSER_TEMT 0x01 /* Transmitter physically empty */ 6 + #include <asm-generic/ioctls.h> 93 7 94 8 #endif
+15
drivers/char/Kconfig
··· 493 493 When not in use, each legacy PTY occupies 12 bytes on 32-bit 494 494 architectures and 24 bytes on 64-bit architectures. 495 495 496 + config TTY_PRINTK 497 + bool "TTY driver to output user messages via printk" 498 + depends on EMBEDDED 499 + default n 500 + ---help--- 501 + If you say Y here, the support for writing user messages (i.e. 502 + console messages) via printk is available. 503 + 504 + The feature is useful to inline user messages with kernel 505 + messages. 506 + In order to use this feature, you should output user messages 507 + to /dev/ttyprintk or redirect console to this TTY. 508 + 509 + If unsure, say N. 510 + 496 511 config BRIQ_PANEL 497 512 tristate 'Total Impact briQ front panel driver' 498 513 depends on PPC_CHRP
+1
drivers/char/Makefile
··· 12 12 obj-y += tty_mutex.o 13 13 obj-$(CONFIG_LEGACY_PTYS) += pty.o 14 14 obj-$(CONFIG_UNIX98_PTYS) += pty.o 15 + obj-$(CONFIG_TTY_PRINTK) += ttyprintk.o 15 16 obj-y += misc.o 16 17 obj-$(CONFIG_VT) += vt_ioctl.o vc_screen.o selection.o keyboard.o 17 18 obj-$(CONFIG_BFIN_JTAG_COMM) += bfin_jtag_comm.o
+31 -25
drivers/char/amiserial.c
··· 1263 1263 return 0; 1264 1264 } 1265 1265 1266 + /* 1267 + * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 1268 + * Return: write counters to the user passed counter struct 1269 + * NB: both 1->0 and 0->1 transitions are counted except for 1270 + * RI where only 0->1 is counted. 1271 + */ 1272 + static int rs_get_icount(struct tty_struct *tty, 1273 + struct serial_icounter_struct *icount) 1274 + { 1275 + struct async_struct *info = tty->driver_data; 1276 + struct async_icount cnow; 1277 + unsigned long flags; 1278 + 1279 + local_irq_save(flags); 1280 + cnow = info->state->icount; 1281 + local_irq_restore(flags); 1282 + icount->cts = cnow.cts; 1283 + icount->dsr = cnow.dsr; 1284 + icount->rng = cnow.rng; 1285 + icount->dcd = cnow.dcd; 1286 + icount->rx = cnow.rx; 1287 + icount->tx = cnow.tx; 1288 + icount->frame = cnow.frame; 1289 + icount->overrun = cnow.overrun; 1290 + icount->parity = cnow.parity; 1291 + icount->brk = cnow.brk; 1292 + icount->buf_overrun = cnow.buf_overrun; 1293 + 1294 + return 0; 1295 + } 1266 1296 1267 1297 static int rs_ioctl(struct tty_struct *tty, struct file * file, 1268 1298 unsigned int cmd, unsigned long arg) ··· 1362 1332 } 1363 1333 /* NOTREACHED */ 1364 1334 1365 - /* 1366 - * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 1367 - * Return: write counters to the user passed counter struct 1368 - * NB: both 1->0 and 0->1 transitions are counted except for 1369 - * RI where only 0->1 is counted. 1370 - */ 1371 - case TIOCGICOUNT: 1372 - local_irq_save(flags); 1373 - cnow = info->state->icount; 1374 - local_irq_restore(flags); 1375 - icount.cts = cnow.cts; 1376 - icount.dsr = cnow.dsr; 1377 - icount.rng = cnow.rng; 1378 - icount.dcd = cnow.dcd; 1379 - icount.rx = cnow.rx; 1380 - icount.tx = cnow.tx; 1381 - icount.frame = cnow.frame; 1382 - icount.overrun = cnow.overrun; 1383 - icount.parity = cnow.parity; 1384 - icount.brk = cnow.brk; 1385 - icount.buf_overrun = cnow.buf_overrun; 1386 - 1387 - if (copy_to_user(argp, &icount, sizeof(icount))) 1388 - return -EFAULT; 1389 - return 0; 1390 1335 case TIOCSERGWILD: 1391 1336 case TIOCSERSWILD: 1392 1337 /* "setserial -W" is called in Debian boot */ ··· 1963 1958 .wait_until_sent = rs_wait_until_sent, 1964 1959 .tiocmget = rs_tiocmget, 1965 1960 .tiocmset = rs_tiocmset, 1961 + .get_icount = rs_get_icount, 1966 1962 .proc_fops = &rs_proc_fops, 1967 1963 }; 1968 1964
+26 -23
drivers/char/cyclades.c
··· 2790 2790 * NB: both 1->0 and 0->1 transitions are counted except for 2791 2791 * RI where only 0->1 is counted. 2792 2792 */ 2793 - case TIOCGICOUNT: { 2794 - struct serial_icounter_struct sic = { }; 2795 - 2796 - spin_lock_irqsave(&info->card->card_lock, flags); 2797 - cnow = info->icount; 2798 - spin_unlock_irqrestore(&info->card->card_lock, flags); 2799 - 2800 - sic.cts = cnow.cts; 2801 - sic.dsr = cnow.dsr; 2802 - sic.rng = cnow.rng; 2803 - sic.dcd = cnow.dcd; 2804 - sic.rx = cnow.rx; 2805 - sic.tx = cnow.tx; 2806 - sic.frame = cnow.frame; 2807 - sic.overrun = cnow.overrun; 2808 - sic.parity = cnow.parity; 2809 - sic.brk = cnow.brk; 2810 - sic.buf_overrun = cnow.buf_overrun; 2811 - 2812 - if (copy_to_user(argp, &sic, sizeof(sic))) 2813 - ret_val = -EFAULT; 2814 - break; 2815 - } 2816 2793 default: 2817 2794 ret_val = -ENOIOCTLCMD; 2818 2795 } ··· 2799 2822 #endif 2800 2823 return ret_val; 2801 2824 } /* cy_ioctl */ 2825 + 2826 + static int cy_get_icount(struct tty_struct *tty, 2827 + struct serial_icounter_struct *sic) 2828 + { 2829 + struct cyclades_port *info = tty->driver_data; 2830 + struct cyclades_icount cnow; /* Used to snapshot */ 2831 + unsigned long flags; 2832 + 2833 + spin_lock_irqsave(&info->card->card_lock, flags); 2834 + cnow = info->icount; 2835 + spin_unlock_irqrestore(&info->card->card_lock, flags); 2836 + 2837 + sic->cts = cnow.cts; 2838 + sic->dsr = cnow.dsr; 2839 + sic->rng = cnow.rng; 2840 + sic->dcd = cnow.dcd; 2841 + sic->rx = cnow.rx; 2842 + sic->tx = cnow.tx; 2843 + sic->frame = cnow.frame; 2844 + sic->overrun = cnow.overrun; 2845 + sic->parity = cnow.parity; 2846 + sic->brk = cnow.brk; 2847 + sic->buf_overrun = cnow.buf_overrun; 2848 + return 0; 2849 + } 2802 2850 2803 2851 /* 2804 2852 * This routine allows the tty driver to be notified when ··· 4086 4084 .wait_until_sent = cy_wait_until_sent, 4087 4085 .tiocmget = cy_tiocmget, 4088 4086 .tiocmset = cy_tiocmset, 4087 + .get_icount = cy_get_icount, 4089 4088 .proc_fops = &cyclades_proc_fops, 4090 4089 }; 4091 4090
+43 -29
drivers/char/ip2/ip2main.c
··· 184 184 static int ip2_tiocmget(struct tty_struct *tty, struct file *file); 185 185 static int ip2_tiocmset(struct tty_struct *tty, struct file *file, 186 186 unsigned int set, unsigned int clear); 187 + static int ip2_get_icount(struct tty_struct *tty, 188 + struct serial_icounter_struct *icount); 187 189 188 190 static void set_irq(int, int); 189 191 static void ip2_interrupt_bh(struct work_struct *work); ··· 458 456 .hangup = ip2_hangup, 459 457 .tiocmget = ip2_tiocmget, 460 458 .tiocmset = ip2_tiocmset, 459 + .get_icount = ip2_get_icount, 461 460 .proc_fops = &ip2_proc_fops, 462 461 }; 463 462 ··· 2133 2130 i2ChanStrPtr pCh = DevTable[tty->index]; 2134 2131 i2eBordStrPtr pB; 2135 2132 struct async_icount cprev, cnow; /* kernel counter temps */ 2136 - struct serial_icounter_struct __user *p_cuser; 2137 2133 int rc = 0; 2138 2134 unsigned long flags; 2139 2135 void __user *argp = (void __user *)arg; ··· 2301 2299 break; 2302 2300 2303 2301 /* 2304 - * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 2305 - * Return: write counters to the user passed counter struct 2306 - * NB: both 1->0 and 0->1 transitions are counted except for RI where 2307 - * only 0->1 is counted. The controller is quite capable of counting 2308 - * both, but this done to preserve compatibility with the standard 2309 - * serial driver. 2310 - */ 2311 - case TIOCGICOUNT: 2312 - ip2trace (CHANN, ITRC_IOCTL, 11, 1, rc ); 2313 - 2314 - write_lock_irqsave(&pB->read_fifo_spinlock, flags); 2315 - cnow = pCh->icount; 2316 - write_unlock_irqrestore(&pB->read_fifo_spinlock, flags); 2317 - p_cuser = argp; 2318 - rc = put_user(cnow.cts, &p_cuser->cts); 2319 - rc = put_user(cnow.dsr, &p_cuser->dsr); 2320 - rc = put_user(cnow.rng, &p_cuser->rng); 2321 - rc = put_user(cnow.dcd, &p_cuser->dcd); 2322 - rc = put_user(cnow.rx, &p_cuser->rx); 2323 - rc = put_user(cnow.tx, &p_cuser->tx); 2324 - rc = put_user(cnow.frame, &p_cuser->frame); 2325 - rc = put_user(cnow.overrun, &p_cuser->overrun); 2326 - rc = put_user(cnow.parity, &p_cuser->parity); 2327 - rc = put_user(cnow.brk, &p_cuser->brk); 2328 - rc = put_user(cnow.buf_overrun, &p_cuser->buf_overrun); 2329 - break; 2330 - 2331 - /* 2332 2302 * The rest are not supported by this driver. By returning -ENOIOCTLCMD they 2333 2303 * will be passed to the line discipline for it to handle. 2334 2304 */ ··· 2322 2348 ip2trace (CHANN, ITRC_IOCTL, ITRC_RETURN, 0 ); 2323 2349 2324 2350 return rc; 2351 + } 2352 + 2353 + static int ip2_get_icount(struct tty_struct *tty, 2354 + struct serial_icounter_struct *icount) 2355 + { 2356 + i2ChanStrPtr pCh = DevTable[tty->index]; 2357 + i2eBordStrPtr pB; 2358 + struct async_icount cnow; /* kernel counter temp */ 2359 + unsigned long flags; 2360 + 2361 + if ( pCh == NULL ) 2362 + return -ENODEV; 2363 + 2364 + pB = pCh->pMyBord; 2365 + 2366 + /* 2367 + * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 2368 + * Return: write counters to the user passed counter struct 2369 + * NB: both 1->0 and 0->1 transitions are counted except for RI where 2370 + * only 0->1 is counted. The controller is quite capable of counting 2371 + * both, but this done to preserve compatibility with the standard 2372 + * serial driver. 2373 + */ 2374 + 2375 + write_lock_irqsave(&pB->read_fifo_spinlock, flags); 2376 + cnow = pCh->icount; 2377 + write_unlock_irqrestore(&pB->read_fifo_spinlock, flags); 2378 + 2379 + icount->cts = cnow.cts; 2380 + icount->dsr = cnow.dsr; 2381 + icount->rng = cnow.rng; 2382 + icount->dcd = cnow.dcd; 2383 + icount->rx = cnow.rx; 2384 + icount->tx = cnow.tx; 2385 + icount->frame = cnow.frame; 2386 + icount->overrun = cnow.overrun; 2387 + icount->parity = cnow.parity; 2388 + icount->brk = cnow.brk; 2389 + icount->buf_overrun = cnow.buf_overrun; 2390 + return 0; 2325 2391 } 2326 2392 2327 2393 /******************************************************************************/
+57 -52
drivers/char/mxser.c
··· 1700 1700 return 0; 1701 1701 } 1702 1702 1703 - if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && cmd != TIOCGICOUNT && 1703 + if (cmd != TIOCGSERIAL && cmd != TIOCMIWAIT && 1704 1704 test_bit(TTY_IO_ERROR, &tty->flags)) 1705 1705 return -EIO; 1706 1706 ··· 1730 1730 1731 1731 return wait_event_interruptible(info->port.delta_msr_wait, 1732 1732 mxser_cflags_changed(info, arg, &cnow)); 1733 - /* 1734 - * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 1735 - * Return: write counters to the user passed counter struct 1736 - * NB: both 1->0 and 0->1 transitions are counted except for 1737 - * RI where only 0->1 is counted. 1738 - */ 1739 - case TIOCGICOUNT: { 1740 - struct serial_icounter_struct icnt = { 0 }; 1741 - spin_lock_irqsave(&info->slock, flags); 1742 - cnow = info->icount; 1743 - spin_unlock_irqrestore(&info->slock, flags); 1744 - 1745 - icnt.frame = cnow.frame; 1746 - icnt.brk = cnow.brk; 1747 - icnt.overrun = cnow.overrun; 1748 - icnt.buf_overrun = cnow.buf_overrun; 1749 - icnt.parity = cnow.parity; 1750 - icnt.rx = cnow.rx; 1751 - icnt.tx = cnow.tx; 1752 - icnt.cts = cnow.cts; 1753 - icnt.dsr = cnow.dsr; 1754 - icnt.rng = cnow.rng; 1755 - icnt.dcd = cnow.dcd; 1756 - 1757 - return copy_to_user(argp, &icnt, sizeof(icnt)) ? -EFAULT : 0; 1758 - } 1759 1733 case MOXA_HighSpeedOn: 1760 1734 return put_user(info->baud_base != 115200 ? 1 : 0, (int __user *)argp); 1761 1735 case MOXA_SDS_RSTICOUNTER: ··· 1799 1825 default: 1800 1826 return -ENOIOCTLCMD; 1801 1827 } 1828 + return 0; 1829 + } 1830 + 1831 + /* 1832 + * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 1833 + * Return: write counters to the user passed counter struct 1834 + * NB: both 1->0 and 0->1 transitions are counted except for 1835 + * RI where only 0->1 is counted. 1836 + */ 1837 + 1838 + static int mxser_get_icount(struct tty_struct *tty, 1839 + struct serial_icounter_struct *icount) 1840 + 1841 + { 1842 + struct mxser_port *info = tty->driver_data; 1843 + struct async_icount cnow; 1844 + unsigned long flags; 1845 + 1846 + spin_lock_irqsave(&info->slock, flags); 1847 + cnow = info->icount; 1848 + spin_unlock_irqrestore(&info->slock, flags); 1849 + 1850 + icount->frame = cnow.frame; 1851 + icount->brk = cnow.brk; 1852 + icount->overrun = cnow.overrun; 1853 + icount->buf_overrun = cnow.buf_overrun; 1854 + icount->parity = cnow.parity; 1855 + icount->rx = cnow.rx; 1856 + icount->tx = cnow.tx; 1857 + icount->cts = cnow.cts; 1858 + icount->dsr = cnow.dsr; 1859 + icount->rng = cnow.rng; 1860 + icount->dcd = cnow.dcd; 1802 1861 return 0; 1803 1862 } 1804 1863 ··· 2333 2326 .wait_until_sent = mxser_wait_until_sent, 2334 2327 .tiocmget = mxser_tiocmget, 2335 2328 .tiocmset = mxser_tiocmset, 2329 + .get_icount = mxser_get_icount, 2336 2330 }; 2337 2331 2338 2332 struct tty_port_operations mxser_port_ops = { ··· 2347 2339 * The MOXA Smartio/Industio serial driver boot-time initialization code! 2348 2340 */ 2349 2341 2350 - static void mxser_release_res(struct mxser_board *brd, struct pci_dev *pdev, 2351 - unsigned int irq) 2342 + static void mxser_release_ISA_res(struct mxser_board *brd) 2352 2343 { 2353 - if (irq) 2354 - free_irq(brd->irq, brd); 2355 - if (pdev != NULL) { /* PCI */ 2356 - #ifdef CONFIG_PCI 2357 - pci_release_region(pdev, 2); 2358 - pci_release_region(pdev, 3); 2359 - #endif 2360 - } else { 2361 - release_region(brd->ports[0].ioaddr, 8 * brd->info->nports); 2362 - release_region(brd->vector, 1); 2363 - } 2344 + free_irq(brd->irq, brd); 2345 + release_region(brd->ports[0].ioaddr, 8 * brd->info->nports); 2346 + release_region(brd->vector, 1); 2364 2347 } 2365 2348 2366 2349 static int __devinit mxser_initbrd(struct mxser_board *brd, ··· 2396 2397 2397 2398 retval = request_irq(brd->irq, mxser_interrupt, IRQF_SHARED, "mxser", 2398 2399 brd); 2399 - if (retval) { 2400 + if (retval) 2400 2401 printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may " 2401 2402 "conflict with another device.\n", 2402 2403 brd->info->name, brd->irq); 2403 - /* We hold resources, we need to release them. */ 2404 - mxser_release_res(brd, pdev, 0); 2405 - } 2404 + 2406 2405 return retval; 2407 2406 } 2408 2407 ··· 2552 2555 ioaddress = pci_resource_start(pdev, 2); 2553 2556 retval = pci_request_region(pdev, 2, "mxser(IO)"); 2554 2557 if (retval) 2555 - goto err; 2558 + goto err_dis; 2556 2559 2557 2560 brd->info = &mxser_cards[ent->driver_data]; 2558 2561 for (i = 0; i < brd->info->nports; i++) ··· 2562 2565 ioaddress = pci_resource_start(pdev, 3); 2563 2566 retval = pci_request_region(pdev, 3, "mxser(vector)"); 2564 2567 if (retval) 2565 - goto err_relio; 2568 + goto err_zero; 2566 2569 brd->vector = ioaddress; 2567 2570 2568 2571 /* irq */ ··· 2605 2608 /* mxser_initbrd will hook ISR. */ 2606 2609 retval = mxser_initbrd(brd, pdev); 2607 2610 if (retval) 2608 - goto err_null; 2611 + goto err_rel3; 2609 2612 2610 2613 for (i = 0; i < brd->info->nports; i++) 2611 2614 tty_register_device(mxvar_sdriver, brd->idx + i, &pdev->dev); ··· 2613 2616 pci_set_drvdata(pdev, brd); 2614 2617 2615 2618 return 0; 2616 - err_relio: 2617 - pci_release_region(pdev, 2); 2618 - err_null: 2619 + err_rel3: 2620 + pci_release_region(pdev, 3); 2621 + err_zero: 2619 2622 brd->info = NULL; 2623 + pci_release_region(pdev, 2); 2624 + err_dis: 2625 + pci_disable_device(pdev); 2620 2626 err: 2621 2627 return retval; 2622 2628 #else ··· 2629 2629 2630 2630 static void __devexit mxser_remove(struct pci_dev *pdev) 2631 2631 { 2632 + #ifdef CONFIG_PCI 2632 2633 struct mxser_board *brd = pci_get_drvdata(pdev); 2633 2634 unsigned int i; 2634 2635 2635 2636 for (i = 0; i < brd->info->nports; i++) 2636 2637 tty_unregister_device(mxvar_sdriver, brd->idx + i); 2637 2638 2638 - mxser_release_res(brd, pdev, 1); 2639 + free_irq(pdev->irq, brd); 2640 + pci_release_region(pdev, 2); 2641 + pci_release_region(pdev, 3); 2642 + pci_disable_device(pdev); 2639 2643 brd->info = NULL; 2644 + #endif 2640 2645 } 2641 2646 2642 2647 static struct pci_driver mxser_driver = { ··· 2746 2741 2747 2742 for (i = 0; i < MXSER_BOARDS; i++) 2748 2743 if (mxser_boards[i].info != NULL) 2749 - mxser_release_res(&mxser_boards[i], NULL, 1); 2744 + mxser_release_ISA_res(&mxser_boards[i]); 2750 2745 } 2751 2746 2752 2747 module_init(mxser_module_init);
+17 -18
drivers/char/nozomi.c
··· 1804 1804 return ret; 1805 1805 } 1806 1806 1807 - static int ntty_ioctl_tiocgicount(struct port *port, void __user *argp) 1807 + static int ntty_tiocgicount(struct tty_struct *tty, 1808 + struct serial_icounter_struct *icount) 1808 1809 { 1810 + struct port *port = tty->driver_data; 1809 1811 const struct async_icount cnow = port->tty_icount; 1810 - struct serial_icounter_struct icount; 1811 1812 1812 - icount.cts = cnow.cts; 1813 - icount.dsr = cnow.dsr; 1814 - icount.rng = cnow.rng; 1815 - icount.dcd = cnow.dcd; 1816 - icount.rx = cnow.rx; 1817 - icount.tx = cnow.tx; 1818 - icount.frame = cnow.frame; 1819 - icount.overrun = cnow.overrun; 1820 - icount.parity = cnow.parity; 1821 - icount.brk = cnow.brk; 1822 - icount.buf_overrun = cnow.buf_overrun; 1823 - 1824 - return copy_to_user(argp, &icount, sizeof(icount)) ? -EFAULT : 0; 1813 + icount->cts = cnow.cts; 1814 + icount->dsr = cnow.dsr; 1815 + icount->rng = cnow.rng; 1816 + icount->dcd = cnow.dcd; 1817 + icount->rx = cnow.rx; 1818 + icount->tx = cnow.tx; 1819 + icount->frame = cnow.frame; 1820 + icount->overrun = cnow.overrun; 1821 + icount->parity = cnow.parity; 1822 + icount->brk = cnow.brk; 1823 + icount->buf_overrun = cnow.buf_overrun; 1824 + return 0; 1825 1825 } 1826 1826 1827 1827 static int ntty_ioctl(struct tty_struct *tty, struct file *file, ··· 1840 1840 rval = wait_event_interruptible(port->tty_wait, 1841 1841 ntty_cflags_changed(port, arg, &cprev)); 1842 1842 break; 1843 - } case TIOCGICOUNT: 1844 - rval = ntty_ioctl_tiocgicount(port, argp); 1845 - break; 1843 + } 1846 1844 default: 1847 1845 DBG1("ERR: 0x%08X, %d", cmd, cmd); 1848 1846 break; ··· 1920 1922 .chars_in_buffer = ntty_chars_in_buffer, 1921 1923 .tiocmget = ntty_tiocmget, 1922 1924 .tiocmset = ntty_tiocmset, 1925 + .get_icount = ntty_tiocgicount, 1923 1926 .install = ntty_install, 1924 1927 .cleanup = ntty_cleanup, 1925 1928 };
+3 -1
drivers/char/pty.c
··· 676 676 677 677 set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */ 678 678 679 - tty_add_file(tty, filp); 679 + retval = tty_add_file(tty, filp); 680 + if (retval) 681 + goto out; 680 682 681 683 retval = devpts_pty_new(inode, tty->link); 682 684 if (retval)
+34 -39
drivers/char/synclink.c
··· 2925 2925 2926 2926 } /* end of mgsl_break() */ 2927 2927 2928 + /* 2929 + * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 2930 + * Return: write counters to the user passed counter struct 2931 + * NB: both 1->0 and 0->1 transitions are counted except for 2932 + * RI where only 0->1 is counted. 2933 + */ 2934 + static int msgl_get_icount(struct tty_struct *tty, 2935 + struct serial_icounter_struct *icount) 2936 + 2937 + { 2938 + struct mgsl_struct * info = tty->driver_data; 2939 + struct mgsl_icount cnow; /* kernel counter temps */ 2940 + unsigned long flags; 2941 + 2942 + spin_lock_irqsave(&info->irq_spinlock,flags); 2943 + cnow = info->icount; 2944 + spin_unlock_irqrestore(&info->irq_spinlock,flags); 2945 + 2946 + icount->cts = cnow.cts; 2947 + icount->dsr = cnow.dsr; 2948 + icount->rng = cnow.rng; 2949 + icount->dcd = cnow.dcd; 2950 + icount->rx = cnow.rx; 2951 + icount->tx = cnow.tx; 2952 + icount->frame = cnow.frame; 2953 + icount->overrun = cnow.overrun; 2954 + icount->parity = cnow.parity; 2955 + icount->brk = cnow.brk; 2956 + icount->buf_overrun = cnow.buf_overrun; 2957 + return 0; 2958 + } 2959 + 2928 2960 /* mgsl_ioctl() Service an IOCTL request 2929 2961 * 2930 2962 * Arguments: ··· 2981 2949 return -ENODEV; 2982 2950 2983 2951 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 2984 - (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { 2952 + (cmd != TIOCMIWAIT)) { 2985 2953 if (tty->flags & (1 << TTY_IO_ERROR)) 2986 2954 return -EIO; 2987 2955 } ··· 2991 2959 2992 2960 static int mgsl_ioctl_common(struct mgsl_struct *info, unsigned int cmd, unsigned long arg) 2993 2961 { 2994 - int error; 2995 - struct mgsl_icount cnow; /* kernel counter temps */ 2996 2962 void __user *argp = (void __user *)arg; 2997 - struct serial_icounter_struct __user *p_cuser; /* user space */ 2998 - unsigned long flags; 2999 2963 3000 2964 switch (cmd) { 3001 2965 case MGSL_IOCGPARAMS: ··· 3020 2992 case TIOCMIWAIT: 3021 2993 return modem_input_wait(info,(int)arg); 3022 2994 3023 - /* 3024 - * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 3025 - * Return: write counters to the user passed counter struct 3026 - * NB: both 1->0 and 0->1 transitions are counted except for 3027 - * RI where only 0->1 is counted. 3028 - */ 3029 - case TIOCGICOUNT: 3030 - spin_lock_irqsave(&info->irq_spinlock,flags); 3031 - cnow = info->icount; 3032 - spin_unlock_irqrestore(&info->irq_spinlock,flags); 3033 - p_cuser = argp; 3034 - PUT_USER(error,cnow.cts, &p_cuser->cts); 3035 - if (error) return error; 3036 - PUT_USER(error,cnow.dsr, &p_cuser->dsr); 3037 - if (error) return error; 3038 - PUT_USER(error,cnow.rng, &p_cuser->rng); 3039 - if (error) return error; 3040 - PUT_USER(error,cnow.dcd, &p_cuser->dcd); 3041 - if (error) return error; 3042 - PUT_USER(error,cnow.rx, &p_cuser->rx); 3043 - if (error) return error; 3044 - PUT_USER(error,cnow.tx, &p_cuser->tx); 3045 - if (error) return error; 3046 - PUT_USER(error,cnow.frame, &p_cuser->frame); 3047 - if (error) return error; 3048 - PUT_USER(error,cnow.overrun, &p_cuser->overrun); 3049 - if (error) return error; 3050 - PUT_USER(error,cnow.parity, &p_cuser->parity); 3051 - if (error) return error; 3052 - PUT_USER(error,cnow.brk, &p_cuser->brk); 3053 - if (error) return error; 3054 - PUT_USER(error,cnow.buf_overrun, &p_cuser->buf_overrun); 3055 - if (error) return error; 3056 - return 0; 3057 2995 default: 3058 2996 return -ENOIOCTLCMD; 3059 2997 } ··· 4322 4328 .hangup = mgsl_hangup, 4323 4329 .tiocmget = tiocmget, 4324 4330 .tiocmset = tiocmset, 4331 + .get_icount = msgl_get_icount, 4325 4332 .proc_fops = &mgsl_proc_fops, 4326 4333 }; 4327 4334
+28 -33
drivers/char/synclinkmp.c
··· 1258 1258 unsigned int cmd, unsigned long arg) 1259 1259 { 1260 1260 SLMP_INFO *info = tty->driver_data; 1261 - int error; 1262 - struct mgsl_icount cnow; /* kernel counter temps */ 1263 - struct serial_icounter_struct __user *p_cuser; /* user space */ 1264 - unsigned long flags; 1265 1261 void __user *argp = (void __user *)arg; 1266 1262 1267 1263 if (debug_level >= DEBUG_LEVEL_INFO) ··· 1268 1272 return -ENODEV; 1269 1273 1270 1274 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && 1271 - (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { 1275 + (cmd != TIOCMIWAIT)) { 1272 1276 if (tty->flags & (1 << TTY_IO_ERROR)) 1273 1277 return -EIO; 1274 1278 } ··· 1306 1310 * NB: both 1->0 and 0->1 transitions are counted except for 1307 1311 * RI where only 0->1 is counted. 1308 1312 */ 1309 - case TIOCGICOUNT: 1310 - spin_lock_irqsave(&info->lock,flags); 1311 - cnow = info->icount; 1312 - spin_unlock_irqrestore(&info->lock,flags); 1313 - p_cuser = argp; 1314 - PUT_USER(error,cnow.cts, &p_cuser->cts); 1315 - if (error) return error; 1316 - PUT_USER(error,cnow.dsr, &p_cuser->dsr); 1317 - if (error) return error; 1318 - PUT_USER(error,cnow.rng, &p_cuser->rng); 1319 - if (error) return error; 1320 - PUT_USER(error,cnow.dcd, &p_cuser->dcd); 1321 - if (error) return error; 1322 - PUT_USER(error,cnow.rx, &p_cuser->rx); 1323 - if (error) return error; 1324 - PUT_USER(error,cnow.tx, &p_cuser->tx); 1325 - if (error) return error; 1326 - PUT_USER(error,cnow.frame, &p_cuser->frame); 1327 - if (error) return error; 1328 - PUT_USER(error,cnow.overrun, &p_cuser->overrun); 1329 - if (error) return error; 1330 - PUT_USER(error,cnow.parity, &p_cuser->parity); 1331 - if (error) return error; 1332 - PUT_USER(error,cnow.brk, &p_cuser->brk); 1333 - if (error) return error; 1334 - PUT_USER(error,cnow.buf_overrun, &p_cuser->buf_overrun); 1335 - if (error) return error; 1336 - return 0; 1337 1313 default: 1338 1314 return -ENOIOCTLCMD; 1339 1315 } 1316 + return 0; 1317 + } 1318 + 1319 + static int get_icount(struct tty_struct *tty, 1320 + struct serial_icounter_struct *icount) 1321 + { 1322 + SLMP_INFO *info = tty->driver_data; 1323 + struct mgsl_icount cnow; /* kernel counter temps */ 1324 + unsigned long flags; 1325 + 1326 + spin_lock_irqsave(&info->lock,flags); 1327 + cnow = info->icount; 1328 + spin_unlock_irqrestore(&info->lock,flags); 1329 + 1330 + icount->cts = cnow.cts; 1331 + icount->dsr = cnow.dsr; 1332 + icount->rng = cnow.rng; 1333 + icount->dcd = cnow.dcd; 1334 + icount->rx = cnow.rx; 1335 + icount->tx = cnow.tx; 1336 + icount->frame = cnow.frame; 1337 + icount->overrun = cnow.overrun; 1338 + icount->parity = cnow.parity; 1339 + icount->brk = cnow.brk; 1340 + icount->buf_overrun = cnow.buf_overrun; 1341 + 1340 1342 return 0; 1341 1343 } 1342 1344 ··· 3903 3909 .hangup = hangup, 3904 3910 .tiocmget = tiocmget, 3905 3911 .tiocmset = tiocmset, 3912 + .get_icount = get_icount, 3906 3913 .proc_fops = &synclinkmp_proc_fops, 3907 3914 }; 3908 3915
+71 -6
drivers/char/tty_io.c
··· 96 96 #include <linux/bitops.h> 97 97 #include <linux/delay.h> 98 98 #include <linux/seq_file.h> 99 + #include <linux/serial.h> 99 100 100 101 #include <linux/uaccess.h> 101 102 #include <asm/system.h> ··· 184 183 185 184 void free_tty_struct(struct tty_struct *tty) 186 185 { 186 + if (tty->dev) 187 + put_device(tty->dev); 187 188 kfree(tty->write_buf); 188 189 tty_buffer_free_all(tty); 189 190 kfree(tty); ··· 197 194 } 198 195 199 196 /* Associate a new file with the tty structure */ 200 - void tty_add_file(struct tty_struct *tty, struct file *file) 197 + int tty_add_file(struct tty_struct *tty, struct file *file) 201 198 { 202 199 struct tty_file_private *priv; 203 200 204 - /* XXX: must implement proper error handling in callers */ 205 - priv = kmalloc(sizeof(*priv), GFP_KERNEL|__GFP_NOFAIL); 201 + priv = kmalloc(sizeof(*priv), GFP_KERNEL); 202 + if (!priv) 203 + return -ENOMEM; 206 204 207 205 priv->tty = tty; 208 206 priv->file = file; ··· 212 208 spin_lock(&tty_files_lock); 213 209 list_add(&priv->list, &tty->tty_files); 214 210 spin_unlock(&tty_files_lock); 211 + 212 + return 0; 215 213 } 216 214 217 215 /* Delete file from its tty */ ··· 1881 1875 return PTR_ERR(tty); 1882 1876 } 1883 1877 1884 - tty_add_file(tty, filp); 1878 + retval = tty_add_file(tty, filp); 1879 + if (retval) { 1880 + tty_unlock(); 1881 + return retval; 1882 + } 1885 1883 1886 1884 check_tty_count(tty, "tty_open"); 1887 1885 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && ··· 2512 2502 return tty->ops->tiocmset(tty, file, set, clear); 2513 2503 } 2514 2504 2505 + static int tty_tiocgicount(struct tty_struct *tty, void __user *arg) 2506 + { 2507 + int retval = -EINVAL; 2508 + struct serial_icounter_struct icount; 2509 + memset(&icount, 0, sizeof(icount)); 2510 + if (tty->ops->get_icount) 2511 + retval = tty->ops->get_icount(tty, &icount); 2512 + if (retval != 0) 2513 + return retval; 2514 + if (copy_to_user(arg, &icount, sizeof(icount))) 2515 + return -EFAULT; 2516 + return 0; 2517 + } 2518 + 2515 2519 struct tty_struct *tty_pair_get_tty(struct tty_struct *tty) 2516 2520 { 2517 2521 if (tty->driver->type == TTY_DRIVER_TYPE_PTY && ··· 2646 2622 case TIOCMBIC: 2647 2623 case TIOCMBIS: 2648 2624 return tty_tiocmset(tty, file, cmd, p); 2625 + case TIOCGICOUNT: 2626 + retval = tty_tiocgicount(tty, p); 2627 + /* For the moment allow fall through to the old method */ 2628 + if (retval != -EINVAL) 2629 + return retval; 2630 + break; 2649 2631 case TCFLSH: 2650 2632 switch (arg) { 2651 2633 case TCIFLUSH: ··· 2813 2783 2814 2784 EXPORT_SYMBOL(do_SAK); 2815 2785 2786 + static int dev_match_devt(struct device *dev, void *data) 2787 + { 2788 + dev_t *devt = data; 2789 + return dev->devt == *devt; 2790 + } 2791 + 2792 + /* Must put_device() after it's unused! */ 2793 + static struct device *tty_get_device(struct tty_struct *tty) 2794 + { 2795 + dev_t devt = tty_devnum(tty); 2796 + return class_find_device(tty_class, NULL, &devt, dev_match_devt); 2797 + } 2798 + 2799 + 2816 2800 /** 2817 2801 * initialize_tty_struct 2818 2802 * @tty: tty to initialize ··· 2867 2823 tty->ops = driver->ops; 2868 2824 tty->index = idx; 2869 2825 tty_line_name(driver, idx, tty->name); 2826 + tty->dev = tty_get_device(tty); 2870 2827 } 2871 2828 2872 2829 /** ··· 3025 2980 int i; 3026 2981 dev_t dev; 3027 2982 void **p = NULL; 2983 + struct device *d; 3028 2984 3029 2985 if (!(driver->flags & TTY_DRIVER_DEVPTS_MEM) && driver->num) { 3030 2986 p = kzalloc(driver->num * 2 * sizeof(void *), GFP_KERNEL); ··· 3073 3027 mutex_unlock(&tty_mutex); 3074 3028 3075 3029 if (!(driver->flags & TTY_DRIVER_DYNAMIC_DEV)) { 3076 - for (i = 0; i < driver->num; i++) 3077 - tty_register_device(driver, i, NULL); 3030 + for (i = 0; i < driver->num; i++) { 3031 + d = tty_register_device(driver, i, NULL); 3032 + if (IS_ERR(d)) { 3033 + error = PTR_ERR(d); 3034 + goto err; 3035 + } 3036 + } 3078 3037 } 3079 3038 proc_tty_register_driver(driver); 3080 3039 driver->flags |= TTY_DRIVER_INSTALLED; 3081 3040 return 0; 3041 + 3042 + err: 3043 + for (i--; i >= 0; i--) 3044 + tty_unregister_device(driver, i); 3045 + 3046 + mutex_lock(&tty_mutex); 3047 + list_del(&driver->tty_drivers); 3048 + mutex_unlock(&tty_mutex); 3049 + 3050 + unregister_chrdev_region(dev, driver->num); 3051 + driver->ttys = NULL; 3052 + driver->termios = NULL; 3053 + kfree(p); 3054 + return error; 3082 3055 } 3083 3056 3084 3057 EXPORT_SYMBOL(tty_register_driver);
+225
drivers/char/ttyprintk.c
··· 1 + /* 2 + * linux/drivers/char/ttyprintk.c 3 + * 4 + * Copyright (C) 2010 Samo Pogacnik 5 + * 6 + * This program is free software; you can redistribute it and/or modify 7 + * it under the smems of the GNU General Public License as published by 8 + * the Free Software Foundation; version 2 of the License. 9 + */ 10 + 11 + /* 12 + * This pseudo device allows user to make printk messages. It is possible 13 + * to store "console" messages inline with kernel messages for better analyses 14 + * of the boot process, for example. 15 + */ 16 + 17 + #include <linux/device.h> 18 + #include <linux/serial.h> 19 + #include <linux/tty.h> 20 + 21 + struct ttyprintk_port { 22 + struct tty_port port; 23 + struct mutex port_write_mutex; 24 + }; 25 + 26 + static struct ttyprintk_port tpk_port; 27 + 28 + /* 29 + * Our simple preformatting supports transparent output of (time-stamped) 30 + * printk messages (also suitable for logging service): 31 + * - any cr is replaced by nl 32 + * - adds a ttyprintk source tag in front of each line 33 + * - too long message is fragmeted, with '\'nl between fragments 34 + * - TPK_STR_SIZE isn't really the write_room limiting factor, bcause 35 + * it is emptied on the fly during preformatting. 36 + */ 37 + #define TPK_STR_SIZE 508 /* should be bigger then max expected line length */ 38 + #define TPK_MAX_ROOM 4096 /* we could assume 4K for instance */ 39 + static const char *tpk_tag = "[U] "; /* U for User */ 40 + static int tpk_curr; 41 + 42 + static int tpk_printk(const unsigned char *buf, int count) 43 + { 44 + static char tmp[TPK_STR_SIZE + 4]; 45 + int i = tpk_curr; 46 + 47 + if (buf == NULL) { 48 + /* flush tmp[] */ 49 + if (tpk_curr > 0) { 50 + /* non nl or cr terminated message - add nl */ 51 + tmp[tpk_curr + 0] = '\n'; 52 + tmp[tpk_curr + 1] = '\0'; 53 + printk(KERN_INFO "%s%s", tpk_tag, tmp); 54 + tpk_curr = 0; 55 + } 56 + return i; 57 + } 58 + 59 + for (i = 0; i < count; i++) { 60 + tmp[tpk_curr] = buf[i]; 61 + if (tpk_curr < TPK_STR_SIZE) { 62 + switch (buf[i]) { 63 + case '\r': 64 + /* replace cr with nl */ 65 + tmp[tpk_curr + 0] = '\n'; 66 + tmp[tpk_curr + 1] = '\0'; 67 + printk(KERN_INFO "%s%s", tpk_tag, tmp); 68 + tpk_curr = 0; 69 + if (buf[i + 1] == '\n') 70 + i++; 71 + break; 72 + case '\n': 73 + tmp[tpk_curr + 1] = '\0'; 74 + printk(KERN_INFO "%s%s", tpk_tag, tmp); 75 + tpk_curr = 0; 76 + break; 77 + default: 78 + tpk_curr++; 79 + } 80 + } else { 81 + /* end of tmp buffer reached: cut the message in two */ 82 + tmp[tpk_curr + 1] = '\\'; 83 + tmp[tpk_curr + 2] = '\n'; 84 + tmp[tpk_curr + 3] = '\0'; 85 + printk(KERN_INFO "%s%s", tpk_tag, tmp); 86 + tpk_curr = 0; 87 + } 88 + } 89 + 90 + return count; 91 + } 92 + 93 + /* 94 + * TTY operations open function. 95 + */ 96 + static int tpk_open(struct tty_struct *tty, struct file *filp) 97 + { 98 + tty->driver_data = &tpk_port; 99 + 100 + return tty_port_open(&tpk_port.port, tty, filp); 101 + } 102 + 103 + /* 104 + * TTY operations close function. 105 + */ 106 + static void tpk_close(struct tty_struct *tty, struct file *filp) 107 + { 108 + struct ttyprintk_port *tpkp = tty->driver_data; 109 + 110 + mutex_lock(&tpkp->port_write_mutex); 111 + /* flush tpk_printk buffer */ 112 + tpk_printk(NULL, 0); 113 + mutex_unlock(&tpkp->port_write_mutex); 114 + 115 + tty_port_close(&tpkp->port, tty, filp); 116 + } 117 + 118 + /* 119 + * TTY operations write function. 120 + */ 121 + static int tpk_write(struct tty_struct *tty, 122 + const unsigned char *buf, int count) 123 + { 124 + struct ttyprintk_port *tpkp = tty->driver_data; 125 + int ret; 126 + 127 + 128 + /* exclusive use of tpk_printk within this tty */ 129 + mutex_lock(&tpkp->port_write_mutex); 130 + ret = tpk_printk(buf, count); 131 + mutex_unlock(&tpkp->port_write_mutex); 132 + 133 + return ret; 134 + } 135 + 136 + /* 137 + * TTY operations write_room function. 138 + */ 139 + static int tpk_write_room(struct tty_struct *tty) 140 + { 141 + return TPK_MAX_ROOM; 142 + } 143 + 144 + /* 145 + * TTY operations ioctl function. 146 + */ 147 + static int tpk_ioctl(struct tty_struct *tty, struct file *file, 148 + unsigned int cmd, unsigned long arg) 149 + { 150 + struct ttyprintk_port *tpkp = tty->driver_data; 151 + 152 + if (!tpkp) 153 + return -EINVAL; 154 + 155 + switch (cmd) { 156 + /* Stop TIOCCONS */ 157 + case TIOCCONS: 158 + return -EOPNOTSUPP; 159 + default: 160 + return -ENOIOCTLCMD; 161 + } 162 + return 0; 163 + } 164 + 165 + static const struct tty_operations ttyprintk_ops = { 166 + .open = tpk_open, 167 + .close = tpk_close, 168 + .write = tpk_write, 169 + .write_room = tpk_write_room, 170 + .ioctl = tpk_ioctl, 171 + }; 172 + 173 + struct tty_port_operations null_ops = { }; 174 + 175 + static struct tty_driver *ttyprintk_driver; 176 + 177 + static int __init ttyprintk_init(void) 178 + { 179 + int ret = -ENOMEM; 180 + void *rp; 181 + 182 + ttyprintk_driver = alloc_tty_driver(1); 183 + if (!ttyprintk_driver) 184 + return ret; 185 + 186 + ttyprintk_driver->owner = THIS_MODULE; 187 + ttyprintk_driver->driver_name = "ttyprintk"; 188 + ttyprintk_driver->name = "ttyprintk"; 189 + ttyprintk_driver->major = TTYAUX_MAJOR; 190 + ttyprintk_driver->minor_start = 3; 191 + ttyprintk_driver->num = 1; 192 + ttyprintk_driver->type = TTY_DRIVER_TYPE_CONSOLE; 193 + ttyprintk_driver->init_termios = tty_std_termios; 194 + ttyprintk_driver->init_termios.c_oflag = OPOST | OCRNL | ONOCR | ONLRET; 195 + ttyprintk_driver->flags = TTY_DRIVER_RESET_TERMIOS | 196 + TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV; 197 + tty_set_operations(ttyprintk_driver, &ttyprintk_ops); 198 + 199 + ret = tty_register_driver(ttyprintk_driver); 200 + if (ret < 0) { 201 + printk(KERN_ERR "Couldn't register ttyprintk driver\n"); 202 + goto error; 203 + } 204 + 205 + /* create our unnumbered device */ 206 + rp = device_create(tty_class, NULL, MKDEV(TTYAUX_MAJOR, 3), NULL, 207 + ttyprintk_driver->name); 208 + if (IS_ERR(rp)) { 209 + printk(KERN_ERR "Couldn't create ttyprintk device\n"); 210 + ret = PTR_ERR(rp); 211 + goto error; 212 + } 213 + 214 + tty_port_init(&tpk_port.port); 215 + tpk_port.port.ops = &null_ops; 216 + mutex_init(&tpk_port.port_write_mutex); 217 + 218 + return 0; 219 + 220 + error: 221 + put_tty_driver(ttyprintk_driver); 222 + ttyprintk_driver = NULL; 223 + return ret; 224 + } 225 + module_init(ttyprintk_init);
+135
drivers/char/vc_screen.c
··· 35 35 #include <linux/console.h> 36 36 #include <linux/device.h> 37 37 #include <linux/smp_lock.h> 38 + #include <linux/sched.h> 39 + #include <linux/fs.h> 40 + #include <linux/poll.h> 41 + #include <linux/signal.h> 42 + #include <linux/slab.h> 43 + #include <linux/notifier.h> 38 44 39 45 #include <asm/uaccess.h> 40 46 #include <asm/byteorder.h> ··· 50 44 #undef org 51 45 #undef addr 52 46 #define HEADER_SIZE 4 47 + 48 + struct vcs_poll_data { 49 + struct notifier_block notifier; 50 + unsigned int cons_num; 51 + bool seen_last_update; 52 + wait_queue_head_t waitq; 53 + struct fasync_struct *fasync; 54 + }; 55 + 56 + static int 57 + vcs_notifier(struct notifier_block *nb, unsigned long code, void *_param) 58 + { 59 + struct vt_notifier_param *param = _param; 60 + struct vc_data *vc = param->vc; 61 + struct vcs_poll_data *poll = 62 + container_of(nb, struct vcs_poll_data, notifier); 63 + int currcons = poll->cons_num; 64 + 65 + if (code != VT_UPDATE) 66 + return NOTIFY_DONE; 67 + 68 + if (currcons == 0) 69 + currcons = fg_console; 70 + else 71 + currcons--; 72 + if (currcons != vc->vc_num) 73 + return NOTIFY_DONE; 74 + 75 + poll->seen_last_update = false; 76 + wake_up_interruptible(&poll->waitq); 77 + kill_fasync(&poll->fasync, SIGIO, POLL_IN); 78 + return NOTIFY_OK; 79 + } 80 + 81 + static void 82 + vcs_poll_data_free(struct vcs_poll_data *poll) 83 + { 84 + unregister_vt_notifier(&poll->notifier); 85 + kfree(poll); 86 + } 87 + 88 + static struct vcs_poll_data * 89 + vcs_poll_data_get(struct file *file) 90 + { 91 + struct vcs_poll_data *poll = file->private_data; 92 + 93 + if (poll) 94 + return poll; 95 + 96 + poll = kzalloc(sizeof(*poll), GFP_KERNEL); 97 + if (!poll) 98 + return NULL; 99 + poll->cons_num = iminor(file->f_path.dentry->d_inode) & 127; 100 + init_waitqueue_head(&poll->waitq); 101 + poll->notifier.notifier_call = vcs_notifier; 102 + if (register_vt_notifier(&poll->notifier) != 0) { 103 + kfree(poll); 104 + return NULL; 105 + } 106 + 107 + /* 108 + * This code may be called either through ->poll() or ->fasync(). 109 + * If we have two threads using the same file descriptor, they could 110 + * both enter this function, both notice that the structure hasn't 111 + * been allocated yet and go ahead allocating it in parallel, but 112 + * only one of them must survive and be shared otherwise we'd leak 113 + * memory with a dangling notifier callback. 114 + */ 115 + spin_lock(&file->f_lock); 116 + if (!file->private_data) { 117 + file->private_data = poll; 118 + } else { 119 + /* someone else raced ahead of us */ 120 + vcs_poll_data_free(poll); 121 + poll = file->private_data; 122 + } 123 + spin_unlock(&file->f_lock); 124 + 125 + return poll; 126 + } 53 127 54 128 static int 55 129 vcs_size(struct inode *inode) ··· 188 102 struct inode *inode = file->f_path.dentry->d_inode; 189 103 unsigned int currcons = iminor(inode); 190 104 struct vc_data *vc; 105 + struct vcs_poll_data *poll; 191 106 long pos; 192 107 long viewed, attr, read; 193 108 int col, maxcol; ··· 221 134 ret = -EINVAL; 222 135 if (pos < 0) 223 136 goto unlock_out; 137 + poll = file->private_data; 138 + if (count && poll) 139 + poll->seen_last_update = true; 224 140 read = 0; 225 141 ret = 0; 226 142 while (count) { ··· 538 448 } 539 449 *ppos += written; 540 450 ret = written; 451 + if (written) 452 + vcs_scr_updated(vc); 541 453 542 454 unlock_out: 543 455 release_console_sem(); ··· 547 455 mutex_unlock(&con_buf_mtx); 548 456 549 457 return ret; 458 + } 459 + 460 + static unsigned int 461 + vcs_poll(struct file *file, poll_table *wait) 462 + { 463 + struct vcs_poll_data *poll = vcs_poll_data_get(file); 464 + int ret = 0; 465 + 466 + if (poll) { 467 + poll_wait(file, &poll->waitq, wait); 468 + if (!poll->seen_last_update) 469 + ret = POLLIN | POLLRDNORM; 470 + } 471 + return ret; 472 + } 473 + 474 + static int 475 + vcs_fasync(int fd, struct file *file, int on) 476 + { 477 + struct vcs_poll_data *poll = file->private_data; 478 + 479 + if (!poll) { 480 + /* don't allocate anything if all we want is disable fasync */ 481 + if (!on) 482 + return 0; 483 + poll = vcs_poll_data_get(file); 484 + if (!poll) 485 + return -ENOMEM; 486 + } 487 + 488 + return fasync_helper(fd, file, on, &poll->fasync); 550 489 } 551 490 552 491 static int ··· 593 470 return ret; 594 471 } 595 472 473 + static int vcs_release(struct inode *inode, struct file *file) 474 + { 475 + struct vcs_poll_data *poll = file->private_data; 476 + 477 + if (poll) 478 + vcs_poll_data_free(poll); 479 + return 0; 480 + } 481 + 596 482 static const struct file_operations vcs_fops = { 597 483 .llseek = vcs_lseek, 598 484 .read = vcs_read, 599 485 .write = vcs_write, 486 + .poll = vcs_poll, 487 + .fasync = vcs_fasync, 600 488 .open = vcs_open, 489 + .release = vcs_release, 601 490 }; 602 491 603 492 static struct class *vc_class;
+5
drivers/char/vt.c
··· 4182 4182 } 4183 4183 } 4184 4184 4185 + void vcs_scr_updated(struct vc_data *vc) 4186 + { 4187 + notify_update(vc); 4188 + } 4189 + 4185 4190 /* 4186 4191 * Visible symbols for modules 4187 4192 */
+1
drivers/input/serio/serport.c
··· 165 165 serio->open = serport_serio_open; 166 166 serio->close = serport_serio_close; 167 167 serio->port_data = serport; 168 + serio->dev.parent = tty->dev; 168 169 169 170 serio_register_port(serport->serio); 170 171 printk(KERN_INFO "serio: Serial port %s\n", tty_name(tty, name));
+16 -19
drivers/net/usb/hso.c
··· 1645 1645 * NB: both 1->0 and 0->1 transitions are counted except for 1646 1646 * RI where only 0->1 is counted. 1647 1647 */ 1648 - static int hso_get_count(struct hso_serial *serial, 1649 - struct serial_icounter_struct __user *icnt) 1648 + static int hso_get_count(struct tty_struct *tty, 1649 + struct serial_icounter_struct *icount) 1650 1650 { 1651 - struct serial_icounter_struct icount; 1652 1651 struct uart_icount cnow; 1652 + struct hso_serial *serial = get_serial_by_tty(tty); 1653 1653 struct hso_tiocmget *tiocmget = serial->tiocmget; 1654 1654 1655 1655 memset(&icount, 0, sizeof(struct serial_icounter_struct)); ··· 1660 1660 memcpy(&cnow, &tiocmget->icount, sizeof(struct uart_icount)); 1661 1661 spin_unlock_irq(&serial->serial_lock); 1662 1662 1663 - icount.cts = cnow.cts; 1664 - icount.dsr = cnow.dsr; 1665 - icount.rng = cnow.rng; 1666 - icount.dcd = cnow.dcd; 1667 - icount.rx = cnow.rx; 1668 - icount.tx = cnow.tx; 1669 - icount.frame = cnow.frame; 1670 - icount.overrun = cnow.overrun; 1671 - icount.parity = cnow.parity; 1672 - icount.brk = cnow.brk; 1673 - icount.buf_overrun = cnow.buf_overrun; 1663 + icount->cts = cnow.cts; 1664 + icount->dsr = cnow.dsr; 1665 + icount->rng = cnow.rng; 1666 + icount->dcd = cnow.dcd; 1667 + icount->rx = cnow.rx; 1668 + icount->tx = cnow.tx; 1669 + icount->frame = cnow.frame; 1670 + icount->overrun = cnow.overrun; 1671 + icount->parity = cnow.parity; 1672 + icount->brk = cnow.brk; 1673 + icount->buf_overrun = cnow.buf_overrun; 1674 1674 1675 - return copy_to_user(icnt, &icount, sizeof(icount)) ? -EFAULT : 0; 1675 + return 0; 1676 1676 } 1677 1677 1678 1678 ··· 1763 1763 switch (cmd) { 1764 1764 case TIOCMIWAIT: 1765 1765 ret = hso_wait_modem_status(serial, arg); 1766 - break; 1767 - 1768 - case TIOCGICOUNT: 1769 - ret = hso_get_count(serial, uarg); 1770 1766 break; 1771 1767 default: 1772 1768 ret = -ENOIOCTLCMD; ··· 3296 3300 .chars_in_buffer = hso_serial_chars_in_buffer, 3297 3301 .tiocmget = hso_serial_tiocmget, 3298 3302 .tiocmset = hso_serial_tiocmset, 3303 + .get_icount = hso_get_count, 3299 3304 .unthrottle = hso_unthrottle 3300 3305 }; 3301 3306
+25 -26
drivers/serial/68360serial.c
··· 1381 1381 } 1382 1382 1383 1383 1384 + /* 1385 + * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 1386 + * Return: write counters to the user passed counter struct 1387 + * NB: both 1->0 and 0->1 transitions are counted except for 1388 + * RI where only 0->1 is counted. 1389 + */ 1390 + static int rs_360_get_icount(struct tty_struct *tty, 1391 + struct serial_icounter_struct *icount) 1392 + { 1393 + ser_info_t *info = (ser_info_t *)tty->driver_data; 1394 + struct async_icount cnow; 1395 + 1396 + local_irq_disable(); 1397 + cnow = info->state->icount; 1398 + local_irq_enable(); 1399 + 1400 + icount->cts = cnow.cts; 1401 + icount->dsr = cnow.dsr; 1402 + icount->rng = cnow.rng; 1403 + icount->dcd = cnow.dcd; 1404 + 1405 + return 0; 1406 + } 1407 + 1384 1408 static int rs_360_ioctl(struct tty_struct *tty, struct file * file, 1385 1409 unsigned int cmd, unsigned long arg) 1386 1410 { ··· 1418 1394 if (serial_paranoia_check(info, tty->name, "rs_ioctl")) 1419 1395 return -ENODEV; 1420 1396 1421 - if ((cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { 1397 + if (cmd != TIOCMIWAIT) { 1422 1398 if (tty->flags & (1 << TTY_IO_ERROR)) 1423 1399 return -EIO; 1424 1400 } ··· 1501 1477 return 0; 1502 1478 #endif 1503 1479 1504 - /* 1505 - * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) 1506 - * Return: write counters to the user passed counter struct 1507 - * NB: both 1->0 and 0->1 transitions are counted except for 1508 - * RI where only 0->1 is counted. 1509 - */ 1510 - case TIOCGICOUNT: 1511 - local_irq_disable(); 1512 - cnow = info->state->icount; 1513 - local_irq_enable(); 1514 - p_cuser = (struct serial_icounter_struct *) arg; 1515 - /* error = put_user(cnow.cts, &p_cuser->cts); */ 1516 - /* if (error) return error; */ 1517 - /* error = put_user(cnow.dsr, &p_cuser->dsr); */ 1518 - /* if (error) return error; */ 1519 - /* error = put_user(cnow.rng, &p_cuser->rng); */ 1520 - /* if (error) return error; */ 1521 - /* error = put_user(cnow.dcd, &p_cuser->dcd); */ 1522 - /* if (error) return error; */ 1523 - 1524 - put_user(cnow.cts, &p_cuser->cts); 1525 - put_user(cnow.dsr, &p_cuser->dsr); 1526 - put_user(cnow.rng, &p_cuser->rng); 1527 - put_user(cnow.dcd, &p_cuser->dcd); 1528 - return 0; 1529 1480 1530 1481 default: 1531 1482 return -ENOIOCTLCMD;
+44 -25
drivers/serial/8250.c
··· 31 31 #include <linux/delay.h> 32 32 #include <linux/platform_device.h> 33 33 #include <linux/tty.h> 34 + #include <linux/ratelimit.h> 34 35 #include <linux/tty_flip.h> 35 36 #include <linux/serial_reg.h> 36 37 #include <linux/serial_core.h> ··· 155 154 unsigned char lsr_saved_flags; 156 155 #define MSR_SAVE_FLAGS UART_MSR_ANY_DELTA 157 156 unsigned char msr_saved_flags; 158 - 159 - /* 160 - * We provide a per-port pm hook. 161 - */ 162 - void (*pm)(struct uart_port *port, 163 - unsigned int state, unsigned int old); 164 157 }; 165 158 166 159 struct irq_info { ··· 1601 1606 1602 1607 if (l == i->head && pass_counter++ > PASS_LIMIT) { 1603 1608 /* If we hit this, we're dead. */ 1604 - printk(KERN_ERR "serial8250: too much work for " 1605 - "irq%d\n", irq); 1609 + printk_ratelimited(KERN_ERR 1610 + "serial8250: too much work for irq%d\n", irq); 1606 1611 break; 1607 1612 } 1608 1613 } while (l != end); ··· 1717 1722 mutex_unlock(&hash_mutex); 1718 1723 } 1719 1724 1720 - /* Base timer interval for polling */ 1721 - static inline int poll_timeout(int timeout) 1722 - { 1723 - return timeout > 6 ? (timeout / 2 - 2) : 1; 1724 - } 1725 - 1726 1725 /* 1727 1726 * This function is used to handle ports that do not have an 1728 1727 * interrupt. This doesn't work very well for 16450's, but gives ··· 1731 1742 iir = serial_in(up, UART_IIR); 1732 1743 if (!(iir & UART_IIR_NO_INT)) 1733 1744 serial8250_handle_port(up); 1734 - mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout)); 1745 + mod_timer(&up->timer, jiffies + uart_poll_timeout(&up->port)); 1735 1746 } 1736 1747 1737 1748 static void serial8250_backup_timeout(unsigned long data) ··· 1776 1787 1777 1788 /* Standard timer interval plus 0.2s to keep the port running */ 1778 1789 mod_timer(&up->timer, 1779 - jiffies + poll_timeout(up->port.timeout) + HZ / 5); 1790 + jiffies + uart_poll_timeout(&up->port) + HZ / 5); 1780 1791 } 1781 1792 1782 1793 static unsigned int serial8250_tx_empty(struct uart_port *port) ··· 1856 1867 unsigned int status, tmout = 10000; 1857 1868 1858 1869 /* Wait up to 10ms for the character(s) to be sent. */ 1859 - do { 1870 + for (;;) { 1860 1871 status = serial_in(up, UART_LSR); 1861 1872 1862 1873 up->lsr_saved_flags |= status & LSR_SAVE_FLAGS; 1863 1874 1875 + if ((status & bits) == bits) 1876 + break; 1864 1877 if (--tmout == 0) 1865 1878 break; 1866 1879 udelay(1); 1867 - } while ((status & bits) != bits); 1880 + } 1868 1881 1869 1882 /* Wait up to 1s for flow control if necessary */ 1870 1883 if (up->port.flags & UPF_CONS_FLOW) { ··· 2060 2069 up->timer.function = serial8250_backup_timeout; 2061 2070 up->timer.data = (unsigned long)up; 2062 2071 mod_timer(&up->timer, jiffies + 2063 - poll_timeout(up->port.timeout) + HZ / 5); 2072 + uart_poll_timeout(port) + HZ / 5); 2064 2073 } 2065 2074 2066 2075 /* ··· 2070 2079 */ 2071 2080 if (!is_real_interrupt(up->port.irq)) { 2072 2081 up->timer.data = (unsigned long)up; 2073 - mod_timer(&up->timer, jiffies + poll_timeout(up->port.timeout)); 2082 + mod_timer(&up->timer, jiffies + uart_poll_timeout(port)); 2074 2083 } else { 2075 2084 retval = serial_link_irq_chain(up); 2076 2085 if (retval) ··· 2431 2440 port->flags &= ~UPF_HARDPPS_CD; 2432 2441 } 2433 2442 2434 - static void 2435 - serial8250_pm(struct uart_port *port, unsigned int state, 2436 - unsigned int oldstate) 2443 + 2444 + void serial8250_do_pm(struct uart_port *port, unsigned int state, 2445 + unsigned int oldstate) 2437 2446 { 2438 2447 struct uart_8250_port *p = (struct uart_8250_port *)port; 2439 2448 2440 2449 serial8250_set_sleep(p, state != 0); 2450 + } 2451 + EXPORT_SYMBOL(serial8250_do_pm); 2441 2452 2442 - if (p->pm) 2443 - p->pm(port, state, oldstate); 2453 + static void 2454 + serial8250_pm(struct uart_port *port, unsigned int state, 2455 + unsigned int oldstate) 2456 + { 2457 + if (port->pm) 2458 + port->pm(port, state, oldstate); 2459 + else 2460 + serial8250_do_pm(port, state, oldstate); 2444 2461 } 2445 2462 2446 2463 static unsigned int serial8250_port_size(struct uart_8250_port *pt) ··· 2673 2674 2674 2675 static struct uart_8250_port serial8250_ports[UART_NR]; 2675 2676 2677 + static void (*serial8250_isa_config)(int port, struct uart_port *up, 2678 + unsigned short *capabilities); 2679 + 2680 + void serial8250_set_isa_configurator( 2681 + void (*v)(int port, struct uart_port *up, unsigned short *capabilities)) 2682 + { 2683 + serial8250_isa_config = v; 2684 + } 2685 + EXPORT_SYMBOL(serial8250_set_isa_configurator); 2686 + 2676 2687 static void __init serial8250_isa_init_ports(void) 2677 2688 { 2678 2689 struct uart_8250_port *up; ··· 2728 2719 up->port.regshift = old_serial_port[i].iomem_reg_shift; 2729 2720 set_io_from_upio(&up->port); 2730 2721 up->port.irqflags |= irqflag; 2722 + if (serial8250_isa_config != NULL) 2723 + serial8250_isa_config(i, &up->port, &up->capabilities); 2724 + 2731 2725 } 2732 2726 } 2733 2727 ··· 3022 3010 port.serial_in = p->serial_in; 3023 3011 port.serial_out = p->serial_out; 3024 3012 port.set_termios = p->set_termios; 3013 + port.pm = p->pm; 3025 3014 port.dev = &dev->dev; 3026 3015 port.irqflags |= irqflag; 3027 3016 ret = serial8250_register_port(&port); ··· 3189 3176 /* Possibly override set_termios call */ 3190 3177 if (port->set_termios) 3191 3178 uart->port.set_termios = port->set_termios; 3179 + if (port->pm) 3180 + uart->port.pm = port->pm; 3181 + 3182 + if (serial8250_isa_config != NULL) 3183 + serial8250_isa_config(0, &uart->port, 3184 + &uart->capabilities); 3192 3185 3193 3186 ret = uart_add_one_port(&serial8250_reg, &uart->port); 3194 3187 if (ret == 0)
-7
drivers/serial/Kconfig
··· 718 718 the Intel Moorestown platform. On other systems use the max3100 719 719 driver. 720 720 721 - config MRST_MAX3110_IRQ 722 - boolean "Enable GPIO IRQ for Max3110 over Moorestown" 723 - default n 724 - depends on SERIAL_MRST_MAX3110 && GPIO_LANGWELL 725 - help 726 - This has to be enabled after Moorestown GPIO driver is loaded 727 - 728 721 config SERIAL_MFD_HSU 729 722 tristate "Medfield High Speed UART support" 730 723 depends on PCI
+106 -50
drivers/serial/altera_uart.c
··· 15 15 16 16 #include <linux/kernel.h> 17 17 #include <linux/init.h> 18 + #include <linux/timer.h> 18 19 #include <linux/interrupt.h> 19 20 #include <linux/module.h> 20 21 #include <linux/console.h> ··· 28 27 #include <linux/altera_uart.h> 29 28 30 29 #define DRV_NAME "altera_uart" 30 + #define SERIAL_ALTERA_MAJOR 204 31 + #define SERIAL_ALTERA_MINOR 213 31 32 32 33 /* 33 34 * Altera UART register definitions according to the Nios UART datasheet: ··· 79 76 */ 80 77 struct altera_uart { 81 78 struct uart_port port; 79 + struct timer_list tmr; 82 80 unsigned int sigs; /* Local copy of line sigs */ 83 81 unsigned short imr; /* Local IMR mirror */ 84 82 }; 85 83 84 + static u32 altera_uart_readl(struct uart_port *port, int reg) 85 + { 86 + struct altera_uart_platform_uart *platp = port->private_data; 87 + 88 + return readl(port->membase + (reg << platp->bus_shift)); 89 + } 90 + 91 + static void altera_uart_writel(struct uart_port *port, u32 dat, int reg) 92 + { 93 + struct altera_uart_platform_uart *platp = port->private_data; 94 + 95 + writel(dat, port->membase + (reg << platp->bus_shift)); 96 + } 97 + 86 98 static unsigned int altera_uart_tx_empty(struct uart_port *port) 87 99 { 88 - return (readl(port->membase + ALTERA_UART_STATUS_REG) & 100 + return (altera_uart_readl(port, ALTERA_UART_STATUS_REG) & 89 101 ALTERA_UART_STATUS_TMT_MSK) ? TIOCSER_TEMT : 0; 90 102 } 91 103 ··· 109 91 struct altera_uart *pp = container_of(port, struct altera_uart, port); 110 92 unsigned int sigs; 111 93 112 - sigs = 113 - (readl(port->membase + ALTERA_UART_STATUS_REG) & 94 + sigs = (altera_uart_readl(port, ALTERA_UART_STATUS_REG) & 114 95 ALTERA_UART_STATUS_CTS_MSK) ? TIOCM_CTS : 0; 115 96 sigs |= (pp->sigs & TIOCM_RTS); 116 97 ··· 125 108 pp->imr |= ALTERA_UART_CONTROL_RTS_MSK; 126 109 else 127 110 pp->imr &= ~ALTERA_UART_CONTROL_RTS_MSK; 128 - writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); 111 + altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); 129 112 } 130 113 131 114 static void altera_uart_start_tx(struct uart_port *port) ··· 133 116 struct altera_uart *pp = container_of(port, struct altera_uart, port); 134 117 135 118 pp->imr |= ALTERA_UART_CONTROL_TRDY_MSK; 136 - writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); 119 + altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); 137 120 } 138 121 139 122 static void altera_uart_stop_tx(struct uart_port *port) ··· 141 124 struct altera_uart *pp = container_of(port, struct altera_uart, port); 142 125 143 126 pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK; 144 - writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); 127 + altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); 145 128 } 146 129 147 130 static void altera_uart_stop_rx(struct uart_port *port) ··· 149 132 struct altera_uart *pp = container_of(port, struct altera_uart, port); 150 133 151 134 pp->imr &= ~ALTERA_UART_CONTROL_RRDY_MSK; 152 - writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); 135 + altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); 153 136 } 154 137 155 138 static void altera_uart_break_ctl(struct uart_port *port, int break_state) ··· 162 145 pp->imr |= ALTERA_UART_CONTROL_TRBK_MSK; 163 146 else 164 147 pp->imr &= ~ALTERA_UART_CONTROL_TRBK_MSK; 165 - writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); 148 + altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); 166 149 spin_unlock_irqrestore(&port->lock, flags); 167 150 } 168 151 ··· 185 168 tty_termios_encode_baud_rate(termios, baud, baud); 186 169 187 170 spin_lock_irqsave(&port->lock, flags); 188 - writel(baudclk, port->membase + ALTERA_UART_DIVISOR_REG); 171 + uart_update_timeout(port, termios->c_cflag, baud); 172 + altera_uart_writel(port, baudclk, ALTERA_UART_DIVISOR_REG); 189 173 spin_unlock_irqrestore(&port->lock, flags); 190 174 } 191 175 ··· 196 178 unsigned char ch, flag; 197 179 unsigned short status; 198 180 199 - while ((status = readl(port->membase + ALTERA_UART_STATUS_REG)) & 181 + while ((status = altera_uart_readl(port, ALTERA_UART_STATUS_REG)) & 200 182 ALTERA_UART_STATUS_RRDY_MSK) { 201 - ch = readl(port->membase + ALTERA_UART_RXDATA_REG); 183 + ch = altera_uart_readl(port, ALTERA_UART_RXDATA_REG); 202 184 flag = TTY_NORMAL; 203 185 port->icount.rx++; 204 186 205 187 if (status & ALTERA_UART_STATUS_E_MSK) { 206 - writel(status, port->membase + ALTERA_UART_STATUS_REG); 188 + altera_uart_writel(port, status, 189 + ALTERA_UART_STATUS_REG); 207 190 208 191 if (status & ALTERA_UART_STATUS_BRK_MSK) { 209 192 port->icount.brk++; ··· 244 225 245 226 if (port->x_char) { 246 227 /* Send special char - probably flow control */ 247 - writel(port->x_char, port->membase + ALTERA_UART_TXDATA_REG); 228 + altera_uart_writel(port, port->x_char, ALTERA_UART_TXDATA_REG); 248 229 port->x_char = 0; 249 230 port->icount.tx++; 250 231 return; 251 232 } 252 233 253 - while (readl(port->membase + ALTERA_UART_STATUS_REG) & 234 + while (altera_uart_readl(port, ALTERA_UART_STATUS_REG) & 254 235 ALTERA_UART_STATUS_TRDY_MSK) { 255 236 if (xmit->head == xmit->tail) 256 237 break; 257 - writel(xmit->buf[xmit->tail], 258 - port->membase + ALTERA_UART_TXDATA_REG); 238 + altera_uart_writel(port, xmit->buf[xmit->tail], 239 + ALTERA_UART_TXDATA_REG); 259 240 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); 260 241 port->icount.tx++; 261 242 } ··· 265 246 266 247 if (xmit->head == xmit->tail) { 267 248 pp->imr &= ~ALTERA_UART_CONTROL_TRDY_MSK; 268 - writel(pp->imr, port->membase + ALTERA_UART_CONTROL_REG); 249 + altera_uart_writel(port, pp->imr, ALTERA_UART_CONTROL_REG); 269 250 } 270 251 } 271 252 ··· 275 256 struct altera_uart *pp = container_of(port, struct altera_uart, port); 276 257 unsigned int isr; 277 258 278 - isr = readl(port->membase + ALTERA_UART_STATUS_REG) & pp->imr; 259 + isr = altera_uart_readl(port, ALTERA_UART_STATUS_REG) & pp->imr; 279 260 280 261 spin_lock(&port->lock); 281 262 if (isr & ALTERA_UART_STATUS_RRDY_MSK) ··· 287 268 return IRQ_RETVAL(isr); 288 269 } 289 270 271 + static void altera_uart_timer(unsigned long data) 272 + { 273 + struct uart_port *port = (void *)data; 274 + struct altera_uart *pp = container_of(port, struct altera_uart, port); 275 + 276 + altera_uart_interrupt(0, port); 277 + mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); 278 + } 279 + 290 280 static void altera_uart_config_port(struct uart_port *port, int flags) 291 281 { 292 282 port->type = PORT_ALTERA_UART; 293 283 294 284 /* Clear mask, so no surprise interrupts. */ 295 - writel(0, port->membase + ALTERA_UART_CONTROL_REG); 285 + altera_uart_writel(port, 0, ALTERA_UART_CONTROL_REG); 296 286 /* Clear status register */ 297 - writel(0, port->membase + ALTERA_UART_STATUS_REG); 287 + altera_uart_writel(port, 0, ALTERA_UART_STATUS_REG); 298 288 } 299 289 300 290 static int altera_uart_startup(struct uart_port *port) ··· 311 283 struct altera_uart *pp = container_of(port, struct altera_uart, port); 312 284 unsigned long flags; 313 285 int ret; 286 + 287 + if (!port->irq) { 288 + setup_timer(&pp->tmr, altera_uart_timer, (unsigned long)port); 289 + mod_timer(&pp->tmr, jiffies + uart_poll_timeout(port)); 290 + return 0; 291 + } 314 292 315 293 ret = request_irq(port->irq, altera_uart_interrupt, IRQF_DISABLED, 316 294 DRV_NAME, port); ··· 350 316 351 317 spin_unlock_irqrestore(&port->lock, flags); 352 318 353 - free_irq(port->irq, port); 319 + if (port->irq) 320 + free_irq(port->irq, port); 321 + else 322 + del_timer_sync(&pp->tmr); 354 323 } 355 324 356 325 static const char *altera_uart_type(struct uart_port *port) ··· 421 384 port->iotype = SERIAL_IO_MEM; 422 385 port->irq = platp[i].irq; 423 386 port->uartclk = platp[i].uartclk; 424 - port->flags = ASYNC_BOOT_AUTOCONF; 387 + port->flags = UPF_BOOT_AUTOCONF; 425 388 port->ops = &altera_uart_ops; 389 + port->private_data = platp; 426 390 } 427 391 428 392 return 0; ··· 431 393 432 394 static void altera_uart_console_putc(struct uart_port *port, const char c) 433 395 { 434 - while (!(readl(port->membase + ALTERA_UART_STATUS_REG) & 396 + while (!(altera_uart_readl(port, ALTERA_UART_STATUS_REG) & 435 397 ALTERA_UART_STATUS_TRDY_MSK)) 436 398 cpu_relax(); 437 399 ··· 461 423 if (co->index < 0 || co->index >= CONFIG_SERIAL_ALTERA_UART_MAXPORTS) 462 424 return -EINVAL; 463 425 port = &altera_uart_ports[co->index].port; 464 - if (port->membase == 0) 426 + if (!port->membase) 465 427 return -ENODEV; 466 428 467 429 if (options) ··· 473 435 static struct uart_driver altera_uart_driver; 474 436 475 437 static struct console altera_uart_console = { 476 - .name = "ttyS", 438 + .name = "ttyAL", 477 439 .write = altera_uart_console_write, 478 440 .device = uart_console_device, 479 441 .setup = altera_uart_console_setup, ··· 504 466 static struct uart_driver altera_uart_driver = { 505 467 .owner = THIS_MODULE, 506 468 .driver_name = DRV_NAME, 507 - .dev_name = "ttyS", 508 - .major = TTY_MAJOR, 509 - .minor = 64, 469 + .dev_name = "ttyAL", 470 + .major = SERIAL_ALTERA_MAJOR, 471 + .minor = SERIAL_ALTERA_MINOR, 510 472 .nr = CONFIG_SERIAL_ALTERA_UART_MAXPORTS, 511 473 .cons = ALTERA_UART_CONSOLE, 512 474 }; ··· 515 477 { 516 478 struct altera_uart_platform_uart *platp = pdev->dev.platform_data; 517 479 struct uart_port *port; 518 - int i; 480 + struct resource *res_mem; 481 + struct resource *res_irq; 482 + int i = pdev->id; 519 483 520 - for (i = 0; i < CONFIG_SERIAL_ALTERA_UART_MAXPORTS && platp[i].mapbase; i++) { 521 - port = &altera_uart_ports[i].port; 484 + /* -1 emphasizes that the platform must have one port, no .N suffix */ 485 + if (i == -1) 486 + i = 0; 522 487 523 - port->line = i; 524 - port->type = PORT_ALTERA_UART; 525 - port->mapbase = platp[i].mapbase; 526 - port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE); 527 - port->iotype = SERIAL_IO_MEM; 528 - port->irq = platp[i].irq; 529 - port->uartclk = platp[i].uartclk; 530 - port->ops = &altera_uart_ops; 531 - port->flags = ASYNC_BOOT_AUTOCONF; 488 + if (i >= CONFIG_SERIAL_ALTERA_UART_MAXPORTS) 489 + return -EINVAL; 532 490 533 - uart_add_one_port(&altera_uart_driver, port); 534 - } 491 + port = &altera_uart_ports[i].port; 492 + 493 + res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 494 + if (res_mem) 495 + port->mapbase = res_mem->start; 496 + else if (platp->mapbase) 497 + port->mapbase = platp->mapbase; 498 + else 499 + return -EINVAL; 500 + 501 + res_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 502 + if (res_irq) 503 + port->irq = res_irq->start; 504 + else if (platp->irq) 505 + port->irq = platp->irq; 506 + 507 + port->membase = ioremap(port->mapbase, ALTERA_UART_SIZE); 508 + if (!port->membase) 509 + return -ENOMEM; 510 + 511 + port->line = i; 512 + port->type = PORT_ALTERA_UART; 513 + port->iotype = SERIAL_IO_MEM; 514 + port->uartclk = platp->uartclk; 515 + port->ops = &altera_uart_ops; 516 + port->flags = UPF_BOOT_AUTOCONF; 517 + port->private_data = platp; 518 + 519 + uart_add_one_port(&altera_uart_driver, port); 535 520 536 521 return 0; 537 522 } 538 523 539 524 static int __devexit altera_uart_remove(struct platform_device *pdev) 540 525 { 541 - struct uart_port *port; 542 - int i; 526 + struct uart_port *port = &altera_uart_ports[pdev->id].port; 543 527 544 - for (i = 0; i < CONFIG_SERIAL_ALTERA_UART_MAXPORTS; i++) { 545 - port = &altera_uart_ports[i].port; 546 - if (port) 547 - uart_remove_one_port(&altera_uart_driver, port); 548 - } 549 - 528 + uart_remove_one_port(&altera_uart_driver, port); 550 529 return 0; 551 530 } 552 531 ··· 605 550 MODULE_AUTHOR("Thomas Chou <thomas@wytron.com.tw>"); 606 551 MODULE_LICENSE("GPL"); 607 552 MODULE_ALIAS("platform:" DRV_NAME); 553 + MODULE_ALIAS_CHARDEV_MAJOR(SERIAL_ALTERA_MAJOR);
+6 -1
drivers/serial/bfin_sport_uart.c
··· 131 131 pr_debug("%s RCR1:%x, RCR2:%x\n", __func__, SPORT_GET_RCR1(up), SPORT_GET_RCR2(up)); 132 132 133 133 tclkdiv = sclk / (2 * baud_rate) - 1; 134 - rclkdiv = sclk / (2 * baud_rate * 2) - 1; 134 + /* The actual uart baud rate of devices vary between +/-2%. The sport 135 + * RX sample rate should be faster than the double of the worst case, 136 + * otherwise, wrong data are received. So, set sport RX clock to be 137 + * 3% faster. 138 + */ 139 + rclkdiv = sclk / (2 * baud_rate * 2 * 97 / 100) - 1; 135 140 SPORT_PUT_TCLKDIV(up, tclkdiv); 136 141 SPORT_PUT_RCLKDIV(up, rclkdiv); 137 142 SSYNC();
+2 -3
drivers/serial/imx.c
··· 327 327 { 328 328 struct circ_buf *xmit = &sport->port.state->xmit; 329 329 330 - while (!(readl(sport->port.membase + UTS) & UTS_TXFULL)) { 330 + while (!uart_circ_empty(xmit) && 331 + !(readl(sport->port.membase + UTS) & UTS_TXFULL)) { 331 332 /* send xmit->buf[xmit->tail] 332 333 * out the port here */ 333 334 writel(xmit->buf[xmit->tail], sport->port.membase + URTX0); 334 335 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); 335 336 sport->port.icount.tx++; 336 - if (uart_circ_empty(xmit)) 337 - break; 338 337 } 339 338 340 339 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
+3 -1
drivers/serial/jsm/jsm_driver.c
··· 172 172 jsm_uart_port_init here! */ 173 173 dev_err(&pdev->dev, "memory allocation for flipbuf failed\n"); 174 174 rc = -ENOMEM; 175 - goto out_free_irq; 175 + goto out_free_uart; 176 176 } 177 177 178 178 pci_set_drvdata(pdev, brd); 179 179 pci_save_state(pdev); 180 180 181 181 return 0; 182 + out_free_uart: 183 + jsm_remove_uart_port(brd); 182 184 out_free_irq: 183 185 jsm_remove_uart_port(brd); 184 186 free_irq(brd->irq, brd);
+25 -9
drivers/serial/max3107.c
··· 986 986 s->rxbuf = kzalloc(sizeof(u16) * (MAX3107_RX_FIFO_SIZE+2), GFP_KERNEL); 987 987 if (!s->rxbuf) { 988 988 pr_err("Allocating RX buffer failed\n"); 989 - return -ENOMEM; 989 + retval = -ENOMEM; 990 + goto err_free4; 990 991 } 991 992 s->rxstr = kzalloc(sizeof(u8) * MAX3107_RX_FIFO_SIZE, GFP_KERNEL); 992 993 if (!s->rxstr) { 993 994 pr_err("Allocating RX buffer failed\n"); 994 - return -ENOMEM; 995 + retval = -ENOMEM; 996 + goto err_free3; 995 997 } 996 998 /* SPI Tx buffer 997 999 * SPI transfer buffer ··· 1004 1002 s->txbuf = kzalloc(sizeof(u16) * MAX3107_TX_FIFO_SIZE + 3, GFP_KERNEL); 1005 1003 if (!s->txbuf) { 1006 1004 pr_err("Allocating TX buffer failed\n"); 1007 - return -ENOMEM; 1005 + retval = -ENOMEM; 1006 + goto err_free2; 1008 1007 } 1009 1008 /* Initialize shared data lock */ 1010 1009 spin_lock_init(&s->data_lock); ··· 1024 1021 buf[0] = MAX3107_REVID_REG; 1025 1022 if (max3107_rw(s, (u8 *)buf, (u8 *)buf, 2)) { 1026 1023 dev_err(&s->spi->dev, "SPI transfer for REVID read failed\n"); 1027 - return -EIO; 1024 + retval = -EIO; 1025 + goto err_free1; 1028 1026 } 1029 1027 if ((buf[0] & MAX3107_SPI_RX_DATA_MASK) != MAX3107_REVID1 && 1030 1028 (buf[0] & MAX3107_SPI_RX_DATA_MASK) != MAX3107_REVID2) { 1031 1029 dev_err(&s->spi->dev, "REVID %x does not match\n", 1032 1030 (buf[0] & MAX3107_SPI_RX_DATA_MASK)); 1033 - return -ENODEV; 1031 + retval = -ENODEV; 1032 + goto err_free1; 1034 1033 } 1035 1034 1036 1035 /* Disable all interrupts */ ··· 1052 1047 /* Perform SPI transfer */ 1053 1048 if (max3107_rw(s, (u8 *)buf, NULL, 4)) { 1054 1049 dev_err(&s->spi->dev, "SPI transfer for init failed\n"); 1055 - return -EIO; 1050 + retval = -EIO; 1051 + goto err_free1; 1056 1052 } 1057 1053 1058 1054 /* Register UART driver */ ··· 1061 1055 retval = uart_register_driver(&max3107_uart_driver); 1062 1056 if (retval) { 1063 1057 dev_err(&s->spi->dev, "Registering UART driver failed\n"); 1064 - return retval; 1058 + goto err_free1; 1065 1059 } 1066 1060 driver_registered = 1; 1067 1061 } ··· 1080 1074 retval = uart_add_one_port(&max3107_uart_driver, &s->port); 1081 1075 if (retval < 0) { 1082 1076 dev_err(&s->spi->dev, "Adding UART port failed\n"); 1083 - return retval; 1077 + goto err_free1; 1084 1078 } 1085 1079 1086 1080 if (pdata->configure) { 1087 1081 retval = pdata->configure(s); 1088 1082 if (retval < 0) 1089 - return retval; 1083 + goto err_free1; 1090 1084 } 1091 1085 1092 1086 /* Go to suspend mode */ ··· 1094 1088 pdata->hw_suspend(s, 1); 1095 1089 1096 1090 return 0; 1091 + 1092 + err_free1: 1093 + kfree(s->txbuf); 1094 + err_free2: 1095 + kfree(s->rxstr); 1096 + err_free3: 1097 + kfree(s->rxbuf); 1098 + err_free4: 1099 + kfree(s); 1100 + return retval; 1097 1101 } 1098 1102 EXPORT_SYMBOL_GPL(max3107_probe); 1099 1103
+33 -14
drivers/serial/mfd.c
··· 172 172 len += snprintf(buf + len, HSU_REGS_BUFSIZE - len, 173 173 "DIV: \t\t0x%08x\n", serial_in(up, UART_DIV)); 174 174 175 + if (len > HSU_REGS_BUFSIZE) 176 + len = HSU_REGS_BUFSIZE; 177 + 175 178 ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); 176 179 kfree(buf); 177 180 return ret; ··· 221 218 "D0SAR: \t\t0x%08x\n", chan_readl(chan, HSU_CH_D3SAR)); 222 219 len += snprintf(buf + len, HSU_REGS_BUFSIZE - len, 223 220 "D0TSR: \t\t0x%08x\n", chan_readl(chan, HSU_CH_D3TSR)); 221 + 222 + if (len > HSU_REGS_BUFSIZE) 223 + len = HSU_REGS_BUFSIZE; 224 224 225 225 ret = simple_read_from_buffer(user_buf, count, ppos, buf, len); 226 226 kfree(buf); ··· 931 925 cval |= UART_LCR_EPAR; 932 926 933 927 /* 928 + * The base clk is 50Mhz, and the baud rate come from: 929 + * baud = 50M * MUL / (DIV * PS * DLAB) 930 + * 934 931 * For those basic low baud rate we can get the direct 935 - * scalar from 2746800, like 115200 = 2746800/24, for those 936 - * higher baud rate, we have to handle them case by case, 937 - * but DIV reg is never touched as its default value 0x3d09 932 + * scalar from 2746800, like 115200 = 2746800/24. For those 933 + * higher baud rate, we handle them case by case, mainly by 934 + * adjusting the MUL/PS registers, and DIV register is kept 935 + * as default value 0x3d09 to make things simple 938 936 */ 939 937 baud = uart_get_baud_rate(port, termios, old, 0, 4000000); 940 - quot = uart_get_divisor(port, baud); 941 938 939 + quot = 1; 942 940 switch (baud) { 943 941 case 3500000: 944 942 mul = 0x3345; 945 943 ps = 0xC; 946 - quot = 1; 944 + break; 945 + case 3000000: 946 + mul = 0x2EE0; 947 947 break; 948 948 case 2500000: 949 949 mul = 0x2710; 950 - ps = 0x10; 951 - quot = 1; 952 950 break; 953 - case 18432000: 951 + case 2000000: 952 + mul = 0x1F40; 953 + break; 954 + case 1843200: 954 955 mul = 0x2400; 955 - ps = 0x10; 956 - quot = 1; 957 956 break; 958 957 case 1500000: 959 - mul = 0x1D4C; 960 - ps = 0xc; 961 - quot = 1; 958 + mul = 0x1770; 959 + break; 960 + case 1000000: 961 + mul = 0xFA0; 962 + break; 963 + case 500000: 964 + mul = 0x7D0; 962 965 break; 963 966 default: 964 - ; 967 + /* Use uart_get_divisor to get quot for other baud rates */ 968 + quot = 0; 965 969 } 970 + 971 + if (!quot) 972 + quot = uart_get_divisor(port, baud); 966 973 967 974 if ((up->port.uartclk / quot) < (2400 * 16)) 968 975 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_HSU_64_1B;
+216 -142
drivers/serial/mrst_max3110.c
··· 1 1 /* 2 - * max3110.c - spi uart protocol driver for Maxim 3110 on Moorestown 2 + * mrst_max3110.c - spi uart protocol driver for Maxim 3110 3 3 * 4 - * Copyright (C) Intel 2008 Feng Tang <feng.tang@intel.com> 4 + * Copyright (c) 2008-2010, Intel Corporation. 5 5 * 6 6 * This program is free software; you can redistribute it and/or modify it 7 7 * under the terms and conditions of the GNU General Public License, ··· 32 32 #include <linux/irq.h> 33 33 #include <linux/init.h> 34 34 #include <linux/console.h> 35 - #include <linux/sysrq.h> 36 - #include <linux/platform_device.h> 37 35 #include <linux/tty.h> 38 36 #include <linux/tty_flip.h> 39 37 #include <linux/serial_core.h> 40 38 #include <linux/serial_reg.h> 41 39 42 40 #include <linux/kthread.h> 43 - #include <linux/delay.h> 44 - #include <asm/atomic.h> 45 41 #include <linux/spi/spi.h> 46 - #include <linux/spi/dw_spi.h> 47 42 48 43 #include "mrst_max3110.h" 49 44 ··· 51 56 struct uart_max3110 { 52 57 struct uart_port port; 53 58 struct spi_device *spi; 54 - char *name; 59 + char name[24]; 55 60 56 61 wait_queue_head_t wq; 57 62 struct task_struct *main_thread; ··· 62 67 u16 cur_conf; 63 68 u8 clock; 64 69 u8 parity, word_7bits; 70 + u16 irq; 65 71 66 72 unsigned long uart_flags; 67 73 68 74 /* console related */ 69 75 struct circ_buf con_xmit; 70 - 71 - /* irq related */ 72 - u16 irq; 73 76 }; 74 77 75 78 /* global data structure, may need be removed */ 76 - struct uart_max3110 *pmax; 77 - static inline void receive_char(struct uart_max3110 *max, u8 ch); 79 + static struct uart_max3110 *pmax; 80 + 78 81 static void receive_chars(struct uart_max3110 *max, 79 82 unsigned char *str, int len); 80 - static int max3110_read_multi(struct uart_max3110 *max, int len, u8 *buf); 81 - static void max3110_console_receive(struct uart_max3110 *max); 83 + static int max3110_read_multi(struct uart_max3110 *max, u8 *buf); 84 + static void max3110_con_receive(struct uart_max3110 *max); 82 85 83 - int max3110_write_then_read(struct uart_max3110 *max, 84 - const u8 *txbuf, u8 *rxbuf, unsigned len, int always_fast) 86 + static int max3110_write_then_read(struct uart_max3110 *max, 87 + const void *txbuf, void *rxbuf, unsigned len, int always_fast) 85 88 { 86 89 struct spi_device *spi = max->spi; 87 90 struct spi_message message; 88 91 struct spi_transfer x; 89 92 int ret; 90 - 91 - if (!txbuf || !rxbuf) 92 - return -EINVAL; 93 93 94 94 spi_message_init(&message); 95 95 memset(&x, 0, sizeof x); ··· 94 104 spi_message_add_tail(&x, &message); 95 105 96 106 if (always_fast) 97 - x.speed_hz = 3125000; 107 + x.speed_hz = spi->max_speed_hz; 98 108 else if (max->baud) 99 109 x.speed_hz = max->baud; 100 110 ··· 103 113 return ret; 104 114 } 105 115 106 - /* Write a u16 to the device, and return one u16 read back */ 107 - int max3110_out(struct uart_max3110 *max, const u16 out) 116 + /* Write a 16b word to the device */ 117 + static int max3110_out(struct uart_max3110 *max, const u16 out) 108 118 { 109 - u16 tmp; 119 + void *buf; 120 + u16 *obuf, *ibuf; 121 + u8 ch; 110 122 int ret; 111 123 112 - ret = max3110_write_then_read(max, (u8 *)&out, (u8 *)&tmp, 2, 1); 113 - if (ret) 114 - return ret; 124 + buf = kzalloc(8, GFP_KERNEL | GFP_DMA); 125 + if (!buf) 126 + return -ENOMEM; 127 + 128 + obuf = buf; 129 + ibuf = buf + 4; 130 + *obuf = out; 131 + ret = max3110_write_then_read(max, obuf, ibuf, 2, 1); 132 + if (ret) { 133 + pr_warning(PR_FMT "%s(): get err msg %d when sending 0x%x\n", 134 + __func__, ret, out); 135 + goto exit; 136 + } 115 137 116 138 /* If some valid data is read back */ 117 - if (tmp & MAX3110_READ_DATA_AVAILABLE) 118 - receive_char(max, (tmp & 0xff)); 139 + if (*ibuf & MAX3110_READ_DATA_AVAILABLE) { 140 + ch = *ibuf & 0xff; 141 + receive_chars(max, &ch, 1); 142 + } 119 143 144 + exit: 145 + kfree(buf); 120 146 return ret; 121 147 } 122 148 123 - #define MAX_READ_LEN 20 124 149 /* 125 150 * This is usually used to read data from SPIC RX FIFO, which doesn't 126 - * need any delay like flushing character out. It returns how many 127 - * valide bytes are read back 151 + * need any delay like flushing character out. 152 + * 153 + * Return how many valide bytes are read back 128 154 */ 129 - static int max3110_read_multi(struct uart_max3110 *max, int len, u8 *buf) 155 + static int max3110_read_multi(struct uart_max3110 *max, u8 *rxbuf) 130 156 { 131 - u16 out[MAX_READ_LEN], in[MAX_READ_LEN]; 132 - u8 *pbuf, valid_str[MAX_READ_LEN]; 133 - int i, j, bytelen; 157 + void *buf; 158 + u16 *obuf, *ibuf; 159 + u8 *pbuf, valid_str[M3110_RX_FIFO_DEPTH]; 160 + int i, j, blen; 134 161 135 - if (len > MAX_READ_LEN) { 136 - pr_err(PR_FMT "read len %d is too large\n", len); 162 + blen = M3110_RX_FIFO_DEPTH * sizeof(u16); 163 + buf = kzalloc(blen * 2, GFP_KERNEL | GFP_DMA); 164 + if (!buf) { 165 + pr_warning(PR_FMT "%s(): fail to alloc dma buffer\n", __func__); 137 166 return 0; 138 167 } 139 168 140 - bytelen = len * 2; 141 - memset(out, 0, bytelen); 142 - memset(in, 0, bytelen); 169 + /* tx/rx always have the same length */ 170 + obuf = buf; 171 + ibuf = buf + blen; 143 172 144 - if (max3110_write_then_read(max, (u8 *)out, (u8 *)in, bytelen, 1)) 173 + if (max3110_write_then_read(max, obuf, ibuf, blen, 1)) { 174 + kfree(buf); 145 175 return 0; 176 + } 146 177 147 - /* If caller don't provide a buffer, then handle received char */ 148 - pbuf = buf ? buf : valid_str; 178 + /* If caller doesn't provide a buffer, then handle received char */ 179 + pbuf = rxbuf ? rxbuf : valid_str; 149 180 150 - for (i = 0, j = 0; i < len; i++) { 151 - if (in[i] & MAX3110_READ_DATA_AVAILABLE) 152 - pbuf[j++] = (u8)(in[i] & 0xff); 181 + for (i = 0, j = 0; i < M3110_RX_FIFO_DEPTH; i++) { 182 + if (ibuf[i] & MAX3110_READ_DATA_AVAILABLE) 183 + pbuf[j++] = ibuf[i] & 0xff; 153 184 } 154 185 155 186 if (j && (pbuf == valid_str)) 156 187 receive_chars(max, valid_str, j); 157 188 189 + kfree(buf); 158 190 return j; 159 191 } 160 192 ··· 190 178 xmit->buf[xmit->head] = (char)ch; 191 179 xmit->head = (xmit->head + 1) & (PAGE_SIZE - 1); 192 180 } 193 - 194 - 195 - if (!test_and_set_bit(CON_TX_NEEDED, &max->uart_flags)) 196 - wake_up_process(max->main_thread); 197 181 } 198 182 199 183 /* ··· 205 197 return; 206 198 207 199 uart_console_write(&pmax->port, s, count, serial_m3110_con_putchar); 200 + 201 + if (!test_and_set_bit(CON_TX_NEEDED, &pmax->uart_flags)) 202 + wake_up_process(pmax->main_thread); 208 203 } 209 204 210 205 static int __init ··· 220 209 int flow = 'n'; 221 210 222 211 pr_info(PR_FMT "setting up console\n"); 212 + 213 + if (co->index == -1) 214 + co->index = 0; 223 215 224 216 if (!max) { 225 217 pr_err(PR_FMT "pmax is NULL, return"); ··· 254 240 .data = &serial_m3110_reg, 255 241 }; 256 242 257 - #define MRST_CONSOLE (&serial_m3110_console) 258 - 259 243 static unsigned int serial_m3110_tx_empty(struct uart_port *port) 260 244 { 261 245 return 1; ··· 271 259 } 272 260 273 261 #define WORDS_PER_XFER 128 274 - static inline void send_circ_buf(struct uart_max3110 *max, 262 + static void send_circ_buf(struct uart_max3110 *max, 275 263 struct circ_buf *xmit) 276 264 { 277 - int len, left = 0; 278 - u16 obuf[WORDS_PER_XFER], ibuf[WORDS_PER_XFER]; 265 + void *buf; 266 + u16 *obuf, *ibuf; 279 267 u8 valid_str[WORDS_PER_XFER]; 280 - int i, j; 268 + int i, j, len, blen, dma_size, left, ret = 0; 269 + 270 + 271 + dma_size = WORDS_PER_XFER * sizeof(u16) * 2; 272 + buf = kzalloc(dma_size, GFP_KERNEL | GFP_DMA); 273 + if (!buf) 274 + return; 275 + obuf = buf; 276 + ibuf = buf + dma_size/2; 281 277 282 278 while (!uart_circ_empty(xmit)) { 283 279 left = uart_circ_chars_pending(xmit); 284 280 while (left) { 285 - len = (left >= WORDS_PER_XFER) ? WORDS_PER_XFER : left; 281 + len = min(left, WORDS_PER_XFER); 282 + blen = len * sizeof(u16); 283 + memset(ibuf, 0, blen); 286 284 287 - memset(obuf, 0, len * 2); 288 - memset(ibuf, 0, len * 2); 289 285 for (i = 0; i < len; i++) { 290 286 obuf[i] = (u8)xmit->buf[xmit->tail] | WD_TAG; 291 287 xmit->tail = (xmit->tail + 1) & 292 288 (UART_XMIT_SIZE - 1); 293 289 } 294 - max3110_write_then_read(max, (u8 *)obuf, 295 - (u8 *)ibuf, len * 2, 0); 290 + 291 + /* Fail to send msg to console is not very critical */ 292 + ret = max3110_write_then_read(max, obuf, ibuf, blen, 0); 293 + if (ret) 294 + pr_warning(PR_FMT "%s(): get err msg %d\n", 295 + __func__, ret); 296 296 297 297 for (i = 0, j = 0; i < len; i++) { 298 298 if (ibuf[i] & MAX3110_READ_DATA_AVAILABLE) 299 - valid_str[j++] = (u8)(ibuf[i] & 0xff); 299 + valid_str[j++] = ibuf[i] & 0xff; 300 300 } 301 301 302 302 if (j) ··· 318 294 left -= len; 319 295 } 320 296 } 297 + 298 + kfree(buf); 321 299 } 322 300 323 301 static void transmit_char(struct uart_max3110 *max) ··· 339 313 serial_m3110_stop_tx(port); 340 314 } 341 315 342 - /* This will be called by uart_write() and tty_write, can't 343 - * go to sleep */ 316 + /* 317 + * This will be called by uart_write() and tty_write, can't 318 + * go to sleep 319 + */ 344 320 static void serial_m3110_start_tx(struct uart_port *port) 345 321 { 346 322 struct uart_max3110 *max = ··· 364 336 365 337 tty = port->state->port.tty; 366 338 if (!tty) 367 - return; /* receive some char before the tty is opened */ 339 + return; 368 340 369 341 while (len) { 370 342 usable = tty_buffer_request_room(tty, len); ··· 372 344 tty_insert_flip_string(tty, str, usable); 373 345 str += usable; 374 346 port->icount.rx += usable; 375 - tty_flip_buffer_push(tty); 376 347 } 377 348 len -= usable; 378 349 } 350 + tty_flip_buffer_push(tty); 379 351 } 380 352 381 - static inline void receive_char(struct uart_max3110 *max, u8 ch) 382 - { 383 - receive_chars(max, &ch, 1); 384 - } 385 - 386 - static void max3110_console_receive(struct uart_max3110 *max) 353 + /* 354 + * This routine will be used in read_thread or RX IRQ handling, 355 + * it will first do one round buffer read(8 words), if there is some 356 + * valid RX data, will try to read 5 more rounds till all data 357 + * is read out. 358 + * 359 + * Use stack space as data buffer to save some system load, and chose 360 + * 504 Btyes as a threadhold to do a bulk push to upper tty layer when 361 + * receiving bulk data, a much bigger buffer may cause stack overflow 362 + */ 363 + static void max3110_con_receive(struct uart_max3110 *max) 387 364 { 388 365 int loop = 1, num, total = 0; 389 366 u8 recv_buf[512], *pbuf; 390 367 391 368 pbuf = recv_buf; 392 369 do { 393 - num = max3110_read_multi(max, 8, pbuf); 370 + num = max3110_read_multi(max, pbuf); 394 371 395 372 if (num) { 396 - loop = 10; 373 + loop = 5; 397 374 pbuf += num; 398 375 total += num; 399 376 400 - if (total >= 500) { 377 + if (total >= 504) { 401 378 receive_chars(max, recv_buf, total); 402 379 pbuf = recv_buf; 403 380 total = 0; ··· 430 397 mutex_lock(&max->thread_mutex); 431 398 432 399 if (test_and_clear_bit(BIT_IRQ_PENDING, &max->uart_flags)) 433 - max3110_console_receive(max); 400 + max3110_con_receive(max); 434 401 435 402 /* first handle console output */ 436 403 if (test_and_clear_bit(CON_TX_NEEDED, &max->uart_flags)) ··· 447 414 return ret; 448 415 } 449 416 450 - #ifdef CONFIG_MRST_MAX3110_IRQ 451 417 static irqreturn_t serial_m3110_irq(int irq, void *dev_id) 452 418 { 453 419 struct uart_max3110 *max = dev_id; ··· 458 426 459 427 return IRQ_HANDLED; 460 428 } 461 - #else 429 + 462 430 /* if don't use RX IRQ, then need a thread to polling read */ 463 431 static int max3110_read_thread(void *_max) 464 432 { ··· 466 434 467 435 pr_info(PR_FMT "start read thread\n"); 468 436 do { 469 - mutex_lock(&max->thread_mutex); 470 - max3110_console_receive(max); 471 - mutex_unlock(&max->thread_mutex); 437 + /* 438 + * If can't acquire the mutex, it means the main thread 439 + * is running which will also perform the rx job 440 + */ 441 + if (mutex_trylock(&max->thread_mutex)) { 442 + max3110_con_receive(max); 443 + mutex_unlock(&max->thread_mutex); 444 + } 472 445 473 446 set_current_state(TASK_INTERRUPTIBLE); 474 447 schedule_timeout(HZ / 20); ··· 481 444 482 445 return 0; 483 446 } 484 - #endif 485 447 486 448 static int serial_m3110_startup(struct uart_port *port) 487 449 { ··· 489 453 u16 config = 0; 490 454 int ret = 0; 491 455 492 - if (port->line != 0) 456 + if (port->line != 0) { 493 457 pr_err(PR_FMT "uart port startup failed\n"); 458 + return -1; 459 + } 494 460 495 - /* firstly disable all IRQ and config it to 115200, 8n1 */ 461 + /* Disable all IRQ and config it to 115200, 8n1 */ 496 462 config = WC_TAG | WC_FIFO_ENABLE 497 463 | WC_1_STOPBITS 498 464 | WC_8BIT_WORD 499 465 | WC_BAUD_DR2; 500 - ret = max3110_out(max, config); 501 466 502 467 /* as we use thread to handle tx/rx, need set low latency */ 503 468 port->state->port.tty->low_latency = 1; 504 469 505 - #ifdef CONFIG_MRST_MAX3110_IRQ 506 - ret = request_irq(max->irq, serial_m3110_irq, 470 + if (max->irq) { 471 + max->read_thread = NULL; 472 + ret = request_irq(max->irq, serial_m3110_irq, 507 473 IRQ_TYPE_EDGE_FALLING, "max3110", max); 508 - if (ret) 509 - return ret; 474 + if (ret) { 475 + max->irq = 0; 476 + pr_err(PR_FMT "unable to allocate IRQ, polling\n"); 477 + } else { 478 + /* Enable RX IRQ only */ 479 + config |= WC_RXA_IRQ_ENABLE; 480 + } 481 + } 510 482 511 - /* enable RX IRQ only */ 512 - config |= WC_RXA_IRQ_ENABLE; 513 - max3110_out(max, config); 514 - #else 515 - /* if IRQ is disabled, start a read thread for input data */ 516 - max->read_thread = 517 - kthread_run(max3110_read_thread, max, "max3110_read"); 518 - #endif 483 + if (max->irq == 0) { 484 + /* If IRQ is disabled, start a read thread for input data */ 485 + max->read_thread = 486 + kthread_run(max3110_read_thread, max, "max3110_read"); 487 + if (IS_ERR(max->read_thread)) { 488 + ret = PTR_ERR(max->read_thread); 489 + max->read_thread = NULL; 490 + pr_err(PR_FMT "Can't create read thread!\n"); 491 + return ret; 492 + } 493 + } 494 + 495 + ret = max3110_out(max, config); 496 + if (ret) { 497 + if (max->irq) 498 + free_irq(max->irq, max); 499 + if (max->read_thread) 500 + kthread_stop(max->read_thread); 501 + max->read_thread = NULL; 502 + return ret; 503 + } 519 504 520 505 max->cur_conf = config; 521 506 return 0; ··· 553 496 max->read_thread = NULL; 554 497 } 555 498 556 - #ifdef CONFIG_MRST_MAX3110_IRQ 557 - free_irq(max->irq, max); 558 - #endif 499 + if (max->irq) 500 + free_irq(max->irq, max); 559 501 560 502 /* Disable interrupts from this port */ 561 503 config = WC_TAG | WC_SW_SHDI; ··· 572 516 573 517 static void serial_m3110_config_port(struct uart_port *port, int flags) 574 518 { 575 - /* give it fake type */ 576 - port->type = PORT_PXA; 519 + port->type = PORT_MAX3100; 577 520 } 578 521 579 522 static int ··· 607 552 new_conf |= WC_7BIT_WORD; 608 553 break; 609 554 default: 555 + /* We only support CS7 & CS8 */ 556 + termios->c_cflag &= ~CSIZE; 557 + termios->c_cflag |= CS8; 610 558 case CS8: 611 559 cval = UART_LCR_WLEN8; 612 560 new_conf |= WC_8BIT_WORD; ··· 618 560 619 561 baud = uart_get_baud_rate(port, termios, old, 0, 230400); 620 562 621 - /* first calc the div for 1.8MHZ clock case */ 563 + /* First calc the div for 1.8MHZ clock case */ 622 564 switch (baud) { 623 565 case 300: 624 566 clk_div = WC_BAUD_DR384; ··· 654 596 if (max->clock & MAX3110_HIGH_CLK) 655 597 break; 656 598 default: 657 - /* pick the previous baud rate */ 599 + /* Pick the previous baud rate */ 658 600 baud = max->baud; 659 601 clk_div = max->cur_conf & WC_BAUD_DIV_MASK; 660 602 tty_termios_encode_baud_rate(termios, baud, baud); ··· 662 604 663 605 if (max->clock & MAX3110_HIGH_CLK) { 664 606 clk_div += 1; 665 - /* high clk version max3110 doesn't support B300 */ 666 - if (baud == 300) 607 + /* High clk version max3110 doesn't support B300 */ 608 + if (baud == 300) { 667 609 baud = 600; 610 + clk_div = WC_BAUD_DR384; 611 + } 668 612 if (baud == 230400) 669 613 clk_div = WC_BAUD_DR1; 670 614 tty_termios_encode_baud_rate(termios, baud, baud); 671 615 } 672 616 673 617 new_conf = (new_conf & ~WC_BAUD_DIV_MASK) | clk_div; 618 + 619 + if (unlikely(termios->c_cflag & CMSPAR)) 620 + termios->c_cflag &= ~CMSPAR; 621 + 674 622 if (termios->c_cflag & CSTOPB) 675 623 new_conf |= WC_2_STOPBITS; 676 624 else ··· 696 632 697 633 new_conf |= WC_TAG; 698 634 if (new_conf != max->cur_conf) { 699 - max3110_out(max, new_conf); 700 - max->cur_conf = new_conf; 701 - max->baud = baud; 635 + if (!max3110_out(max, new_conf)) { 636 + max->cur_conf = new_conf; 637 + max->baud = baud; 638 + } 702 639 } 703 640 } 704 641 705 - /* don't handle hw handshaking */ 642 + /* Don't handle hw handshaking */ 706 643 static unsigned int serial_m3110_get_mctrl(struct uart_port *port) 707 644 { 708 645 return TIOCM_DSR | TIOCM_CAR | TIOCM_DSR; ··· 737 672 .break_ctl = serial_m3110_break_ctl, 738 673 .startup = serial_m3110_startup, 739 674 .shutdown = serial_m3110_shutdown, 740 - .set_termios = serial_m3110_set_termios, /* must have */ 675 + .set_termios = serial_m3110_set_termios, 741 676 .pm = serial_m3110_pm, 742 677 .type = serial_m3110_type, 743 678 .release_port = serial_m3110_release_port, ··· 753 688 .major = TTY_MAJOR, 754 689 .minor = 64, 755 690 .nr = 1, 756 - .cons = MRST_CONSOLE, 691 + .cons = &serial_m3110_console, 757 692 }; 758 693 694 + #ifdef CONFIG_PM 759 695 static int serial_m3110_suspend(struct spi_device *spi, pm_message_t state) 760 696 { 697 + struct uart_max3110 *max = spi_get_drvdata(spi); 698 + 699 + disable_irq(max->irq); 700 + uart_suspend_port(&serial_m3110_reg, &max->port); 701 + max3110_out(max, max->cur_conf | WC_SW_SHDI); 761 702 return 0; 762 703 } 763 704 764 705 static int serial_m3110_resume(struct spi_device *spi) 765 706 { 707 + struct uart_max3110 *max = spi_get_drvdata(spi); 708 + 709 + max3110_out(max, max->cur_conf); 710 + uart_resume_port(&serial_m3110_reg, &max->port); 711 + enable_irq(max->irq); 766 712 return 0; 767 713 } 714 + #else 715 + #define serial_m3110_suspend NULL 716 + #define serial_m3110_resume NULL 717 + #endif 768 718 769 - static struct dw_spi_chip spi0_uart = { 770 - .poll_mode = 1, 771 - .enable_dma = 0, 772 - .type = SPI_FRF_SPI, 773 - }; 774 - 775 - static int serial_m3110_probe(struct spi_device *spi) 719 + static int __devinit serial_m3110_probe(struct spi_device *spi) 776 720 { 777 721 struct uart_max3110 *max; 778 - int ret; 779 - unsigned char *buffer; 722 + void *buffer; 780 723 u16 res; 724 + int ret = 0; 725 + 781 726 max = kzalloc(sizeof(*max), GFP_KERNEL); 782 727 if (!max) 783 728 return -ENOMEM; 784 729 785 - /* set spi info */ 786 - spi->mode = SPI_MODE_0; 730 + /* Set spi info */ 787 731 spi->bits_per_word = 16; 788 732 max->clock = MAX3110_HIGH_CLK; 789 - spi->controller_data = &spi0_uart; 790 733 791 734 spi_setup(spi); 792 735 793 - max->port.type = PORT_PXA; /* need apply for a max3110 type */ 794 - max->port.fifosize = 2; /* only have 16b buffer */ 736 + max->port.type = PORT_MAX3100; 737 + max->port.fifosize = 2; /* Only have 16b buffer */ 795 738 max->port.ops = &serial_m3110_ops; 796 739 max->port.line = 0; 797 740 max->port.dev = &spi->dev; 798 741 max->port.uartclk = 115200; 799 742 800 743 max->spi = spi; 801 - max->name = spi->modalias; /* use spi name as the name */ 744 + strcpy(max->name, spi->modalias); 802 745 max->irq = (u16)spi->irq; 803 746 804 747 mutex_init(&max->thread_mutex); ··· 828 755 ret = -ENODEV; 829 756 goto err_get_page; 830 757 } 831 - buffer = (unsigned char *)__get_free_page(GFP_KERNEL); 758 + 759 + buffer = (void *)__get_free_page(GFP_KERNEL); 832 760 if (!buffer) { 833 761 ret = -ENOMEM; 834 762 goto err_get_page; 835 763 } 836 - max->con_xmit.buf = (unsigned char *)buffer; 837 - max->con_xmit.head = max->con_xmit.tail = 0; 764 + max->con_xmit.buf = buffer; 765 + max->con_xmit.head = 0; 766 + max->con_xmit.tail = 0; 838 767 839 768 max->main_thread = kthread_run(max3110_main_thread, 840 769 max, "max3110_main"); ··· 845 770 goto err_kthread; 846 771 } 847 772 773 + spi_set_drvdata(spi, max); 848 774 pmax = max; 849 - /* give membase a psudo value to pass serial_core's check */ 775 + 776 + /* Give membase a psudo value to pass serial_core's check */ 850 777 max->port.membase = (void *)0xff110000; 851 778 uart_add_one_port(&serial_m3110_reg, &max->port); 852 779 ··· 857 780 err_kthread: 858 781 free_page((unsigned long)buffer); 859 782 err_get_page: 860 - pmax = NULL; 861 783 kfree(max); 862 784 return ret; 863 785 } 864 786 865 - static int max3110_remove(struct spi_device *dev) 787 + static int __devexit serial_m3110_remove(struct spi_device *dev) 866 788 { 867 - struct uart_max3110 *max = pmax; 789 + struct uart_max3110 *max = spi_get_drvdata(dev); 868 790 869 - if (!pmax) 791 + if (!max) 870 792 return 0; 871 793 872 - pmax = NULL; 873 794 uart_remove_one_port(&serial_m3110_reg, &max->port); 874 795 875 796 free_page((unsigned long)max->con_xmit.buf); ··· 886 811 .owner = THIS_MODULE, 887 812 }, 888 813 .probe = serial_m3110_probe, 889 - .remove = __devexit_p(max3110_remove), 814 + .remove = __devexit_p(serial_m3110_remove), 890 815 .suspend = serial_m3110_suspend, 891 816 .resume = serial_m3110_resume, 892 817 }; 893 818 894 - 895 - int __init serial_m3110_init(void) 819 + static int __init serial_m3110_init(void) 896 820 { 897 821 int ret = 0; 898 822 ··· 906 832 return ret; 907 833 } 908 834 909 - void __exit serial_m3110_exit(void) 835 + static void __exit serial_m3110_exit(void) 910 836 { 911 837 spi_unregister_driver(&uart_max3110_driver); 912 838 uart_unregister_driver(&serial_m3110_reg); ··· 915 841 module_init(serial_m3110_init); 916 842 module_exit(serial_m3110_exit); 917 843 918 - MODULE_LICENSE("GPL"); 844 + MODULE_LICENSE("GPL v2"); 919 845 MODULE_ALIAS("max3110-uart");
+1
drivers/serial/mrst_max3110.h
··· 56 56 #define WC_BAUD_DR192 (0xE) 57 57 #define WC_BAUD_DR384 (0xF) 58 58 59 + #define M3110_RX_FIFO_DEPTH 8 59 60 #endif
+29 -20
drivers/serial/serial_core.c
··· 1074 1074 * NB: both 1->0 and 0->1 transitions are counted except for 1075 1075 * RI where only 0->1 is counted. 1076 1076 */ 1077 - static int uart_get_count(struct uart_state *state, 1078 - struct serial_icounter_struct __user *icnt) 1077 + static int uart_get_icount(struct tty_struct *tty, 1078 + struct serial_icounter_struct *icount) 1079 1079 { 1080 - struct serial_icounter_struct icount; 1080 + struct uart_state *state = tty->driver_data; 1081 1081 struct uart_icount cnow; 1082 1082 struct uart_port *uport = state->uart_port; 1083 1083 ··· 1085 1085 memcpy(&cnow, &uport->icount, sizeof(struct uart_icount)); 1086 1086 spin_unlock_irq(&uport->lock); 1087 1087 1088 - icount.cts = cnow.cts; 1089 - icount.dsr = cnow.dsr; 1090 - icount.rng = cnow.rng; 1091 - icount.dcd = cnow.dcd; 1092 - icount.rx = cnow.rx; 1093 - icount.tx = cnow.tx; 1094 - icount.frame = cnow.frame; 1095 - icount.overrun = cnow.overrun; 1096 - icount.parity = cnow.parity; 1097 - icount.brk = cnow.brk; 1098 - icount.buf_overrun = cnow.buf_overrun; 1088 + icount->cts = cnow.cts; 1089 + icount->dsr = cnow.dsr; 1090 + icount->rng = cnow.rng; 1091 + icount->dcd = cnow.dcd; 1092 + icount->rx = cnow.rx; 1093 + icount->tx = cnow.tx; 1094 + icount->frame = cnow.frame; 1095 + icount->overrun = cnow.overrun; 1096 + icount->parity = cnow.parity; 1097 + icount->brk = cnow.brk; 1098 + icount->buf_overrun = cnow.buf_overrun; 1099 1099 1100 - return copy_to_user(icnt, &icount, sizeof(icount)) ? -EFAULT : 0; 1100 + return 0; 1101 1101 } 1102 1102 1103 1103 /* ··· 1149 1149 switch (cmd) { 1150 1150 case TIOCMIWAIT: 1151 1151 ret = uart_wait_modem_status(state, arg); 1152 - break; 1153 - 1154 - case TIOCGICOUNT: 1155 - ret = uart_get_count(state, uarg); 1156 1152 break; 1157 1153 } 1158 1154 ··· 2061 2065 /* 2062 2066 * Re-enable the console device after suspending. 2063 2067 */ 2064 - if (uart_console(uport)) { 2068 + if (console_suspend_enabled && uart_console(uport)) { 2069 + /* 2070 + * First try to use the console cflag setting. 2071 + */ 2072 + memset(&termios, 0, sizeof(struct ktermios)); 2073 + termios.c_cflag = uport->cons->cflag; 2074 + 2075 + /* 2076 + * If that's unset, use the tty termios setting. 2077 + */ 2078 + if (port->tty && port->tty->termios && termios.c_cflag == 0) 2079 + termios = *(port->tty->termios); 2080 + 2065 2081 uart_change_pm(state, 0); 2066 2082 uport->ops->set_termios(uport, &termios, NULL); 2067 2083 console_start(uport->cons); ··· 2291 2283 #endif 2292 2284 .tiocmget = uart_tiocmget, 2293 2285 .tiocmset = uart_tiocmset, 2286 + .get_icount = uart_get_icount, 2294 2287 #ifdef CONFIG_CONSOLE_POLL 2295 2288 .poll_init = uart_poll_init, 2296 2289 .poll_get_char = uart_poll_get_char,
+25 -1
drivers/serial/uartlite.c
··· 322 322 return -EINVAL; 323 323 } 324 324 325 + #ifdef CONFIG_CONSOLE_POLL 326 + static int ulite_get_poll_char(struct uart_port *port) 327 + { 328 + if (!(ioread32be(port->membase + ULITE_STATUS) 329 + & ULITE_STATUS_RXVALID)) 330 + return NO_POLL_CHAR; 331 + 332 + return ioread32be(port->membase + ULITE_RX); 333 + } 334 + 335 + static void ulite_put_poll_char(struct uart_port *port, unsigned char ch) 336 + { 337 + while (ioread32be(port->membase + ULITE_STATUS) & ULITE_STATUS_TXFULL) 338 + cpu_relax(); 339 + 340 + /* write char to device */ 341 + iowrite32be(ch, port->membase + ULITE_TX); 342 + } 343 + #endif 344 + 325 345 static struct uart_ops ulite_ops = { 326 346 .tx_empty = ulite_tx_empty, 327 347 .set_mctrl = ulite_set_mctrl, ··· 358 338 .release_port = ulite_release_port, 359 339 .request_port = ulite_request_port, 360 340 .config_port = ulite_config_port, 361 - .verify_port = ulite_verify_port 341 + .verify_port = ulite_verify_port, 342 + #ifdef CONFIG_CONSOLE_POLL 343 + .poll_get_char = ulite_get_poll_char, 344 + .poll_put_char = ulite_put_poll_char, 345 + #endif 362 346 }; 363 347 364 348 /* ---------------------------------------------------------------------
+21 -19
drivers/usb/serial/ark3116.c
··· 411 411 return result; 412 412 } 413 413 414 + static int ark3116_get_icount(struct tty_struct *tty, 415 + struct serial_icounter_struct *icount) 416 + { 417 + struct usb_serial_port *port = tty->driver_data; 418 + struct ark3116_private *priv = usb_get_serial_port_data(port); 419 + struct async_icount cnow = priv->icount; 420 + icount->cts = cnow.cts; 421 + icount->dsr = cnow.dsr; 422 + icount->rng = cnow.rng; 423 + icount->dcd = cnow.dcd; 424 + icount->rx = cnow.rx; 425 + icount->tx = cnow.tx; 426 + icount->frame = cnow.frame; 427 + icount->overrun = cnow.overrun; 428 + icount->parity = cnow.parity; 429 + icount->brk = cnow.brk; 430 + icount->buf_overrun = cnow.buf_overrun; 431 + return 0; 432 + } 433 + 414 434 static int ark3116_ioctl(struct tty_struct *tty, struct file *file, 415 435 unsigned int cmd, unsigned long arg) 416 436 { ··· 480 460 return 0; 481 461 } 482 462 break; 483 - case TIOCGICOUNT: { 484 - struct serial_icounter_struct icount; 485 - struct async_icount cnow = priv->icount; 486 - memset(&icount, 0, sizeof(icount)); 487 - icount.cts = cnow.cts; 488 - icount.dsr = cnow.dsr; 489 - icount.rng = cnow.rng; 490 - icount.dcd = cnow.dcd; 491 - icount.rx = cnow.rx; 492 - icount.tx = cnow.tx; 493 - icount.frame = cnow.frame; 494 - icount.overrun = cnow.overrun; 495 - icount.parity = cnow.parity; 496 - icount.brk = cnow.brk; 497 - icount.buf_overrun = cnow.buf_overrun; 498 - if (copy_to_user(user_arg, &icount, sizeof(icount))) 499 - return -EFAULT; 500 - return 0; 501 - } 502 463 } 503 464 504 465 return -ENOIOCTLCMD; ··· 737 736 .ioctl = ark3116_ioctl, 738 737 .tiocmget = ark3116_tiocmget, 739 738 .tiocmset = ark3116_tiocmset, 739 + .get_icount = ark3116_get_icount, 740 740 .open = ark3116_open, 741 741 .close = ark3116_close, 742 742 .break_ctl = ark3116_break_ctl,
+1
drivers/usb/serial/ftdi_sio.c
··· 2168 2168 * - mask passed in arg for lines of interest 2169 2169 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) 2170 2170 * Caller should use TIOCGICOUNT to see which one it was. 2171 + * (except that the driver doesn't support it !) 2171 2172 * 2172 2173 * This code is borrowed from linux/drivers/char/serial.c 2173 2174 */
+27 -22
drivers/usb/serial/io_edgeport.c
··· 222 222 static int edge_tiocmget(struct tty_struct *tty, struct file *file); 223 223 static int edge_tiocmset(struct tty_struct *tty, struct file *file, 224 224 unsigned int set, unsigned int clear); 225 + static int edge_get_icount(struct tty_struct *tty, 226 + struct serial_icounter_struct *icount); 225 227 static int edge_startup(struct usb_serial *serial); 226 228 static void edge_disconnect(struct usb_serial *serial); 227 229 static void edge_release(struct usb_serial *serial); ··· 1626 1624 return result; 1627 1625 } 1628 1626 1627 + static int edge_get_icount(struct tty_struct *tty, 1628 + struct serial_icounter_struct *icount) 1629 + { 1630 + struct usb_serial_port *port = tty->driver_data; 1631 + struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1632 + struct async_icount cnow; 1633 + cnow = edge_port->icount; 1634 + 1635 + icount->cts = cnow.cts; 1636 + icount->dsr = cnow.dsr; 1637 + icount->rng = cnow.rng; 1638 + icount->dcd = cnow.dcd; 1639 + icount->rx = cnow.rx; 1640 + icount->tx = cnow.tx; 1641 + icount->frame = cnow.frame; 1642 + icount->overrun = cnow.overrun; 1643 + icount->parity = cnow.parity; 1644 + icount->brk = cnow.brk; 1645 + icount->buf_overrun = cnow.buf_overrun; 1646 + 1647 + dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", 1648 + __func__, port->number, icount->rx, icount->tx); 1649 + return 0; 1650 + } 1651 + 1629 1652 static int get_serial_info(struct edgeport_port *edge_port, 1630 1653 struct serial_struct __user *retinfo) 1631 1654 { ··· 1677 1650 } 1678 1651 1679 1652 1680 - 1681 1653 /***************************************************************************** 1682 1654 * SerialIoctl 1683 1655 * this function handles any ioctl calls to the driver ··· 1689 1663 struct edgeport_port *edge_port = usb_get_serial_port_data(port); 1690 1664 struct async_icount cnow; 1691 1665 struct async_icount cprev; 1692 - struct serial_icounter_struct icount; 1693 1666 1694 1667 dbg("%s - port %d, cmd = 0x%x", __func__, port->number, cmd); 1695 1668 ··· 1727 1702 /* NOTREACHED */ 1728 1703 break; 1729 1704 1730 - case TIOCGICOUNT: 1731 - cnow = edge_port->icount; 1732 - memset(&icount, 0, sizeof(icount)); 1733 - icount.cts = cnow.cts; 1734 - icount.dsr = cnow.dsr; 1735 - icount.rng = cnow.rng; 1736 - icount.dcd = cnow.dcd; 1737 - icount.rx = cnow.rx; 1738 - icount.tx = cnow.tx; 1739 - icount.frame = cnow.frame; 1740 - icount.overrun = cnow.overrun; 1741 - icount.parity = cnow.parity; 1742 - icount.brk = cnow.brk; 1743 - icount.buf_overrun = cnow.buf_overrun; 1744 - 1745 - dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", 1746 - __func__, port->number, icount.rx, icount.tx); 1747 - if (copy_to_user((void __user *)arg, &icount, sizeof(icount))) 1748 - return -EFAULT; 1749 - return 0; 1750 1705 } 1751 1706 return -ENOIOCTLCMD; 1752 1707 }
+4
drivers/usb/serial/io_tables.h
··· 123 123 .set_termios = edge_set_termios, 124 124 .tiocmget = edge_tiocmget, 125 125 .tiocmset = edge_tiocmset, 126 + .get_icount = edge_get_icount, 126 127 .write = edge_write, 127 128 .write_room = edge_write_room, 128 129 .chars_in_buffer = edge_chars_in_buffer, ··· 153 152 .set_termios = edge_set_termios, 154 153 .tiocmget = edge_tiocmget, 155 154 .tiocmset = edge_tiocmset, 155 + .get_icount = edge_get_icount, 156 156 .write = edge_write, 157 157 .write_room = edge_write_room, 158 158 .chars_in_buffer = edge_chars_in_buffer, ··· 183 181 .set_termios = edge_set_termios, 184 182 .tiocmget = edge_tiocmget, 185 183 .tiocmset = edge_tiocmset, 184 + .get_icount = edge_get_icount, 186 185 .write = edge_write, 187 186 .write_room = edge_write_room, 188 187 .chars_in_buffer = edge_chars_in_buffer, ··· 212 209 .set_termios = edge_set_termios, 213 210 .tiocmget = edge_tiocmget, 214 211 .tiocmset = edge_tiocmset, 212 + .get_icount = edge_get_icount, 215 213 .write = edge_write, 216 214 .write_room = edge_write_room, 217 215 .chars_in_buffer = edge_chars_in_buffer,
+22 -7
drivers/usb/serial/io_ti.c
··· 2510 2510 return result; 2511 2511 } 2512 2512 2513 + static int edge_get_icount(struct tty_struct *tty, 2514 + struct serial_icounter_struct *icount) 2515 + { 2516 + struct usb_serial_port *port = tty->driver_data; 2517 + struct edgeport_port *edge_port = usb_get_serial_port_data(port); 2518 + struct async_icount *ic = &edge_port->icount; 2519 + 2520 + icount->cts = ic->cts; 2521 + icount->dsr = ic->dsr; 2522 + icount->rng = ic->rng; 2523 + icount->dcd = ic->dcd; 2524 + icount->tx = ic->tx; 2525 + icount->rx = ic->rx; 2526 + icount->frame = ic->frame; 2527 + icount->parity = ic->parity; 2528 + icount->overrun = ic->overrun; 2529 + icount->brk = ic->brk; 2530 + icount->buf_overrun = ic->buf_overrun; 2531 + return 0; 2532 + } 2533 + 2513 2534 static int get_serial_info(struct edgeport_port *edge_port, 2514 2535 struct serial_struct __user *retinfo) 2515 2536 { ··· 2593 2572 } 2594 2573 /* not reached */ 2595 2574 break; 2596 - case TIOCGICOUNT: 2597 - dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, 2598 - port->number, edge_port->icount.rx, edge_port->icount.tx); 2599 - if (copy_to_user((void __user *)arg, &edge_port->icount, 2600 - sizeof(edge_port->icount))) 2601 - return -EFAULT; 2602 - return 0; 2603 2575 } 2604 2576 return -ENOIOCTLCMD; 2605 2577 } ··· 2772 2758 .set_termios = edge_set_termios, 2773 2759 .tiocmget = edge_tiocmget, 2774 2760 .tiocmset = edge_tiocmset, 2761 + .get_icount = edge_get_icount, 2775 2762 .write = edge_write, 2776 2763 .write_room = edge_write_room, 2777 2764 .chars_in_buffer = edge_chars_in_buffer,
+29 -25
drivers/usb/serial/mos7720.c
··· 1896 1896 return 0; 1897 1897 } 1898 1898 1899 + static int mos7720_get_icount(struct tty_struct *tty, 1900 + struct serial_icounter_struct *icount) 1901 + { 1902 + struct usb_serial_port *port = tty->driver_data; 1903 + struct moschip_port *mos7720_port; 1904 + struct async_icount cnow; 1905 + 1906 + mos7720_port = usb_get_serial_port_data(port); 1907 + cnow = mos7720_port->icount; 1908 + 1909 + icount->cts = cnow.cts; 1910 + icount->dsr = cnow.dsr; 1911 + icount->rng = cnow.rng; 1912 + icount->dcd = cnow.dcd; 1913 + icount->rx = cnow.rx; 1914 + icount->tx = cnow.tx; 1915 + icount->frame = cnow.frame; 1916 + icount->overrun = cnow.overrun; 1917 + icount->parity = cnow.parity; 1918 + icount->brk = cnow.brk; 1919 + icount->buf_overrun = cnow.buf_overrun; 1920 + 1921 + dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, 1922 + port->number, icount->rx, icount->tx); 1923 + return 0; 1924 + } 1925 + 1899 1926 static int set_modem_info(struct moschip_port *mos7720_port, unsigned int cmd, 1900 1927 unsigned int __user *value) 1901 1928 { 1902 - unsigned int mcr ; 1929 + unsigned int mcr; 1903 1930 unsigned int arg; 1904 1931 1905 1932 struct usb_serial_port *port; ··· 2000 1973 struct moschip_port *mos7720_port; 2001 1974 struct async_icount cnow; 2002 1975 struct async_icount cprev; 2003 - struct serial_icounter_struct icount; 2004 1976 2005 1977 mos7720_port = usb_get_serial_port_data(port); 2006 1978 if (mos7720_port == NULL) ··· 2047 2021 } 2048 2022 /* NOTREACHED */ 2049 2023 break; 2050 - 2051 - case TIOCGICOUNT: 2052 - cnow = mos7720_port->icount; 2053 - 2054 - memset(&icount, 0, sizeof(struct serial_icounter_struct)); 2055 - 2056 - icount.cts = cnow.cts; 2057 - icount.dsr = cnow.dsr; 2058 - icount.rng = cnow.rng; 2059 - icount.dcd = cnow.dcd; 2060 - icount.rx = cnow.rx; 2061 - icount.tx = cnow.tx; 2062 - icount.frame = cnow.frame; 2063 - icount.overrun = cnow.overrun; 2064 - icount.parity = cnow.parity; 2065 - icount.brk = cnow.brk; 2066 - icount.buf_overrun = cnow.buf_overrun; 2067 - 2068 - dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, 2069 - port->number, icount.rx, icount.tx); 2070 - if (copy_to_user((void __user *)arg, &icount, sizeof(icount))) 2071 - return -EFAULT; 2072 - return 0; 2073 2024 } 2074 2025 2075 2026 return -ENOIOCTLCMD; ··· 2215 2212 .ioctl = mos7720_ioctl, 2216 2213 .tiocmget = mos7720_tiocmget, 2217 2214 .tiocmset = mos7720_tiocmset, 2215 + .get_icount = mos7720_get_icount, 2218 2216 .set_termios = mos7720_set_termios, 2219 2217 .write = mos7720_write, 2220 2218 .write_room = mos7720_write_room,
+29 -24
drivers/usb/serial/mos7840.c
··· 2209 2209 return 0; 2210 2210 } 2211 2211 2212 + static int mos7840_get_icount(struct tty_struct *tty, 2213 + struct serial_icounter_struct *icount) 2214 + { 2215 + struct usb_serial_port *port = tty->driver_data; 2216 + struct moschip_port *mos7840_port; 2217 + struct async_icount cnow; 2218 + 2219 + mos7840_port = mos7840_get_port_private(port); 2220 + cnow = mos7840_port->icount; 2221 + 2222 + smp_rmb(); 2223 + icount->cts = cnow.cts; 2224 + icount->dsr = cnow.dsr; 2225 + icount->rng = cnow.rng; 2226 + icount->dcd = cnow.dcd; 2227 + icount->rx = cnow.rx; 2228 + icount->tx = cnow.tx; 2229 + icount->frame = cnow.frame; 2230 + icount->overrun = cnow.overrun; 2231 + icount->parity = cnow.parity; 2232 + icount->brk = cnow.brk; 2233 + icount->buf_overrun = cnow.buf_overrun; 2234 + 2235 + dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, 2236 + port->number, icount->rx, icount->tx); 2237 + return 0; 2238 + } 2239 + 2212 2240 /***************************************************************************** 2213 2241 * SerialIoctl 2214 2242 * this function handles any ioctl calls to the driver ··· 2251 2223 2252 2224 struct async_icount cnow; 2253 2225 struct async_icount cprev; 2254 - struct serial_icounter_struct icount; 2255 2226 2256 2227 if (mos7840_port_paranoia_check(port, __func__)) { 2257 2228 dbg("%s", "Invalid port"); ··· 2309 2282 /* NOTREACHED */ 2310 2283 break; 2311 2284 2312 - case TIOCGICOUNT: 2313 - cnow = mos7840_port->icount; 2314 - smp_rmb(); 2315 - 2316 - memset(&icount, 0, sizeof(struct serial_icounter_struct)); 2317 - 2318 - icount.cts = cnow.cts; 2319 - icount.dsr = cnow.dsr; 2320 - icount.rng = cnow.rng; 2321 - icount.dcd = cnow.dcd; 2322 - icount.rx = cnow.rx; 2323 - icount.tx = cnow.tx; 2324 - icount.frame = cnow.frame; 2325 - icount.overrun = cnow.overrun; 2326 - icount.parity = cnow.parity; 2327 - icount.brk = cnow.brk; 2328 - icount.buf_overrun = cnow.buf_overrun; 2329 - 2330 - dbg("%s (%d) TIOCGICOUNT RX=%d, TX=%d", __func__, 2331 - port->number, icount.rx, icount.tx); 2332 - if (copy_to_user(argp, &icount, sizeof(icount))) 2333 - return -EFAULT; 2334 - return 0; 2335 2285 default: 2336 2286 break; 2337 2287 } ··· 2678 2674 .break_ctl = mos7840_break, 2679 2675 .tiocmget = mos7840_tiocmget, 2680 2676 .tiocmset = mos7840_tiocmset, 2677 + .get_icount = mos7840_get_icount, 2681 2678 .attach = mos7840_startup, 2682 2679 .disconnect = mos7840_disconnect, 2683 2680 .release = mos7840_release,
+25 -23
drivers/usb/serial/ssu100.c
··· 416 416 return 0; 417 417 } 418 418 419 + static int ssu100_get_icount(struct tty_struct *tty, 420 + struct serial_icounter_struct *icount) 421 + { 422 + struct usb_serial_port *port = tty->driver_data; 423 + struct ssu100_port_private *priv = usb_get_serial_port_data(port); 424 + struct async_icount cnow = priv->icount; 425 + 426 + icount->cts = cnow.cts; 427 + icount->dsr = cnow.dsr; 428 + icount->rng = cnow.rng; 429 + icount->dcd = cnow.dcd; 430 + icount->rx = cnow.rx; 431 + icount->tx = cnow.tx; 432 + icount->frame = cnow.frame; 433 + icount->overrun = cnow.overrun; 434 + icount->parity = cnow.parity; 435 + icount->brk = cnow.brk; 436 + icount->buf_overrun = cnow.buf_overrun; 437 + 438 + return 0; 439 + } 440 + 441 + 442 + 419 443 static int ssu100_ioctl(struct tty_struct *tty, struct file *file, 420 444 unsigned int cmd, unsigned long arg) 421 445 { 422 446 struct usb_serial_port *port = tty->driver_data; 423 - struct ssu100_port_private *priv = usb_get_serial_port_data(port); 424 - void __user *user_arg = (void __user *)arg; 425 447 426 448 dbg("%s cmd 0x%04x", __func__, cmd); 427 449 ··· 454 432 455 433 case TIOCMIWAIT: 456 434 return wait_modem_info(port, arg); 457 - 458 - case TIOCGICOUNT: 459 - { 460 - struct serial_icounter_struct icount; 461 - struct async_icount cnow = priv->icount; 462 - memset(&icount, 0, sizeof(icount)); 463 - icount.cts = cnow.cts; 464 - icount.dsr = cnow.dsr; 465 - icount.rng = cnow.rng; 466 - icount.dcd = cnow.dcd; 467 - icount.rx = cnow.rx; 468 - icount.tx = cnow.tx; 469 - icount.frame = cnow.frame; 470 - icount.overrun = cnow.overrun; 471 - icount.parity = cnow.parity; 472 - icount.brk = cnow.brk; 473 - icount.buf_overrun = cnow.buf_overrun; 474 - if (copy_to_user(user_arg, &icount, sizeof(icount))) 475 - return -EFAULT; 476 - return 0; 477 - } 478 435 479 436 default: 480 437 break; ··· 727 726 .process_read_urb = ssu100_process_read_urb, 728 727 .tiocmget = ssu100_tiocmget, 729 728 .tiocmset = ssu100_tiocmset, 729 + .get_icount = ssu100_get_icount, 730 730 .ioctl = ssu100_ioctl, 731 731 .set_termios = ssu100_set_termios, 732 732 .disconnect = usb_serial_generic_disconnect,
+29 -8
drivers/usb/serial/ti_usb_3410_5052.c
··· 108 108 static void ti_unthrottle(struct tty_struct *tty); 109 109 static int ti_ioctl(struct tty_struct *tty, struct file *file, 110 110 unsigned int cmd, unsigned long arg); 111 + static int ti_get_icount(struct tty_struct *tty, 112 + struct serial_icounter_struct *icount); 111 113 static void ti_set_termios(struct tty_struct *tty, 112 114 struct usb_serial_port *port, struct ktermios *old_termios); 113 115 static int ti_tiocmget(struct tty_struct *tty, struct file *file); ··· 239 237 .set_termios = ti_set_termios, 240 238 .tiocmget = ti_tiocmget, 241 239 .tiocmset = ti_tiocmset, 240 + .get_icount = ti_get_icount, 242 241 .break_ctl = ti_break, 243 242 .read_int_callback = ti_interrupt_callback, 244 243 .read_bulk_callback = ti_bulk_in_callback, ··· 268 265 .set_termios = ti_set_termios, 269 266 .tiocmget = ti_tiocmget, 270 267 .tiocmset = ti_tiocmset, 268 + .get_icount = ti_get_icount, 271 269 .break_ctl = ti_break, 272 270 .read_int_callback = ti_interrupt_callback, 273 271 .read_bulk_callback = ti_bulk_in_callback, ··· 792 788 } 793 789 } 794 790 791 + static int ti_get_icount(struct tty_struct *tty, 792 + struct serial_icounter_struct *icount) 793 + { 794 + struct usb_serial_port *port = tty->driver_data; 795 + struct ti_port *tport = usb_get_serial_port_data(port); 796 + struct async_icount cnow = tport->tp_icount; 797 + 798 + dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", 799 + __func__, port->number, 800 + cnow.rx, cnow.tx); 801 + 802 + icount->cts = cnow.cts; 803 + icount->dsr = cnow.dsr; 804 + icount->rng = cnow.rng; 805 + icount->dcd = cnow.dcd; 806 + icount->rx = cnow.rx; 807 + icount->tx = cnow.tx; 808 + icount->frame = cnow.frame; 809 + icount->overrun = cnow.overrun; 810 + icount->parity = cnow.parity; 811 + icount->brk = cnow.brk; 812 + icount->buf_overrun = cnow.buf_overrun; 813 + 814 + return 0; 815 + } 795 816 796 817 static int ti_ioctl(struct tty_struct *tty, struct file *file, 797 818 unsigned int cmd, unsigned long arg) ··· 859 830 cprev = cnow; 860 831 } 861 832 break; 862 - case TIOCGICOUNT: 863 - dbg("%s - (%d) TIOCGICOUNT RX=%d, TX=%d", 864 - __func__, port->number, 865 - tport->tp_icount.rx, tport->tp_icount.tx); 866 - if (copy_to_user((void __user *)arg, &tport->tp_icount, 867 - sizeof(tport->tp_icount))) 868 - return -EFAULT; 869 - return 0; 870 833 } 871 834 return -ENOIOCTLCMD; 872 835 }
+13
drivers/usb/serial/usb-serial.c
··· 519 519 return -EINVAL; 520 520 } 521 521 522 + static int serial_get_icount(struct tty_struct *tty, 523 + struct serial_icounter_struct *icount) 524 + { 525 + struct usb_serial_port *port = tty->driver_data; 526 + 527 + dbg("%s - port %d", __func__, port->number); 528 + 529 + if (port->serial->type->get_icount) 530 + return port->serial->type->get_icount(tty, icount); 531 + return -EINVAL; 532 + } 533 + 522 534 /* 523 535 * We would be calling tty_wakeup here, but unfortunately some line 524 536 * disciplines have an annoying habit of calling tty->write from ··· 1207 1195 .chars_in_buffer = serial_chars_in_buffer, 1208 1196 .tiocmget = serial_tiocmget, 1209 1197 .tiocmset = serial_tiocmset, 1198 + .get_icount = serial_get_icount, 1210 1199 .cleanup = serial_cleanup, 1211 1200 .install = serial_install, 1212 1201 .proc_fops = &serial_proc_fops,
+158
fs/proc/proc_tty.c
··· 12 12 #include <linux/proc_fs.h> 13 13 #include <linux/stat.h> 14 14 #include <linux/tty.h> 15 + #include <linux/tty_driver.h> 16 + #include <linux/console.h> 15 17 #include <linux/seq_file.h> 18 + #include <linux/fdtable.h> 16 19 #include <linux/bitops.h> 17 20 18 21 /* ··· 140 137 }; 141 138 142 139 /* 140 + * The device ID of file descriptor 0 of the current reading 141 + * task if a character device... 142 + */ 143 + static dev_t current_dev; 144 + 145 + /* 146 + * This is the handler for /proc/tty/consoles 147 + */ 148 + static int show_console_dev(struct seq_file *m, void *v) 149 + { 150 + const struct tty_driver *driver; 151 + struct console *con; 152 + int index, len; 153 + char flags[10]; 154 + dev_t dev; 155 + 156 + if (v == SEQ_START_TOKEN) 157 + return 0; 158 + con = (struct console *)v; 159 + if (!con) 160 + return 0; 161 + driver = con->device(con, &index); 162 + if (!driver) 163 + return 0; 164 + dev = MKDEV(driver->major, driver->minor_start) + index; 165 + 166 + index = 0; 167 + if (con->flags & CON_ENABLED) 168 + flags[index++] = 'E'; 169 + if (con->flags & CON_CONSDEV) 170 + flags[index++] = 'C'; 171 + if (con->flags & CON_BOOT) 172 + flags[index++] = 'B'; 173 + if (con->flags & CON_PRINTBUFFER) 174 + flags[index++] = 'p'; 175 + if (con->flags & CON_BRL) 176 + flags[index++] = 'b'; 177 + if (con->flags & CON_ANYTIME) 178 + flags[index++] = 'a'; 179 + if (current_dev == dev) 180 + flags[index++] = '*'; 181 + flags[index] = 0; 182 + 183 + seq_printf(m, "%s%d%n", con->name, con->index, &len); 184 + len = 21 - len; 185 + if (len < 1) 186 + len = 1; 187 + seq_printf(m, "%*c", len, ' '); 188 + seq_printf(m, "%c%c%c (%s)%n", con->read ? 'R' : '-', 189 + con->write ? 'W' : '-', con->unblank ? 'U' : '-', 190 + flags, &len); 191 + len = 13 - len; 192 + if (len < 1) 193 + len = 1; 194 + seq_printf(m, "%*c%4d:%d\n", len, ' ', MAJOR(dev), MINOR(dev)); 195 + 196 + return 0; 197 + } 198 + 199 + /* iterator for consoles */ 200 + static void *c_start(struct seq_file *m, loff_t *pos) 201 + { 202 + struct console *con; 203 + loff_t off = 0; 204 + 205 + if (*pos == 0) 206 + return SEQ_START_TOKEN; 207 + 208 + acquire_console_sem(); 209 + for (con = console_drivers; con; con = con->next) { 210 + if (!con->device) 211 + continue; 212 + if (++off == *pos) 213 + break; 214 + } 215 + release_console_sem(); 216 + 217 + return con; 218 + } 219 + 220 + static void *c_next(struct seq_file *m, void *v, loff_t *pos) 221 + { 222 + struct console *con; 223 + 224 + acquire_console_sem(); 225 + if (v == SEQ_START_TOKEN) 226 + con = console_drivers; 227 + else 228 + con = ((struct console *)v)->next; 229 + for (; con; con = con->next) { 230 + if (!con->device) 231 + continue; 232 + ++*pos; 233 + break; 234 + } 235 + release_console_sem(); 236 + 237 + return con; 238 + } 239 + 240 + static void c_stop(struct seq_file *m, void *v) 241 + { 242 + } 243 + 244 + static const struct seq_operations tty_consoles_op = { 245 + .start = c_start, 246 + .next = c_next, 247 + .stop = c_stop, 248 + .show = show_console_dev 249 + }; 250 + 251 + /* 252 + * Used for open /proc/tty/consoles. Before this detect 253 + * the device ID of file descriptor 0 of the current 254 + * reading task if a character device... 255 + */ 256 + static int tty_consoles_open(struct inode *inode, struct file *file) 257 + { 258 + struct files_struct *curfiles; 259 + 260 + current_dev = 0; 261 + curfiles = get_files_struct(current); 262 + if (curfiles) { 263 + const struct file *curfp; 264 + spin_lock(&curfiles->file_lock); 265 + curfp = fcheck_files(curfiles, 0); 266 + if (curfp && curfp->private_data) { 267 + const struct inode *inode; 268 + dget(curfp->f_dentry); 269 + inode = curfp->f_dentry->d_inode; 270 + if (S_ISCHR(inode->i_mode)) { 271 + struct tty_struct *tty; 272 + tty = (struct tty_struct *)curfp->private_data; 273 + if (tty && tty->magic == TTY_MAGIC) { 274 + tty = tty_pair_get_tty(tty); 275 + current_dev = tty_devnum(tty); 276 + } 277 + } 278 + dput(curfp->f_dentry); 279 + } 280 + spin_unlock(&curfiles->file_lock); 281 + put_files_struct(curfiles); 282 + } 283 + return seq_open(file, &tty_consoles_op); 284 + } 285 + 286 + static const struct file_operations proc_tty_consoles_operations = { 287 + .open = tty_consoles_open, 288 + .read = seq_read, 289 + .llseek = seq_lseek, 290 + .release = seq_release, 291 + }; 292 + 293 + /* 143 294 * This function is called by tty_register_driver() to handle 144 295 * registering the driver's /proc handler into /proc/tty/driver/<foo> 145 296 */ ··· 343 186 proc_tty_driver = proc_mkdir_mode("tty/driver", S_IRUSR|S_IXUSR, NULL); 344 187 proc_create("tty/ldiscs", 0, NULL, &tty_ldiscs_proc_fops); 345 188 proc_create("tty/drivers", 0, NULL, &proc_tty_drivers_operations); 189 + proc_create("tty/consoles", 0, NULL, &proc_tty_consoles_operations); 346 190 }
+2
include/asm-generic/ioctls.h
··· 62 62 #define TCSETSW2 _IOW('T', 0x2C, struct termios2) 63 63 #define TCSETSF2 _IOW('T', 0x2D, struct termios2) 64 64 #define TIOCGRS485 0x542E 65 + #ifndef TIOCSRS485 65 66 #define TIOCSRS485 0x542F 67 + #endif 66 68 #define TIOCGPTN _IOR('T', 0x30, unsigned int) /* Get Pty Number (of pty-mux device) */ 67 69 #define TIOCSPTLCK _IOW('T', 0x31, int) /* Lock/unlock Pty */ 68 70 #define TCGETX 0x5432 /* SYS5 TCGETX compatibility */
+5
include/linux/altera_uart.h
··· 5 5 #ifndef __ALTUART_H 6 6 #define __ALTUART_H 7 7 8 + #include <linux/init.h> 9 + 8 10 struct altera_uart_platform_uart { 9 11 unsigned long mapbase; /* Physical address base */ 10 12 unsigned int irq; /* Interrupt vector */ 11 13 unsigned int uartclk; /* UART clock rate */ 14 + unsigned int bus_shift; /* Bus shift (address stride) */ 12 15 }; 16 + 17 + int __init early_altera_uart_setup(struct altera_uart_platform_uart *platp); 13 18 14 19 #endif /* __ALTUART_H */
+1
include/linux/selection.h
··· 39 39 40 40 extern u16 vcs_scr_readw(struct vc_data *vc, const u16 *org); 41 41 extern void vcs_scr_writew(struct vc_data *vc, u16 val, u16 *org); 42 + extern void vcs_scr_updated(struct vc_data *vc); 42 43 43 44 #endif
+8
include/linux/serial_8250.h
··· 35 35 void (*set_termios)(struct uart_port *, 36 36 struct ktermios *new, 37 37 struct ktermios *old); 38 + void (*pm)(struct uart_port *, unsigned int state, 39 + unsigned old); 38 40 }; 39 41 40 42 /* ··· 78 76 extern int setup_early_serial8250_console(char *cmdline); 79 77 extern void serial8250_do_set_termios(struct uart_port *port, 80 78 struct ktermios *termios, struct ktermios *old); 79 + extern void serial8250_do_pm(struct uart_port *port, unsigned int state, 80 + unsigned int oldstate); 81 + 82 + extern void serial8250_set_isa_configurator(void (*v) 83 + (int port, struct uart_port *up, 84 + unsigned short *capabilities)); 81 85 82 86 #endif
+10
include/linux/serial_core.h
··· 289 289 void (*set_termios)(struct uart_port *, 290 290 struct ktermios *new, 291 291 struct ktermios *old); 292 + void (*pm)(struct uart_port *, unsigned int state, 293 + unsigned int old); 292 294 unsigned int irq; /* irq number */ 293 295 unsigned long irqflags; /* irq flags */ 294 296 unsigned int uartclk; /* base uart clock */ ··· 412 410 struct ktermios *old, unsigned int min, 413 411 unsigned int max); 414 412 unsigned int uart_get_divisor(struct uart_port *port, unsigned int baud); 413 + 414 + /* Base timer interval for polling */ 415 + static inline int uart_poll_timeout(struct uart_port *port) 416 + { 417 + int timeout = port->timeout; 418 + 419 + return timeout > 6 ? (timeout / 2 - 2) : 1; 420 + } 415 421 416 422 /* 417 423 * Console helpers.
+2 -1
include/linux/tty.h
··· 256 256 struct tty_struct { 257 257 int magic; 258 258 struct kref kref; 259 + struct device *dev; 259 260 struct tty_driver *driver; 260 261 const struct tty_operations *ops; 261 262 int index; ··· 466 465 extern struct tty_struct *get_current_tty(void); 467 466 extern void tty_default_fops(struct file_operations *fops); 468 467 extern struct tty_struct *alloc_tty_struct(void); 469 - extern void tty_add_file(struct tty_struct *tty, struct file *file); 468 + extern int tty_add_file(struct tty_struct *tty, struct file *file); 470 469 extern void free_tty_struct(struct tty_struct *tty); 471 470 extern void initialize_tty_struct(struct tty_struct *tty, 472 471 struct tty_driver *driver, int idx);
+9
include/linux/tty_driver.h
··· 224 224 * unless the tty also has a valid tty->termiox pointer. 225 225 * 226 226 * Optional: Called under the termios lock 227 + * 228 + * int (*get_icount)(struct tty_struct *tty, struct serial_icounter *icount); 229 + * 230 + * Called when the device receives a TIOCGICOUNT ioctl. Passed a kernel 231 + * structure to complete. This method is optional and will only be called 232 + * if provided (otherwise EINVAL will be returned). 227 233 */ 228 234 229 235 #include <linux/fs.h> ··· 238 232 239 233 struct tty_struct; 240 234 struct tty_driver; 235 + struct serial_icounter_struct; 241 236 242 237 struct tty_operations { 243 238 struct tty_struct * (*lookup)(struct tty_driver *driver, ··· 275 268 unsigned int set, unsigned int clear); 276 269 int (*resize)(struct tty_struct *tty, struct winsize *ws); 277 270 int (*set_termiox)(struct tty_struct *tty, struct termiox *tnew); 271 + int (*get_icount)(struct tty_struct *tty, 272 + struct serial_icounter_struct *icount); 278 273 #ifdef CONFIG_CONSOLE_POLL 279 274 int (*poll_init)(struct tty_driver *driver, int line, char *options); 280 275 int (*poll_get_char)(struct tty_driver *driver, int line);
+2
include/linux/usb/serial.h
··· 271 271 int (*tiocmget)(struct tty_struct *tty, struct file *file); 272 272 int (*tiocmset)(struct tty_struct *tty, struct file *file, 273 273 unsigned int set, unsigned int clear); 274 + int (*get_icount)(struct tty_struct *tty, 275 + struct serial_icounter_struct *icount); 274 276 /* Called by the tty layer for port level work. There may or may not 275 277 be an attached tty at this point */ 276 278 void (*dtr_rts)(struct usb_serial_port *port, int on);
-4
net/bluetooth/rfcomm/tty.c
··· 844 844 BT_DBG("TIOCMIWAIT"); 845 845 break; 846 846 847 - case TIOCGICOUNT: 848 - BT_DBG("TIOCGICOUNT"); 849 - break; 850 - 851 847 case TIOCGSERIAL: 852 848 BT_ERR("TIOCGSERIAL is not supported"); 853 849 return -ENOIOCTLCMD;