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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'tty-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty

Pull tty / serial updates from Greg KH:
"Here is the big set of tty and serial driver changes for 6.8-rc1.

As usual, Jiri has a bunch of refactoring and cleanups for the tty
core and drivers in here, along with the usual set of rs485 updates
(someday this might work properly...)

Along with those, in here are changes for:

- sc16is7xx serial driver updates

- platform driver removal api updates

- amba-pl011 driver updates

- tty driver binding updates

- other small tty/serial driver updates and changes

All of these have been in linux-next for a while with no reported
issues"

* tag 'tty-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (197 commits)
serial: sc16is7xx: refactor EFR lock
serial: sc16is7xx: reorder code to remove prototype declarations
serial: sc16is7xx: refactor FIFO access functions to increase commonality
serial: sc16is7xx: drop unneeded MODULE_ALIAS
serial: sc16is7xx: replace hardcoded divisor value with BIT() macro
serial: sc16is7xx: add explicit return for some switch default cases
serial: sc16is7xx: add macro for max number of UART ports
serial: sc16is7xx: add driver name to struct uart_driver
serial: sc16is7xx: use i2c_get_match_data()
serial: sc16is7xx: use spi_get_device_match_data()
serial: sc16is7xx: use DECLARE_BITMAP for sc16is7xx_lines bitfield
serial: sc16is7xx: improve do/while loop in sc16is7xx_irq()
serial: sc16is7xx: remove obsolete loop in sc16is7xx_port_irq()
serial: sc16is7xx: set safe default SPI clock frequency
serial: sc16is7xx: add check for unsupported SPI modes during probe
serial: sc16is7xx: fix invalid sc16is7xx_lines bitfield in case of probe error
serial: 8250_exar: Set missing rs485_supported flag
serial: omap: do not override settings for RS485 support
serial: core, imx: do not set RS485 enabled if it is not supported
serial: core: make sure RS485 cannot be enabled when it is not supported
...

+1661 -1556
+3
Documentation/admin-guide/devices.txt
··· 2704 2704 ... 2705 2705 185 = /dev/ttyNX15 Hilscher netX serial port 15 2706 2706 186 = /dev/ttyJ0 JTAG1 DCC protocol based serial port emulation 2707 + 2708 + If maximum number of uartlite serial ports is more than 4, then the driver 2709 + uses dynamic allocation instead of static allocation for major number. 2707 2710 187 = /dev/ttyUL0 Xilinx uartlite - port 0 2708 2711 ... 2709 2712 190 = /dev/ttyUL3 Xilinx uartlite - port 3
+10 -1
Documentation/admin-guide/sysrq.rst
··· 75 75 submit a patch to be included in this section. 76 76 77 77 On all 78 - Write a character to /proc/sysrq-trigger. e.g.:: 78 + Write a single character to /proc/sysrq-trigger. 79 + Only the first character is processed, the rest of the string is 80 + ignored. However, it is not recommended to write any extra characters 81 + as the behavior is undefined and might change in the future versions. 82 + E.g.:: 79 83 80 84 echo t > /proc/sysrq-trigger 85 + 86 + Alternatively, write multiple characters prepended by underscore. 87 + This way, all characters will be processed. E.g.:: 88 + 89 + echo _reisub > /proc/sysrq-trigger 81 90 82 91 The :kbd:`<command key>` is case sensitive. 83 92
+30
Documentation/devicetree/bindings/serial/arm,dcc.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/serial/arm,dcc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: ARM DCC (Data communication channel) serial emulation 8 + 9 + maintainers: 10 + - Michal Simek <michal.simek@amd.com> 11 + 12 + description: | 13 + ARM DCC (Data communication channel) serial emulation interface available 14 + via JTAG can be also used as one of serial line tightly coupled with every 15 + ARM CPU available in the system. 16 + 17 + properties: 18 + compatible: 19 + const: arm,dcc 20 + 21 + required: 22 + - compatible 23 + 24 + additionalProperties: false 25 + 26 + examples: 27 + - | 28 + serial { 29 + compatible = "arm,dcc"; 30 + };
+1 -1
Documentation/devicetree/bindings/serial/fsl,s32-linflexuart.yaml
··· 13 13 https://www.nxp.com/webapp/Download?colCode=S32V234RM. 14 14 15 15 maintainers: 16 - - Chester Lin <clin@suse.com> 16 + - Chester Lin <chester62515@gmail.com> 17 17 18 18 allOf: 19 19 - $ref: serial.yaml#
+24 -5
Documentation/devicetree/bindings/serial/fsl-imx-uart.yaml
··· 9 9 maintainers: 10 10 - Fabio Estevam <festevam@gmail.com> 11 11 12 - allOf: 13 - - $ref: serial.yaml# 14 - - $ref: rs485.yaml# 15 - 16 12 properties: 17 13 compatible: 18 14 oneOf: ··· 64 68 - const: tx 65 69 66 70 interrupts: 67 - maxItems: 1 71 + items: 72 + - description: UART RX Interrupt 73 + - description: UART TX Interrupt 74 + - description: UART RTS Interrupt 75 + minItems: 1 68 76 69 77 wakeup-source: true 70 78 ··· 109 109 - clocks 110 110 - clock-names 111 111 - interrupts 112 + 113 + allOf: 114 + - $ref: serial.yaml# 115 + - $ref: rs485.yaml# 116 + 117 + - if: 118 + properties: 119 + compatible: 120 + contains: 121 + const: fsl,imx1-uart 122 + then: 123 + properties: 124 + interrupts: 125 + minItems: 3 126 + maxItems: 3 127 + else: 128 + properties: 129 + interrupts: 130 + maxItems: 1 112 131 113 132 unevaluatedProperties: false 114 133
+13
Documentation/devicetree/bindings/serial/qcom,msm-uartdm.yaml
··· 48 48 - const: tx 49 49 - const: rx 50 50 51 + interconnects: 52 + maxItems: 1 53 + 51 54 interrupts: 55 + maxItems: 1 56 + 57 + operating-points-v2: true 58 + 59 + power-domains: 52 60 maxItems: 1 53 61 54 62 qcom,rx-crci: ··· 107 99 108 100 examples: 109 101 - | 102 + #include <dt-bindings/interconnect/qcom,msm8996.h> 110 103 #include <dt-bindings/interrupt-controller/arm-gic.h> 104 + #include <dt-bindings/power/qcom-rpmpd.h> 111 105 112 106 serial@f991e000 { 113 107 compatible = "qcom,msm-uartdm-v1.4", "qcom,msm-uartdm"; ··· 119 109 clock-names = "core", "iface"; 120 110 dmas = <&dma0 0>, <&dma0 1>; 121 111 dma-names = "tx", "rx"; 112 + power-domains = <&rpmpd MSM8996_VDDCX>; 113 + operating-points-v2 = <&uart_opp_table>; 114 + interconnects = <&pnoc MASTER_BLSP_1 &bimc SLAVE_EBI_CH0>; 122 115 };
+1 -1
Documentation/devicetree/bindings/serial/renesas,sci.yaml
··· 17 17 oneOf: 18 18 - items: 19 19 - enum: 20 - - renesas,r9a07g043-sci # RZ/G2UL 20 + - renesas,r9a07g043-sci # RZ/G2UL and RZ/Five 21 21 - renesas,r9a07g044-sci # RZ/G2{L,LC} 22 22 - renesas,r9a07g054-sci # RZ/V2L 23 23 - const: renesas,sci # generic SCI compatible UART
+1
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
··· 11 11 12 12 allOf: 13 13 - $ref: serial.yaml# 14 + - $ref: rs485.yaml# 14 15 15 16 properties: 16 17 compatible:
+1
Documentation/devicetree/bindings/serial/sprd-uart.yaml
··· 20 20 - sprd,sc9860-uart 21 21 - sprd,sc9863a-uart 22 22 - sprd,ums512-uart 23 + - sprd,ums9620-uart 23 24 - const: sprd,sc9836-uart 24 25 - const: sprd,sc9836-uart 25 26
-1
MAINTAINERS
··· 23185 23185 L: virtualization@lists.linux.dev 23186 23186 S: Maintained 23187 23187 F: drivers/char/virtio_console.c 23188 - F: include/linux/virtio_console.h 23189 23188 F: include/uapi/linux/virtio_console.h 23190 23189 23191 23190 VIRTIO CORE AND NET DRIVERS
+15 -19
arch/alpha/kernel/srmcons.c
··· 53 53 do { 54 54 result.as_long = callback_getc(0); 55 55 if (result.bits.status < 2) { 56 - tty_insert_flip_char(port, (char)result.bits.c, 0); 56 + tty_insert_flip_char(port, (u8)result.bits.c, 0); 57 57 count++; 58 58 } 59 59 } while((result.bits.status & 1) && (++loops < 10)); ··· 88 88 } 89 89 90 90 /* called with callback_lock held */ 91 - static int 92 - srmcons_do_write(struct tty_port *port, const char *buf, int count) 91 + static void 92 + srmcons_do_write(struct tty_port *port, const u8 *buf, size_t count) 93 93 { 94 - static char str_cr[1] = "\r"; 95 - long c, remaining = count; 94 + size_t c; 96 95 srmcons_result result; 97 - char *cur; 98 - int need_cr; 99 96 100 - for (cur = (char *)buf; remaining > 0; ) { 101 - need_cr = 0; 97 + while (count > 0) { 98 + bool need_cr = false; 102 99 /* 103 100 * Break it up into reasonable size chunks to allow a chance 104 101 * for input to get in 105 102 */ 106 - for (c = 0; c < min_t(long, 128L, remaining) && !need_cr; c++) 107 - if (cur[c] == '\n') 108 - need_cr = 1; 103 + for (c = 0; c < min_t(size_t, 128U, count) && !need_cr; c++) 104 + if (buf[c] == '\n') 105 + need_cr = true; 109 106 110 107 while (c > 0) { 111 - result.as_long = callback_puts(0, cur, c); 108 + result.as_long = callback_puts(0, buf, c); 112 109 c -= result.bits.c; 113 - remaining -= result.bits.c; 114 - cur += result.bits.c; 110 + count -= result.bits.c; 111 + buf += result.bits.c; 115 112 116 113 /* 117 114 * Check for pending input iff a tty port was provided ··· 118 121 } 119 122 120 123 while (need_cr) { 121 - result.as_long = callback_puts(0, str_cr, 1); 124 + result.as_long = callback_puts(0, "\r", 1); 122 125 if (result.bits.c > 0) 123 - need_cr = 0; 126 + need_cr = false; 124 127 } 125 128 } 126 - return count; 127 129 } 128 130 129 131 static ssize_t ··· 131 135 unsigned long flags; 132 136 133 137 spin_lock_irqsave(&srmcons_callback_lock, flags); 134 - srmcons_do_write(tty->port, (const char *) buf, count); 138 + srmcons_do_write(tty->port, buf, count); 135 139 spin_unlock_irqrestore(&srmcons_callback_lock, flags); 136 140 137 141 return count;
+2 -2
arch/m68k/emu/nfcon.c
··· 23 23 static struct tty_port nfcon_tty_port; 24 24 static struct tty_driver *nfcon_tty_driver; 25 25 26 - static void nfputs(const char *str, unsigned int count) 26 + static void nfputs(const u8 *str, size_t count) 27 27 { 28 - char buf[68]; 28 + u8 buf[68]; 29 29 unsigned long phys = virt_to_phys(buf); 30 30 31 31 buf[64] = 0;
+2 -2
arch/powerpc/include/asm/hvconsole.h
··· 21 21 * Vio firmware always attempts to fetch MAX_VIO_GET_CHARS chars. The 'count' 22 22 * parm is included to conform to put_chars() function pointer template 23 23 */ 24 - extern int hvc_get_chars(uint32_t vtermno, char *buf, int count); 25 - extern int hvc_put_chars(uint32_t vtermno, const char *buf, int count); 24 + extern ssize_t hvc_get_chars(uint32_t vtermno, u8 *buf, size_t count); 25 + extern ssize_t hvc_put_chars(uint32_t vtermno, const u8 *buf, size_t count); 26 26 27 27 /* Provided by HVC VIO */ 28 28 void hvc_vio_init_early(void);
+10 -8
arch/powerpc/include/asm/hvsi.h
··· 64 64 unsigned int inbuf_len; /* data in input buffer */ 65 65 unsigned char inbuf[HVSI_INBUF_SIZE]; 66 66 unsigned int inbuf_cur; /* Cursor in input buffer */ 67 - unsigned int inbuf_pktlen; /* packet length from cursor */ 67 + size_t inbuf_pktlen; /* packet length from cursor */ 68 68 atomic_t seqno; /* packet sequence number */ 69 69 unsigned int opened:1; /* driver opened */ 70 70 unsigned int established:1; /* protocol established */ ··· 72 72 unsigned int mctrl_update:1; /* modem control updated */ 73 73 unsigned short mctrl; /* modem control */ 74 74 struct tty_struct *tty; /* tty structure */ 75 - int (*get_chars)(uint32_t termno, char *buf, int count); 76 - int (*put_chars)(uint32_t termno, const char *buf, int count); 75 + ssize_t (*get_chars)(uint32_t termno, u8 *buf, size_t count); 76 + ssize_t (*put_chars)(uint32_t termno, const u8 *buf, size_t count); 77 77 uint32_t termno; 78 78 }; 79 79 80 80 /* hvsi lib functions */ 81 81 struct hvc_struct; 82 82 extern void hvsilib_init(struct hvsi_priv *pv, 83 - int (*get_chars)(uint32_t termno, char *buf, int count), 84 - int (*put_chars)(uint32_t termno, const char *buf, 85 - int count), 83 + ssize_t (*get_chars)(uint32_t termno, u8 *buf, 84 + size_t count), 85 + ssize_t (*put_chars)(uint32_t termno, const u8 *buf, 86 + size_t count), 86 87 int termno, int is_console); 87 88 extern int hvsilib_open(struct hvsi_priv *pv, struct hvc_struct *hp); 88 89 extern void hvsilib_close(struct hvsi_priv *pv, struct hvc_struct *hp); 89 90 extern int hvsilib_read_mctrl(struct hvsi_priv *pv); 90 91 extern int hvsilib_write_mctrl(struct hvsi_priv *pv, int dtr); 91 92 extern void hvsilib_establish(struct hvsi_priv *pv); 92 - extern int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count); 93 - extern int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count); 93 + extern ssize_t hvsilib_get_chars(struct hvsi_priv *pv, u8 *buf, size_t count); 94 + extern ssize_t hvsilib_put_chars(struct hvsi_priv *pv, const u8 *buf, 95 + size_t count); 94 96 95 97 #endif /* _HVSI_H */
+5 -3
arch/powerpc/include/asm/opal.h
··· 313 313 const char *uname, int depth, void *data); 314 314 void __init opal_configure_cores(void); 315 315 316 - extern int opal_get_chars(uint32_t vtermno, char *buf, int count); 317 - extern int opal_put_chars(uint32_t vtermno, const char *buf, int total_len); 318 - extern int opal_put_chars_atomic(uint32_t vtermno, const char *buf, int total_len); 316 + extern ssize_t opal_get_chars(uint32_t vtermno, u8 *buf, size_t count); 317 + extern ssize_t opal_put_chars(uint32_t vtermno, const u8 *buf, 318 + size_t total_len); 319 + extern ssize_t opal_put_chars_atomic(uint32_t vtermno, const u8 *buf, 320 + size_t total_len); 319 321 extern int opal_flush_chars(uint32_t vtermno, bool wait); 320 322 extern int opal_flush_console(uint32_t vtermno); 321 323
+8 -6
arch/powerpc/platforms/powernv/opal.c
··· 424 424 return 0; 425 425 } 426 426 427 - int opal_get_chars(uint32_t vtermno, char *buf, int count) 427 + ssize_t opal_get_chars(uint32_t vtermno, u8 *buf, size_t count) 428 428 { 429 429 s64 rc; 430 430 __be64 evt, len; ··· 441 441 return 0; 442 442 } 443 443 444 - static int __opal_put_chars(uint32_t vtermno, const char *data, int total_len, bool atomic) 444 + static ssize_t __opal_put_chars(uint32_t vtermno, const u8 *data, 445 + size_t total_len, bool atomic) 445 446 { 446 447 unsigned long flags = 0 /* shut up gcc */; 447 - int written; 448 + ssize_t written; 448 449 __be64 olen; 449 450 s64 rc; 450 451 ··· 485 484 if (atomic) { 486 485 /* Should not happen */ 487 486 pr_warn("atomic console write returned partial " 488 - "len=%d written=%d\n", total_len, written); 487 + "len=%zu written=%zd\n", total_len, written); 489 488 } 490 489 if (!written) 491 490 written = -EAGAIN; ··· 498 497 return written; 499 498 } 500 499 501 - int opal_put_chars(uint32_t vtermno, const char *data, int total_len) 500 + ssize_t opal_put_chars(uint32_t vtermno, const u8 *data, size_t total_len) 502 501 { 503 502 return __opal_put_chars(vtermno, data, total_len, false); 504 503 } ··· 509 508 * true at the moment because console space can race with OPAL's console 510 509 * writes. 511 510 */ 512 - int opal_put_chars_atomic(uint32_t vtermno, const char *data, int total_len) 511 + ssize_t opal_put_chars_atomic(uint32_t vtermno, const u8 *data, 512 + size_t total_len) 513 513 { 514 514 return __opal_put_chars(vtermno, data, total_len, true); 515 515 }
+2 -2
arch/powerpc/platforms/pseries/hvconsole.c
··· 25 25 * firmware. 26 26 * @count: not used? 27 27 */ 28 - int hvc_get_chars(uint32_t vtermno, char *buf, int count) 28 + ssize_t hvc_get_chars(uint32_t vtermno, u8 *buf, size_t count) 29 29 { 30 30 long ret; 31 31 unsigned long retbuf[PLPAR_HCALL_BUFSIZE]; ··· 52 52 * firmware. Must be at least 16 bytes, even if count is less than 16. 53 53 * @count: Send this number of characters. 54 54 */ 55 - int hvc_put_chars(uint32_t vtermno, const char *buf, int count) 55 + ssize_t hvc_put_chars(uint32_t vtermno, const u8 *buf, size_t count) 56 56 { 57 57 unsigned long *lbuf = (unsigned long *) buf; 58 58 long ret;
+1 -1
arch/um/drivers/chan.h
··· 30 30 extern void chan_interrupt(struct line *line, int irq); 31 31 extern int parse_chan_pair(char *str, struct line *line, int device, 32 32 const struct chan_opts *opts, char **error_out); 33 - extern int write_chan(struct chan *chan, const char *buf, int len, 33 + extern int write_chan(struct chan *chan, const u8 *buf, size_t len, 34 34 int write_irq); 35 35 extern int console_write_chan(struct chan *chan, const char *buf, 36 36 int len);
+4 -5
arch/um/drivers/chan_kern.c
··· 33 33 "UML\n"); 34 34 } 35 35 36 - static int not_configged_read(int fd, char *c_out, void *data) 36 + static int not_configged_read(int fd, u8 *c_out, void *data) 37 37 { 38 38 printk(KERN_ERR "Using a channel type which is configured out of " 39 39 "UML\n"); 40 40 return -EIO; 41 41 } 42 42 43 - static int not_configged_write(int fd, const char *buf, int len, void *data) 43 + static int not_configged_write(int fd, const u8 *buf, size_t len, void *data) 44 44 { 45 45 printk(KERN_ERR "Using a channel type which is configured out of " 46 46 "UML\n"); ··· 247 247 deactivate_fd(chan->fd, irq); 248 248 } 249 249 250 - int write_chan(struct chan *chan, const char *buf, int len, 251 - int write_irq) 250 + int write_chan(struct chan *chan, const u8 *buf, size_t len, int write_irq) 252 251 { 253 252 int n, ret = 0; 254 253 ··· 539 540 struct tty_port *port = &line->port; 540 541 struct chan *chan = line->chan_in; 541 542 int err; 542 - char c; 543 + u8 c; 543 544 544 545 if (!chan || !chan->ops->read) 545 546 goto out;
+2 -2
arch/um/drivers/chan_user.c
··· 19 19 close(fd); 20 20 } 21 21 22 - int generic_read(int fd, char *c_out, void *unused) 22 + int generic_read(int fd, __u8 *c_out, void *unused) 23 23 { 24 24 int n; 25 25 ··· 35 35 36 36 /* XXX Trivial wrapper around write */ 37 37 38 - int generic_write(int fd, const char *buf, int n, void *unused) 38 + int generic_write(int fd, const __u8 *buf, size_t n, void *unused) 39 39 { 40 40 int err; 41 41
+5 -4
arch/um/drivers/chan_user.h
··· 7 7 #define __CHAN_USER_H__ 8 8 9 9 #include <init.h> 10 + #include <linux/types.h> 10 11 11 12 struct chan_opts { 12 13 void (*const announce)(char *dev_name, int dev); ··· 20 19 void *(*init)(char *, int, const struct chan_opts *); 21 20 int (*open)(int, int, int, void *, char **); 22 21 void (*close)(int, void *); 23 - int (*read)(int, char *, void *); 24 - int (*write)(int, const char *, int, void *); 22 + int (*read)(int, __u8 *, void *); 23 + int (*write)(int, const __u8 *, size_t, void *); 25 24 int (*console_write)(int, const char *, int); 26 25 int (*window_size)(int, void *, unsigned short *, unsigned short *); 27 26 void (*free)(void *); ··· 32 31 tty_ops, xterm_ops; 33 32 34 33 extern void generic_close(int fd, void *unused); 35 - extern int generic_read(int fd, char *c_out, void *unused); 36 - extern int generic_write(int fd, const char *buf, int n, void *unused); 34 + extern int generic_read(int fd, __u8 *c_out, void *unused); 35 + extern int generic_write(int fd, const __u8 *buf, size_t n, void *unused); 37 36 extern int generic_console_write(int fd, const char *buf, int n); 38 37 extern int generic_window_size(int fd, void *unused, unsigned short *rows_out, 39 38 unsigned short *cols_out);
+1 -1
arch/um/drivers/line.c
··· 83 83 * 84 84 * Must be called while holding line->lock! 85 85 */ 86 - static int buffer_data(struct line *line, const char *buf, int len) 86 + static int buffer_data(struct line *line, const u8 *buf, size_t len) 87 87 { 88 88 int end, room; 89 89
+3 -3
arch/um/drivers/line.h
··· 47 47 * 48 48 * buffer points to a buffer allocated on demand, of length 49 49 * LINE_BUFSIZE, head to the start of the ring, tail to the end.*/ 50 - char *buffer; 51 - char *head; 52 - char *tail; 50 + u8 *buffer; 51 + u8 *head; 52 + u8 *tail; 53 53 54 54 int sigio; 55 55 struct delayed_work task;
+1 -1
arch/um/drivers/null.c
··· 28 28 return (fd < 0) ? -errno : fd; 29 29 } 30 30 31 - static int null_read(int fd, char *c_out, void *unused) 31 + static int null_read(int fd, __u8 *c_out, void *unused) 32 32 { 33 33 return -ENODEV; 34 34 }
+1 -1
arch/xtensa/platforms/iss/console.c
··· 65 65 struct tty_port *port = &serial_port; 66 66 int i = 0; 67 67 int rd = 1; 68 - unsigned char c; 68 + u8 c; 69 69 70 70 while (simc_poll(0)) { 71 71 rd = simc_read(0, &c, 1);
+2 -2
drivers/bluetooth/btmtkuart.c
··· 383 383 } 384 384 } 385 385 386 - static int btmtkuart_receive_buf(struct serdev_device *serdev, const u8 *data, 387 - size_t count) 386 + static ssize_t btmtkuart_receive_buf(struct serdev_device *serdev, 387 + const u8 *data, size_t count) 388 388 { 389 389 struct btmtkuart_dev *bdev = serdev_device_get_drvdata(serdev); 390 390
+2 -2
drivers/bluetooth/btnxpuart.c
··· 1264 1264 { NXP_RECV_FW_REQ_V3, .recv = nxp_recv_fw_req_v3 }, 1265 1265 }; 1266 1266 1267 - static int btnxpuart_receive_buf(struct serdev_device *serdev, const u8 *data, 1268 - size_t count) 1267 + static ssize_t btnxpuart_receive_buf(struct serdev_device *serdev, 1268 + const u8 *data, size_t count) 1269 1269 { 1270 1270 struct btnxpuart_dev *nxpdev = serdev_device_get_drvdata(serdev); 1271 1271
+2 -2
drivers/bluetooth/hci_serdev.c
··· 271 271 * 272 272 * Return: number of processed bytes 273 273 */ 274 - static int hci_uart_receive_buf(struct serdev_device *serdev, const u8 *data, 275 - size_t count) 274 + static ssize_t hci_uart_receive_buf(struct serdev_device *serdev, 275 + const u8 *data, size_t count) 276 276 { 277 277 struct hci_uart *hu = serdev_device_get_drvdata(serdev); 278 278
+3 -3
drivers/char/ttyprintk.c
··· 40 40 41 41 static int tpk_curr; 42 42 43 - static char tpk_buffer[TPK_STR_SIZE + 4]; 43 + static u8 tpk_buffer[TPK_STR_SIZE + 4]; 44 44 45 45 static void tpk_flush(void) 46 46 { ··· 51 51 } 52 52 } 53 53 54 - static int tpk_printk(const u8 *buf, int count) 54 + static int tpk_printk(const u8 *buf, size_t count) 55 55 { 56 - int i; 56 + size_t i; 57 57 58 58 for (i = 0; i < count; i++) { 59 59 if (tpk_curr >= TPK_STR_SIZE) {
+5 -53
drivers/char/virtio_console.c
··· 230 230 bool guest_connected; 231 231 }; 232 232 233 - /* This is the very early arch-specified put chars function. */ 234 - static int (*early_put_chars)(u32, const char *, int); 235 - 236 233 static struct port *find_port_by_vtermno(u32 vtermno) 237 234 { 238 235 struct port *port; ··· 650 653 * Give out the data that's requested from the buffer that we have 651 654 * queued up. 652 655 */ 653 - static ssize_t fill_readbuf(struct port *port, char __user *out_buf, 656 + static ssize_t fill_readbuf(struct port *port, u8 __user *out_buf, 654 657 size_t out_count, bool to_user) 655 658 { 656 659 struct port_buffer *buf; ··· 669 672 if (ret) 670 673 return -EFAULT; 671 674 } else { 672 - memcpy((__force char *)out_buf, buf->buf + buf->offset, 675 + memcpy((__force u8 *)out_buf, buf->buf + buf->offset, 673 676 out_count); 674 677 } 675 678 ··· 1104 1107 * it to finish: inefficient in theory, but in practice 1105 1108 * implementations will do it immediately. 1106 1109 */ 1107 - static int put_chars(u32 vtermno, const char *buf, int count) 1110 + static ssize_t put_chars(u32 vtermno, const u8 *buf, size_t count) 1108 1111 { 1109 1112 struct port *port; 1110 1113 struct scatterlist sg[1]; 1111 1114 void *data; 1112 1115 int ret; 1113 - 1114 - if (unlikely(early_put_chars)) 1115 - return early_put_chars(vtermno, buf, count); 1116 1116 1117 1117 port = find_port_by_vtermno(vtermno); 1118 1118 if (!port) ··· 1132 1138 * We call out to fill_readbuf that gets us the required data from the 1133 1139 * buffers that are queued up. 1134 1140 */ 1135 - static int get_chars(u32 vtermno, char *buf, int count) 1141 + static ssize_t get_chars(u32 vtermno, u8 *buf, size_t count) 1136 1142 { 1137 1143 struct port *port; 1138 - 1139 - /* If we've not set up the port yet, we have no input to give. */ 1140 - if (unlikely(early_put_chars)) 1141 - return 0; 1142 1144 1143 1145 port = find_port_by_vtermno(vtermno); 1144 1146 if (!port) ··· 1143 1153 /* If we don't have an input queue yet, we can't get input. */ 1144 1154 BUG_ON(!port->in_vq); 1145 1155 1146 - return fill_readbuf(port, (__force char __user *)buf, count, false); 1156 + return fill_readbuf(port, (__force u8 __user *)buf, count, false); 1147 1157 } 1148 1158 1149 1159 static void resize_console(struct port *port) ··· 1191 1201 .notifier_hangup = notifier_del_vio, 1192 1202 }; 1193 1203 1194 - /* 1195 - * Console drivers are initialized very early so boot messages can go 1196 - * out, so we do things slightly differently from the generic virtio 1197 - * initialization of the net and block drivers. 1198 - * 1199 - * At this stage, the console is output-only. It's too early to set 1200 - * up a virtqueue, so we let the drivers do some boutique early-output 1201 - * thing. 1202 - */ 1203 - int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int)) 1204 - { 1205 - early_put_chars = put_chars; 1206 - return hvc_instantiate(0, 0, &hv_ops); 1207 - } 1208 - 1209 1204 static int init_port_console(struct port *port) 1210 1205 { 1211 1206 int ret; ··· 1230 1255 list_add_tail(&port->cons.list, &pdrvdata.consoles); 1231 1256 spin_unlock_irq(&pdrvdata_lock); 1232 1257 port->guest_connected = true; 1233 - 1234 - /* 1235 - * Start using the new console output if this is the first 1236 - * console to come up. 1237 - */ 1238 - if (early_put_chars) 1239 - early_put_chars = NULL; 1240 1258 1241 1259 /* Notify host of port being opened */ 1242 1260 send_control_msg(port, VIRTIO_CONSOLE_PORT_OPEN, 1); ··· 1967 1999 struct ports_device *portdev; 1968 2000 int err; 1969 2001 bool multiport; 1970 - bool early = early_put_chars != NULL; 1971 2002 1972 2003 /* We only need a config space if features are offered */ 1973 2004 if (!vdev->config->get && ··· 1976 2009 __func__); 1977 2010 return -EINVAL; 1978 2011 } 1979 - 1980 - /* Ensure to read early_put_chars now */ 1981 - barrier(); 1982 2012 1983 2013 portdev = kmalloc(sizeof(*portdev), GFP_KERNEL); 1984 2014 if (!portdev) { ··· 2063 2099 2064 2100 __send_control_msg(portdev, VIRTIO_CONSOLE_BAD_ID, 2065 2101 VIRTIO_CONSOLE_DEVICE_READY, 1); 2066 - 2067 - /* 2068 - * If there was an early virtio console, assume that there are no 2069 - * other consoles. We need to wait until the hvc_alloc matches the 2070 - * hvc_instantiate, otherwise tty_open will complain, resulting in 2071 - * a "Warning: unable to open an initial console" boot failure. 2072 - * Without multiport this is done in add_port above. With multiport 2073 - * this might take some host<->guest communication - thus we have to 2074 - * wait. 2075 - */ 2076 - if (multiport && early) 2077 - wait_for_completion(&early_console_added); 2078 2102 2079 2103 return 0; 2080 2104
+2 -2
drivers/gnss/serial.c
··· 80 80 .write_raw = gnss_serial_write_raw, 81 81 }; 82 82 83 - static int gnss_serial_receive_buf(struct serdev_device *serdev, 84 - const unsigned char *buf, size_t count) 83 + static ssize_t gnss_serial_receive_buf(struct serdev_device *serdev, 84 + const u8 *buf, size_t count) 85 85 { 86 86 struct gnss_serial *gserial = serdev_device_get_drvdata(serdev); 87 87 struct gnss_device *gdev = gserial->gdev;
+2 -2
drivers/gnss/sirf.c
··· 160 160 .write_raw = sirf_write_raw, 161 161 }; 162 162 163 - static int sirf_receive_buf(struct serdev_device *serdev, 164 - const unsigned char *buf, size_t count) 163 + static ssize_t sirf_receive_buf(struct serdev_device *serdev, 164 + const u8 *buf, size_t count) 165 165 { 166 166 struct sirf_data *data = serdev_device_get_drvdata(serdev); 167 167 struct gnss_device *gdev = data->gdev;
+3 -2
drivers/greybus/gb-beagleplay.c
··· 271 271 } 272 272 } 273 273 274 - static int hdlc_rx(struct gb_beagleplay *bg, const u8 *data, size_t count) 274 + static ssize_t hdlc_rx(struct gb_beagleplay *bg, const u8 *data, size_t count) 275 275 { 276 276 size_t i; 277 277 u8 c; ··· 331 331 flush_work(&bg->tx_work); 332 332 } 333 333 334 - static int gb_tty_receive(struct serdev_device *sd, const unsigned char *data, size_t count) 334 + static ssize_t gb_tty_receive(struct serdev_device *sd, const u8 *data, 335 + size_t count) 335 336 { 336 337 struct gb_beagleplay *bg = serdev_device_get_drvdata(sd); 337 338
+3 -3
drivers/iio/chemical/pms7003.c
··· 211 211 return checksum == pms7003_calc_checksum(frame); 212 212 } 213 213 214 - static int pms7003_receive_buf(struct serdev_device *serdev, 215 - const unsigned char *buf, size_t size) 214 + static ssize_t pms7003_receive_buf(struct serdev_device *serdev, const u8 *buf, 215 + size_t size) 216 216 { 217 217 struct iio_dev *indio_dev = serdev_device_get_drvdata(serdev); 218 218 struct pms7003_state *state = iio_priv(indio_dev); 219 219 struct pms7003_frame *frame = &state->frame; 220 - int num; 220 + size_t num; 221 221 222 222 if (!frame->expected_length) { 223 223 u16 magic;
+3 -3
drivers/iio/chemical/scd30_serial.c
··· 174 174 return 0; 175 175 } 176 176 177 - static int scd30_serdev_receive_buf(struct serdev_device *serdev, 178 - const unsigned char *buf, size_t size) 177 + static ssize_t scd30_serdev_receive_buf(struct serdev_device *serdev, 178 + const u8 *buf, size_t size) 179 179 { 180 180 struct iio_dev *indio_dev = serdev_device_get_drvdata(serdev); 181 181 struct scd30_serdev_priv *priv; 182 182 struct scd30_state *state; 183 - int num; 183 + size_t num; 184 184 185 185 if (!indio_dev) 186 186 return 0;
+9 -9
drivers/iio/chemical/sps30_serial.c
··· 74 74 } 75 75 76 76 static const struct { 77 - unsigned char byte; 78 - unsigned char byte2; 77 + u8 byte; 78 + u8 byte2; 79 79 } sps30_serial_bytes[] = { 80 80 { 0x11, 0x31 }, 81 81 { 0x13, 0x33 }, ··· 83 83 { 0x7d, 0x5d }, 84 84 }; 85 85 86 - static int sps30_serial_put_byte(unsigned char *buf, unsigned char byte) 86 + static int sps30_serial_put_byte(u8 *buf, u8 byte) 87 87 { 88 88 int i; 89 89 ··· 102 102 return 1; 103 103 } 104 104 105 - static char sps30_serial_get_byte(bool escaped, unsigned char byte2) 105 + static u8 sps30_serial_get_byte(bool escaped, u8 byte2) 106 106 { 107 107 int i; 108 108 ··· 130 130 return ~chksum; 131 131 } 132 132 133 - static int sps30_serial_prep_frame(unsigned char *buf, unsigned char cmd, 134 - const unsigned char *arg, size_t arg_size) 133 + static int sps30_serial_prep_frame(u8 *buf, u8 cmd, const u8 *arg, 134 + size_t arg_size) 135 135 { 136 136 unsigned char chksum; 137 137 int num = 0; ··· 210 210 return rsp_size; 211 211 } 212 212 213 - static int sps30_serial_receive_buf(struct serdev_device *serdev, 214 - const unsigned char *buf, size_t size) 213 + static ssize_t sps30_serial_receive_buf(struct serdev_device *serdev, 214 + const u8 *buf, size_t size) 215 215 { 216 216 struct iio_dev *indio_dev = dev_get_drvdata(&serdev->dev); 217 217 struct sps30_serial_priv *priv; 218 218 struct sps30_state *state; 219 - unsigned char byte; 220 219 size_t i; 220 + u8 byte; 221 221 222 222 if (!indio_dev) 223 223 return 0;
+3 -3
drivers/iio/imu/bno055/bno055_ser_core.c
··· 378 378 * Also, we assume to RX one pkt per time (i.e. the HW doesn't send anything 379 379 * unless we require to AND we don't queue more than one request per time). 380 380 */ 381 - static int bno055_ser_receive_buf(struct serdev_device *serdev, 382 - const unsigned char *buf, size_t size) 381 + static ssize_t bno055_ser_receive_buf(struct serdev_device *serdev, 382 + const u8 *buf, size_t size) 383 383 { 384 384 int status; 385 385 struct bno055_ser_priv *priv = serdev_device_get_drvdata(serdev); 386 - int remaining = size; 386 + size_t remaining = size; 387 387 388 388 if (size == 0) 389 389 return 0;
+6 -8
drivers/ipack/devices/ipoctal.c
··· 158 158 static void ipoctal_irq_rx(struct ipoctal_channel *channel, u8 sr) 159 159 { 160 160 struct tty_port *port = &channel->tty_port; 161 - unsigned char value; 162 - unsigned char flag; 163 - u8 isr; 161 + u8 isr, value, flag; 164 162 165 163 do { 166 164 value = ioread8(&channel->regs->r.rhr); ··· 200 202 201 203 static void ipoctal_irq_tx(struct ipoctal_channel *channel) 202 204 { 203 - unsigned char value; 204 205 unsigned int *pointer_write = &channel->pointer_write; 206 + u8 value; 205 207 206 208 if (channel->nb_bytes == 0) 207 209 return; ··· 434 436 return res; 435 437 } 436 438 437 - static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel, 438 - const u8 *buf, int count) 439 + static inline size_t ipoctal_copy_write_buffer(struct ipoctal_channel *channel, 440 + const u8 *buf, size_t count) 439 441 { 440 442 unsigned long flags; 441 - int i; 443 + size_t i; 442 444 unsigned int *pointer_read = &channel->pointer_read; 443 445 444 446 /* Copy the bytes from the user buffer to the internal one */ ··· 460 462 size_t count) 461 463 { 462 464 struct ipoctal_channel *channel = tty->driver_data; 463 - unsigned int char_copied; 465 + size_t char_copied; 464 466 465 467 char_copied = ipoctal_copy_write_buffer(channel, buf, count); 466 468
+2 -2
drivers/isdn/capi/capi.c
··· 1231 1231 tty_port_hangup(&mp->port); 1232 1232 } 1233 1233 1234 - static void capinc_tty_send_xchar(struct tty_struct *tty, char ch) 1234 + static void capinc_tty_send_xchar(struct tty_struct *tty, u8 ch) 1235 1235 { 1236 - pr_debug("capinc_tty_send_xchar(%d)\n", ch); 1236 + pr_debug("capinc_tty_send_xchar(%u)\n", ch); 1237 1237 } 1238 1238 1239 1239 static const struct tty_operations capinc_ops = {
+5 -5
drivers/mfd/rave-sp.c
··· 471 471 rave_sp_receive_reply(sp, data, length); 472 472 } 473 473 474 - static int rave_sp_receive_buf(struct serdev_device *serdev, 475 - const unsigned char *buf, size_t size) 474 + static ssize_t rave_sp_receive_buf(struct serdev_device *serdev, 475 + const u8 *buf, size_t size) 476 476 { 477 477 struct device *dev = &serdev->dev; 478 478 struct rave_sp *sp = dev_get_drvdata(dev); 479 479 struct rave_sp_deframer *deframer = &sp->deframer; 480 - const unsigned char *src = buf; 481 - const unsigned char *end = buf + size; 480 + const u8 *src = buf; 481 + const u8 *end = buf + size; 482 482 483 483 while (src < end) { 484 - const unsigned char byte = *src++; 484 + const u8 byte = *src++; 485 485 486 486 switch (deframer->state) { 487 487 case RAVE_SP_EXPECT_SOF:
+2 -2
drivers/misc/bcm-vk/bcm_vk_tty.c
··· 64 64 struct bcm_vk_tty *vktty; 65 65 int card_status; 66 66 int count; 67 - unsigned char c; 68 67 int i; 69 68 int wr; 69 + u8 c; 70 70 71 71 card_status = vkread32(vk, BAR_0, BAR_CARD_STATUS); 72 72 if (BCM_VK_INTF_IS_DOWN(card_status)) ··· 192 192 int index; 193 193 struct bcm_vk *vk; 194 194 struct bcm_vk_tty *vktty; 195 - int i; 195 + size_t i; 196 196 197 197 index = tty->index; 198 198 vk = dev_get_drvdata(tty->dev);
+9 -13
drivers/mmc/core/sdio_uart.c
··· 178 178 sdio_release_host(port->func); 179 179 } 180 180 181 - static inline unsigned int sdio_in(struct sdio_uart_port *port, int offset) 181 + static inline u8 sdio_in(struct sdio_uart_port *port, int offset) 182 182 { 183 - unsigned char c; 184 - c = sdio_readb(port->func, port->regs_offset + offset, NULL); 185 - return c; 183 + return sdio_readb(port->func, port->regs_offset + offset, NULL); 186 184 } 187 185 188 186 static inline void sdio_out(struct sdio_uart_port *port, int offset, int value) ··· 190 192 191 193 static unsigned int sdio_uart_get_mctrl(struct sdio_uart_port *port) 192 194 { 193 - unsigned char status; 194 195 unsigned int ret; 196 + u8 status; 195 197 196 198 /* FIXME: What stops this losing the delta bits and breaking 197 199 sdio_uart_check_modem_status ? */ ··· 352 354 sdio_out(port, UART_IER, port->ier); 353 355 } 354 356 355 - static void sdio_uart_receive_chars(struct sdio_uart_port *port, 356 - unsigned int *status) 357 + static void sdio_uart_receive_chars(struct sdio_uart_port *port, u8 *status) 357 358 { 358 - unsigned int ch, flag; 359 359 int max_count = 256; 360 360 361 361 do { 362 - ch = sdio_in(port, UART_RX); 363 - flag = TTY_NORMAL; 362 + u8 ch = sdio_in(port, UART_RX); 363 + u8 flag = TTY_NORMAL; 364 364 port->icount.rx++; 365 365 366 366 if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE | ··· 445 449 446 450 static void sdio_uart_check_modem_status(struct sdio_uart_port *port) 447 451 { 448 - int status; 449 452 struct tty_struct *tty; 453 + u8 status; 450 454 451 455 status = sdio_in(port, UART_MSR); 452 456 ··· 495 499 static void sdio_uart_irq(struct sdio_func *func) 496 500 { 497 501 struct sdio_uart_port *port = sdio_get_drvdata(func); 498 - unsigned int iir, lsr; 502 + u8 iir, lsr; 499 503 500 504 /* 501 505 * In a few places sdio_uart_irq() is called directly instead of ··· 791 795 return kfifo_len(&port->xmit_fifo); 792 796 } 793 797 794 - static void sdio_uart_send_xchar(struct tty_struct *tty, char ch) 798 + static void sdio_uart_send_xchar(struct tty_struct *tty, u8 ch) 795 799 { 796 800 struct sdio_uart_port *port = tty->driver_data; 797 801
+2 -3
drivers/net/ethernet/qualcomm/qca_uart.c
··· 58 58 unsigned char *tx_buffer; 59 59 }; 60 60 61 - static int 62 - qca_tty_receive(struct serdev_device *serdev, const unsigned char *data, 63 - size_t count) 61 + static ssize_t 62 + qca_tty_receive(struct serdev_device *serdev, const u8 *data, size_t count) 64 63 { 65 64 struct qcauart *qca = serdev_device_get_drvdata(serdev); 66 65 struct net_device *netdev = qca->net_dev;
-11
drivers/net/usb/hso.c
··· 363 363 /* driver info */ 364 364 static const char driver_name[] = "hso"; 365 365 static const char tty_filename[] = "ttyHS"; 366 - static const char *version = __FILE__ ": " MOD_AUTHOR; 367 366 /* the usb driver itself (registered in hso_init) */ 368 367 static struct usb_driver hso_driver; 369 368 /* serial structures */ ··· 3227 3228 3228 3229 static int __init hso_init(void) 3229 3230 { 3230 - int i; 3231 3231 int result; 3232 - 3233 - /* put it in the log */ 3234 - pr_info("%s\n", version); 3235 - 3236 - /* Initialise the serial table semaphore and table */ 3237 - for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) 3238 - serial_table[i] = NULL; 3239 3232 3240 3233 /* allocate our driver using the proper amount of supported minors */ 3241 3234 tty_drv = tty_alloc_driver(HSO_SERIAL_TTY_MINORS, TTY_DRIVER_REAL_RAW | ··· 3276 3285 3277 3286 static void __exit hso_exit(void) 3278 3287 { 3279 - pr_info("unloaded\n"); 3280 - 3281 3288 tty_unregister_driver(tty_drv); 3282 3289 /* deregister the usb driver */ 3283 3290 usb_deregister(&hso_driver);
+2 -2
drivers/nfc/pn533/uart.c
··· 203 203 return 0; 204 204 } 205 205 206 - static int pn532_receive_buf(struct serdev_device *serdev, 207 - const unsigned char *data, size_t count) 206 + static ssize_t pn532_receive_buf(struct serdev_device *serdev, 207 + const u8 *data, size_t count) 208 208 { 209 209 struct pn532_uart_phy *dev = serdev_device_get_drvdata(serdev); 210 210 size_t i;
+2 -3
drivers/nfc/s3fwrn5/uart.c
··· 51 51 .write = s3fwrn82_uart_write, 52 52 }; 53 53 54 - static int s3fwrn82_uart_read(struct serdev_device *serdev, 55 - const unsigned char *data, 56 - size_t count) 54 + static ssize_t s3fwrn82_uart_read(struct serdev_device *serdev, 55 + const u8 *data, size_t count) 57 56 { 58 57 struct s3fwrn82_uart_phy *phy = serdev_device_get_drvdata(serdev); 59 58 size_t i;
+2 -3
drivers/platform/chrome/cros_ec_uart.c
··· 81 81 struct response_info response; 82 82 }; 83 83 84 - static int cros_ec_uart_rx_bytes(struct serdev_device *serdev, 85 - const u8 *data, 86 - size_t count) 84 + static ssize_t cros_ec_uart_rx_bytes(struct serdev_device *serdev, 85 + const u8 *data, size_t count) 87 86 { 88 87 struct ec_host_response *host_response; 89 88 struct cros_ec_device *ec_dev = serdev_device_get_drvdata(serdev);
+2 -2
drivers/platform/surface/aggregator/controller.h
··· 238 238 * layer of the controller has been shut down, %-ESHUTDOWN. 239 239 */ 240 240 static inline 241 - int ssam_controller_receive_buf(struct ssam_controller *ctrl, 242 - const unsigned char *buf, size_t n) 241 + ssize_t ssam_controller_receive_buf(struct ssam_controller *ctrl, const u8 *buf, 242 + size_t n) 243 243 { 244 244 return ssh_ptl_rx_rcvbuf(&ctrl->rtl.ptl, buf, n); 245 245 }
+2 -2
drivers/platform/surface/aggregator/core.c
··· 227 227 228 228 /* -- Glue layer (serdev_device -> ssam_controller). ------------------------ */ 229 229 230 - static int ssam_receive_buf(struct serdev_device *dev, const unsigned char *buf, 231 - size_t n) 230 + static ssize_t ssam_receive_buf(struct serdev_device *dev, const u8 *buf, 231 + size_t n) 232 232 { 233 233 struct ssam_controller *ctrl; 234 234 int ret;
+2 -2
drivers/platform/surface/aggregator/ssh_packet_layer.c
··· 1887 1887 * Return: Returns the number of bytes transferred (positive or zero) on 1888 1888 * success. Returns %-ESHUTDOWN if the packet layer has been shut down. 1889 1889 */ 1890 - int ssh_ptl_rx_rcvbuf(struct ssh_ptl *ptl, const u8 *buf, size_t n) 1890 + ssize_t ssh_ptl_rx_rcvbuf(struct ssh_ptl *ptl, const u8 *buf, size_t n) 1891 1891 { 1892 - int used; 1892 + size_t used; 1893 1893 1894 1894 if (test_bit(SSH_PTL_SF_SHUTDOWN_BIT, &ptl->state)) 1895 1895 return -ESHUTDOWN;
+1 -1
drivers/platform/surface/aggregator/ssh_packet_layer.h
··· 162 162 int ssh_ptl_submit(struct ssh_ptl *ptl, struct ssh_packet *p); 163 163 void ssh_ptl_cancel(struct ssh_packet *p); 164 164 165 - int ssh_ptl_rx_rcvbuf(struct ssh_ptl *ptl, const u8 *buf, size_t n); 165 + ssize_t ssh_ptl_rx_rcvbuf(struct ssh_ptl *ptl, const u8 *buf, size_t n); 166 166 167 167 /** 168 168 * ssh_ptl_tx_wakeup_transfer() - Wake up packet transmitter thread for
+12 -13
drivers/s390/char/con3215.c
··· 79 79 struct ccw_device *cdev; /* device for tty driver */ 80 80 spinlock_t *lock; /* pointer to irq lock */ 81 81 int flags; /* state flags */ 82 - char *buffer; /* pointer to output buffer */ 83 - char *inbuf; /* pointer to input buffer */ 82 + u8 *buffer; /* pointer to output buffer */ 83 + u8 *inbuf; /* pointer to input buffer */ 84 84 int head; /* first free byte in output buffer */ 85 85 int count; /* number of bytes in output buffer */ 86 86 int written; /* number of bytes in write requests */ ··· 89 89 wait_queue_head_t empty_wait; /* wait queue for flushing */ 90 90 struct timer_list timer; /* timer for delayed output */ 91 91 int line_pos; /* position on the line (for tabs) */ 92 - char ubuffer[80]; /* copy_from_user buffer */ 93 92 }; 94 93 95 94 /* array of 3215 devices structures */ ··· 522 523 * string without blocking. 523 524 * Return value is the number of bytes copied. 524 525 */ 525 - static unsigned int raw3215_addtext(const char *str, unsigned int length, 526 + static unsigned int raw3215_addtext(const u8 *str, size_t length, 526 527 struct raw3215_info *raw, int opmode, 527 528 unsigned int todrop) 528 529 { 529 - unsigned int c, ch, i, blanks, expanded_size = 0; 530 + unsigned int i, blanks, expanded_size = 0; 530 531 unsigned int column = raw->line_pos; 532 + size_t c; 533 + u8 ch; 531 534 532 535 if (opmode == RAW3215_COUNT) 533 536 todrop = 0; ··· 560 559 if (todrop && expanded_size < todrop) /* Drop head data */ 561 560 continue; 562 561 for (i = 0; i < blanks; i++) { 563 - raw->buffer[raw->head] = (char)_ascebc[(int)ch]; 562 + raw->buffer[raw->head] = _ascebc[ch]; 564 563 raw->head = (raw->head + 1) & (RAW3215_BUFFER_SIZE - 1); 565 564 raw->count++; 566 565 } ··· 572 571 /* 573 572 * String write routine for 3215 devices 574 573 */ 575 - static void raw3215_write(struct raw3215_info *raw, const char *str, 576 - unsigned int length) 574 + static void raw3215_write(struct raw3215_info *raw, const u8 *str, 575 + size_t length) 577 576 { 578 577 unsigned int count, avail; 579 578 unsigned long flags; ··· 598 597 /* 599 598 * Put character routine for 3215 devices 600 599 */ 601 - static void raw3215_putchar(struct raw3215_info *raw, unsigned char ch) 600 + static void raw3215_putchar(struct raw3215_info *raw, u8 ch) 602 601 { 603 602 raw3215_write(raw, &ch, 1); 604 603 } ··· 825 824 .int_class = IRQIO_C15, 826 825 }; 827 826 828 - static void handle_write(struct raw3215_info *raw, const char *str, int count) 827 + static void handle_write(struct raw3215_info *raw, const u8 *str, size_t count) 829 828 { 830 - int i; 831 - 832 829 while (count > 0) { 833 - i = min_t(int, count, RAW3215_BUFFER_SIZE - 1); 830 + size_t i = min_t(size_t, count, RAW3215_BUFFER_SIZE - 1); 834 831 raw3215_write(raw, str, i); 835 832 count -= i; 836 833 str += i;
+6 -6
drivers/s390/char/con3270.c
··· 54 54 }; 55 55 56 56 struct tty3270_cell { 57 - unsigned char character; 57 + u8 character; 58 58 struct tty3270_attribute attributes; 59 59 }; 60 60 ··· 123 123 124 124 /* Character array for put_char/flush_chars. */ 125 125 unsigned int char_count; 126 - char char_buf[TTY3270_CHAR_BUF_SIZE]; 126 + u8 char_buf[TTY3270_CHAR_BUF_SIZE]; 127 127 }; 128 128 129 129 /* tty3270->update_flags. See tty3270_update for details. */ ··· 1255 1255 * Insert character into the screen at the current position with the 1256 1256 * current color and highlight. This function does NOT do cursor movement. 1257 1257 */ 1258 - static void tty3270_put_character(struct tty3270 *tp, char ch) 1258 + static void tty3270_put_character(struct tty3270 *tp, u8 ch) 1259 1259 { 1260 1260 struct tty3270_line *line; 1261 1261 struct tty3270_cell *cell; ··· 1561 1561 * Pn is a numeric parameter, a string of zero or more decimal digits. 1562 1562 * Ps is a selective parameter. 1563 1563 */ 1564 - static void tty3270_escape_sequence(struct tty3270 *tp, char ch) 1564 + static void tty3270_escape_sequence(struct tty3270 *tp, u8 ch) 1565 1565 { 1566 1566 enum { ES_NORMAL, ES_ESC, ES_SQUARE, ES_PAREN, ES_GETPARS }; 1567 1567 ··· 1726 1726 * String write routine for 3270 ttys 1727 1727 */ 1728 1728 static void tty3270_do_write(struct tty3270 *tp, struct tty_struct *tty, 1729 - const unsigned char *buf, int count) 1729 + const u8 *buf, size_t count) 1730 1730 { 1731 1731 int i_msg, i; 1732 1732 ··· 2052 2052 { 2053 2053 struct tty3270 *tp = co->data; 2054 2054 unsigned long flags; 2055 - char c; 2055 + u8 c; 2056 2056 2057 2057 spin_lock_irqsave(&tp->view.lock, flags); 2058 2058 while (count--) {
+7 -9
drivers/tty/amiserial.c
··· 81 81 int quot; 82 82 int IER; /* Interrupt Enable Register */ 83 83 int MCR; /* Modem control register */ 84 - int x_char; /* xon/xoff character */ 84 + u8 x_char; /* xon/xoff character */ 85 85 }; 86 86 87 87 static struct tty_driver *serial_driver; ··· 178 178 { 179 179 int status; 180 180 int serdatr; 181 - unsigned char ch, flag; 181 + u8 ch, flag; 182 182 struct async_icount *icount; 183 - int oe = 0; 183 + bool overrun = false; 184 184 185 185 icount = &info->icount; 186 186 ··· 230 230 * should be ignored. 231 231 */ 232 232 if (status & info->ignore_status_mask) 233 - goto out; 233 + return; 234 234 235 235 status &= info->read_status_mask; 236 236 ··· 251 251 * reported immediately, and doesn't 252 252 * affect the current character 253 253 */ 254 - oe = 1; 254 + overrun = true; 255 255 } 256 256 } 257 257 tty_insert_flip_char(&info->tport, ch, flag); 258 - if (oe == 1) 258 + if (overrun) 259 259 tty_insert_flip_char(&info->tport, 0, TTY_OVERRUN); 260 260 tty_flip_buffer_push(&info->tport); 261 - out: 262 - return; 263 261 } 264 262 265 263 static void transmit_chars(struct serial_state *info) ··· 811 813 * This function is used to send a high-priority XON/XOFF character to 812 814 * the device 813 815 */ 814 - static void rs_send_xchar(struct tty_struct *tty, char ch) 816 + static void rs_send_xchar(struct tty_struct *tty, u8 ch) 815 817 { 816 818 struct serial_state *info = tty->driver_data; 817 819 unsigned long flags;
+10 -8
drivers/tty/ehv_bytechan.c
··· 49 49 unsigned int tx_irq; 50 50 51 51 spinlock_t lock; /* lock for transmit buffer */ 52 - unsigned char buf[BUF_SIZE]; /* transmit circular buffer */ 52 + u8 buf[BUF_SIZE]; /* transmit circular buffer */ 53 53 unsigned int head; /* circular buffer head */ 54 54 unsigned int tail; /* circular buffer tail */ 55 55 ··· 138 138 139 139 static unsigned int local_ev_byte_channel_send(unsigned int handle, 140 140 unsigned int *count, 141 - const char *p) 141 + const u8 *p) 142 142 { 143 - char buffer[EV_BYTE_CHANNEL_MAX_BYTES]; 143 + u8 buffer[EV_BYTE_CHANNEL_MAX_BYTES]; 144 144 unsigned int c = *count; 145 145 146 + /* 147 + * ev_byte_channel_send() expects at least EV_BYTE_CHANNEL_MAX_BYTES 148 + * (16 B) in the buffer. Fake it using a local buffer if needed. 149 + */ 146 150 if (c < sizeof(buffer)) { 147 - memcpy(buffer, p, c); 148 - memset(&buffer[c], 0, sizeof(buffer) - c); 151 + memcpy_and_pad(buffer, sizeof(buffer), p, c, 0); 149 152 p = buffer; 150 153 } 151 154 return ev_byte_channel_send(handle, count, p); ··· 166 163 * has been sent, or if some error has occurred. 167 164 * 168 165 */ 169 - static void byte_channel_spin_send(const char data) 166 + static void byte_channel_spin_send(const u8 data) 170 167 { 171 168 int ret, count; 172 169 ··· 474 471 { 475 472 struct ehv_bc_data *bc = ttys->driver_data; 476 473 unsigned long flags; 477 - unsigned int len; 478 - unsigned int written = 0; 474 + size_t len, written = 0; 479 475 480 476 while (1) { 481 477 spin_lock_irqsave(&bc->lock, flags);
+8 -15
drivers/tty/goldfish.c
··· 50 50 static u32 goldfish_tty_current_line_count; 51 51 static struct goldfish_tty *goldfish_ttys; 52 52 53 - static void do_rw_io(struct goldfish_tty *qtty, 54 - unsigned long address, 55 - unsigned int count, 56 - int is_write) 53 + static void do_rw_io(struct goldfish_tty *qtty, unsigned long address, 54 + size_t count, bool is_write) 57 55 { 58 56 unsigned long irq_flags; 59 57 void __iomem *base = qtty->base; ··· 71 73 spin_unlock_irqrestore(&qtty->lock, irq_flags); 72 74 } 73 75 74 - static void goldfish_tty_rw(struct goldfish_tty *qtty, 75 - unsigned long addr, 76 - unsigned int count, 77 - int is_write) 76 + static void goldfish_tty_rw(struct goldfish_tty *qtty, unsigned long addr, 77 + size_t count, bool is_write) 78 78 { 79 79 dma_addr_t dma_handle; 80 80 enum dma_data_direction dma_dir; ··· 121 125 } 122 126 } 123 127 124 - static void goldfish_tty_do_write(int line, const u8 *buf, unsigned int count) 128 + static void goldfish_tty_do_write(int line, const u8 *buf, size_t count) 125 129 { 126 130 struct goldfish_tty *qtty = &goldfish_ttys[line]; 127 - unsigned long address = (unsigned long)(void *)buf; 128 131 129 - goldfish_tty_rw(qtty, address, count, 1); 132 + goldfish_tty_rw(qtty, (unsigned long)buf, count, true); 130 133 } 131 134 132 135 static irqreturn_t goldfish_tty_interrupt(int irq, void *dev_id) 133 136 { 134 137 struct goldfish_tty *qtty = dev_id; 135 138 void __iomem *base = qtty->base; 136 - unsigned long address; 137 - unsigned char *buf; 139 + u8 *buf; 138 140 u32 count; 139 141 140 142 count = gf_ioread32(base + GOLDFISH_TTY_REG_BYTES_READY); ··· 141 147 142 148 count = tty_prepare_flip_string(&qtty->port, &buf, count); 143 149 144 - address = (unsigned long)(void *)buf; 145 - goldfish_tty_rw(qtty, address, count, 0); 150 + goldfish_tty_rw(qtty, (unsigned long)buf, count, false); 146 151 147 152 tty_flip_buffer_push(&qtty->port); 148 153 return IRQ_HANDLED;
+2 -5
drivers/tty/hvc/hvc_console.c
··· 922 922 return ERR_PTR(err); 923 923 } 924 924 925 - hp = kzalloc(ALIGN(sizeof(*hp), sizeof(long)) + outbuf_size, 926 - GFP_KERNEL); 925 + hp = kzalloc(struct_size(hp, outbuf, outbuf_size), GFP_KERNEL); 927 926 if (!hp) 928 927 return ERR_PTR(-ENOMEM); 929 928 ··· 930 931 hp->data = data; 931 932 hp->ops = ops; 932 933 hp->outbuf_size = outbuf_size; 933 - hp->outbuf = &((char *)hp)[ALIGN(sizeof(*hp), sizeof(long))]; 934 934 935 935 tty_port_init(&hp->port); 936 936 hp->port.ops = &hvc_port_ops; ··· 974 976 } 975 977 EXPORT_SYMBOL_GPL(hvc_alloc); 976 978 977 - int hvc_remove(struct hvc_struct *hp) 979 + void hvc_remove(struct hvc_struct *hp) 978 980 { 979 981 unsigned long flags; 980 982 struct tty_struct *tty; ··· 1008 1010 tty_vhangup(tty); 1009 1011 tty_kref_put(tty); 1010 1012 } 1011 - return 0; 1012 1013 } 1013 1014 EXPORT_SYMBOL_GPL(hvc_remove); 1014 1015
+4 -4
drivers/tty/hvc/hvc_console.h
··· 37 37 spinlock_t lock; 38 38 int index; 39 39 int do_wakeup; 40 - char *outbuf; 41 40 int outbuf_size; 42 41 int n_outbuf; 43 42 uint32_t vtermno; ··· 47 48 struct work_struct tty_resize; 48 49 struct list_head next; 49 50 unsigned long flags; 51 + u8 outbuf[] __aligned(sizeof(long)); 50 52 }; 51 53 52 54 /* implemented by a low level driver */ 53 55 struct hv_ops { 54 - int (*get_chars)(uint32_t vtermno, char *buf, int count); 55 - int (*put_chars)(uint32_t vtermno, const char *buf, int count); 56 + ssize_t (*get_chars)(uint32_t vtermno, u8 *buf, size_t count); 57 + ssize_t (*put_chars)(uint32_t vtermno, const u8 *buf, size_t count); 56 58 int (*flush)(uint32_t vtermno, bool wait); 57 59 58 60 /* Callbacks for notification. Called in open, close and hangup */ ··· 77 77 extern struct hvc_struct * hvc_alloc(uint32_t vtermno, int data, 78 78 const struct hv_ops *ops, int outbuf_size); 79 79 /* remove a vterm from hvc tty operation (module_exit or hotplug remove) */ 80 - extern int hvc_remove(struct hvc_struct *hp); 80 + extern void hvc_remove(struct hvc_struct *hp); 81 81 82 82 /* data available */ 83 83 int hvc_poll(struct hvc_struct *hp);
+20 -12
drivers/tty/hvc/hvc_dcc.c
··· 26 26 /* Lock to serialize access to DCC fifo */ 27 27 static DEFINE_SPINLOCK(dcc_lock); 28 28 29 - static DEFINE_KFIFO(inbuf, unsigned char, DCC_INBUF_SIZE); 30 - static DEFINE_KFIFO(outbuf, unsigned char, DCC_OUTBUF_SIZE); 29 + static DEFINE_KFIFO(inbuf, u8, DCC_INBUF_SIZE); 30 + static DEFINE_KFIFO(outbuf, u8, DCC_OUTBUF_SIZE); 31 31 32 - static void dcc_uart_console_putchar(struct uart_port *port, unsigned char ch) 32 + static void dcc_uart_console_putchar(struct uart_port *port, u8 ch) 33 33 { 34 34 while (__dcc_getstatus() & DCC_STATUS_TX) 35 35 cpu_relax(); ··· 47 47 static int __init dcc_early_console_setup(struct earlycon_device *device, 48 48 const char *opt) 49 49 { 50 + unsigned int count = 0x4000000; 51 + 52 + while (--count && (__dcc_getstatus() & DCC_STATUS_TX)) 53 + cpu_relax(); 54 + 55 + if (__dcc_getstatus() & DCC_STATUS_TX) 56 + return -ENODEV; 57 + 50 58 device->con->write = dcc_early_write; 51 59 52 60 return 0; ··· 62 54 63 55 EARLYCON_DECLARE(dcc, dcc_early_console_setup); 64 56 65 - static int hvc_dcc_put_chars(uint32_t vt, const char *buf, int count) 57 + static ssize_t hvc_dcc_put_chars(uint32_t vt, const u8 *buf, size_t count) 66 58 { 67 - int i; 59 + size_t i; 68 60 69 61 for (i = 0; i < count; i++) { 70 62 while (__dcc_getstatus() & DCC_STATUS_TX) ··· 76 68 return count; 77 69 } 78 70 79 - static int hvc_dcc_get_chars(uint32_t vt, char *buf, int count) 71 + static ssize_t hvc_dcc_get_chars(uint32_t vt, u8 *buf, size_t count) 80 72 { 81 - int i; 73 + size_t i; 82 74 83 75 for (i = 0; i < count; ++i) 84 76 if (__dcc_getstatus() & DCC_STATUS_RX) ··· 157 149 */ 158 150 static void dcc_get_work(struct work_struct *work) 159 151 { 160 - unsigned char ch; 161 152 unsigned long irqflags; 153 + u8 ch; 162 154 163 155 /* 164 156 * Read characters from DCC and put them into the input FIFO, as ··· 180 172 * Write characters directly to the DCC if we're on core 0 and the FIFO 181 173 * is empty, or write them to the FIFO if we're not. 182 174 */ 183 - static int hvc_dcc0_put_chars(u32 vt, const char *buf, int count) 175 + static ssize_t hvc_dcc0_put_chars(u32 vt, const u8 *buf, size_t count) 184 176 { 185 - int len; 186 177 unsigned long irqflags; 178 + ssize_t len; 187 179 188 180 if (!IS_ENABLED(CONFIG_HVC_DCC_SERIALIZE_SMP)) 189 181 return hvc_dcc_put_chars(vt, buf, count); ··· 219 211 * Read characters directly from the DCC if we're on core 0 and the FIFO 220 212 * is empty, or read them from the FIFO if we're not. 221 213 */ 222 - static int hvc_dcc0_get_chars(u32 vt, char *buf, int count) 214 + static ssize_t hvc_dcc0_get_chars(u32 vt, u8 *buf, size_t count) 223 215 { 224 - int len; 225 216 unsigned long irqflags; 217 + ssize_t len; 226 218 227 219 if (!IS_ENABLED(CONFIG_HVC_DCC_SERIALIZE_SMP)) 228 220 return hvc_dcc_get_chars(vt, buf, count);
+9 -9
drivers/tty/hvc/hvc_iucv.c
··· 215 215 * If the IUCV path has been severed, then -EPIPE is returned to cause a 216 216 * hang up (that is issued by the HVC layer). 217 217 */ 218 - static int hvc_iucv_write(struct hvc_iucv_private *priv, 219 - char *buf, int count, int *has_more_data) 218 + static ssize_t hvc_iucv_write(struct hvc_iucv_private *priv, 219 + u8 *buf, size_t count, int *has_more_data) 220 220 { 221 221 struct iucv_tty_buffer *rb; 222 - int written; 222 + ssize_t written; 223 223 int rc; 224 224 225 225 /* immediately return if there is no IUCV connection */ ··· 312 312 * the routine locks the struct hvc_iucv_private->lock to call 313 313 * helper functions. 314 314 */ 315 - static int hvc_iucv_get_chars(uint32_t vtermno, char *buf, int count) 315 + static ssize_t hvc_iucv_get_chars(uint32_t vtermno, u8 *buf, size_t count) 316 316 { 317 317 struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno); 318 - int written; 318 + ssize_t written; 319 319 int has_more_data; 320 320 321 321 if (count <= 0) ··· 352 352 * If an existing IUCV communicaton path has been severed, -EPIPE is returned 353 353 * (that can be passed to HVC layer to cause a tty hangup). 354 354 */ 355 - static int hvc_iucv_queue(struct hvc_iucv_private *priv, const char *buf, 356 - int count) 355 + static ssize_t hvc_iucv_queue(struct hvc_iucv_private *priv, const u8 *buf, 356 + size_t count) 357 357 { 358 358 size_t len; 359 359 ··· 455 455 * Locking: The method gets called under an irqsave() spinlock; and 456 456 * locks struct hvc_iucv_private->lock. 457 457 */ 458 - static int hvc_iucv_put_chars(uint32_t vtermno, const char *buf, int count) 458 + static ssize_t hvc_iucv_put_chars(uint32_t vtermno, const u8 *buf, size_t count) 459 459 { 460 460 struct hvc_iucv_private *priv = hvc_iucv_get_private(vtermno); 461 461 int queued; 462 462 463 - if (count <= 0) 463 + if (!count) 464 464 return 0; 465 465 466 466 if (!priv)
+10 -12
drivers/tty/hvc/hvc_opal.c
··· 58 58 .notifier_hangup = notifier_hangup_irq, 59 59 }; 60 60 61 - static int hvc_opal_hvsi_get_chars(uint32_t vtermno, char *buf, int count) 61 + static ssize_t hvc_opal_hvsi_get_chars(uint32_t vtermno, u8 *buf, size_t count) 62 62 { 63 63 struct hvc_opal_priv *pv = hvc_opal_privs[vtermno]; 64 64 ··· 68 68 return hvsilib_get_chars(&pv->hvsi, buf, count); 69 69 } 70 70 71 - static int hvc_opal_hvsi_put_chars(uint32_t vtermno, const char *buf, int count) 71 + static ssize_t hvc_opal_hvsi_put_chars(uint32_t vtermno, const u8 *buf, 72 + size_t count) 72 73 { 73 74 struct hvc_opal_priv *pv = hvc_opal_privs[vtermno]; 74 75 ··· 233 232 return 0; 234 233 } 235 234 236 - static int hvc_opal_remove(struct platform_device *dev) 235 + static void hvc_opal_remove(struct platform_device *dev) 237 236 { 238 237 struct hvc_struct *hp = dev_get_drvdata(&dev->dev); 239 - int rc, termno; 238 + int termno; 240 239 241 240 termno = hp->vtermno; 242 - rc = hvc_remove(hp); 243 - if (rc == 0) { 244 - if (hvc_opal_privs[termno] != &hvc_opal_boot_priv) 245 - kfree(hvc_opal_privs[termno]); 246 - hvc_opal_privs[termno] = NULL; 247 - } 248 - return rc; 241 + hvc_remove(hp); 242 + if (hvc_opal_privs[termno] != &hvc_opal_boot_priv) 243 + kfree(hvc_opal_privs[termno]); 244 + hvc_opal_privs[termno] = NULL; 249 245 } 250 246 251 247 static struct platform_driver hvc_opal_driver = { 252 248 .probe = hvc_opal_probe, 253 - .remove = hvc_opal_remove, 249 + .remove_new = hvc_opal_remove, 254 250 .driver = { 255 251 .name = hvc_opal_name, 256 252 .of_match_table = hvc_opal_match,
+5 -4
drivers/tty/hvc/hvc_riscv_sbi.c
··· 15 15 16 16 #include "hvc_console.h" 17 17 18 - static int hvc_sbi_tty_put(uint32_t vtermno, const char *buf, int count) 18 + static ssize_t hvc_sbi_tty_put(uint32_t vtermno, const u8 *buf, size_t count) 19 19 { 20 - int i; 20 + size_t i; 21 21 22 22 for (i = 0; i < count; i++) 23 23 sbi_console_putchar(buf[i]); ··· 25 25 return i; 26 26 } 27 27 28 - static int hvc_sbi_tty_get(uint32_t vtermno, char *buf, int count) 28 + static ssize_t hvc_sbi_tty_get(uint32_t vtermno, u8 *buf, size_t count) 29 29 { 30 - int i, c; 30 + size_t i; 31 + int c; 31 32 32 33 for (i = 0; i < count; i++) { 33 34 c = sbi_console_getchar();
+6 -5
drivers/tty/hvc/hvc_rtas.c
··· 31 31 static int rtascons_put_char_token = RTAS_UNKNOWN_SERVICE; 32 32 static int rtascons_get_char_token = RTAS_UNKNOWN_SERVICE; 33 33 34 - static inline int hvc_rtas_write_console(uint32_t vtermno, const char *buf, 35 - int count) 34 + static ssize_t hvc_rtas_write_console(uint32_t vtermno, const u8 *buf, 35 + size_t count) 36 36 { 37 - int i; 37 + size_t i; 38 38 39 39 for (i = 0; i < count; i++) { 40 40 if (rtas_call(rtascons_put_char_token, 1, 1, NULL, buf[i])) ··· 44 44 return i; 45 45 } 46 46 47 - static int hvc_rtas_read_console(uint32_t vtermno, char *buf, int count) 47 + static ssize_t hvc_rtas_read_console(uint32_t vtermno, u8 *buf, size_t count) 48 48 { 49 - int i, c; 49 + size_t i; 50 + int c; 50 51 51 52 for (i = 0; i < count; i++) { 52 53 if (rtas_call(rtascons_get_char_token, 0, 2, &c))
+5 -4
drivers/tty/hvc/hvc_udbg.c
··· 19 19 20 20 static struct hvc_struct *hvc_udbg_dev; 21 21 22 - static int hvc_udbg_put(uint32_t vtermno, const char *buf, int count) 22 + static ssize_t hvc_udbg_put(uint32_t vtermno, const u8 *buf, size_t count) 23 23 { 24 - int i; 24 + size_t i; 25 25 26 26 for (i = 0; i < count && udbg_putc; i++) 27 27 udbg_putc(buf[i]); ··· 29 29 return i; 30 30 } 31 31 32 - static int hvc_udbg_get(uint32_t vtermno, char *buf, int count) 32 + static ssize_t hvc_udbg_get(uint32_t vtermno, u8 *buf, size_t count) 33 33 { 34 - int i, c; 34 + size_t i; 35 + int c; 35 36 36 37 if (!udbg_getc_poll) 37 38 return 0;
+10 -8
drivers/tty/hvc/hvc_vio.c
··· 58 58 hv_protocol_t proto; /* Raw data or HVSI packets */ 59 59 struct hvsi_priv hvsi; /* HVSI specific data */ 60 60 spinlock_t buf_lock; 61 - char buf[SIZE_VIO_GET_CHARS]; 62 - int left; 63 - int offset; 61 + u8 buf[SIZE_VIO_GET_CHARS]; 62 + size_t left; 63 + size_t offset; 64 64 }; 65 65 static struct hvterm_priv *hvterm_privs[MAX_NR_HVC_CONSOLES]; 66 66 /* For early boot console */ 67 67 static struct hvterm_priv hvterm_priv0; 68 68 69 - static int hvterm_raw_get_chars(uint32_t vtermno, char *buf, int count) 69 + static ssize_t hvterm_raw_get_chars(uint32_t vtermno, u8 *buf, size_t count) 70 70 { 71 71 struct hvterm_priv *pv = hvterm_privs[vtermno]; 72 72 unsigned long i; 73 73 unsigned long flags; 74 - int got; 74 + size_t got; 75 75 76 76 if (WARN_ON(!pv)) 77 77 return 0; ··· 115 115 * you are sending fewer chars. 116 116 * @count: number of chars to send. 117 117 */ 118 - static int hvterm_raw_put_chars(uint32_t vtermno, const char *buf, int count) 118 + static ssize_t hvterm_raw_put_chars(uint32_t vtermno, const u8 *buf, 119 + size_t count) 119 120 { 120 121 struct hvterm_priv *pv = hvterm_privs[vtermno]; 121 122 ··· 134 133 .notifier_hangup = notifier_hangup_irq, 135 134 }; 136 135 137 - static int hvterm_hvsi_get_chars(uint32_t vtermno, char *buf, int count) 136 + static ssize_t hvterm_hvsi_get_chars(uint32_t vtermno, u8 *buf, size_t count) 138 137 { 139 138 struct hvterm_priv *pv = hvterm_privs[vtermno]; 140 139 ··· 144 143 return hvsilib_get_chars(&pv->hvsi, buf, count); 145 144 } 146 145 147 - static int hvterm_hvsi_put_chars(uint32_t vtermno, const char *buf, int count) 146 + static ssize_t hvterm_hvsi_put_chars(uint32_t vtermno, const u8 *buf, 147 + size_t count) 148 148 { 149 149 struct hvterm_priv *pv = hvterm_privs[vtermno]; 150 150
+12 -11
drivers/tty/hvc/hvc_xen.c
··· 84 84 notify_remote_via_evtchn(cons->evtchn); 85 85 } 86 86 87 - static int __write_console(struct xencons_info *xencons, 88 - const char *data, int len) 87 + static ssize_t __write_console(struct xencons_info *xencons, 88 + const u8 *data, size_t len) 89 89 { 90 90 XENCONS_RING_IDX cons, prod; 91 91 struct xencons_interface *intf = xencons->intf; 92 - int sent = 0; 93 92 unsigned long flags; 93 + size_t sent = 0; 94 94 95 95 spin_lock_irqsave(&xencons->ring_lock, flags); 96 96 cons = intf->out_cons; ··· 115 115 return sent; 116 116 } 117 117 118 - static int domU_write_console(uint32_t vtermno, const char *data, int len) 118 + static ssize_t domU_write_console(uint32_t vtermno, const u8 *data, size_t len) 119 119 { 120 - int ret = len; 121 120 struct xencons_info *cons = vtermno_to_xencons(vtermno); 121 + size_t ret = len; 122 + 122 123 if (cons == NULL) 123 124 return -EINVAL; 124 125 ··· 130 129 * kernel is crippled. 131 130 */ 132 131 while (len) { 133 - int sent = __write_console(cons, data, len); 132 + ssize_t sent = __write_console(cons, data, len); 134 133 135 134 if (sent < 0) 136 135 return sent; ··· 145 144 return ret; 146 145 } 147 146 148 - static int domU_read_console(uint32_t vtermno, char *buf, int len) 147 + static ssize_t domU_read_console(uint32_t vtermno, u8 *buf, size_t len) 149 148 { 150 149 struct xencons_interface *intf; 151 150 XENCONS_RING_IDX cons, prod; 152 - int recv = 0; 153 151 struct xencons_info *xencons = vtermno_to_xencons(vtermno); 154 152 unsigned int eoiflag = 0; 155 153 unsigned long flags; 154 + size_t recv = 0; 156 155 157 156 if (xencons == NULL) 158 157 return -EINVAL; ··· 210 209 .notifier_hangup = notifier_hangup_irq, 211 210 }; 212 211 213 - static int dom0_read_console(uint32_t vtermno, char *buf, int len) 212 + static ssize_t dom0_read_console(uint32_t vtermno, u8 *buf, size_t len) 214 213 { 215 214 return HYPERVISOR_console_io(CONSOLEIO_read, len, buf); 216 215 } ··· 219 218 * Either for a dom0 to write to the system console, or a domU with a 220 219 * debug version of Xen 221 220 */ 222 - static int dom0_write_console(uint32_t vtermno, const char *str, int len) 221 + static ssize_t dom0_write_console(uint32_t vtermno, const u8 *str, size_t len) 223 222 { 224 - int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (char *)str); 223 + int rc = HYPERVISOR_console_io(CONSOLEIO_write, len, (u8 *)str); 225 224 if (rc < 0) 226 225 return rc; 227 226
+11 -9
drivers/tty/hvc/hvsi_lib.c
··· 12 12 packet->seqno = cpu_to_be16(atomic_inc_return(&pv->seqno)); 13 13 14 14 /* Assumes that always succeeds, works in practice */ 15 - return pv->put_chars(pv->termno, (char *)packet, packet->len); 15 + return pv->put_chars(pv->termno, (u8 *)packet, packet->len); 16 16 } 17 17 18 18 static void hvsi_start_handshake(struct hvsi_priv *pv) ··· 178 178 return 0; 179 179 } 180 180 181 - int hvsilib_get_chars(struct hvsi_priv *pv, char *buf, int count) 181 + ssize_t hvsilib_get_chars(struct hvsi_priv *pv, u8 *buf, size_t count) 182 182 { 183 - unsigned int tries, read = 0; 183 + unsigned int tries; 184 + size_t read = 0; 184 185 185 186 if (WARN_ON(!pv)) 186 187 return -ENXIO; ··· 200 199 for (tries = 1; count && tries < 2; tries++) { 201 200 /* Consume existing data packet */ 202 201 if (pv->inbuf_pktlen) { 203 - unsigned int l = min(count, (int)pv->inbuf_pktlen); 202 + size_t l = min(count, pv->inbuf_pktlen); 204 203 memcpy(&buf[read], &pv->inbuf[pv->inbuf_cur], l); 205 204 pv->inbuf_cur += l; 206 205 pv->inbuf_pktlen -= l; ··· 229 228 return read; 230 229 } 231 230 232 - int hvsilib_put_chars(struct hvsi_priv *pv, const char *buf, int count) 231 + ssize_t hvsilib_put_chars(struct hvsi_priv *pv, const u8 *buf, size_t count) 233 232 { 234 233 struct hvsi_data dp; 235 - int rc, adjcount = min(count, HVSI_MAX_OUTGOING_DATA); 234 + size_t adjcount = min_t(size_t, count, HVSI_MAX_OUTGOING_DATA); 235 + int rc; 236 236 237 237 if (WARN_ON(!pv)) 238 238 return -ENODEV; ··· 413 411 } 414 412 415 413 void hvsilib_init(struct hvsi_priv *pv, 416 - int (*get_chars)(uint32_t termno, char *buf, int count), 417 - int (*put_chars)(uint32_t termno, const char *buf, 418 - int count), 414 + ssize_t (*get_chars)(uint32_t termno, u8 *buf, size_t count), 415 + ssize_t (*put_chars)(uint32_t termno, const u8 *buf, 416 + size_t count), 419 417 int termno, int is_console) 420 418 { 421 419 memset(pv, 0, sizeof(*pv));
-3
drivers/tty/ipwireless/main.h
··· 49 49 50 50 void __iomem *common_memory; 51 51 52 - /* Reference to attribute memory, containing CIS data */ 53 - void *attribute_memory; 54 - 55 52 /* Hardware context */ 56 53 struct ipw_hardware *hardware; 57 54 /* Network layer context */
+5 -5
drivers/tty/mips_ejtag_fdc.c
··· 213 213 */ 214 214 215 215 /* ranges >= 1 && sizes[0] >= 1 */ 216 - static struct fdc_word mips_ejtag_fdc_encode(const char **ptrs, 216 + static struct fdc_word mips_ejtag_fdc_encode(const u8 **ptrs, 217 217 unsigned int *sizes, 218 218 unsigned int ranges) 219 219 { 220 220 struct fdc_word word = { 0, 0 }; 221 - const char **ptrs_end = ptrs + ranges; 221 + const u8 **ptrs_end = ptrs + ranges; 222 222 223 223 for (; ptrs < ptrs_end; ++ptrs) { 224 - const char *ptr = *(ptrs++); 225 - const char *end = ptr + *(sizes++); 224 + const u8 *ptr = *(ptrs++); 225 + const u8 *end = ptr + *(sizes++); 226 226 227 227 for (; ptr < end; ++ptr) { 228 228 word.word |= (u8)*ptr << (8*word.bytes); ··· 417 417 { 418 418 struct mips_ejtag_fdc_tty_port *dport; 419 419 struct tty_struct *tty; 420 - const char *ptrs[2]; 420 + const u8 *ptrs[2]; 421 421 unsigned int sizes[2] = { 0 }; 422 422 struct fdc_word word = { .bytes = 0 }; 423 423 unsigned long flags;
+8 -7
drivers/tty/moxa.c
··· 514 514 static void MoxaPortFlowCtrl(struct moxa_port *, int, int, int, int, int); 515 515 static int MoxaPortLineStatus(struct moxa_port *); 516 516 static void MoxaPortFlushData(struct moxa_port *, int); 517 - static int MoxaPortWriteData(struct tty_struct *, const unsigned char *, int); 517 + static ssize_t MoxaPortWriteData(struct tty_struct *, const u8 *, size_t); 518 518 static int MoxaPortReadData(struct moxa_port *); 519 519 static unsigned int MoxaPortTxQueue(struct moxa_port *); 520 520 static int MoxaPortRxQueue(struct moxa_port *); ··· 1933 1933 * 1934 1934 * Function 20: Write data. 1935 1935 * Syntax: 1936 - * int MoxaPortWriteData(int port, unsigned char * buffer, int length); 1936 + * ssize_t MoxaPortWriteData(int port, u8 *buffer, size_t length); 1937 1937 * int port : port number (0 - 127) 1938 - * unsigned char * buffer : pointer to write data buffer. 1939 - * int length : write data length 1938 + * u8 *buffer : pointer to write data buffer. 1939 + * size_t length : write data length 1940 1940 * 1941 1941 * return: 0 - length : real write data length 1942 1942 * ··· 2163 2163 return val; 2164 2164 } 2165 2165 2166 - static int MoxaPortWriteData(struct tty_struct *tty, const u8 *buffer, int len) 2166 + static ssize_t MoxaPortWriteData(struct tty_struct *tty, const u8 *buffer, 2167 + size_t len) 2167 2168 { 2168 2169 struct moxa_port *port = tty->driver_data; 2169 2170 void __iomem *baseAddr, *ofsAddr, *ofs; 2170 - unsigned int c, total; 2171 + size_t c, total; 2171 2172 u16 head, tail, tx_mask, spage, epage; 2172 2173 u16 pageno, pageofs, bufhead; 2173 2174 ··· 2225 2224 static int MoxaPortReadData(struct moxa_port *port) 2226 2225 { 2227 2226 struct tty_struct *tty = port->port.tty; 2228 - unsigned char *dst; 2229 2227 void __iomem *baseAddr, *ofsAddr, *ofs; 2228 + u8 *dst; 2230 2229 unsigned int count, len, total; 2231 2230 u16 tail, rx_mask, spage, epage; 2232 2231 u16 pageno, pageofs, bufhead, head;
+4 -4
drivers/tty/mxser.c
··· 264 264 u8 rx_low_water; 265 265 int type; /* UART type */ 266 266 267 - unsigned char x_char; /* xon/xoff character */ 267 + u8 x_char; /* xon/xoff character */ 268 268 u8 IER; /* Interrupt Enable Register */ 269 269 u8 MCR; /* Modem control register */ 270 270 u8 FCR; /* FIFO control register */ ··· 905 905 { 906 906 struct mxser_port *info = tty->driver_data; 907 907 unsigned long flags; 908 - int written; 908 + size_t written; 909 909 bool is_empty; 910 910 911 911 spin_lock_irqsave(&info->slock, flags); ··· 1521 1521 if (++ignored > 100) 1522 1522 break; 1523 1523 } else { 1524 - char flag = 0; 1524 + u8 flag = 0; 1525 1525 if (status & UART_LSR_BRK_ERROR_BITS) { 1526 1526 if (status & UART_LSR_BI) { 1527 1527 flag = TTY_BREAK; ··· 1585 1585 1586 1586 count = port->xmit_fifo_size; 1587 1587 do { 1588 - unsigned char c; 1588 + u8 c; 1589 1589 1590 1590 if (!kfifo_get(&port->port.xmit_fifo, &c)) 1591 1591 break;
+8 -9
drivers/tty/n_gsm.c
··· 124 124 u8 addr; /* DLCI address + flags */ 125 125 u8 ctrl; /* Control byte + flags */ 126 126 unsigned int len; /* Length of data block (can be zero) */ 127 - unsigned char *data; /* Points into buffer but not at the start */ 128 - unsigned char buffer[]; 127 + u8 *data; /* Points into buffer but not at the start */ 128 + u8 buffer[]; 129 129 }; 130 130 131 131 enum gsm_dlci_state { ··· 283 283 /* Bits for GSM mode decoding */ 284 284 285 285 /* Framing Layer */ 286 - unsigned char *buf; 286 + u8 *buf; 287 287 enum gsm_mux_state state; 288 288 unsigned int len; 289 289 unsigned int address; ··· 2856 2856 * Receive bytes in gsm mode 0 2857 2857 */ 2858 2858 2859 - static void gsm0_receive(struct gsm_mux *gsm, unsigned char c) 2859 + static void gsm0_receive(struct gsm_mux *gsm, u8 c) 2860 2860 { 2861 2861 unsigned int len; 2862 2862 ··· 2947 2947 * Receive bytes in mode 1 (Advanced option) 2948 2948 */ 2949 2949 2950 - static void gsm1_receive(struct gsm_mux *gsm, unsigned char c) 2950 + static void gsm1_receive(struct gsm_mux *gsm, u8 c) 2951 2951 { 2952 2952 /* handle XON/XOFF */ 2953 2953 if ((c & ISO_IEC_646_MASK) == XON) { ··· 3541 3541 const u8 *fp, size_t count) 3542 3542 { 3543 3543 struct gsm_mux *gsm = tty->disc_data; 3544 - char flags = TTY_NORMAL; 3544 + u8 flags = TTY_NORMAL; 3545 3545 3546 3546 if (debug & DBG_DATA) 3547 3547 gsm_hex_dump_bytes(__func__, cp, count); ··· 3711 3711 { 3712 3712 struct gsm_mux *gsm = tty->disc_data; 3713 3713 unsigned long flags; 3714 - int space; 3714 + size_t space; 3715 3715 int ret; 3716 3716 3717 3717 if (!gsm) ··· 3909 3909 net->stats.tx_errors++; 3910 3910 } 3911 3911 3912 - static void gsm_mux_rx_netchar(struct gsm_dlci *dlci, 3913 - const unsigned char *in_buf, int size) 3912 + static void gsm_mux_rx_netchar(struct gsm_dlci *dlci, const u8 *in_buf, int size) 3914 3913 { 3915 3914 struct net_device *net = dlci->net; 3916 3915 struct sk_buff *skb;
+5 -5
drivers/tty/n_hdlc.c
··· 109 109 110 110 struct n_hdlc_buf { 111 111 struct list_head list_item; 112 - int count; 113 - char buf[]; 112 + size_t count; 113 + u8 buf[]; 114 114 }; 115 115 116 116 struct n_hdlc_buf_list { ··· 263 263 */ 264 264 static void n_hdlc_send_frames(struct n_hdlc *n_hdlc, struct tty_struct *tty) 265 265 { 266 - register int actual; 267 266 unsigned long flags; 268 267 struct n_hdlc_buf *tbuf; 268 + ssize_t actual; 269 269 270 270 check_again: 271 271 ··· 281 281 282 282 tbuf = n_hdlc_buf_get(&n_hdlc->tx_buf_list); 283 283 while (tbuf) { 284 - pr_debug("sending frame %p, count=%d\n", tbuf, tbuf->count); 284 + pr_debug("sending frame %p, count=%zu\n", tbuf, tbuf->count); 285 285 286 286 /* Send the next block of data to device */ 287 287 set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags); ··· 521 521 const u8 *data, size_t count) 522 522 { 523 523 struct n_hdlc *n_hdlc = tty->disc_data; 524 - int error = 0; 525 524 DECLARE_WAITQUEUE(wait, current); 526 525 struct n_hdlc_buf *tbuf; 526 + ssize_t error = 0; 527 527 528 528 pr_debug("%s() called count=%zd\n", __func__, count); 529 529
+4 -23
drivers/tty/nozomi.c
··· 65 65 #define DBG3(args...) DBG_(0x04, ##args) 66 66 #define DBG4(args...) DBG_(0x08, ##args) 67 67 68 - /* TODO: rewrite to optimize macros... */ 69 - 70 68 #define TMP_BUF_MAX 256 71 - 72 - #define DUMP(buf__, len__) \ 73 - do { \ 74 - char tbuf[TMP_BUF_MAX] = {0}; \ 75 - if (len__ > 1) { \ 76 - u32 data_len = min_t(u32, len__, TMP_BUF_MAX); \ 77 - strscpy(tbuf, buf__, data_len); \ 78 - if (tbuf[data_len - 2] == '\r') \ 79 - tbuf[data_len - 2] = 'r'; \ 80 - DBG1("SENDING: '%s' (%d+n)", tbuf, len__); \ 81 - } else { \ 82 - DBG1("SENDING: '%s' (%d)", tbuf, len__); \ 83 - } \ 84 - } while (0) 85 69 86 70 /* Defines */ 87 71 #define NOZOMI_NAME "nozomi" ··· 738 754 return 0; 739 755 } 740 756 741 - /* DUMP(buf, size); */ 742 - 743 757 /* Write length + data */ 744 758 write_mem32(addr, (u32 *) &size, 4); 745 759 write_mem32(addr + 4, (u32 *) dc->send_buf, size); ··· 783 801 tty_insert_flip_char(&port->port, buf[0], TTY_NORMAL); 784 802 size = 0; 785 803 } else if (size < RECEIVE_BUF_MAX) { 786 - size -= tty_insert_flip_string(&port->port, 787 - (char *)buf, size); 804 + size -= tty_insert_flip_string(&port->port, buf, size); 788 805 } else { 789 - i = tty_insert_flip_string(&port->port, 790 - (char *)buf, RECEIVE_BUF_MAX); 806 + i = tty_insert_flip_string(&port->port, buf, 807 + RECEIVE_BUF_MAX); 791 808 size -= i; 792 809 offset += i; 793 810 } ··· 1583 1602 static ssize_t ntty_write(struct tty_struct *tty, const u8 *buffer, 1584 1603 size_t count) 1585 1604 { 1586 - int rval = -EINVAL; 1587 1605 struct nozomi *dc = get_dc_by_tty(tty); 1588 1606 struct port *port = tty->driver_data; 1589 1607 unsigned long flags; 1608 + size_t rval; 1590 1609 1591 1610 if (!dc || !port) 1592 1611 return -ENODEV;
+16 -15
drivers/tty/serdev/core.c
··· 77 77 static void serdev_ctrl_release(struct device *dev) 78 78 { 79 79 struct serdev_controller *ctrl = to_serdev_controller(dev); 80 - ida_simple_remove(&ctrl_ida, ctrl->nr); 80 + ida_free(&ctrl_ida, ctrl->nr); 81 81 kfree(ctrl); 82 82 } 83 83 ··· 225 225 * Return: The number of bytes written (less than count if not enough room in 226 226 * the write buffer), or a negative errno on errors. 227 227 */ 228 - int serdev_device_write_buf(struct serdev_device *serdev, 229 - const unsigned char *buf, size_t count) 228 + int serdev_device_write_buf(struct serdev_device *serdev, const u8 *buf, size_t count) 230 229 { 231 230 struct serdev_controller *ctrl = serdev->ctrl; 232 231 ··· 258 259 * -ETIMEDOUT or -ERESTARTSYS if interrupted before any bytes were written, or 259 260 * a negative errno on errors. 260 261 */ 261 - int serdev_device_write(struct serdev_device *serdev, 262 - const unsigned char *buf, size_t count, 263 - long timeout) 262 + ssize_t serdev_device_write(struct serdev_device *serdev, const u8 *buf, 263 + size_t count, long timeout) 264 264 { 265 265 struct serdev_controller *ctrl = serdev->ctrl; 266 - int written = 0; 267 - int ret; 266 + size_t written = 0; 267 + ssize_t ret; 268 268 269 269 if (!ctrl || !ctrl->ops->write_buf || !serdev->ops->write_wakeup) 270 270 return -EINVAL; ··· 466 468 467 469 /** 468 470 * serdev_controller_alloc() - Allocate a new serdev controller 471 + * @host: serial port hardware controller device 469 472 * @parent: parent device 470 473 * @size: size of private data 471 474 * ··· 475 476 * The allocated private data region may be accessed via 476 477 * serdev_controller_get_drvdata() 477 478 */ 478 - struct serdev_controller *serdev_controller_alloc(struct device *parent, 479 - size_t size) 479 + struct serdev_controller *serdev_controller_alloc(struct device *host, 480 + struct device *parent, 481 + size_t size) 480 482 { 481 483 struct serdev_controller *ctrl; 482 484 int id; ··· 489 489 if (!ctrl) 490 490 return NULL; 491 491 492 - id = ida_simple_get(&ctrl_ida, 0, 0, GFP_KERNEL); 492 + id = ida_alloc(&ctrl_ida, GFP_KERNEL); 493 493 if (id < 0) { 494 494 dev_err(parent, 495 495 "unable to allocate serdev controller identifier.\n"); ··· 502 502 ctrl->dev.type = &serdev_ctrl_type; 503 503 ctrl->dev.bus = &serdev_bus_type; 504 504 ctrl->dev.parent = parent; 505 - device_set_node(&ctrl->dev, dev_fwnode(parent)); 505 + ctrl->host = host; 506 + device_set_node(&ctrl->dev, dev_fwnode(host)); 506 507 serdev_controller_set_drvdata(ctrl, &ctrl[1]); 507 508 508 509 dev_set_name(&ctrl->dev, "serial%d", id); ··· 666 665 acpi_get_parent(adev->handle, &lookup.controller_handle); 667 666 668 667 /* Make sure controller and ResourceSource handle match */ 669 - if (!device_match_acpi_handle(ctrl->dev.parent, lookup.controller_handle)) 668 + if (!device_match_acpi_handle(ctrl->host, lookup.controller_handle)) 670 669 return -ENODEV; 671 670 672 671 return 0; ··· 731 730 bool skip; 732 731 int ret; 733 732 734 - if (!has_acpi_companion(ctrl->dev.parent)) 733 + if (!has_acpi_companion(ctrl->host)) 735 734 return -ENODEV; 736 735 737 736 /* ··· 740 739 * succeed in this case, so that the proper serdev devices can be 741 740 * added "manually" later. 742 741 */ 743 - ret = acpi_quirk_skip_serdev_enumeration(ctrl->dev.parent, &skip); 742 + ret = acpi_quirk_skip_serdev_enumeration(ctrl->host, &skip); 744 743 if (ret) 745 744 return ret; 746 745 if (skip)
+3 -2
drivers/tty/serdev/serdev-ttyport.c
··· 74 74 * Callback functions from the serdev core. 75 75 */ 76 76 77 - static int ttyport_write_buf(struct serdev_controller *ctrl, const unsigned char *data, size_t len) 77 + static ssize_t ttyport_write_buf(struct serdev_controller *ctrl, const u8 *data, size_t len) 78 78 { 79 79 struct serport *serport = serdev_controller_get_drvdata(ctrl); 80 80 struct tty_struct *tty = serport->tty; ··· 274 274 }; 275 275 276 276 struct device *serdev_tty_port_register(struct tty_port *port, 277 + struct device *host, 277 278 struct device *parent, 278 279 struct tty_driver *drv, int idx) 279 280 { ··· 285 284 if (!port || !drv || !parent) 286 285 return ERR_PTR(-ENODEV); 287 286 288 - ctrl = serdev_controller_alloc(parent, sizeof(struct serport)); 287 + ctrl = serdev_controller_alloc(host, parent, sizeof(struct serport)); 289 288 if (!ctrl) 290 289 return ERR_PTR(-ENOMEM); 291 290 serport = serdev_controller_get_drvdata(ctrl);
+2 -4
drivers/tty/serial/8250/8250_aspeed_vuart.c
··· 566 566 return rc; 567 567 } 568 568 569 - static int aspeed_vuart_remove(struct platform_device *pdev) 569 + static void aspeed_vuart_remove(struct platform_device *pdev) 570 570 { 571 571 struct aspeed_vuart *vuart = platform_get_drvdata(pdev); 572 572 ··· 574 574 aspeed_vuart_set_enabled(vuart, false); 575 575 serial8250_unregister_port(vuart->line); 576 576 sysfs_remove_group(&vuart->dev->kobj, &aspeed_vuart_attr_group); 577 - 578 - return 0; 579 577 } 580 578 581 579 static const struct of_device_id aspeed_vuart_table[] = { ··· 588 590 .of_match_table = aspeed_vuart_table, 589 591 }, 590 592 .probe = aspeed_vuart_probe, 591 - .remove = aspeed_vuart_remove, 593 + .remove_new = aspeed_vuart_remove, 592 594 }; 593 595 594 596 module_platform_driver(aspeed_vuart_driver);
+4 -4
drivers/tty/serial/8250/8250_bcm2835aux.c
··· 119 119 120 120 /* get the clock - this also enables the HW */ 121 121 data->clk = devm_clk_get_optional(&pdev->dev, NULL); 122 + if (IS_ERR(data->clk)) 123 + return dev_err_probe(&pdev->dev, PTR_ERR(data->clk), "could not get clk\n"); 122 124 123 125 /* get the interrupt */ 124 126 ret = platform_get_irq(pdev, 0); ··· 197 195 return ret; 198 196 } 199 197 200 - static int bcm2835aux_serial_remove(struct platform_device *pdev) 198 + static void bcm2835aux_serial_remove(struct platform_device *pdev) 201 199 { 202 200 struct bcm2835aux_data *data = platform_get_drvdata(pdev); 203 201 204 202 serial8250_unregister_port(data->line); 205 203 clk_disable_unprepare(data->clk); 206 - 207 - return 0; 208 204 } 209 205 210 206 static const struct bcm2835_aux_serial_driver_data bcm2835_acpi_data = { ··· 228 228 .acpi_match_table = bcm2835aux_serial_acpi_match, 229 229 }, 230 230 .probe = bcm2835aux_serial_probe, 231 - .remove = bcm2835aux_serial_remove, 231 + .remove_new = bcm2835aux_serial_remove, 232 232 }; 233 233 module_platform_driver(bcm2835aux_serial_driver); 234 234
+2 -3
drivers/tty/serial/8250/8250_bcm7271.c
··· 1121 1121 return ret; 1122 1122 } 1123 1123 1124 - static int brcmuart_remove(struct platform_device *pdev) 1124 + static void brcmuart_remove(struct platform_device *pdev) 1125 1125 { 1126 1126 struct brcmuart_priv *priv = platform_get_drvdata(pdev); 1127 1127 ··· 1131 1131 brcmuart_free_bufs(&pdev->dev, priv); 1132 1132 if (priv->dma_enabled) 1133 1133 brcmuart_arbitration(priv, 0); 1134 - return 0; 1135 1134 } 1136 1135 1137 1136 static int __maybe_unused brcmuart_suspend(struct device *dev) ··· 1206 1207 .of_match_table = brcmuart_dt_ids, 1207 1208 }, 1208 1209 .probe = brcmuart_probe, 1209 - .remove = brcmuart_remove, 1210 + .remove_new = brcmuart_remove, 1210 1211 }; 1211 1212 1212 1213 static int __init brcmuart_init(void)
+2 -3
drivers/tty/serial/8250/8250_core.c
··· 883 883 /* 884 884 * Remove serial ports registered against a platform device. 885 885 */ 886 - static int serial8250_remove(struct platform_device *dev) 886 + static void serial8250_remove(struct platform_device *dev) 887 887 { 888 888 int i; 889 889 ··· 893 893 if (up->port.dev == &dev->dev) 894 894 serial8250_unregister_port(i); 895 895 } 896 - return 0; 897 896 } 898 897 899 898 static int serial8250_suspend(struct platform_device *dev, pm_message_t state) ··· 925 926 926 927 static struct platform_driver serial8250_isa_driver = { 927 928 .probe = serial8250_probe, 928 - .remove = serial8250_remove, 929 + .remove_new = serial8250_remove, 929 930 .suspend = serial8250_suspend, 930 931 .resume = serial8250_resume, 931 932 .driver = {
+2 -4
drivers/tty/serial/8250/8250_dw.c
··· 663 663 return 0; 664 664 } 665 665 666 - static int dw8250_remove(struct platform_device *pdev) 666 + static void dw8250_remove(struct platform_device *pdev) 667 667 { 668 668 struct dw8250_data *data = platform_get_drvdata(pdev); 669 669 struct device *dev = &pdev->dev; ··· 680 680 681 681 pm_runtime_disable(dev); 682 682 pm_runtime_put_noidle(dev); 683 - 684 - return 0; 685 683 } 686 684 687 685 static int dw8250_suspend(struct device *dev) ··· 788 790 .acpi_match_table = dw8250_acpi_match, 789 791 }, 790 792 .probe = dw8250_probe, 791 - .remove = dw8250_remove, 793 + .remove_new = dw8250_remove, 792 794 }; 793 795 794 796 module_platform_driver(dw8250_platform_driver);
+5 -11
drivers/tty/serial/8250/8250_dwlib.c
··· 259 259 } 260 260 up->capabilities |= UART_CAP_NOTEMT; 261 261 262 - /* 263 - * If the Component Version Register returns zero, we know that 264 - * ADDITIONAL_FEATURES are not enabled. No need to go any further. 265 - */ 266 - reg = dw8250_readl_ext(p, DW_UART_UCV); 267 - if (!reg) 268 - return; 269 - 270 - dev_dbg(p->dev, "Designware UART version %c.%c%c\n", 271 - (reg >> 24) & 0xff, (reg >> 16) & 0xff, (reg >> 8) & 0xff); 272 - 273 262 /* Preserve value written by firmware or bootloader */ 274 263 old_dlf = dw8250_readl_ext(p, DW_UART_DLF); 275 264 dw8250_writel_ext(p, DW_UART_DLF, ~0U); ··· 270 281 p->get_divisor = dw8250_get_divisor; 271 282 p->set_divisor = dw8250_set_divisor; 272 283 } 284 + 285 + reg = dw8250_readl_ext(p, DW_UART_UCV); 286 + if (reg) 287 + dev_dbg(p->dev, "Designware UART version %c.%c%c\n", 288 + (reg >> 24) & 0xff, (reg >> 16) & 0xff, (reg >> 8) & 0xff); 273 289 274 290 reg = dw8250_readl_ext(p, DW_UART_CPR); 275 291 if (!reg) {
+2 -3
drivers/tty/serial/8250/8250_em.c
··· 200 200 return 0; 201 201 } 202 202 203 - static int serial8250_em_remove(struct platform_device *pdev) 203 + static void serial8250_em_remove(struct platform_device *pdev) 204 204 { 205 205 struct serial8250_em_priv *priv = platform_get_drvdata(pdev); 206 206 207 207 serial8250_unregister_port(priv->line); 208 - return 0; 209 208 } 210 209 211 210 static const struct of_device_id serial8250_em_dt_ids[] = { ··· 219 220 .of_match_table = serial8250_em_dt_ids, 220 221 }, 221 222 .probe = serial8250_em_probe, 222 - .remove = serial8250_em_remove, 223 + .remove_new = serial8250_em_remove, 223 224 }; 224 225 225 226 module_platform_driver(serial8250_em_platform_driver);
+3 -2
drivers/tty/serial/8250/8250_exar.c
··· 480 480 } 481 481 482 482 static const struct serial_rs485 generic_rs485_supported = { 483 - .flags = SER_RS485_ENABLED, 483 + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND, 484 484 }; 485 485 486 486 static const struct exar8250_platform exar8250_default_platform = { ··· 524 524 } 525 525 526 526 static const struct serial_rs485 iot2040_rs485_supported = { 527 - .flags = SER_RS485_ENABLED | SER_RS485_RX_DURING_TX | SER_RS485_TERMINATE_BUS, 527 + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | 528 + SER_RS485_RX_DURING_TX | SER_RS485_TERMINATE_BUS, 528 529 }; 529 530 530 531 static const struct property_entry iot2040_gpio_properties[] = {
+4 -4
drivers/tty/serial/8250/8250_fsl.c
··· 51 51 * immediately and interrupt the CPU again. The hardware clears LSR.BI 52 52 * when the next valid char is read.) 53 53 */ 54 - if (unlikely(up->lsr_saved_flags & UART_LSR_BI)) { 54 + if (unlikely((iir & UART_IIR_ID) == UART_IIR_RLSI && 55 + (up->lsr_saved_flags & UART_LSR_BI))) { 55 56 up->lsr_saved_flags &= ~UART_LSR_BI; 56 57 port->serial_in(port, UART_RX); 57 58 uart_port_unlock_irqrestore(&up->port, flags); ··· 160 159 return 0; 161 160 } 162 161 163 - static int fsl8250_acpi_remove(struct platform_device *pdev) 162 + static void fsl8250_acpi_remove(struct platform_device *pdev) 164 163 { 165 164 struct fsl8250_data *data = platform_get_drvdata(pdev); 166 165 167 166 serial8250_unregister_port(data->line); 168 - return 0; 169 167 } 170 168 171 169 static const struct acpi_device_id fsl_8250_acpi_id[] = { ··· 179 179 .acpi_match_table = ACPI_PTR(fsl_8250_acpi_id), 180 180 }, 181 181 .probe = fsl8250_acpi_probe, 182 - .remove = fsl8250_acpi_remove, 182 + .remove_new = fsl8250_acpi_remove, 183 183 }; 184 184 185 185 module_platform_driver(fsl8250_platform_driver);
+2 -3
drivers/tty/serial/8250/8250_ingenic.c
··· 320 320 return err; 321 321 } 322 322 323 - static int ingenic_uart_remove(struct platform_device *pdev) 323 + static void ingenic_uart_remove(struct platform_device *pdev) 324 324 { 325 325 struct ingenic_uart_data *data = platform_get_drvdata(pdev); 326 326 327 327 serial8250_unregister_port(data->line); 328 328 clk_disable_unprepare(data->clk_module); 329 329 clk_disable_unprepare(data->clk_baud); 330 - return 0; 331 330 } 332 331 333 332 static const struct ingenic_uart_config jz4740_uart_config = { ··· 367 368 .of_match_table = of_match, 368 369 }, 369 370 .probe = ingenic_uart_probe, 370 - .remove = ingenic_uart_remove, 371 + .remove_new = ingenic_uart_remove, 371 372 }; 372 373 373 374 module_platform_driver(ingenic_uart_platform_driver);
+2 -3
drivers/tty/serial/8250/8250_ioc3.c
··· 75 75 return 0; 76 76 } 77 77 78 - static int serial8250_ioc3_remove(struct platform_device *pdev) 78 + static void serial8250_ioc3_remove(struct platform_device *pdev) 79 79 { 80 80 struct ioc3_8250_data *data = platform_get_drvdata(pdev); 81 81 82 82 serial8250_unregister_port(data->line); 83 - return 0; 84 83 } 85 84 86 85 static struct platform_driver serial8250_ioc3_driver = { 87 86 .probe = serial8250_ioc3_probe, 88 - .remove = serial8250_ioc3_remove, 87 + .remove_new = serial8250_ioc3_remove, 89 88 .driver = { 90 89 .name = "ioc3-serial8250", 91 90 }
+2 -4
drivers/tty/serial/8250/8250_lpc18xx.c
··· 182 182 return ret; 183 183 } 184 184 185 - static int lpc18xx_serial_remove(struct platform_device *pdev) 185 + static void lpc18xx_serial_remove(struct platform_device *pdev) 186 186 { 187 187 struct lpc18xx_uart_data *data = platform_get_drvdata(pdev); 188 188 189 189 serial8250_unregister_port(data->line); 190 190 clk_disable_unprepare(data->clk_uart); 191 191 clk_disable_unprepare(data->clk_reg); 192 - 193 - return 0; 194 192 } 195 193 196 194 static const struct of_device_id lpc18xx_serial_match[] = { ··· 199 201 200 202 static struct platform_driver lpc18xx_serial_driver = { 201 203 .probe = lpc18xx_serial_probe, 202 - .remove = lpc18xx_serial_remove, 204 + .remove_new = lpc18xx_serial_remove, 203 205 .driver = { 204 206 .name = "lpc18xx-uart", 205 207 .of_match_table = lpc18xx_serial_match,
+2 -5
drivers/tty/serial/8250/8250_lpss.c
··· 287 287 return 0; 288 288 } 289 289 290 - rx_param = devm_kzalloc(dev, sizeof(*rx_param), GFP_KERNEL); 290 + rx_param = devm_kmemdup(dev, &lpss->dma_param, sizeof(*rx_param), GFP_KERNEL); 291 291 if (!rx_param) 292 292 return -ENOMEM; 293 293 294 - tx_param = devm_kzalloc(dev, sizeof(*tx_param), GFP_KERNEL); 294 + tx_param = devm_kmemdup(dev, &lpss->dma_param, sizeof(*tx_param), GFP_KERNEL); 295 295 if (!tx_param) 296 296 return -ENOMEM; 297 - 298 - *rx_param = lpss->dma_param; 299 - *tx_param = lpss->dma_param; 300 297 301 298 dma->fn = lpss8250_dma_filter; 302 299 dma->rx_param = rx_param;
+2 -4
drivers/tty/serial/8250/8250_mtk.c
··· 581 581 return 0; 582 582 } 583 583 584 - static int mtk8250_remove(struct platform_device *pdev) 584 + static void mtk8250_remove(struct platform_device *pdev) 585 585 { 586 586 struct mtk8250_data *data = platform_get_drvdata(pdev); 587 587 ··· 591 591 592 592 pm_runtime_disable(&pdev->dev); 593 593 pm_runtime_put_noidle(&pdev->dev); 594 - 595 - return 0; 596 594 } 597 595 598 596 static int __maybe_unused mtk8250_suspend(struct device *dev) ··· 650 652 .of_match_table = mtk8250_of_match, 651 653 }, 652 654 .probe = mtk8250_probe, 653 - .remove = mtk8250_remove, 655 + .remove_new = mtk8250_remove, 654 656 }; 655 657 module_platform_driver(mtk8250_platform_driver); 656 658
+2 -3
drivers/tty/serial/8250/8250_of.c
··· 251 251 /* 252 252 * Release a line 253 253 */ 254 - static int of_platform_serial_remove(struct platform_device *ofdev) 254 + static void of_platform_serial_remove(struct platform_device *ofdev) 255 255 { 256 256 struct of_serial_info *info = platform_get_drvdata(ofdev); 257 257 ··· 261 261 pm_runtime_put_sync(&ofdev->dev); 262 262 pm_runtime_disable(&ofdev->dev); 263 263 kfree(info); 264 - return 0; 265 264 } 266 265 267 266 #ifdef CONFIG_PM_SLEEP ··· 336 337 .pm = &of_serial_pm_ops, 337 338 }, 338 339 .probe = of_platform_serial_probe, 339 - .remove = of_platform_serial_remove, 340 + .remove_new = of_platform_serial_remove, 340 341 }; 341 342 342 343 module_platform_driver(of_platform_serial_driver);
+3 -4
drivers/tty/serial/8250/8250_omap.c
··· 1586 1586 return ret; 1587 1587 } 1588 1588 1589 - static int omap8250_remove(struct platform_device *pdev) 1589 + static void omap8250_remove(struct platform_device *pdev) 1590 1590 { 1591 1591 struct omap8250_priv *priv = platform_get_drvdata(pdev); 1592 1592 struct uart_8250_port *up; ··· 1594 1594 1595 1595 err = pm_runtime_resume_and_get(&pdev->dev); 1596 1596 if (err) 1597 - return err; 1597 + dev_err(&pdev->dev, "Failed to resume hardware\n"); 1598 1598 1599 1599 up = serial8250_get_port(priv->line); 1600 1600 omap_8250_shutdown(&up->port); ··· 1606 1606 pm_runtime_disable(&pdev->dev); 1607 1607 cpu_latency_qos_remove_request(&priv->pm_qos_request); 1608 1608 device_init_wakeup(&pdev->dev, false); 1609 - return 0; 1610 1609 } 1611 1610 1612 1611 static int omap8250_prepare(struct device *dev) ··· 1864 1865 .of_match_table = omap8250_dt_ids, 1865 1866 }, 1866 1867 .probe = omap8250_probe, 1867 - .remove = omap8250_remove, 1868 + .remove_new = omap8250_remove, 1868 1869 }; 1869 1870 module_platform_driver(omap8250_platform_driver); 1870 1871
+59 -2
drivers/tty/serial/8250/8250_pci.c
··· 19 19 #include <linux/serial_core.h> 20 20 #include <linux/8250_pci.h> 21 21 #include <linux/bitops.h> 22 + #include <linux/bitfield.h> 22 23 23 24 #include <asm/byteorder.h> 24 25 #include <asm/io.h> ··· 1971 1970 1972 1971 #define MOXA_GPIO_PIN2 BIT(2) 1973 1972 1973 + #define MOXA_RS232 0x00 1974 + #define MOXA_RS422 0x01 1975 + #define MOXA_RS485_4W 0x0B 1976 + #define MOXA_RS485_2W 0x0F 1977 + #define MOXA_UIR_OFFSET 0x04 1978 + #define MOXA_EVEN_RS_MASK GENMASK(3, 0) 1979 + #define MOXA_ODD_RS_MASK GENMASK(7, 4) 1980 + 1981 + enum { 1982 + MOXA_SUPP_RS232 = BIT(0), 1983 + MOXA_SUPP_RS422 = BIT(1), 1984 + MOXA_SUPP_RS485 = BIT(2), 1985 + }; 1986 + 1974 1987 static bool pci_moxa_is_mini_pcie(unsigned short device) 1975 1988 { 1976 1989 if (device == PCI_DEVICE_ID_MOXA_CP102N || ··· 1998 1983 return false; 1999 1984 } 2000 1985 1986 + static unsigned int pci_moxa_supported_rs(struct pci_dev *dev) 1987 + { 1988 + switch (dev->device & 0x0F00) { 1989 + case 0x0000: 1990 + case 0x0600: 1991 + return MOXA_SUPP_RS232; 1992 + case 0x0100: 1993 + return MOXA_SUPP_RS232 | MOXA_SUPP_RS422 | MOXA_SUPP_RS485; 1994 + case 0x0300: 1995 + return MOXA_SUPP_RS422 | MOXA_SUPP_RS485; 1996 + } 1997 + return 0; 1998 + } 1999 + 2000 + static int pci_moxa_set_interface(const struct pci_dev *dev, 2001 + unsigned int port_idx, 2002 + u8 mode) 2003 + { 2004 + resource_size_t iobar_addr = pci_resource_start(dev, 2); 2005 + resource_size_t UIR_addr = iobar_addr + MOXA_UIR_OFFSET + port_idx / 2; 2006 + u8 val; 2007 + 2008 + val = inb(UIR_addr); 2009 + 2010 + if (port_idx % 2) { 2011 + val &= ~MOXA_ODD_RS_MASK; 2012 + val |= FIELD_PREP(MOXA_ODD_RS_MASK, mode); 2013 + } else { 2014 + val &= ~MOXA_EVEN_RS_MASK; 2015 + val |= FIELD_PREP(MOXA_EVEN_RS_MASK, mode); 2016 + } 2017 + outb(val, UIR_addr); 2018 + 2019 + return 0; 2020 + } 2021 + 2001 2022 static int pci_moxa_init(struct pci_dev *dev) 2002 2023 { 2003 2024 unsigned short device = dev->device; 2004 2025 resource_size_t iobar_addr = pci_resource_start(dev, 2); 2005 - unsigned int num_ports = (device & 0x00F0) >> 4; 2006 - u8 val; 2026 + unsigned int num_ports = (device & 0x00F0) >> 4, i; 2027 + u8 val, init_mode = MOXA_RS232; 2028 + 2029 + if (!(pci_moxa_supported_rs(dev) & MOXA_SUPP_RS232)) { 2030 + init_mode = MOXA_RS422; 2031 + } 2032 + for (i = 0; i < num_ports; ++i) 2033 + pci_moxa_set_interface(dev, i, init_mode); 2007 2034 2008 2035 /* 2009 2036 * Enable hardware buffer to prevent break signal output when system boots up.
+196 -14
drivers/tty/serial/8250/8250_pci1xxxx.c
··· 9 9 10 10 #include <linux/bitfield.h> 11 11 #include <linux/bitops.h> 12 + #include <linux/delay.h> 12 13 #include <linux/io.h> 14 + #include <linux/iopoll.h> 13 15 #include <linux/kernel.h> 14 16 #include <linux/module.h> 15 17 #include <linux/pci.h> 16 18 #include <linux/serial_core.h> 19 + #include <linux/serial_reg.h> 20 + #include <linux/serial_8250.h> 17 21 #include <linux/slab.h> 18 22 #include <linux/string.h> 19 23 #include <linux/units.h> 20 24 #include <linux/tty.h> 25 + #include <linux/tty_flip.h> 26 + #include <linux/8250_pci.h> 21 27 22 28 #include <asm/byteorder.h> 23 29 ··· 58 52 #define PCI_SUBDEVICE_ID_EFAR_PCI11400 PCI_DEVICE_ID_EFAR_PCI11400 59 53 #define PCI_SUBDEVICE_ID_EFAR_PCI11414 PCI_DEVICE_ID_EFAR_PCI11414 60 54 55 + #define UART_SYSTEM_ADDR_BASE 0x1000 56 + #define UART_DEV_REV_REG (UART_SYSTEM_ADDR_BASE + 0x00) 57 + #define UART_DEV_REV_MASK GENMASK(7, 0) 58 + #define UART_SYSLOCK_REG (UART_SYSTEM_ADDR_BASE + 0xA0) 59 + #define UART_SYSLOCK BIT(2) 60 + #define SYSLOCK_SLEEP_TIMEOUT 100 61 + #define SYSLOCK_RETRY_CNT 1000 62 + 63 + #define UART_RX_BYTE_FIFO 0x00 64 + #define UART_FIFO_CTL 0x02 65 + 61 66 #define UART_ACTV_REG 0x11 62 67 #define UART_BLOCK_SET_ACTIVE BIT(0) 63 68 ··· 99 82 #define UART_RESET_REG 0x94 100 83 #define UART_RESET_D3_RESET_DISABLE BIT(16) 101 84 85 + #define UART_BURST_STATUS_REG 0x9C 86 + #define UART_RX_BURST_FIFO 0xA4 87 + 102 88 #define MAX_PORTS 4 103 89 #define PORT_OFFSET 0x100 90 + #define RX_BUF_SIZE 512 91 + #define UART_BYTE_SIZE 1 92 + #define UART_BURST_SIZE 4 93 + 94 + #define UART_BST_STAT_RX_COUNT_MASK 0x00FF 95 + #define UART_BST_STAT_IIR_INT_PEND 0x100000 96 + #define UART_LSR_OVERRUN_ERR_CLR 0x43 97 + #define UART_BST_STAT_LSR_RX_MASK 0x9F000000 98 + #define UART_BST_STAT_LSR_RX_ERR_MASK 0x9E000000 99 + #define UART_BST_STAT_LSR_OVERRUN_ERR 0x2000000 100 + #define UART_BST_STAT_LSR_PARITY_ERR 0x4000000 101 + #define UART_BST_STAT_LSR_FRAME_ERR 0x8000000 102 + 103 + struct pci1xxxx_8250 { 104 + unsigned int nr; 105 + u8 dev_rev; 106 + u8 pad[3]; 107 + void __iomem *membase; 108 + int line[] __counted_by(nr); 109 + }; 110 + 111 + static const struct serial_rs485 pci1xxxx_rs485_supported = { 112 + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | 113 + SER_RS485_RTS_AFTER_SEND, 114 + .delay_rts_after_send = 1, 115 + /* Delay RTS before send is not supported */ 116 + }; 117 + 118 + static int pci1xxxx_set_sys_lock(struct pci1xxxx_8250 *port) 119 + { 120 + writel(UART_SYSLOCK, port->membase + UART_SYSLOCK_REG); 121 + return readl(port->membase + UART_SYSLOCK_REG); 122 + } 123 + 124 + static int pci1xxxx_acquire_sys_lock(struct pci1xxxx_8250 *port) 125 + { 126 + u32 regval; 127 + 128 + return readx_poll_timeout(pci1xxxx_set_sys_lock, port, regval, 129 + (regval & UART_SYSLOCK), 130 + SYSLOCK_SLEEP_TIMEOUT, 131 + SYSLOCK_RETRY_CNT * SYSLOCK_SLEEP_TIMEOUT); 132 + } 133 + 134 + static void pci1xxxx_release_sys_lock(struct pci1xxxx_8250 *port) 135 + { 136 + writel(0x0, port->membase + UART_SYSLOCK_REG); 137 + } 104 138 105 139 static const int logical_to_physical_port_idx[][MAX_PORTS] = { 106 140 {0, 1, 2, 3}, /* PCI12000, PCI11010, PCI11101, PCI11400, PCI11414 */ ··· 170 102 {1, -1, -1, -1}, /* PCI1p1 */ 171 103 {2, -1, -1, -1}, /* PCI1p2 */ 172 104 {3, -1, -1, -1}, /* PCI1p3 */ 173 - }; 174 - 175 - struct pci1xxxx_8250 { 176 - unsigned int nr; 177 - void __iomem *membase; 178 - int line[] __counted_by(nr); 179 105 }; 180 106 181 107 static int pci1xxxx_get_num_ports(struct pci_dev *dev) ··· 267 205 return 0; 268 206 } 269 207 270 - static const struct serial_rs485 pci1xxxx_rs485_supported = { 271 - .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | 272 - SER_RS485_RTS_AFTER_SEND, 273 - .delay_rts_after_send = 1, 274 - /* Delay RTS before send is not supported */ 275 - }; 208 + static u32 pci1xxxx_read_burst_status(struct uart_port *port) 209 + { 210 + u32 status; 211 + 212 + status = readl(port->membase + UART_BURST_STATUS_REG); 213 + if (status & UART_BST_STAT_LSR_RX_ERR_MASK) { 214 + if (status & UART_BST_STAT_LSR_OVERRUN_ERR) { 215 + writeb(UART_LSR_OVERRUN_ERR_CLR, 216 + port->membase + UART_FIFO_CTL); 217 + port->icount.overrun++; 218 + } 219 + 220 + if (status & UART_BST_STAT_LSR_FRAME_ERR) 221 + port->icount.frame++; 222 + 223 + if (status & UART_BST_STAT_LSR_PARITY_ERR) 224 + port->icount.parity++; 225 + } 226 + return status; 227 + } 228 + 229 + static void pci1xxxx_process_read_data(struct uart_port *port, 230 + unsigned char *rx_buff, u32 *buff_index, 231 + u32 *valid_byte_count) 232 + { 233 + u32 valid_burst_count = *valid_byte_count / UART_BURST_SIZE; 234 + u32 *burst_buf; 235 + 236 + /* 237 + * Depending on the RX Trigger Level the number of bytes that can be 238 + * stored in RX FIFO at a time varies. Each transaction reads data 239 + * in DWORDs. If there are less than four remaining valid_byte_count 240 + * to read, the data is received one byte at a time. 241 + */ 242 + while (valid_burst_count--) { 243 + if (*buff_index > (RX_BUF_SIZE - UART_BURST_SIZE)) 244 + break; 245 + burst_buf = (u32 *)&rx_buff[*buff_index]; 246 + *burst_buf = readl(port->membase + UART_RX_BURST_FIFO); 247 + *buff_index += UART_BURST_SIZE; 248 + *valid_byte_count -= UART_BURST_SIZE; 249 + } 250 + 251 + while (*valid_byte_count) { 252 + if (*buff_index > RX_BUF_SIZE) 253 + break; 254 + rx_buff[*buff_index] = readb(port->membase + 255 + UART_RX_BYTE_FIFO); 256 + *buff_index += UART_BYTE_SIZE; 257 + *valid_byte_count -= UART_BYTE_SIZE; 258 + } 259 + } 260 + 261 + static void pci1xxxx_rx_burst(struct uart_port *port, u32 uart_status) 262 + { 263 + u32 valid_byte_count = uart_status & UART_BST_STAT_RX_COUNT_MASK; 264 + struct tty_port *tty_port = &port->state->port; 265 + unsigned char rx_buff[RX_BUF_SIZE]; 266 + u32 buff_index = 0; 267 + u32 copied_len; 268 + 269 + if (valid_byte_count != 0 && 270 + valid_byte_count < RX_BUF_SIZE) { 271 + pci1xxxx_process_read_data(port, rx_buff, &buff_index, 272 + &valid_byte_count); 273 + 274 + copied_len = (u32)tty_insert_flip_string(tty_port, rx_buff, 275 + buff_index); 276 + 277 + if (copied_len != buff_index) 278 + port->icount.overrun += buff_index - copied_len; 279 + 280 + port->icount.rx += buff_index; 281 + tty_flip_buffer_push(tty_port); 282 + } 283 + } 284 + 285 + static int pci1xxxx_handle_irq(struct uart_port *port) 286 + { 287 + unsigned long flags; 288 + u32 status; 289 + 290 + status = pci1xxxx_read_burst_status(port); 291 + 292 + if (status & UART_BST_STAT_IIR_INT_PEND) 293 + return 0; 294 + 295 + spin_lock_irqsave(&port->lock, flags); 296 + 297 + if (status & UART_BST_STAT_LSR_RX_MASK) 298 + pci1xxxx_rx_burst(port, status); 299 + 300 + spin_unlock_irqrestore(&port->lock, flags); 301 + 302 + return 1; 303 + } 276 304 277 305 static bool pci1xxxx_port_suspend(int line) 278 306 { ··· 475 323 } 476 324 477 325 static int pci1xxxx_setup(struct pci_dev *pdev, 478 - struct uart_8250_port *port, int port_idx) 326 + struct uart_8250_port *port, int port_idx, int rev) 479 327 { 480 328 int ret; 481 329 ··· 486 334 port->port.set_divisor = pci1xxxx_set_divisor; 487 335 port->port.rs485_config = pci1xxxx_rs485_config; 488 336 port->port.rs485_supported = pci1xxxx_rs485_supported; 337 + 338 + /* From C0 rev Burst operation is supported */ 339 + if (rev >= 0xC0) 340 + port->port.handle_irq = pci1xxxx_handle_irq; 489 341 490 342 ret = serial8250_pci_setup_port(pdev, port, 0, PORT_OFFSET * port_idx, 0); 491 343 if (ret < 0) ··· 526 370 return logical_to_physical_port_idx[0][port]; 527 371 } 528 372 373 + static int pci1xxxx_get_device_revision(struct pci1xxxx_8250 *priv) 374 + { 375 + u32 regval; 376 + int ret; 377 + 378 + /* 379 + * DEV REV is a system register, HW Syslock bit 380 + * should be acquired before accessing the register 381 + */ 382 + ret = pci1xxxx_acquire_sys_lock(priv); 383 + if (ret) 384 + return ret; 385 + 386 + regval = readl(priv->membase + UART_DEV_REV_REG); 387 + priv->dev_rev = regval & UART_DEV_REV_MASK; 388 + 389 + pci1xxxx_release_sys_lock(priv); 390 + 391 + return 0; 392 + } 393 + 529 394 static int pci1xxxx_serial_probe(struct pci_dev *pdev, 530 395 const struct pci_device_id *id) 531 396 { ··· 558 381 int num_vectors; 559 382 int subsys_dev; 560 383 int port_idx; 384 + int ret; 561 385 int rc; 562 386 563 387 rc = pcim_enable_device(pdev); ··· 574 396 priv->membase = pci_ioremap_bar(pdev, 0); 575 397 if (!priv->membase) 576 398 return -ENOMEM; 399 + 400 + ret = pci1xxxx_get_device_revision(priv); 401 + if (ret) 402 + return ret; 577 403 578 404 pci_set_master(pdev); 579 405 ··· 610 428 else 611 429 uart.port.irq = pci_irq_vector(pdev, 0); 612 430 613 - rc = pci1xxxx_setup(pdev, &uart, port_idx); 431 + rc = pci1xxxx_setup(pdev, &uart, port_idx, priv->dev_rev); 614 432 if (rc) { 615 433 dev_warn(dev, "Failed to setup port %u\n", i); 616 434 continue;
+2 -4
drivers/tty/serial/8250/8250_pxa.c
··· 146 146 return ret; 147 147 } 148 148 149 - static int serial_pxa_remove(struct platform_device *pdev) 149 + static void serial_pxa_remove(struct platform_device *pdev) 150 150 { 151 151 struct pxa8250_data *data = platform_get_drvdata(pdev); 152 152 153 153 serial8250_unregister_port(data->line); 154 154 155 155 clk_unprepare(data->clk); 156 - 157 - return 0; 158 156 } 159 157 160 158 static struct platform_driver serial_pxa_driver = { 161 159 .probe = serial_pxa_probe, 162 - .remove = serial_pxa_remove, 160 + .remove_new = serial_pxa_remove, 163 161 164 162 .driver = { 165 163 .name = "pxa2xx-uart",
+2 -4
drivers/tty/serial/8250/8250_tegra.c
··· 128 128 return ret; 129 129 } 130 130 131 - static int tegra_uart_remove(struct platform_device *pdev) 131 + static void tegra_uart_remove(struct platform_device *pdev) 132 132 { 133 133 struct tegra_uart *uart = platform_get_drvdata(pdev); 134 134 135 135 serial8250_unregister_port(uart->line); 136 136 reset_control_assert(uart->rst); 137 137 clk_disable_unprepare(uart->clk); 138 - 139 - return 0; 140 138 } 141 139 142 140 #ifdef CONFIG_PM_SLEEP ··· 190 192 .acpi_match_table = ACPI_PTR(tegra_uart_acpi_match), 191 193 }, 192 194 .probe = tegra_uart_probe, 193 - .remove = tegra_uart_remove, 195 + .remove_new = tegra_uart_remove, 194 196 }; 195 197 196 198 module_platform_driver(tegra_uart_driver);
+2 -4
drivers/tty/serial/8250/8250_uniphier.c
··· 241 241 return 0; 242 242 } 243 243 244 - static int uniphier_uart_remove(struct platform_device *pdev) 244 + static void uniphier_uart_remove(struct platform_device *pdev) 245 245 { 246 246 struct uniphier8250_priv *priv = platform_get_drvdata(pdev); 247 247 248 248 serial8250_unregister_port(priv->line); 249 249 clk_disable_unprepare(priv->clk); 250 - 251 - return 0; 252 250 } 253 251 254 252 static int __maybe_unused uniphier_uart_suspend(struct device *dev) ··· 291 293 292 294 static struct platform_driver uniphier_uart_platform_driver = { 293 295 .probe = uniphier_uart_probe, 294 - .remove = uniphier_uart_remove, 296 + .remove_new = uniphier_uart_remove, 295 297 .driver = { 296 298 .name = "uniphier-uart", 297 299 .of_match_table = uniphier_uart_match,
-6
drivers/tty/serial/8250/serial_cs.c
··· 90 90 const struct serial_quirk *quirk; 91 91 }; 92 92 93 - struct serial_cfg_mem { 94 - tuple_t tuple; 95 - cisparse_t parse; 96 - u_char buf[256]; 97 - }; 98 - 99 93 /* 100 94 * vers_1 5.0, "Brain Boxes", "2-Port RS232 card", "r6" 101 95 * manfid 0x0160, 0x0104
+3
drivers/tty/serial/Kconfig
··· 532 532 help 533 533 Set this to the number of uartlites in your system, or the number 534 534 you think you might implement. 535 + If maximum number of uartlite serial ports is more than 4, then the 536 + driver uses dynamic allocation instead of static allocation for major 537 + number. 535 538 536 539 config SERIAL_SUNCORE 537 540 bool
+2 -4
drivers/tty/serial/altera_jtaguart.c
··· 425 425 return 0; 426 426 } 427 427 428 - static int altera_jtaguart_remove(struct platform_device *pdev) 428 + static void altera_jtaguart_remove(struct platform_device *pdev) 429 429 { 430 430 struct uart_port *port; 431 431 int i = pdev->id; ··· 436 436 port = &altera_jtaguart_ports[i]; 437 437 uart_remove_one_port(&altera_jtaguart_driver, port); 438 438 iounmap(port->membase); 439 - 440 - return 0; 441 439 } 442 440 443 441 #ifdef CONFIG_OF ··· 449 451 450 452 static struct platform_driver altera_jtaguart_platform_driver = { 451 453 .probe = altera_jtaguart_probe, 452 - .remove = altera_jtaguart_remove, 454 + .remove_new = altera_jtaguart_remove, 453 455 .driver = { 454 456 .name = DRV_NAME, 455 457 .of_match_table = of_match_ptr(altera_jtaguart_match),
+3 -5
drivers/tty/serial/altera_uart.c
··· 305 305 int ret; 306 306 307 307 ret = request_irq(port->irq, altera_uart_interrupt, 0, 308 - DRV_NAME, port); 308 + dev_name(port->dev), port); 309 309 if (ret) { 310 310 pr_err(DRV_NAME ": unable to attach Altera UART %d " 311 311 "interrupt vector=%d\n", port->line, port->irq); ··· 595 595 return 0; 596 596 } 597 597 598 - static int altera_uart_remove(struct platform_device *pdev) 598 + static void altera_uart_remove(struct platform_device *pdev) 599 599 { 600 600 struct uart_port *port = platform_get_drvdata(pdev); 601 601 ··· 604 604 port->mapbase = 0; 605 605 iounmap(port->membase); 606 606 } 607 - 608 - return 0; 609 607 } 610 608 611 609 #ifdef CONFIG_OF ··· 617 619 618 620 static struct platform_driver altera_uart_platform_driver = { 619 621 .probe = altera_uart_probe, 620 - .remove = altera_uart_remove, 622 + .remove_new = altera_uart_remove, 621 623 .driver = { 622 624 .name = DRV_NAME, 623 625 .of_match_table = of_match_ptr(altera_uart_match),
+141 -135
drivers/tty/serial/amba-pl011.c
··· 50 50 51 51 #define AMBA_ISR_PASS_LIMIT 256 52 52 53 - #define UART_DR_ERROR (UART011_DR_OE|UART011_DR_BE|UART011_DR_PE|UART011_DR_FE) 54 - #define UART_DUMMY_DR_RX (1 << 16) 53 + #define UART_DR_ERROR (UART011_DR_OE | UART011_DR_BE | UART011_DR_PE | UART011_DR_FE) 54 + #define UART_DUMMY_DR_RX BIT(16) 55 55 56 56 enum { 57 57 REG_DR, ··· 125 125 126 126 static struct vendor_data vendor_arm = { 127 127 .reg_offset = pl011_std_offsets, 128 - .ifls = UART011_IFLS_RX4_8|UART011_IFLS_TX4_8, 128 + .ifls = UART011_IFLS_RX4_8 | UART011_IFLS_TX4_8, 129 129 .fr_busy = UART01x_FR_BUSY, 130 130 .fr_dsr = UART01x_FR_DSR, 131 131 .fr_cts = UART01x_FR_CTS, ··· 203 203 204 204 static struct vendor_data vendor_st = { 205 205 .reg_offset = pl011_st_offsets, 206 - .ifls = UART011_IFLS_RX_HALF|UART011_IFLS_TX_HALF, 206 + .ifls = UART011_IFLS_RX_HALF | UART011_IFLS_TX_HALF, 207 207 .fr_busy = UART01x_FR_BUSY, 208 208 .fr_dsr = UART01x_FR_DSR, 209 209 .fr_cts = UART01x_FR_CTS, ··· 277 277 static unsigned int pl011_tx_empty(struct uart_port *port); 278 278 279 279 static unsigned int pl011_reg_to_offset(const struct uart_amba_port *uap, 280 - unsigned int reg) 280 + unsigned int reg) 281 281 { 282 282 return uap->reg_offset[reg]; 283 283 } 284 284 285 285 static unsigned int pl011_read(const struct uart_amba_port *uap, 286 - unsigned int reg) 286 + unsigned int reg) 287 287 { 288 288 void __iomem *addr = uap->port.membase + pl011_reg_to_offset(uap, reg); 289 289 ··· 292 292 } 293 293 294 294 static void pl011_write(unsigned int val, const struct uart_amba_port *uap, 295 - unsigned int reg) 295 + unsigned int reg) 296 296 { 297 297 void __iomem *addr = uap->port.membase + pl011_reg_to_offset(uap, reg); 298 298 ··· 330 330 uap->port.icount.brk++; 331 331 if (uart_handle_break(&uap->port)) 332 332 continue; 333 - } else if (ch & UART011_DR_PE) 333 + } else if (ch & UART011_DR_PE) { 334 334 uap->port.icount.parity++; 335 - else if (ch & UART011_DR_FE) 335 + } else if (ch & UART011_DR_FE) { 336 336 uap->port.icount.frame++; 337 + } 337 338 if (ch & UART011_DR_OE) 338 339 uap->port.icount.overrun++; 339 340 ··· 359 358 return fifotaken; 360 359 } 361 360 362 - 363 361 /* 364 362 * All the DMA operation mode stuff goes inside this ifdef. 365 363 * This assumes that you have a generic DMA device interface, ··· 369 369 #define PL011_DMA_BUFFER_SIZE PAGE_SIZE 370 370 371 371 static int pl011_dmabuf_init(struct dma_chan *chan, struct pl011_dmabuf *db, 372 - enum dma_data_direction dir) 372 + enum dma_data_direction dir) 373 373 { 374 374 db->buf = dma_alloc_coherent(chan->device->dev, PL011_DMA_BUFFER_SIZE, 375 375 &db->dma, GFP_KERNEL); ··· 381 381 } 382 382 383 383 static void pl011_dmabuf_free(struct dma_chan *chan, struct pl011_dmabuf *db, 384 - enum dma_data_direction dir) 384 + enum dma_data_direction dir) 385 385 { 386 386 if (db->buf) { 387 387 dma_free_coherent(chan->device->dev, ··· 424 424 dma_cap_set(DMA_SLAVE, mask); 425 425 426 426 chan = dma_request_channel(mask, plat->dma_filter, 427 - plat->dma_tx_param); 427 + plat->dma_tx_param); 428 428 if (!chan) { 429 429 dev_err(uap->port.dev, "no TX DMA channel!\n"); 430 430 return; ··· 438 438 dma_chan_name(uap->dmatx.chan)); 439 439 440 440 /* Optionally make use of an RX channel as well */ 441 - chan = dma_request_slave_channel(dev, "rx"); 441 + chan = dma_request_chan(dev, "rx"); 442 442 443 - if (!chan && plat && plat->dma_rx_param) { 443 + if (IS_ERR(chan) && plat && plat->dma_rx_param) { 444 444 chan = dma_request_channel(mask, plat->dma_filter, plat->dma_rx_param); 445 445 446 446 if (!chan) { ··· 449 449 } 450 450 } 451 451 452 - if (chan) { 452 + if (!IS_ERR(chan)) { 453 453 struct dma_slave_config rx_conf = { 454 454 .src_addr = uap->port.mapbase + 455 455 pl011_reg_to_offset(uap, REG_DR), ··· 465 465 * If the controller does, check for suitable residue processing 466 466 * otherwise assime all is well. 467 467 */ 468 - if (0 == dma_get_slave_caps(chan, &caps)) { 468 + if (dma_get_slave_caps(chan, &caps) == 0) { 469 469 if (caps.residue_granularity == 470 470 DMA_RESIDUE_GRANULARITY_DESCRIPTOR) { 471 471 dma_release_channel(chan); 472 472 dev_info(uap->port.dev, 473 - "RX DMA disabled - no residue processing\n"); 473 + "RX DMA disabled - no residue processing\n"); 474 474 return; 475 475 } 476 476 } ··· 499 499 else 500 500 uap->dmarx.poll_timeout = 3000; 501 501 } else if (!plat && dev->of_node) { 502 - uap->dmarx.auto_poll_rate = of_property_read_bool( 503 - dev->of_node, "auto-poll"); 502 + uap->dmarx.auto_poll_rate = 503 + of_property_read_bool(dev->of_node, "auto-poll"); 504 504 if (uap->dmarx.auto_poll_rate) { 505 505 u32 x; 506 506 507 - if (0 == of_property_read_u32(dev->of_node, 508 - "poll-rate-ms", &x)) 507 + if (of_property_read_u32(dev->of_node, "poll-rate-ms", &x) == 0) 509 508 uap->dmarx.poll_rate = x; 510 509 else 511 510 uap->dmarx.poll_rate = 100; 512 - if (0 == of_property_read_u32(dev->of_node, 513 - "poll-timeout-ms", &x)) 511 + if (of_property_read_u32(dev->of_node, "poll-timeout-ms", &x) == 0) 514 512 uap->dmarx.poll_timeout = x; 515 513 else 516 514 uap->dmarx.poll_timeout = 3000; ··· 545 547 uart_port_lock_irqsave(&uap->port, &flags); 546 548 if (uap->dmatx.queued) 547 549 dma_unmap_single(dmatx->chan->device->dev, dmatx->dma, 548 - dmatx->len, DMA_TO_DEVICE); 550 + dmatx->len, DMA_TO_DEVICE); 549 551 550 552 dmacr = uap->dmacr; 551 553 uap->dmacr = dmacr & ~UART011_TXDMAE; ··· 616 618 if (count > PL011_DMA_BUFFER_SIZE) 617 619 count = PL011_DMA_BUFFER_SIZE; 618 620 619 - if (xmit->tail < xmit->head) 621 + if (xmit->tail < xmit->head) { 620 622 memcpy(&dmatx->buf[0], &xmit->buf[xmit->tail], count); 621 - else { 623 + } else { 622 624 size_t first = UART_XMIT_SIZE - xmit->tail; 623 625 size_t second; 624 626 ··· 641 643 } 642 644 643 645 desc = dmaengine_prep_slave_single(chan, dmatx->dma, dmatx->len, DMA_MEM_TO_DEV, 644 - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 646 + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 645 647 if (!desc) { 646 648 dma_unmap_single(dma_dev->dev, dmatx->dma, dmatx->len, DMA_TO_DEVICE); 647 649 uap->dmatx.queued = false; ··· 752 754 if (pl011_dma_tx_refill(uap) > 0) { 753 755 uap->im &= ~UART011_TXIM; 754 756 pl011_write(uap->im, uap, REG_IMSC); 755 - } else 757 + } else { 756 758 ret = false; 759 + } 757 760 } else if (!(uap->dmacr & UART011_TXDMAE)) { 758 761 uap->dmacr |= UART011_TXDMAE; 759 762 pl011_write(uap->dmacr, uap, REG_DMACR); ··· 831 832 dbuf = uap->dmarx.use_buf_b ? 832 833 &uap->dmarx.dbuf_b : &uap->dmarx.dbuf_a; 833 834 desc = dmaengine_prep_slave_single(rxchan, dbuf->dma, dbuf->len, 834 - DMA_DEV_TO_MEM, 835 - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 835 + DMA_DEV_TO_MEM, 836 + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 836 837 /* 837 838 * If the DMA engine is busy and cannot prepare a 838 839 * channel, no big deal, the driver will fall back ··· 888 889 889 890 /* Pick the remain data from the DMA */ 890 891 if (pending) { 891 - 892 892 /* 893 893 * First take all chars in the DMA pipe, then look in the FIFO. 894 894 * Note that tty_insert_flip_buf() tries to take as many chars 895 895 * as it can. 896 896 */ 897 - dma_count = tty_insert_flip_string(port, dbuf->buf + dmataken, 898 - pending); 897 + dma_count = tty_insert_flip_string(port, dbuf->buf + dmataken, pending); 899 898 900 899 uap->port.icount.rx += dma_count; 901 900 if (dma_count < pending) ··· 975 978 /* Switch buffer & re-trigger DMA job */ 976 979 dmarx->use_buf_b = !dmarx->use_buf_b; 977 980 if (pl011_dma_rx_trigger_dma(uap)) { 978 - dev_dbg(uap->port.dev, "could not retrigger RX DMA job " 979 - "fall back to interrupt mode\n"); 981 + dev_dbg(uap->port.dev, 982 + "could not retrigger RX DMA job fall back to interrupt mode\n"); 980 983 uap->im |= UART011_RXIM; 981 984 pl011_write(uap->im, uap, REG_IMSC); 982 985 } ··· 1023 1026 * get some IRQ immediately from RX. 1024 1027 */ 1025 1028 if (ret) { 1026 - dev_dbg(uap->port.dev, "could not retrigger RX DMA job " 1027 - "fall back to interrupt mode\n"); 1029 + dev_dbg(uap->port.dev, 1030 + "could not retrigger RX DMA job fall back to interrupt mode\n"); 1028 1031 uap->im |= UART011_RXIM; 1029 1032 pl011_write(uap->im, uap, REG_IMSC); 1030 1033 } ··· 1069 1072 dmataken = dbuf->len - dmarx->last_residue; 1070 1073 size = dmarx->last_residue - state.residue; 1071 1074 dma_count = tty_insert_flip_string(port, dbuf->buf + dmataken, 1072 - size); 1075 + size); 1073 1076 if (dma_count == size) 1074 1077 dmarx->last_residue = state.residue; 1075 1078 dmarx->last_jiffies = jiffies; ··· 1082 1085 */ 1083 1086 if (jiffies_to_msecs(jiffies - dmarx->last_jiffies) 1084 1087 > uap->dmarx.poll_timeout) { 1085 - 1086 1088 uart_port_lock_irqsave(&uap->port, &flags); 1087 1089 pl011_dma_rx_stop(uap); 1088 1090 uap->im |= UART011_RXIM; ··· 1093 1097 del_timer(&uap->dmarx.timer); 1094 1098 } else { 1095 1099 mod_timer(&uap->dmarx.timer, 1096 - jiffies + msecs_to_jiffies(uap->dmarx.poll_rate)); 1100 + jiffies + msecs_to_jiffies(uap->dmarx.poll_rate)); 1097 1101 } 1098 1102 } 1099 1103 ··· 1109 1113 1110 1114 uap->dmatx.buf = kmalloc(PL011_DMA_BUFFER_SIZE, GFP_KERNEL | __GFP_DMA); 1111 1115 if (!uap->dmatx.buf) { 1112 - dev_err(uap->port.dev, "no memory for DMA TX buffer\n"); 1113 1116 uap->port.fifosize = uap->fifosize; 1114 1117 return; 1115 1118 } ··· 1124 1129 1125 1130 /* Allocate and map DMA RX buffers */ 1126 1131 ret = pl011_dmabuf_init(uap->dmarx.chan, &uap->dmarx.dbuf_a, 1127 - DMA_FROM_DEVICE); 1132 + DMA_FROM_DEVICE); 1128 1133 if (ret) { 1129 1134 dev_err(uap->port.dev, "failed to init DMA %s: %d\n", 1130 1135 "RX buffer A", ret); ··· 1132 1137 } 1133 1138 1134 1139 ret = pl011_dmabuf_init(uap->dmarx.chan, &uap->dmarx.dbuf_b, 1135 - DMA_FROM_DEVICE); 1140 + DMA_FROM_DEVICE); 1136 1141 if (ret) { 1137 1142 dev_err(uap->port.dev, "failed to init DMA %s: %d\n", 1138 1143 "RX buffer B", ret); 1139 1144 pl011_dmabuf_free(uap->dmarx.chan, &uap->dmarx.dbuf_a, 1140 - DMA_FROM_DEVICE); 1145 + DMA_FROM_DEVICE); 1141 1146 goto skip_rx; 1142 1147 } 1143 1148 ··· 1159 1164 1160 1165 if (uap->using_rx_dma) { 1161 1166 if (pl011_dma_rx_trigger_dma(uap)) 1162 - dev_dbg(uap->port.dev, "could not trigger initial " 1163 - "RX DMA job, fall back to interrupt mode\n"); 1167 + dev_dbg(uap->port.dev, 1168 + "could not trigger initial RX DMA job, fall back to interrupt mode\n"); 1164 1169 if (uap->dmarx.poll_rate) { 1165 1170 timer_setup(&uap->dmarx.timer, pl011_dma_rx_poll, 0); 1166 1171 mod_timer(&uap->dmarx.timer, 1167 - jiffies + 1168 - msecs_to_jiffies(uap->dmarx.poll_rate)); 1172 + jiffies + msecs_to_jiffies(uap->dmarx.poll_rate)); 1169 1173 uap->dmarx.last_residue = PL011_DMA_BUFFER_SIZE; 1170 1174 uap->dmarx.last_jiffies = jiffies; 1171 1175 } ··· 1353 1359 struct uart_amba_port *uap = 1354 1360 container_of(port, struct uart_amba_port, port); 1355 1361 1356 - uap->im &= ~(UART011_RXIM|UART011_RTIM|UART011_FEIM| 1357 - UART011_PEIM|UART011_BEIM|UART011_OEIM); 1362 + uap->im &= ~(UART011_RXIM | UART011_RTIM | UART011_FEIM | 1363 + UART011_PEIM | UART011_BEIM | UART011_OEIM); 1358 1364 pl011_write(uap->im, uap, REG_IMSC); 1359 1365 1360 1366 pl011_dma_rx_stop(uap); ··· 1374 1380 struct uart_amba_port *uap = 1375 1381 container_of(port, struct uart_amba_port, port); 1376 1382 1377 - uap->im |= UART011_RIMIM|UART011_CTSMIM|UART011_DCDMIM|UART011_DSRMIM; 1383 + uap->im |= UART011_RIMIM | UART011_CTSMIM | UART011_DCDMIM | UART011_DSRMIM; 1378 1384 pl011_write(uap->im, uap, REG_IMSC); 1379 1385 } 1380 1386 ··· 1392 1398 */ 1393 1399 if (pl011_dma_rx_available(uap)) { 1394 1400 if (pl011_dma_rx_trigger_dma(uap)) { 1395 - dev_dbg(uap->port.dev, "could not trigger RX DMA job " 1396 - "fall back to interrupt mode again\n"); 1401 + dev_dbg(uap->port.dev, 1402 + "could not trigger RX DMA job fall back to interrupt mode again\n"); 1397 1403 uap->im |= UART011_RXIM; 1398 1404 pl011_write(uap->im, uap, REG_IMSC); 1399 1405 } else { ··· 1403 1409 uap->dmarx.last_jiffies = jiffies; 1404 1410 uap->dmarx.last_residue = PL011_DMA_BUFFER_SIZE; 1405 1411 mod_timer(&uap->dmarx.timer, 1406 - jiffies + 1407 - msecs_to_jiffies(uap->dmarx.poll_rate)); 1412 + jiffies + msecs_to_jiffies(uap->dmarx.poll_rate)); 1408 1413 } 1409 1414 #endif 1410 1415 } ··· 1550 1557 do { 1551 1558 check_apply_cts_event_workaround(uap); 1552 1559 1553 - pl011_write(status & ~(UART011_TXIS|UART011_RTIS| 1554 - UART011_RXIS), 1560 + pl011_write(status & ~(UART011_TXIS | UART011_RTIS | UART011_RXIS), 1555 1561 uap, REG_ICR); 1556 1562 1557 - if (status & (UART011_RTIS|UART011_RXIS)) { 1563 + if (status & (UART011_RTIS | UART011_RXIS)) { 1558 1564 if (pl011_dma_rx_running(uap)) 1559 1565 pl011_dma_rx_irq(uap); 1560 1566 else 1561 1567 pl011_rx_chars(uap); 1562 1568 } 1563 - if (status & (UART011_DSRMIS|UART011_DCDMIS| 1564 - UART011_CTSMIS|UART011_RIMIS)) 1569 + if (status & (UART011_DSRMIS | UART011_DCDMIS | 1570 + UART011_CTSMIS | UART011_RIMIS)) 1565 1571 pl011_modem_status(uap); 1566 1572 if (status & UART011_TXIS) 1567 1573 pl011_tx_chars(uap, true); ··· 1590 1598 0 : TIOCSER_TEMT; 1591 1599 } 1592 1600 1601 + static void pl011_maybe_set_bit(bool cond, unsigned int *ptr, unsigned int mask) 1602 + { 1603 + if (cond) 1604 + *ptr |= mask; 1605 + } 1606 + 1593 1607 static unsigned int pl011_get_mctrl(struct uart_port *port) 1594 1608 { 1595 1609 struct uart_amba_port *uap = ··· 1603 1605 unsigned int result = 0; 1604 1606 unsigned int status = pl011_read(uap, REG_FR); 1605 1607 1606 - #define TIOCMBIT(uartbit, tiocmbit) \ 1607 - if (status & uartbit) \ 1608 - result |= tiocmbit 1608 + pl011_maybe_set_bit(status & UART01x_FR_DCD, &result, TIOCM_CAR); 1609 + pl011_maybe_set_bit(status & uap->vendor->fr_dsr, &result, TIOCM_DSR); 1610 + pl011_maybe_set_bit(status & uap->vendor->fr_cts, &result, TIOCM_CTS); 1611 + pl011_maybe_set_bit(status & uap->vendor->fr_ri, &result, TIOCM_RNG); 1609 1612 1610 - TIOCMBIT(UART01x_FR_DCD, TIOCM_CAR); 1611 - TIOCMBIT(uap->vendor->fr_dsr, TIOCM_DSR); 1612 - TIOCMBIT(uap->vendor->fr_cts, TIOCM_CTS); 1613 - TIOCMBIT(uap->vendor->fr_ri, TIOCM_RNG); 1614 - #undef TIOCMBIT 1615 1613 return result; 1614 + } 1615 + 1616 + static void pl011_assign_bit(bool cond, unsigned int *ptr, unsigned int mask) 1617 + { 1618 + if (cond) 1619 + *ptr |= mask; 1620 + else 1621 + *ptr &= ~mask; 1616 1622 } 1617 1623 1618 1624 static void pl011_set_mctrl(struct uart_port *port, unsigned int mctrl) ··· 1627 1625 1628 1626 cr = pl011_read(uap, REG_CR); 1629 1627 1630 - #define TIOCMBIT(tiocmbit, uartbit) \ 1631 - if (mctrl & tiocmbit) \ 1632 - cr |= uartbit; \ 1633 - else \ 1634 - cr &= ~uartbit 1635 - 1636 - TIOCMBIT(TIOCM_RTS, UART011_CR_RTS); 1637 - TIOCMBIT(TIOCM_DTR, UART011_CR_DTR); 1638 - TIOCMBIT(TIOCM_OUT1, UART011_CR_OUT1); 1639 - TIOCMBIT(TIOCM_OUT2, UART011_CR_OUT2); 1640 - TIOCMBIT(TIOCM_LOOP, UART011_CR_LBE); 1628 + pl011_assign_bit(mctrl & TIOCM_RTS, &cr, UART011_CR_RTS); 1629 + pl011_assign_bit(mctrl & TIOCM_DTR, &cr, UART011_CR_DTR); 1630 + pl011_assign_bit(mctrl & TIOCM_OUT1, &cr, UART011_CR_OUT1); 1631 + pl011_assign_bit(mctrl & TIOCM_OUT2, &cr, UART011_CR_OUT2); 1632 + pl011_assign_bit(mctrl & TIOCM_LOOP, &cr, UART011_CR_LBE); 1641 1633 1642 1634 if (port->status & UPSTAT_AUTORTS) { 1643 1635 /* We need to disable auto-RTS if we want to turn RTS off */ 1644 - TIOCMBIT(TIOCM_RTS, UART011_CR_RTSEN); 1636 + pl011_assign_bit(mctrl & TIOCM_RTS, &cr, UART011_CR_RTSEN); 1645 1637 } 1646 - #undef TIOCMBIT 1647 1638 1648 1639 pl011_write(cr, uap, REG_CR); 1649 1640 } ··· 1702 1707 return pl011_read(uap, REG_DR); 1703 1708 } 1704 1709 1705 - static void pl011_put_poll_char(struct uart_port *port, 1706 - unsigned char ch) 1710 + static void pl011_put_poll_char(struct uart_port *port, unsigned char ch) 1707 1711 { 1708 1712 struct uart_amba_port *uap = 1709 1713 container_of(port, struct uart_amba_port, port); ··· 1903 1909 return 0; 1904 1910 } 1905 1911 1906 - static void pl011_shutdown_channel(struct uart_amba_port *uap, 1907 - unsigned int lcrh) 1912 + static void pl011_shutdown_channel(struct uart_amba_port *uap, unsigned int lcrh) 1908 1913 { 1909 - unsigned long val; 1914 + unsigned long val; 1910 1915 1911 - val = pl011_read(uap, lcrh); 1912 - val &= ~(UART01x_LCRH_BRK | UART01x_LCRH_FEN); 1913 - pl011_write(val, uap, lcrh); 1916 + val = pl011_read(uap, lcrh); 1917 + val &= ~(UART01x_LCRH_BRK | UART01x_LCRH_FEN); 1918 + pl011_write(val, uap, lcrh); 1914 1919 } 1915 1920 1916 1921 /* ··· 2058 2065 uap->dmarx.poll_rate = DIV_ROUND_UP(10000000, baud); 2059 2066 #endif 2060 2067 2061 - if (baud > port->uartclk/16) 2068 + if (baud > port->uartclk / 16) 2062 2069 quot = DIV_ROUND_CLOSEST(port->uartclk * 8, baud); 2063 2070 else 2064 2071 quot = DIV_ROUND_CLOSEST(port->uartclk * 4, baud); ··· 2140 2147 * else we see data corruption. 2141 2148 */ 2142 2149 if (uap->vendor->oversampling) { 2143 - if ((baud >= 3000000) && (baud < 3250000) && (quot > 1)) 2150 + if (baud >= 3000000 && baud < 3250000 && quot > 1) 2144 2151 quot -= 1; 2145 - else if ((baud > 3250000) && (quot > 2)) 2152 + else if (baud > 3250000 && quot > 2) 2146 2153 quot -= 2; 2147 2154 } 2148 2155 /* Set baud rate */ ··· 2211 2218 static int pl011_verify_port(struct uart_port *port, struct serial_struct *ser) 2212 2219 { 2213 2220 int ret = 0; 2221 + 2214 2222 if (ser->type != PORT_UNKNOWN && ser->type != PORT_AMBA) 2215 2223 ret = -EINVAL; 2216 2224 if (ser->irq < 0 || ser->irq >= nr_irqs) 2217 2225 ret = -EINVAL; 2218 2226 if (ser->baud_base < 9600) 2219 2227 ret = -EINVAL; 2220 - if (port->mapbase != (unsigned long) ser->iomem_base) 2228 + if (port->mapbase != (unsigned long)ser->iomem_base) 2221 2229 ret = -EINVAL; 2222 2230 return ret; 2223 2231 } ··· 2363 2369 static void pl011_console_get_options(struct uart_amba_port *uap, int *baud, 2364 2370 int *parity, int *bits) 2365 2371 { 2366 - if (pl011_read(uap, REG_CR) & UART01x_CR_UARTEN) { 2367 - unsigned int lcr_h, ibrd, fbrd; 2372 + unsigned int lcr_h, ibrd, fbrd; 2368 2373 2369 - lcr_h = pl011_read(uap, REG_LCRH_TX); 2374 + if (!(pl011_read(uap, REG_CR) & UART01x_CR_UARTEN)) 2375 + return; 2370 2376 2371 - *parity = 'n'; 2372 - if (lcr_h & UART01x_LCRH_PEN) { 2373 - if (lcr_h & UART01x_LCRH_EPS) 2374 - *parity = 'e'; 2375 - else 2376 - *parity = 'o'; 2377 - } 2377 + lcr_h = pl011_read(uap, REG_LCRH_TX); 2378 2378 2379 - if ((lcr_h & 0x60) == UART01x_LCRH_WLEN_7) 2380 - *bits = 7; 2379 + *parity = 'n'; 2380 + if (lcr_h & UART01x_LCRH_PEN) { 2381 + if (lcr_h & UART01x_LCRH_EPS) 2382 + *parity = 'e'; 2381 2383 else 2382 - *bits = 8; 2383 - 2384 - ibrd = pl011_read(uap, REG_IBRD); 2385 - fbrd = pl011_read(uap, REG_FBRD); 2386 - 2387 - *baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd); 2388 - 2389 - if (uap->vendor->oversampling) { 2390 - if (pl011_read(uap, REG_CR) 2391 - & ST_UART011_CR_OVSFACT) 2392 - *baud *= 2; 2393 - } 2384 + *parity = 'o'; 2394 2385 } 2386 + 2387 + if ((lcr_h & 0x60) == UART01x_LCRH_WLEN_7) 2388 + *bits = 7; 2389 + else 2390 + *bits = 8; 2391 + 2392 + ibrd = pl011_read(uap, REG_IBRD); 2393 + fbrd = pl011_read(uap, REG_FBRD); 2394 + 2395 + *baud = uap->port.uartclk * 4 / (64 * ibrd + fbrd); 2396 + 2397 + if (uap->vendor->oversampling && 2398 + (pl011_read(uap, REG_CR) & ST_UART011_CR_OVSFACT)) 2399 + *baud *= 2; 2395 2400 } 2396 2401 2397 2402 static int pl011_console_setup(struct console *co, char *options) ··· 2526 2533 cpu_relax(); 2527 2534 } 2528 2535 2529 - static void qdf2400_e44_early_write(struct console *con, const char *s, unsigned n) 2536 + static void qdf2400_e44_early_write(struct console *con, const char *s, unsigned int n) 2530 2537 { 2531 2538 struct earlycon_device *dev = con->data; 2532 2539 ··· 2545 2552 cpu_relax(); 2546 2553 } 2547 2554 2548 - static void pl011_early_write(struct console *con, const char *s, unsigned n) 2555 + static void pl011_early_write(struct console *con, const char *s, unsigned int n) 2549 2556 { 2550 2557 struct earlycon_device *dev = con->data; 2551 2558 ··· 2606 2613 2607 2614 return 0; 2608 2615 } 2616 + 2609 2617 OF_EARLYCON_DECLARE(pl011, "arm,pl011", pl011_early_console_setup); 2618 + 2610 2619 OF_EARLYCON_DECLARE(pl011, "arm,sbsa-uart", pl011_early_console_setup); 2611 2620 2612 2621 /* ··· 2631 2636 device->con->write = qdf2400_e44_early_write; 2632 2637 return 0; 2633 2638 } 2639 + 2634 2640 EARLYCON_DECLARE(qdf2400_e44, qdf2400_e44_early_console_setup); 2635 2641 2636 2642 #else ··· 2651 2655 static int pl011_probe_dt_alias(int index, struct device *dev) 2652 2656 { 2653 2657 struct device_node *np; 2654 - static bool seen_dev_with_alias = false; 2655 - static bool seen_dev_without_alias = false; 2658 + static bool seen_dev_with_alias; 2659 + static bool seen_dev_without_alias; 2656 2660 int ret = index; 2657 2661 2658 2662 if (!IS_ENABLED(CONFIG_OF)) ··· 2668 2672 ret = index; 2669 2673 } else { 2670 2674 seen_dev_with_alias = true; 2671 - if (ret >= ARRAY_SIZE(amba_ports) || amba_ports[ret] != NULL) { 2675 + if (ret >= ARRAY_SIZE(amba_ports) || amba_ports[ret]) { 2672 2676 dev_warn(dev, "requested serial port %d not available.\n", ret); 2673 2677 ret = index; 2674 2678 } ··· 2702 2706 int i; 2703 2707 2704 2708 for (i = 0; i < ARRAY_SIZE(amba_ports); i++) 2705 - if (amba_ports[i] == NULL) 2709 + if (!amba_ports[i]) 2706 2710 return i; 2707 2711 2708 2712 return -EBUSY; ··· 2869 2873 2870 2874 static SIMPLE_DEV_PM_OPS(pl011_dev_pm_ops, pl011_suspend, pl011_resume); 2871 2875 2876 + #ifdef CONFIG_ACPI_SPCR_TABLE 2877 + static void qpdf2400_erratum44_workaround(struct device *dev, 2878 + struct uart_amba_port *uap) 2879 + { 2880 + if (!qdf2400_e44_present) 2881 + return; 2882 + 2883 + dev_info(dev, "working around QDF2400 SoC erratum 44\n"); 2884 + uap->vendor = &vendor_qdt_qdf2400_e44; 2885 + } 2886 + #else 2887 + static void qpdf2400_erratum44_workaround(struct device *dev, 2888 + struct uart_amba_port *uap) 2889 + { /* empty */ } 2890 + #endif 2891 + 2872 2892 static int sbsa_uart_probe(struct platform_device *pdev) 2873 2893 { 2874 2894 struct uart_amba_port *uap; ··· 2920 2908 return ret; 2921 2909 uap->port.irq = ret; 2922 2910 2923 - #ifdef CONFIG_ACPI_SPCR_TABLE 2924 - if (qdf2400_e44_present) { 2925 - dev_info(&pdev->dev, "working around QDF2400 SoC erratum 44\n"); 2926 - uap->vendor = &vendor_qdt_qdf2400_e44; 2927 - } else 2928 - #endif 2929 - uap->vendor = &vendor_sbsa; 2911 + uap->vendor = &vendor_sbsa; 2912 + qpdf2400_erratum44_workaround(&pdev->dev, uap); 2930 2913 2931 2914 uap->reg_offset = uap->vendor->reg_offset; 2932 2915 uap->fifosize = 32; ··· 2942 2935 return pl011_register_port(uap); 2943 2936 } 2944 2937 2945 - static int sbsa_uart_remove(struct platform_device *pdev) 2938 + static void sbsa_uart_remove(struct platform_device *pdev) 2946 2939 { 2947 2940 struct uart_amba_port *uap = platform_get_drvdata(pdev); 2948 2941 2949 2942 uart_remove_one_port(&amba_reg, &uap->port); 2950 2943 pl011_unregister_port(uap); 2951 - return 0; 2952 2944 } 2953 2945 2954 2946 static const struct of_device_id sbsa_uart_of_match[] = { ··· 2965 2959 2966 2960 static struct platform_driver arm_sbsa_uart_platform_driver = { 2967 2961 .probe = sbsa_uart_probe, 2968 - .remove = sbsa_uart_remove, 2962 + .remove_new = sbsa_uart_remove, 2969 2963 .driver = { 2970 2964 .name = "sbsa-uart", 2971 2965 .pm = &pl011_dev_pm_ops, ··· 3004 2998 3005 2999 static int __init pl011_init(void) 3006 3000 { 3007 - printk(KERN_INFO "Serial: AMBA PL011 UART driver\n"); 3001 + pr_info("Serial: AMBA PL011 UART driver\n"); 3008 3002 3009 3003 if (platform_driver_register(&arm_sbsa_uart_platform_driver)) 3010 3004 pr_warn("could not register SBSA UART platform driver\n");
+1 -1
drivers/tty/serial/apbuart.c
··· 122 122 { 123 123 u8 ch; 124 124 125 - uart_port_tx_limited(port, ch, port->fifosize >> 1, 125 + uart_port_tx_limited(port, ch, port->fifosize, 126 126 true, 127 127 UART_PUT_CHAR(port, ch), 128 128 ({}));
+2 -4
drivers/tty/serial/ar933x_uart.c
··· 818 818 return ret; 819 819 } 820 820 821 - static int ar933x_uart_remove(struct platform_device *pdev) 821 + static void ar933x_uart_remove(struct platform_device *pdev) 822 822 { 823 823 struct ar933x_uart_port *up; 824 824 ··· 828 828 uart_remove_one_port(&ar933x_uart_driver, &up->port); 829 829 clk_disable_unprepare(up->clk); 830 830 } 831 - 832 - return 0; 833 831 } 834 832 835 833 #ifdef CONFIG_OF ··· 840 842 841 843 static struct platform_driver ar933x_uart_platform_driver = { 842 844 .probe = ar933x_uart_probe, 843 - .remove = ar933x_uart_remove, 845 + .remove_new = ar933x_uart_remove, 844 846 .driver = { 845 847 .name = DRIVER_NAME, 846 848 .of_match_table = of_match_ptr(ar933x_uart_of_ids),
+14 -8
drivers/tty/serial/atmel_serial.c
··· 1013 1013 struct device *mfd_dev = port->dev->parent; 1014 1014 dma_cap_mask_t mask; 1015 1015 struct dma_slave_config config; 1016 + struct dma_chan *chan; 1016 1017 int ret, nent; 1017 1018 1018 1019 dma_cap_zero(mask); 1019 1020 dma_cap_set(DMA_SLAVE, mask); 1020 1021 1021 - atmel_port->chan_tx = dma_request_slave_channel(mfd_dev, "tx"); 1022 - if (atmel_port->chan_tx == NULL) 1022 + chan = dma_request_chan(mfd_dev, "tx"); 1023 + if (IS_ERR(chan)) { 1024 + atmel_port->chan_tx = NULL; 1023 1025 goto chan_err; 1026 + } 1027 + atmel_port->chan_tx = chan; 1024 1028 dev_info(port->dev, "using %s for tx DMA transfers\n", 1025 1029 dma_chan_name(atmel_port->chan_tx)); 1026 1030 ··· 1192 1188 dma_cap_mask_t mask; 1193 1189 struct dma_slave_config config; 1194 1190 struct circ_buf *ring; 1191 + struct dma_chan *chan; 1195 1192 int ret, nent; 1196 1193 1197 1194 ring = &atmel_port->rx_ring; ··· 1200 1195 dma_cap_zero(mask); 1201 1196 dma_cap_set(DMA_CYCLIC, mask); 1202 1197 1203 - atmel_port->chan_rx = dma_request_slave_channel(mfd_dev, "rx"); 1204 - if (atmel_port->chan_rx == NULL) 1198 + chan = dma_request_chan(mfd_dev, "rx"); 1199 + if (IS_ERR(chan)) { 1200 + atmel_port->chan_rx = NULL; 1205 1201 goto chan_err; 1202 + } 1203 + atmel_port->chan_rx = chan; 1206 1204 dev_info(port->dev, "using %s for rx DMA transfers\n", 1207 1205 dma_chan_name(atmel_port->chan_rx)); 1208 1206 ··· 3009 3001 * protocol that needs bitbanging on IO lines, but use the regular serial 3010 3002 * port in the normal case. 3011 3003 */ 3012 - static int atmel_serial_remove(struct platform_device *pdev) 3004 + static void atmel_serial_remove(struct platform_device *pdev) 3013 3005 { 3014 3006 struct uart_port *port = platform_get_drvdata(pdev); 3015 3007 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); ··· 3028 3020 clear_bit(port->line, atmel_ports_in_use); 3029 3021 3030 3022 pdev->dev.of_node = NULL; 3031 - 3032 - return 0; 3033 3023 } 3034 3024 3035 3025 static SIMPLE_DEV_PM_OPS(atmel_serial_pm_ops, atmel_serial_suspend, ··· 3035 3029 3036 3030 static struct platform_driver atmel_serial_driver = { 3037 3031 .probe = atmel_serial_probe, 3038 - .remove = atmel_serial_remove, 3032 + .remove_new = atmel_serial_remove, 3039 3033 .driver = { 3040 3034 .name = "atmel_usart_serial", 3041 3035 .of_match_table = of_match_ptr(atmel_serial_dt_ids),
+2 -3
drivers/tty/serial/bcm63xx_uart.c
··· 868 868 return 0; 869 869 } 870 870 871 - static int bcm_uart_remove(struct platform_device *pdev) 871 + static void bcm_uart_remove(struct platform_device *pdev) 872 872 { 873 873 struct uart_port *port; 874 874 ··· 876 876 uart_remove_one_port(&bcm_uart_driver, port); 877 877 /* mark port as free */ 878 878 ports[pdev->id].membase = NULL; 879 - return 0; 880 879 } 881 880 882 881 static const struct of_device_id bcm63xx_of_match[] = { ··· 889 890 */ 890 891 static struct platform_driver bcm_uart_platform_driver = { 891 892 .probe = bcm_uart_probe, 892 - .remove = bcm_uart_remove, 893 + .remove_new = bcm_uart_remove, 893 894 .driver = { 894 895 .name = "bcm63xx_uart", 895 896 .of_match_table = bcm63xx_of_match,
+2 -4
drivers/tty/serial/clps711x.c
··· 510 510 return ret; 511 511 } 512 512 513 - static int uart_clps711x_remove(struct platform_device *pdev) 513 + static void uart_clps711x_remove(struct platform_device *pdev) 514 514 { 515 515 struct clps711x_port *s = platform_get_drvdata(pdev); 516 516 517 517 uart_remove_one_port(&clps711x_uart, &s->port); 518 - 519 - return 0; 520 518 } 521 519 522 520 static const struct of_device_id __maybe_unused clps711x_uart_dt_ids[] = { ··· 529 531 .of_match_table = of_match_ptr(clps711x_uart_dt_ids), 530 532 }, 531 533 .probe = uart_clps711x_probe, 532 - .remove = uart_clps711x_remove, 534 + .remove_new = uart_clps711x_remove, 533 535 }; 534 536 535 537 static int __init uart_clps711x_init(void)
+2 -4
drivers/tty/serial/cpm_uart.c
··· 1549 1549 return ret; 1550 1550 } 1551 1551 1552 - static int cpm_uart_remove(struct platform_device *ofdev) 1552 + static void cpm_uart_remove(struct platform_device *ofdev) 1553 1553 { 1554 1554 struct uart_cpm_port *pinfo = platform_get_drvdata(ofdev); 1555 1555 1556 1556 uart_remove_one_port(&cpm_reg, &pinfo->port); 1557 - 1558 - return 0; 1559 1557 } 1560 1558 1561 1559 static const struct of_device_id cpm_uart_match[] = { ··· 1579 1581 .of_match_table = cpm_uart_match, 1580 1582 }, 1581 1583 .probe = cpm_uart_probe, 1582 - .remove = cpm_uart_remove, 1584 + .remove_new = cpm_uart_remove, 1583 1585 }; 1584 1586 1585 1587 static int __init cpm_uart_init(void)
+2 -4
drivers/tty/serial/digicolor-usart.c
··· 503 503 return uart_add_one_port(&digicolor_uart, &dp->port); 504 504 } 505 505 506 - static int digicolor_uart_remove(struct platform_device *pdev) 506 + static void digicolor_uart_remove(struct platform_device *pdev) 507 507 { 508 508 struct uart_port *port = platform_get_drvdata(pdev); 509 509 510 510 uart_remove_one_port(&digicolor_uart, port); 511 - 512 - return 0; 513 511 } 514 512 515 513 static const struct of_device_id digicolor_uart_dt_ids[] = { ··· 522 524 .of_match_table = of_match_ptr(digicolor_uart_dt_ids), 523 525 }, 524 526 .probe = digicolor_uart_probe, 525 - .remove = digicolor_uart_remove, 527 + .remove_new = digicolor_uart_remove, 526 528 }; 527 529 528 530 static int __init digicolor_uart_init(void)
+3 -4
drivers/tty/serial/esp32_acm.c
··· 8 8 #include <linux/irq.h> 9 9 #include <linux/module.h> 10 10 #include <linux/of.h> 11 - #include <linux/of_device.h> 11 + #include <linux/platform_device.h> 12 12 #include <linux/serial_core.h> 13 13 #include <linux/slab.h> 14 14 #include <linux/tty_flip.h> ··· 413 413 return uart_add_one_port(&esp32s3_acm_reg, port); 414 414 } 415 415 416 - static int esp32s3_acm_remove(struct platform_device *pdev) 416 + static void esp32s3_acm_remove(struct platform_device *pdev) 417 417 { 418 418 struct uart_port *port = platform_get_drvdata(pdev); 419 419 420 420 uart_remove_one_port(&esp32s3_acm_reg, port); 421 - return 0; 422 421 } 423 422 424 423 425 424 static struct platform_driver esp32s3_acm_driver = { 426 425 .probe = esp32s3_acm_probe, 427 - .remove = esp32s3_acm_remove, 426 + .remove_new = esp32s3_acm_remove, 428 427 .driver = { 429 428 .name = DRIVER_NAME, 430 429 .of_match_table = esp32s3_acm_dt_ids,
+5 -11
drivers/tty/serial/esp32_uart.c
··· 9 9 #include <linux/irq.h> 10 10 #include <linux/module.h> 11 11 #include <linux/of.h> 12 - #include <linux/of_device.h> 12 + #include <linux/platform_device.h> 13 + #include <linux/property.h> 13 14 #include <linux/serial_core.h> 14 15 #include <linux/slab.h> 15 16 #include <linux/tty_flip.h> ··· 679 678 static int esp32_uart_probe(struct platform_device *pdev) 680 679 { 681 680 struct device_node *np = pdev->dev.of_node; 682 - static const struct of_device_id *match; 683 681 struct uart_port *port; 684 682 struct esp32_port *sport; 685 683 struct resource *res; 686 684 int ret; 687 - 688 - match = of_match_device(esp32_uart_dt_ids, &pdev->dev); 689 - if (!match) 690 - return -ENODEV; 691 685 692 686 sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL); 693 687 if (!sport) ··· 724 728 port->flags = UPF_BOOT_AUTOCONF; 725 729 port->has_sysrq = 1; 726 730 port->fifosize = ESP32_UART_TX_FIFO_SIZE; 727 - port->private_data = (void *)match->data; 731 + port->private_data = (void *)device_get_match_data(&pdev->dev); 728 732 729 733 esp32_uart_ports[port->line] = sport; 730 734 ··· 733 737 return uart_add_one_port(&esp32_uart_reg, port); 734 738 } 735 739 736 - static int esp32_uart_remove(struct platform_device *pdev) 740 + static void esp32_uart_remove(struct platform_device *pdev) 737 741 { 738 742 struct uart_port *port = platform_get_drvdata(pdev); 739 743 740 744 uart_remove_one_port(&esp32_uart_reg, port); 741 - 742 - return 0; 743 745 } 744 746 745 747 746 748 static struct platform_driver esp32_uart_driver = { 747 749 .probe = esp32_uart_probe, 748 - .remove = esp32_uart_remove, 750 + .remove_new = esp32_uart_remove, 749 751 .driver = { 750 752 .name = DRIVER_NAME, 751 753 .of_match_table = esp32_uart_dt_ids,
+2 -4
drivers/tty/serial/fsl_linflexuart.c
··· 851 851 return uart_add_one_port(&linflex_reg, sport); 852 852 } 853 853 854 - static int linflex_remove(struct platform_device *pdev) 854 + static void linflex_remove(struct platform_device *pdev) 855 855 { 856 856 struct uart_port *sport = platform_get_drvdata(pdev); 857 857 858 858 uart_remove_one_port(&linflex_reg, sport); 859 - 860 - return 0; 861 859 } 862 860 863 861 #ifdef CONFIG_PM_SLEEP ··· 882 884 883 885 static struct platform_driver linflex_driver = { 884 886 .probe = linflex_probe, 885 - .remove = linflex_remove, 887 + .remove_new = linflex_remove, 886 888 .driver = { 887 889 .name = DRIVER_NAME, 888 890 .of_match_table = linflex_dt_ids,
+2 -3
drivers/tty/serial/fsl_lpuart.c
··· 2959 2959 return ret; 2960 2960 } 2961 2961 2962 - static int lpuart_remove(struct platform_device *pdev) 2962 + static void lpuart_remove(struct platform_device *pdev) 2963 2963 { 2964 2964 struct lpuart_port *sport = platform_get_drvdata(pdev); 2965 2965 ··· 2976 2976 pm_runtime_disable(&pdev->dev); 2977 2977 pm_runtime_set_suspended(&pdev->dev); 2978 2978 pm_runtime_dont_use_autosuspend(&pdev->dev); 2979 - return 0; 2980 2979 } 2981 2980 2982 2981 static int lpuart_runtime_suspend(struct device *dev) ··· 3209 3210 3210 3211 static struct platform_driver lpuart_driver = { 3211 3212 .probe = lpuart_probe, 3212 - .remove = lpuart_remove, 3213 + .remove_new = lpuart_remove, 3213 3214 .driver = { 3214 3215 .name = "fsl-lpuart", 3215 3216 .of_match_table = lpuart_dt_ids,
+28 -35
drivers/tty/serial/imx.c
··· 415 415 ucr1 = imx_uart_readl(sport, UCR1); 416 416 imx_uart_writel(sport, ucr1 & ~UCR1_TRDYEN, UCR1); 417 417 418 + ucr4 = imx_uart_readl(sport, UCR4); 418 419 usr2 = imx_uart_readl(sport, USR2); 419 - if (!(usr2 & USR2_TXDC)) { 420 + if ((!(usr2 & USR2_TXDC)) && (ucr4 & UCR4_TCEN)) { 420 421 /* The shifter is still busy, so retry once TC triggers */ 421 422 return; 422 423 } 423 424 424 - ucr4 = imx_uart_readl(sport, UCR4); 425 425 ucr4 &= ~UCR4_TCEN; 426 426 imx_uart_writel(sport, ucr4, UCR4); 427 427 ··· 1336 1336 { 1337 1337 struct dma_slave_config slave_config = {}; 1338 1338 struct device *dev = sport->port.dev; 1339 + struct dma_chan *chan; 1339 1340 int ret; 1340 1341 1341 1342 /* Prepare for RX : */ 1342 - sport->dma_chan_rx = dma_request_slave_channel(dev, "rx"); 1343 - if (!sport->dma_chan_rx) { 1343 + chan = dma_request_chan(dev, "rx"); 1344 + if (IS_ERR(chan)) { 1344 1345 dev_dbg(dev, "cannot get the DMA channel.\n"); 1345 - ret = -EINVAL; 1346 + sport->dma_chan_rx = NULL; 1347 + ret = PTR_ERR(chan); 1346 1348 goto err; 1347 1349 } 1350 + sport->dma_chan_rx = chan; 1348 1351 1349 1352 slave_config.direction = DMA_DEV_TO_MEM; 1350 1353 slave_config.src_addr = sport->port.mapbase + URXD0; ··· 1369 1366 sport->rx_ring.buf = sport->rx_buf; 1370 1367 1371 1368 /* Prepare for TX : */ 1372 - sport->dma_chan_tx = dma_request_slave_channel(dev, "tx"); 1373 - if (!sport->dma_chan_tx) { 1369 + chan = dma_request_chan(dev, "tx"); 1370 + if (IS_ERR(chan)) { 1374 1371 dev_err(dev, "cannot get the TX DMA channel!\n"); 1375 - ret = -EINVAL; 1372 + sport->dma_chan_tx = NULL; 1373 + ret = PTR_ERR(chan); 1376 1374 goto err; 1377 1375 } 1376 + sport->dma_chan_tx = chan; 1378 1377 1379 1378 slave_config.direction = DMA_MEM_TO_DEV; 1380 1379 slave_config.dst_addr = sport->port.mapbase + URTX0; ··· 1948 1943 rs485conf->flags & SER_RS485_RX_DURING_TX) 1949 1944 imx_uart_start_rx(port); 1950 1945 1951 - if (port->rs485_rx_during_tx_gpio) 1952 - gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 1953 - !!(rs485conf->flags & SER_RS485_RX_DURING_TX)); 1954 - 1955 1946 return 0; 1956 1947 } 1957 1948 ··· 2211 2210 return HRTIMER_NORESTART; 2212 2211 } 2213 2212 2214 - static const struct serial_rs485 imx_no_rs485 = {}; /* No RS485 if no RTS */ 2215 2213 static const struct serial_rs485 imx_rs485_supported = { 2216 2214 .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND | 2217 2215 SER_RS485_RX_DURING_TX, ··· 2294 2294 /* RTS is required to control the RS485 transmitter */ 2295 2295 if (sport->have_rtscts || sport->have_rtsgpio) 2296 2296 sport->port.rs485_supported = imx_rs485_supported; 2297 - else 2298 - sport->port.rs485_supported = imx_no_rs485; 2299 2297 sport->port.flags = UPF_BOOT_AUTOCONF; 2300 2298 timer_setup(&sport->timer, imx_uart_timeout, 0); 2301 2299 ··· 2320 2322 /* For register access, we only need to enable the ipg clock. */ 2321 2323 ret = clk_prepare_enable(sport->clk_ipg); 2322 2324 if (ret) { 2323 - dev_err(&pdev->dev, "failed to enable per clk: %d\n", ret); 2325 + dev_err(&pdev->dev, "failed to enable ipg clk: %d\n", ret); 2324 2326 return ret; 2325 2327 } 2326 2328 2327 2329 ret = uart_get_rs485_mode(&sport->port); 2328 - if (ret) { 2329 - clk_disable_unprepare(sport->clk_ipg); 2330 - return ret; 2331 - } 2332 - 2333 - if (sport->port.rs485.flags & SER_RS485_ENABLED && 2334 - (!sport->have_rtscts && !sport->have_rtsgpio)) 2335 - dev_err(&pdev->dev, "no RTS control, disabling rs485\n"); 2330 + if (ret) 2331 + goto err_clk; 2336 2332 2337 2333 /* 2338 2334 * If using the i.MX UART RTS/CTS control then the RTS (CTS_B) ··· 2406 2414 imx_uart_writel(sport, ucr3, UCR3); 2407 2415 } 2408 2416 2409 - clk_disable_unprepare(sport->clk_ipg); 2410 - 2411 2417 hrtimer_init(&sport->trigger_start_tx, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 2412 2418 hrtimer_init(&sport->trigger_stop_tx, CLOCK_MONOTONIC, HRTIMER_MODE_REL); 2413 2419 sport->trigger_start_tx.function = imx_trigger_start_tx; ··· 2421 2431 if (ret) { 2422 2432 dev_err(&pdev->dev, "failed to request rx irq: %d\n", 2423 2433 ret); 2424 - return ret; 2434 + goto err_clk; 2425 2435 } 2426 2436 2427 2437 ret = devm_request_irq(&pdev->dev, txirq, imx_uart_txint, 0, ··· 2429 2439 if (ret) { 2430 2440 dev_err(&pdev->dev, "failed to request tx irq: %d\n", 2431 2441 ret); 2432 - return ret; 2442 + goto err_clk; 2433 2443 } 2434 2444 2435 2445 ret = devm_request_irq(&pdev->dev, rtsirq, imx_uart_rtsint, 0, ··· 2437 2447 if (ret) { 2438 2448 dev_err(&pdev->dev, "failed to request rts irq: %d\n", 2439 2449 ret); 2440 - return ret; 2450 + goto err_clk; 2441 2451 } 2442 2452 } else { 2443 2453 ret = devm_request_irq(&pdev->dev, rxirq, imx_uart_int, 0, 2444 2454 dev_name(&pdev->dev), sport); 2445 2455 if (ret) { 2446 2456 dev_err(&pdev->dev, "failed to request irq: %d\n", ret); 2447 - return ret; 2457 + goto err_clk; 2448 2458 } 2449 2459 } 2450 2460 ··· 2452 2462 2453 2463 platform_set_drvdata(pdev, sport); 2454 2464 2455 - return uart_add_one_port(&imx_uart_uart_driver, &sport->port); 2465 + ret = uart_add_one_port(&imx_uart_uart_driver, &sport->port); 2466 + 2467 + err_clk: 2468 + clk_disable_unprepare(sport->clk_ipg); 2469 + 2470 + return ret; 2456 2471 } 2457 2472 2458 - static int imx_uart_remove(struct platform_device *pdev) 2473 + static void imx_uart_remove(struct platform_device *pdev) 2459 2474 { 2460 2475 struct imx_port *sport = platform_get_drvdata(pdev); 2461 2476 2462 2477 uart_remove_one_port(&imx_uart_uart_driver, &sport->port); 2463 - 2464 - return 0; 2465 2478 } 2466 2479 2467 2480 static void imx_uart_restore_context(struct imx_port *sport) ··· 2633 2640 2634 2641 static struct platform_driver imx_uart_platform_driver = { 2635 2642 .probe = imx_uart_probe, 2636 - .remove = imx_uart_remove, 2643 + .remove_new = imx_uart_remove, 2637 2644 2638 2645 .driver = { 2639 2646 .name = "imx-uart",
-5
drivers/tty/serial/jsm/jsm.h
··· 115 115 void (*send_start_character)(struct jsm_channel *ch); 116 116 void (*send_stop_character)(struct jsm_channel *ch); 117 117 void (*copy_data_from_queue_to_uart)(struct jsm_channel *ch); 118 - u32 (*get_uart_bytes_left)(struct jsm_channel *ch); 119 - void (*send_immediate_char)(struct jsm_channel *ch, unsigned char); 120 118 }; 121 119 122 120 ··· 125 127 { 126 128 int boardnum; /* Board number: 0-32 */ 127 129 128 - int type; /* Type of board */ 129 130 u8 rev; /* PCI revision ID */ 130 131 struct pci_dev *pci_dev; 131 132 u32 maxports; /* MAX ports this board can handle */ ··· 152 155 u32 bd_dividend; /* Board/UARTs specific dividend */ 153 156 154 157 struct board_ops *bd_ops; 155 - 156 - struct list_head jsm_board_entry; 157 158 }; 158 159 159 160 /************************************************************************
-36
drivers/tty/serial/jsm/jsm_cls.c
··· 878 878 } 879 879 880 880 /* 881 - * cls_get_uarts_bytes_left. 882 - * Returns 0 is nothing left in the FIFO, returns 1 otherwise. 883 - * 884 - * The channel lock MUST be held by the calling function. 885 - */ 886 - static u32 cls_get_uart_bytes_left(struct jsm_channel *ch) 887 - { 888 - u8 left = 0; 889 - u8 lsr = readb(&ch->ch_cls_uart->lsr); 890 - 891 - /* Determine whether the Transmitter is empty or not */ 892 - if (!(lsr & UART_LSR_TEMT)) 893 - left = 1; 894 - else { 895 - ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); 896 - left = 0; 897 - } 898 - 899 - return left; 900 - } 901 - 902 - /* 903 881 * cls_send_break. 904 882 * Starts sending a break thru the UART. 905 883 * ··· 892 914 writeb((temp | UART_LCR_SBC), &ch->ch_cls_uart->lcr); 893 915 ch->ch_flags |= (CH_BREAK_SENDING); 894 916 } 895 - } 896 - 897 - /* 898 - * cls_send_immediate_char. 899 - * Sends a specific character as soon as possible to the UART, 900 - * jumping over any bytes that might be in the write queue. 901 - * 902 - * The channel lock MUST be held by the calling function. 903 - */ 904 - static void cls_send_immediate_char(struct jsm_channel *ch, unsigned char c) 905 - { 906 - writeb(c, &ch->ch_cls_uart->txrx); 907 917 } 908 918 909 919 struct board_ops jsm_cls_ops = { ··· 909 943 .send_start_character = cls_send_start_character, 910 944 .send_stop_character = cls_send_stop_character, 911 945 .copy_data_from_queue_to_uart = cls_copy_data_from_queue_to_uart, 912 - .get_uart_bytes_left = cls_get_uart_bytes_left, 913 - .send_immediate_char = cls_send_immediate_char 914 946 }; 915 947
-40
drivers/tty/serial/jsm/jsm_neo.c
··· 1309 1309 writeb(0, &ch->ch_neo_uart->ier); 1310 1310 } 1311 1311 1312 - static u32 neo_get_uart_bytes_left(struct jsm_channel *ch) 1313 - { 1314 - u8 left = 0; 1315 - u8 lsr = readb(&ch->ch_neo_uart->lsr); 1316 - 1317 - /* We must cache the LSR as some of the bits get reset once read... */ 1318 - ch->ch_cached_lsr |= lsr; 1319 - 1320 - /* Determine whether the Transmitter is empty or not */ 1321 - if (!(lsr & UART_LSR_TEMT)) 1322 - left = 1; 1323 - else { 1324 - ch->ch_flags |= (CH_TX_FIFO_EMPTY | CH_TX_FIFO_LWM); 1325 - left = 0; 1326 - } 1327 - 1328 - return left; 1329 - } 1330 - 1331 1312 /* Channel lock MUST be held by the calling function! */ 1332 1313 static void neo_send_break(struct jsm_channel *ch) 1333 1314 { ··· 1329 1348 } 1330 1349 } 1331 1350 1332 - /* 1333 - * neo_send_immediate_char. 1334 - * 1335 - * Sends a specific character as soon as possible to the UART, 1336 - * jumping over any bytes that might be in the write queue. 1337 - * 1338 - * The channel lock MUST be held by the calling function. 1339 - */ 1340 - static void neo_send_immediate_char(struct jsm_channel *ch, unsigned char c) 1341 - { 1342 - if (!ch) 1343 - return; 1344 - 1345 - writeb(c, &ch->ch_neo_uart->txrx); 1346 - 1347 - /* flush write operation */ 1348 - neo_pci_posting_flush(ch->ch_bd); 1349 - } 1350 - 1351 1351 struct board_ops jsm_neo_ops = { 1352 1352 .intr = neo_intr, 1353 1353 .uart_init = neo_uart_init, ··· 1344 1382 .send_start_character = neo_send_start_character, 1345 1383 .send_stop_character = neo_send_stop_character, 1346 1384 .copy_data_from_queue_to_uart = neo_copy_data_from_queue_to_uart, 1347 - .get_uart_bytes_left = neo_get_uart_bytes_left, 1348 - .send_immediate_char = neo_send_immediate_char 1349 1385 };
+2 -4
drivers/tty/serial/lantiq.c
··· 887 887 return ret; 888 888 } 889 889 890 - static int lqasc_remove(struct platform_device *pdev) 890 + static void lqasc_remove(struct platform_device *pdev) 891 891 { 892 892 struct uart_port *port = platform_get_drvdata(pdev); 893 893 894 894 uart_remove_one_port(&lqasc_reg, port); 895 - 896 - return 0; 897 895 } 898 896 899 897 static const struct ltq_soc_data soc_data_lantiq = { ··· 915 917 916 918 static struct platform_driver lqasc_driver = { 917 919 .probe = lqasc_probe, 918 - .remove = lqasc_remove, 920 + .remove_new = lqasc_remove, 919 921 .driver = { 920 922 .name = DRVNAME, 921 923 .of_match_table = ltq_asc_match,
+2 -4
drivers/tty/serial/liteuart.c
··· 336 336 return ret; 337 337 } 338 338 339 - static int liteuart_remove(struct platform_device *pdev) 339 + static void liteuart_remove(struct platform_device *pdev) 340 340 { 341 341 struct uart_port *port = platform_get_drvdata(pdev); 342 342 unsigned int line = port->line; 343 343 344 344 uart_remove_one_port(&liteuart_driver, port); 345 345 xa_erase(&liteuart_array, line); 346 - 347 - return 0; 348 346 } 349 347 350 348 static const struct of_device_id liteuart_of_match[] = { ··· 353 355 354 356 static struct platform_driver liteuart_platform_driver = { 355 357 .probe = liteuart_probe, 356 - .remove = liteuart_remove, 358 + .remove_new = liteuart_remove, 357 359 .driver = { 358 360 .name = KBUILD_MODNAME, 359 361 .of_match_table = liteuart_of_match,
+2 -4
drivers/tty/serial/lpc32xx_hs.c
··· 659 659 /* 660 660 * Remove serial ports registered against a platform device. 661 661 */ 662 - static int serial_hs_lpc32xx_remove(struct platform_device *pdev) 662 + static void serial_hs_lpc32xx_remove(struct platform_device *pdev) 663 663 { 664 664 struct lpc32xx_hsuart_port *p = platform_get_drvdata(pdev); 665 665 666 666 uart_remove_one_port(&lpc32xx_hs_reg, &p->port); 667 - 668 - return 0; 669 667 } 670 668 671 669 ··· 700 702 701 703 static struct platform_driver serial_hs_lpc32xx_driver = { 702 704 .probe = serial_hs_lpc32xx_probe, 703 - .remove = serial_hs_lpc32xx_remove, 705 + .remove_new = serial_hs_lpc32xx_remove, 704 706 .suspend = serial_hs_lpc32xx_suspend, 705 707 .resume = serial_hs_lpc32xx_resume, 706 708 .driver = {
+3 -4
drivers/tty/serial/ma35d1_serial.c
··· 558 558 u32 ier; 559 559 560 560 if ((co->index < 0) || (co->index >= MA35_UART_NR)) { 561 - pr_warn("Failed to write on ononsole port %x, out of range\n", 561 + pr_warn("Failed to write on console port %x, out of range\n", 562 562 co->index); 563 563 return; 564 564 } ··· 754 754 /* 755 755 * Remove serial ports registered against a platform device. 756 756 */ 757 - static int ma35d1serial_remove(struct platform_device *dev) 757 + static void ma35d1serial_remove(struct platform_device *dev) 758 758 { 759 759 struct uart_port *port = platform_get_drvdata(dev); 760 760 struct uart_ma35d1_port *up = to_ma35d1_uart_port(port); 761 761 762 762 uart_remove_one_port(&ma35d1serial_reg, port); 763 763 clk_disable_unprepare(up->clk); 764 - return 0; 765 764 } 766 765 767 766 static int ma35d1serial_suspend(struct platform_device *dev, pm_message_t state) ··· 793 794 794 795 static struct platform_driver ma35d1serial_driver = { 795 796 .probe = ma35d1serial_probe, 796 - .remove = ma35d1serial_remove, 797 + .remove_new = ma35d1serial_remove, 797 798 .suspend = ma35d1serial_suspend, 798 799 .resume = ma35d1serial_resume, 799 800 .driver = {
+1 -1
drivers/tty/serial/max310x.c
··· 780 780 to_send = uart_circ_chars_pending(xmit); 781 781 until_end = CIRC_CNT_TO_END(xmit->head, xmit->tail, UART_XMIT_SIZE); 782 782 if (likely(to_send)) { 783 - /* Limit to size of TX FIFO */ 783 + /* Limit to space available in TX FIFO */ 784 784 txlen = max310x_port_read(port, MAX310X_TXFIFOLVL_REG); 785 785 txlen = port->fifosize - txlen; 786 786 to_send = (to_send > txlen) ? txlen : to_send;
+2 -4
drivers/tty/serial/mcf.c
··· 627 627 628 628 /****************************************************************************/ 629 629 630 - static int mcf_remove(struct platform_device *pdev) 630 + static void mcf_remove(struct platform_device *pdev) 631 631 { 632 632 struct uart_port *port; 633 633 int i; ··· 637 637 if (port) 638 638 uart_remove_one_port(&mcf_driver, port); 639 639 } 640 - 641 - return 0; 642 640 } 643 641 644 642 /****************************************************************************/ 645 643 646 644 static struct platform_driver mcf_platform_driver = { 647 645 .probe = mcf_probe, 648 - .remove = mcf_remove, 646 + .remove_new = mcf_remove, 649 647 .driver = { 650 648 .name = "mcfuart", 651 649 },
+3 -5
drivers/tty/serial/meson_uart.c
··· 795 795 return ret; 796 796 } 797 797 798 - static int meson_uart_remove(struct platform_device *pdev) 798 + static void meson_uart_remove(struct platform_device *pdev) 799 799 { 800 800 struct uart_driver *uart_driver; 801 801 struct uart_port *port; ··· 807 807 808 808 for (int id = 0; id < AML_UART_PORT_NUM; id++) 809 809 if (meson_ports[id]) 810 - return 0; 810 + return; 811 811 812 812 /* No more available uart ports, unregister uart driver */ 813 813 uart_unregister_driver(uart_driver); 814 - 815 - return 0; 816 814 } 817 815 818 816 static struct meson_uart_data meson_g12a_uart_data = { ··· 850 852 851 853 static struct platform_driver meson_uart_platform_driver = { 852 854 .probe = meson_uart_probe, 853 - .remove = meson_uart_remove, 855 + .remove_new = meson_uart_remove, 854 856 .driver = { 855 857 .name = "meson_uart", 856 858 .of_match_table = meson_uart_dt_match,
+2 -4
drivers/tty/serial/milbeaut_usio.c
··· 552 552 return ret; 553 553 } 554 554 555 - static int mlb_usio_remove(struct platform_device *pdev) 555 + static void mlb_usio_remove(struct platform_device *pdev) 556 556 { 557 557 struct uart_port *port = &mlb_usio_ports[pdev->id]; 558 558 struct clk *clk = port->private_data; 559 559 560 560 uart_remove_one_port(&mlb_usio_uart_driver, port); 561 561 clk_disable_unprepare(clk); 562 - 563 - return 0; 564 562 } 565 563 566 564 static const struct of_device_id mlb_usio_dt_ids[] = { ··· 569 571 570 572 static struct platform_driver mlb_usio_driver = { 571 573 .probe = mlb_usio_probe, 572 - .remove = mlb_usio_remove, 574 + .remove_new = mlb_usio_remove, 573 575 .driver = { 574 576 .name = USIO_NAME, 575 577 .of_match_table = mlb_usio_dt_ids,
+2 -5
drivers/tty/serial/mpc52xx_uart.c
··· 1765 1765 return 0; 1766 1766 } 1767 1767 1768 - static int 1769 - mpc52xx_uart_of_remove(struct platform_device *op) 1768 + static void mpc52xx_uart_of_remove(struct platform_device *op) 1770 1769 { 1771 1770 struct uart_port *port = platform_get_drvdata(op); 1772 1771 1773 1772 if (port) 1774 1773 uart_remove_one_port(&mpc52xx_uart_driver, port); 1775 - 1776 - return 0; 1777 1774 } 1778 1775 1779 1776 #ifdef CONFIG_PM ··· 1843 1846 1844 1847 static struct platform_driver mpc52xx_uart_of_driver = { 1845 1848 .probe = mpc52xx_uart_of_probe, 1846 - .remove = mpc52xx_uart_of_remove, 1849 + .remove_new = mpc52xx_uart_of_remove, 1847 1850 #ifdef CONFIG_PM 1848 1851 .suspend = mpc52xx_uart_of_suspend, 1849 1852 .resume = mpc52xx_uart_of_resume,
+19 -6
drivers/tty/serial/msm_serial.c
··· 24 24 #include <linux/slab.h> 25 25 #include <linux/clk.h> 26 26 #include <linux/platform_device.h> 27 + #include <linux/pm_opp.h> 27 28 #include <linux/delay.h> 28 29 #include <linux/of.h> 29 30 #include <linux/of_device.h> ··· 1132 1131 uart_port_unlock_irqrestore(port, flags); 1133 1132 1134 1133 entry = msm_find_best_baud(port, baud, &rate); 1135 - clk_set_rate(msm_port->clk, rate); 1134 + dev_pm_opp_set_rate(port->dev, rate); 1136 1135 baud = rate / 16 / entry->divisor; 1137 1136 1138 1137 uart_port_lock_irqsave(port, &flags); ··· 1187 1186 { 1188 1187 struct msm_port *msm_port = to_msm_port(port); 1189 1188 1189 + dev_pm_opp_set_rate(port->dev, port->uartclk); 1190 1190 clk_prepare_enable(msm_port->clk); 1191 1191 clk_prepare_enable(msm_port->pclk); 1192 1192 msm_serial_set_mnd_regs(port); ··· 1241 1239 1242 1240 clk_disable_unprepare(msm_port->pclk); 1243 1241 clk_disable_unprepare(msm_port->clk); 1242 + dev_pm_opp_set_rate(port->dev, 0); 1244 1243 1245 1244 return ret; 1246 1245 } ··· 1257 1254 msm_release_dma(msm_port); 1258 1255 1259 1256 clk_disable_unprepare(msm_port->clk); 1257 + dev_pm_opp_set_rate(port->dev, 0); 1260 1258 1261 1259 free_irq(port->irq, port); 1262 1260 } ··· 1423 1419 1424 1420 switch (state) { 1425 1421 case 0: 1422 + dev_pm_opp_set_rate(port->dev, port->uartclk); 1426 1423 clk_prepare_enable(msm_port->clk); 1427 1424 clk_prepare_enable(msm_port->pclk); 1428 1425 break; 1429 1426 case 3: 1430 1427 clk_disable_unprepare(msm_port->clk); 1428 + dev_pm_opp_set_rate(port->dev, 0); 1431 1429 clk_disable_unprepare(msm_port->pclk); 1432 1430 break; 1433 1431 default: ··· 1795 1789 struct resource *resource; 1796 1790 struct uart_port *port; 1797 1791 const struct of_device_id *id; 1798 - int irq, line; 1792 + int irq, line, ret; 1799 1793 1800 1794 if (pdev->dev.of_node) 1801 1795 line = of_alias_get_id(pdev->dev.of_node, "serial"); ··· 1830 1824 return PTR_ERR(msm_port->pclk); 1831 1825 } 1832 1826 1827 + ret = devm_pm_opp_set_clkname(&pdev->dev, "core"); 1828 + if (ret) 1829 + return ret; 1830 + 1831 + /* OPP table is optional */ 1832 + ret = devm_pm_opp_of_add_table(&pdev->dev); 1833 + if (ret && ret != -ENODEV) 1834 + return dev_err_probe(&pdev->dev, ret, "invalid OPP table\n"); 1835 + 1833 1836 port->uartclk = clk_get_rate(msm_port->clk); 1834 1837 dev_info(&pdev->dev, "uartclk = %d\n", port->uartclk); 1835 1838 ··· 1858 1843 return uart_add_one_port(&msm_uart_driver, port); 1859 1844 } 1860 1845 1861 - static int msm_serial_remove(struct platform_device *pdev) 1846 + static void msm_serial_remove(struct platform_device *pdev) 1862 1847 { 1863 1848 struct uart_port *port = platform_get_drvdata(pdev); 1864 1849 1865 1850 uart_remove_one_port(&msm_uart_driver, port); 1866 - 1867 - return 0; 1868 1851 } 1869 1852 1870 1853 static const struct of_device_id msm_match_table[] = { ··· 1895 1882 }; 1896 1883 1897 1884 static struct platform_driver msm_platform_driver = { 1898 - .remove = msm_serial_remove, 1885 + .remove_new = msm_serial_remove, 1899 1886 .probe = msm_serial_probe, 1900 1887 .driver = { 1901 1888 .name = "msm_serial",
+12 -8
drivers/tty/serial/mxs-auart.c
··· 904 904 905 905 static int mxs_auart_dma_init(struct mxs_auart_port *s) 906 906 { 907 + struct dma_chan *chan; 908 + 907 909 if (auart_dma_enabled(s)) 908 910 return 0; 909 911 910 912 /* init for RX */ 911 - s->rx_dma_chan = dma_request_slave_channel(s->dev, "rx"); 912 - if (!s->rx_dma_chan) 913 + chan = dma_request_chan(s->dev, "rx"); 914 + if (IS_ERR(chan)) 913 915 goto err_out; 916 + s->rx_dma_chan = chan; 917 + 914 918 s->rx_dma_buf = kzalloc(UART_XMIT_SIZE, GFP_KERNEL | GFP_DMA); 915 919 if (!s->rx_dma_buf) 916 920 goto err_out; 917 921 918 922 /* init for TX */ 919 - s->tx_dma_chan = dma_request_slave_channel(s->dev, "tx"); 920 - if (!s->tx_dma_chan) 923 + chan = dma_request_chan(s->dev, "tx"); 924 + if (IS_ERR(chan)) 921 925 goto err_out; 926 + s->tx_dma_chan = chan; 927 + 922 928 s->tx_dma_buf = kzalloc(UART_XMIT_SIZE, GFP_KERNEL | GFP_DMA); 923 929 if (!s->tx_dma_buf) 924 930 goto err_out; ··· 1692 1686 return ret; 1693 1687 } 1694 1688 1695 - static int mxs_auart_remove(struct platform_device *pdev) 1689 + static void mxs_auart_remove(struct platform_device *pdev) 1696 1690 { 1697 1691 struct mxs_auart_port *s = platform_get_drvdata(pdev); 1698 1692 ··· 1704 1698 clk_disable_unprepare(s->clk); 1705 1699 clk_disable_unprepare(s->clk_ahb); 1706 1700 } 1707 - 1708 - return 0; 1709 1701 } 1710 1702 1711 1703 static struct platform_driver mxs_auart_driver = { 1712 1704 .probe = mxs_auart_probe, 1713 - .remove = mxs_auart_remove, 1705 + .remove_new = mxs_auart_remove, 1714 1706 .driver = { 1715 1707 .name = "mxs-auart", 1716 1708 .of_match_table = mxs_auart_dt_ids,
+16 -17
drivers/tty/serial/omap-serial.c
··· 1483 1483 return omap_up_info; 1484 1484 } 1485 1485 1486 + static const struct serial_rs485 serial_omap_rs485_supported = { 1487 + .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND | 1488 + SER_RS485_RX_DURING_TX, 1489 + .delay_rts_before_send = 1, 1490 + .delay_rts_after_send = 1, 1491 + }; 1492 + 1486 1493 static int serial_omap_probe_rs485(struct uart_omap_port *up, 1487 1494 struct device *dev) 1488 1495 { ··· 1503 1496 1504 1497 if (!np) 1505 1498 return 0; 1499 + 1500 + up->port.rs485_config = serial_omap_config_rs485; 1501 + up->port.rs485_supported = serial_omap_rs485_supported; 1506 1502 1507 1503 ret = uart_get_rs485_mode(&up->port); 1508 1504 if (ret) ··· 1540 1530 1541 1531 return 0; 1542 1532 } 1543 - 1544 - static const struct serial_rs485 serial_omap_rs485_supported = { 1545 - .flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RTS_AFTER_SEND | 1546 - SER_RS485_RX_DURING_TX, 1547 - .delay_rts_before_send = 1, 1548 - .delay_rts_after_send = 1, 1549 - }; 1550 1533 1551 1534 static int serial_omap_probe(struct platform_device *pdev) 1552 1535 { ··· 1607 1604 dev_info(up->port.dev, "no wakeirq for uart%d\n", 1608 1605 up->port.line); 1609 1606 1610 - ret = serial_omap_probe_rs485(up, &pdev->dev); 1611 - if (ret < 0) 1612 - goto err_rs485; 1613 - 1614 1607 sprintf(up->name, "OMAP UART%d", up->port.line); 1615 1608 up->port.mapbase = mem->start; 1616 1609 up->port.membase = base; 1617 1610 up->port.flags = omap_up_info->flags; 1618 1611 up->port.uartclk = omap_up_info->uartclk; 1619 - up->port.rs485_config = serial_omap_config_rs485; 1620 - up->port.rs485_supported = serial_omap_rs485_supported; 1621 1612 if (!up->port.uartclk) { 1622 1613 up->port.uartclk = DEFAULT_CLK_SPEED; 1623 1614 dev_warn(&pdev->dev, 1624 1615 "No clock speed specified: using default: %d\n", 1625 1616 DEFAULT_CLK_SPEED); 1626 1617 } 1618 + 1619 + ret = serial_omap_probe_rs485(up, &pdev->dev); 1620 + if (ret < 0) 1621 + goto err_rs485; 1627 1622 1628 1623 up->latency = PM_QOS_CPU_LATENCY_DEFAULT_VALUE; 1629 1624 up->calc_latency = PM_QOS_CPU_LATENCY_DEFAULT_VALUE; ··· 1659 1658 return ret; 1660 1659 } 1661 1660 1662 - static int serial_omap_remove(struct platform_device *dev) 1661 + static void serial_omap_remove(struct platform_device *dev) 1663 1662 { 1664 1663 struct uart_omap_port *up = platform_get_drvdata(dev); 1665 1664 ··· 1671 1670 pm_runtime_disable(up->dev); 1672 1671 cpu_latency_qos_remove_request(&up->pm_qos_request); 1673 1672 device_init_wakeup(&dev->dev, false); 1674 - 1675 - return 0; 1676 1673 } 1677 1674 1678 1675 /* ··· 1807 1808 1808 1809 static struct platform_driver serial_omap_driver = { 1809 1810 .probe = serial_omap_probe, 1810 - .remove = serial_omap_remove, 1811 + .remove_new = serial_omap_remove, 1811 1812 .driver = { 1812 1813 .name = OMAP_SERIAL_DRIVER_NAME, 1813 1814 .pm = &serial_omap_dev_pm_ops,
+2 -4
drivers/tty/serial/owl-uart.c
··· 725 725 return ret; 726 726 } 727 727 728 - static int owl_uart_remove(struct platform_device *pdev) 728 + static void owl_uart_remove(struct platform_device *pdev) 729 729 { 730 730 struct owl_uart_port *owl_port = platform_get_drvdata(pdev); 731 731 732 732 uart_remove_one_port(&owl_uart_driver, &owl_port->port); 733 733 owl_uart_ports[pdev->id] = NULL; 734 734 clk_disable_unprepare(owl_port->clk); 735 - 736 - return 0; 737 735 } 738 736 739 737 static struct platform_driver owl_uart_platform_driver = { 740 738 .probe = owl_uart_probe, 741 - .remove = owl_uart_remove, 739 + .remove_new = owl_uart_remove, 742 740 .driver = { 743 741 .name = "owl-uart", 744 742 .of_match_table = owl_uart_dt_matches,
+2 -5
drivers/tty/serial/pic32_uart.c
··· 938 938 return ret; 939 939 } 940 940 941 - static int pic32_uart_remove(struct platform_device *pdev) 941 + static void pic32_uart_remove(struct platform_device *pdev) 942 942 { 943 943 struct uart_port *port = platform_get_drvdata(pdev); 944 944 struct pic32_sport *sport = to_pic32_sport(port); ··· 947 947 clk_disable_unprepare(sport->clk); 948 948 platform_set_drvdata(pdev, NULL); 949 949 pic32_sports[sport->idx] = NULL; 950 - 951 - /* automatic unroll of sport and gpios */ 952 - return 0; 953 950 } 954 951 955 952 static const struct of_device_id pic32_serial_dt_ids[] = { ··· 957 960 958 961 static struct platform_driver pic32_uart_platform_driver = { 959 962 .probe = pic32_uart_probe, 960 - .remove = pic32_uart_remove, 963 + .remove_new = pic32_uart_remove, 961 964 .driver = { 962 965 .name = PIC32_DEV_NAME, 963 966 .of_match_table = of_match_ptr(pic32_serial_dt_ids),
+2 -4
drivers/tty/serial/qcom_geni_serial.c
··· 1696 1696 return 0; 1697 1697 } 1698 1698 1699 - static int qcom_geni_serial_remove(struct platform_device *pdev) 1699 + static void qcom_geni_serial_remove(struct platform_device *pdev) 1700 1700 { 1701 1701 struct qcom_geni_serial_port *port = platform_get_drvdata(pdev); 1702 1702 struct uart_driver *drv = port->private_data.drv; ··· 1704 1704 dev_pm_clear_wake_irq(&pdev->dev); 1705 1705 device_init_wakeup(&pdev->dev, false); 1706 1706 uart_remove_one_port(drv, &port->uport); 1707 - 1708 - return 0; 1709 1707 } 1710 1708 1711 1709 static int qcom_geni_serial_sys_suspend(struct device *dev) ··· 1803 1805 MODULE_DEVICE_TABLE(of, qcom_geni_serial_match_table); 1804 1806 1805 1807 static struct platform_driver qcom_geni_serial_platform_driver = { 1806 - .remove = qcom_geni_serial_remove, 1808 + .remove_new = qcom_geni_serial_remove, 1807 1809 .probe = qcom_geni_serial_probe, 1808 1810 .driver = { 1809 1811 .name = "qcom_geni_serial",
+2 -4
drivers/tty/serial/rda-uart.c
··· 780 780 return ret; 781 781 } 782 782 783 - static int rda_uart_remove(struct platform_device *pdev) 783 + static void rda_uart_remove(struct platform_device *pdev) 784 784 { 785 785 struct rda_uart_port *rda_port = platform_get_drvdata(pdev); 786 786 787 787 uart_remove_one_port(&rda_uart_driver, &rda_port->port); 788 788 rda_uart_ports[pdev->id] = NULL; 789 - 790 - return 0; 791 789 } 792 790 793 791 static struct platform_driver rda_uart_platform_driver = { 794 792 .probe = rda_uart_probe, 795 - .remove = rda_uart_remove, 793 + .remove_new = rda_uart_remove, 796 794 .driver = { 797 795 .name = "rda-uart", 798 796 .of_match_table = rda_uart_dt_matches,
-1
drivers/tty/serial/rp2.c
··· 178 178 struct rp2_uart_port { 179 179 struct uart_port port; 180 180 int idx; 181 - int ignore_rx; 182 181 struct rp2_card *card; 183 182 void __iomem *asic_base; 184 183 void __iomem *base;
+2 -4
drivers/tty/serial/sa1100.c
··· 870 870 return 0; 871 871 } 872 872 873 - static int sa1100_serial_remove(struct platform_device *pdev) 873 + static void sa1100_serial_remove(struct platform_device *pdev) 874 874 { 875 875 struct sa1100_port *sport = platform_get_drvdata(pdev); 876 876 877 877 if (sport) 878 878 uart_remove_one_port(&sa1100_reg, &sport->port); 879 - 880 - return 0; 881 879 } 882 880 883 881 static struct platform_driver sa11x0_serial_driver = { 884 882 .probe = sa1100_serial_probe, 885 - .remove = sa1100_serial_remove, 883 + .remove_new = sa1100_serial_remove, 886 884 .suspend = sa1100_serial_suspend, 887 885 .resume = sa1100_serial_resume, 888 886 .driver = {
+2 -4
drivers/tty/serial/samsung_tty.c
··· 2054 2054 return 0; 2055 2055 } 2056 2056 2057 - static int s3c24xx_serial_remove(struct platform_device *dev) 2057 + static void s3c24xx_serial_remove(struct platform_device *dev) 2058 2058 { 2059 2059 struct uart_port *port = s3c24xx_dev_to_port(&dev->dev); 2060 2060 ··· 2063 2063 } 2064 2064 2065 2065 uart_unregister_driver(&s3c24xx_uart_drv); 2066 - 2067 - return 0; 2068 2066 } 2069 2067 2070 2068 /* UART power management code */ ··· 2625 2627 2626 2628 static struct platform_driver samsung_serial_driver = { 2627 2629 .probe = s3c24xx_serial_probe, 2628 - .remove = s3c24xx_serial_remove, 2630 + .remove_new = s3c24xx_serial_remove, 2629 2631 .id_table = s3c24xx_serial_driver_ids, 2630 2632 .driver = { 2631 2633 .name = "samsung-uart",
+288 -279
drivers/tty/serial/sc16is7xx.c
··· 24 24 #include <linux/tty_flip.h> 25 25 #include <linux/spi/spi.h> 26 26 #include <linux/uaccess.h> 27 + #include <linux/units.h> 27 28 #include <uapi/linux/sched/types.h> 28 29 29 30 #define SC16IS7XX_NAME "sc16is7xx" 30 31 #define SC16IS7XX_MAX_DEVS 8 32 + #define SC16IS7XX_MAX_PORTS 2 /* Maximum number of UART ports per IC. */ 31 33 32 34 /* SC16IS7XX register definitions */ 33 35 #define SC16IS7XX_RHR_REG (0x00) /* RX FIFO */ ··· 302 300 303 301 304 302 /* Misc definitions */ 303 + #define SC16IS7XX_SPI_READ_BIT BIT(7) 305 304 #define SC16IS7XX_FIFO_SIZE (64) 306 - #define SC16IS7XX_REG_SHIFT 2 307 305 #define SC16IS7XX_GPIOS_PER_BANK 4 308 306 309 307 struct sc16is7xx_devtype { ··· 324 322 325 323 struct sc16is7xx_one { 326 324 struct uart_port port; 327 - u8 line; 325 + struct regmap *regmap; 326 + struct mutex efr_lock; /* EFR registers access */ 328 327 struct kthread_work tx_work; 329 328 struct kthread_work reg_work; 330 329 struct kthread_delayed_work ms_work; 331 330 struct sc16is7xx_one_config config; 332 - bool irda_mode; 333 331 unsigned int old_mctrl; 332 + u8 old_lcr; /* Value before EFR access. */ 333 + bool irda_mode; 334 334 }; 335 335 336 336 struct sc16is7xx_port { 337 337 const struct sc16is7xx_devtype *devtype; 338 - struct regmap *regmap; 339 338 struct clk *clk; 340 339 #ifdef CONFIG_GPIOLIB 341 340 struct gpio_chip gpio; ··· 346 343 unsigned char buf[SC16IS7XX_FIFO_SIZE]; 347 344 struct kthread_worker kworker; 348 345 struct task_struct *kworker_task; 349 - struct mutex efr_lock; 350 346 struct sc16is7xx_one p[]; 351 347 }; 352 348 353 - static unsigned long sc16is7xx_lines; 349 + static DECLARE_BITMAP(sc16is7xx_lines, SC16IS7XX_MAX_DEVS); 354 350 355 351 static struct uart_driver sc16is7xx_uart = { 356 352 .owner = THIS_MODULE, 353 + .driver_name = SC16IS7XX_NAME, 357 354 .dev_name = "ttySC", 358 355 .nr = SC16IS7XX_MAX_DEVS, 359 356 }; 360 357 361 - static void sc16is7xx_ier_set(struct uart_port *port, u8 bit); 362 - static void sc16is7xx_stop_tx(struct uart_port *port); 363 - 364 358 #define to_sc16is7xx_one(p,e) ((container_of((p), struct sc16is7xx_one, e))) 365 - 366 - static int sc16is7xx_line(struct uart_port *port) 367 - { 368 - struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 369 - 370 - return one->line; 371 - } 372 359 373 360 static u8 sc16is7xx_port_read(struct uart_port *port, u8 reg) 374 361 { 375 - struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 362 + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 376 363 unsigned int val = 0; 377 - const u8 line = sc16is7xx_line(port); 378 364 379 - regmap_read(s->regmap, (reg << SC16IS7XX_REG_SHIFT) | line, &val); 365 + regmap_read(one->regmap, reg, &val); 380 366 381 367 return val; 382 368 } 383 369 384 370 static void sc16is7xx_port_write(struct uart_port *port, u8 reg, u8 val) 385 371 { 386 - struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 387 - const u8 line = sc16is7xx_line(port); 372 + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 388 373 389 - regmap_write(s->regmap, (reg << SC16IS7XX_REG_SHIFT) | line, val); 374 + regmap_write(one->regmap, reg, val); 390 375 } 391 376 392 - static void sc16is7xx_fifo_read(struct uart_port *port, unsigned int rxlen) 377 + static void sc16is7xx_fifo_read(struct uart_port *port, u8 *rxbuf, unsigned int rxlen) 393 378 { 394 - struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 395 - const u8 line = sc16is7xx_line(port); 396 - u8 addr = (SC16IS7XX_RHR_REG << SC16IS7XX_REG_SHIFT) | line; 379 + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 397 380 398 - regcache_cache_bypass(s->regmap, true); 399 - regmap_raw_read(s->regmap, addr, s->buf, rxlen); 400 - regcache_cache_bypass(s->regmap, false); 381 + regmap_noinc_read(one->regmap, SC16IS7XX_RHR_REG, rxbuf, rxlen); 401 382 } 402 383 403 - static void sc16is7xx_fifo_write(struct uart_port *port, u8 to_send) 384 + static void sc16is7xx_fifo_write(struct uart_port *port, u8 *txbuf, u8 to_send) 404 385 { 405 - struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 406 - const u8 line = sc16is7xx_line(port); 407 - u8 addr = (SC16IS7XX_THR_REG << SC16IS7XX_REG_SHIFT) | line; 386 + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 408 387 409 388 /* 410 389 * Don't send zero-length data, at least on SPI it confuses the chip ··· 395 410 if (unlikely(!to_send)) 396 411 return; 397 412 398 - regcache_cache_bypass(s->regmap, true); 399 - regmap_raw_write(s->regmap, addr, s->buf, to_send); 400 - regcache_cache_bypass(s->regmap, false); 413 + regmap_noinc_write(one->regmap, SC16IS7XX_THR_REG, txbuf, to_send); 401 414 } 402 415 403 416 static void sc16is7xx_port_update(struct uart_port *port, u8 reg, 404 417 u8 mask, u8 val) 405 418 { 406 - struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 407 - const u8 line = sc16is7xx_line(port); 419 + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 408 420 409 - regmap_update_bits(s->regmap, (reg << SC16IS7XX_REG_SHIFT) | line, 410 - mask, val); 411 - } 412 - 413 - static int sc16is7xx_alloc_line(void) 414 - { 415 - int i; 416 - 417 - BUILD_BUG_ON(SC16IS7XX_MAX_DEVS > BITS_PER_LONG); 418 - 419 - for (i = 0; i < SC16IS7XX_MAX_DEVS; i++) 420 - if (!test_and_set_bit(i, &sc16is7xx_lines)) 421 - break; 422 - 423 - return i; 421 + regmap_update_bits(one->regmap, reg, mask, val); 424 422 } 425 423 426 424 static void sc16is7xx_power(struct uart_port *port, int on) ··· 411 443 sc16is7xx_port_update(port, SC16IS7XX_IER_REG, 412 444 SC16IS7XX_IER_SLEEP_BIT, 413 445 on ? 0 : SC16IS7XX_IER_SLEEP_BIT); 446 + } 447 + 448 + /* 449 + * In an amazing feat of design, the Enhanced Features Register (EFR) 450 + * shares the address of the Interrupt Identification Register (IIR). 451 + * Access to EFR is switched on by writing a magic value (0xbf) to the 452 + * Line Control Register (LCR). Any interrupt firing during this time will 453 + * see the EFR where it expects the IIR to be, leading to 454 + * "Unexpected interrupt" messages. 455 + * 456 + * Prevent this possibility by claiming a mutex while accessing the EFR, 457 + * and claiming the same mutex from within the interrupt handler. This is 458 + * similar to disabling the interrupt, but that doesn't work because the 459 + * bulk of the interrupt processing is run as a workqueue job in thread 460 + * context. 461 + */ 462 + static void sc16is7xx_efr_lock(struct uart_port *port) 463 + { 464 + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 465 + 466 + mutex_lock(&one->efr_lock); 467 + 468 + /* Backup content of LCR. */ 469 + one->old_lcr = sc16is7xx_port_read(port, SC16IS7XX_LCR_REG); 470 + 471 + /* Enable access to Enhanced register set */ 472 + sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, SC16IS7XX_LCR_CONF_MODE_B); 473 + 474 + /* Disable cache updates when writing to EFR registers */ 475 + regcache_cache_bypass(one->regmap, true); 476 + } 477 + 478 + static void sc16is7xx_efr_unlock(struct uart_port *port) 479 + { 480 + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 481 + 482 + /* Re-enable cache updates when writing to normal registers */ 483 + regcache_cache_bypass(one->regmap, false); 484 + 485 + /* Restore original content of LCR */ 486 + sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, one->old_lcr); 487 + 488 + mutex_unlock(&one->efr_lock); 489 + } 490 + 491 + static void sc16is7xx_ier_clear(struct uart_port *port, u8 bit) 492 + { 493 + struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 494 + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 495 + 496 + lockdep_assert_held_once(&port->lock); 497 + 498 + one->config.flags |= SC16IS7XX_RECONF_IER; 499 + one->config.ier_mask |= bit; 500 + one->config.ier_val &= ~bit; 501 + kthread_queue_work(&s->kworker, &one->reg_work); 502 + } 503 + 504 + static void sc16is7xx_ier_set(struct uart_port *port, u8 bit) 505 + { 506 + struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 507 + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 508 + 509 + lockdep_assert_held_once(&port->lock); 510 + 511 + one->config.flags |= SC16IS7XX_RECONF_IER; 512 + one->config.ier_mask |= bit; 513 + one->config.ier_val |= bit; 514 + kthread_queue_work(&s->kworker, &one->reg_work); 515 + } 516 + 517 + static void sc16is7xx_stop_tx(struct uart_port *port) 518 + { 519 + sc16is7xx_ier_clear(port, SC16IS7XX_IER_THRI_BIT); 520 + } 521 + 522 + static void sc16is7xx_stop_rx(struct uart_port *port) 523 + { 524 + sc16is7xx_ier_clear(port, SC16IS7XX_IER_RDI_BIT); 414 525 } 415 526 416 527 static const struct sc16is7xx_devtype sc16is74x_devtype = { ··· 524 477 525 478 static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg) 526 479 { 527 - switch (reg >> SC16IS7XX_REG_SHIFT) { 480 + switch (reg) { 528 481 case SC16IS7XX_RHR_REG: 529 482 case SC16IS7XX_IIR_REG: 530 483 case SC16IS7XX_LSR_REG: ··· 535 488 case SC16IS7XX_IOCONTROL_REG: 536 489 return true; 537 490 default: 538 - break; 491 + return false; 539 492 } 540 - 541 - return false; 542 493 } 543 494 544 495 static bool sc16is7xx_regmap_precious(struct device *dev, unsigned int reg) 545 496 { 546 - switch (reg >> SC16IS7XX_REG_SHIFT) { 497 + switch (reg) { 547 498 case SC16IS7XX_RHR_REG: 548 499 return true; 549 500 default: 550 - break; 501 + return false; 551 502 } 503 + } 552 504 553 - return false; 505 + static bool sc16is7xx_regmap_noinc(struct device *dev, unsigned int reg) 506 + { 507 + return reg == SC16IS7XX_RHR_REG; 554 508 } 555 509 556 510 static int sc16is7xx_set_baud(struct uart_port *port, int baud) 557 511 { 558 - struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 512 + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 559 513 u8 lcr; 560 514 u8 prescaler = 0; 561 515 unsigned long clk = port->uartclk, div = clk / 16 / baud; 562 516 563 - if (div > 0xffff) { 517 + if (div >= BIT(16)) { 564 518 prescaler = SC16IS7XX_MCR_CLKSEL_BIT; 565 519 div /= 4; 566 520 } 567 521 568 - /* In an amazing feat of design, the Enhanced Features Register shares 569 - * the address of the Interrupt Identification Register, and is 570 - * switched in by writing a magic value (0xbf) to the Line Control 571 - * Register. Any interrupt firing during this time will see the EFR 572 - * where it expects the IIR to be, leading to "Unexpected interrupt" 573 - * messages. 574 - * 575 - * Prevent this possibility by claiming a mutex while accessing the 576 - * EFR, and claiming the same mutex from within the interrupt handler. 577 - * This is similar to disabling the interrupt, but that doesn't work 578 - * because the bulk of the interrupt processing is run as a workqueue 579 - * job in thread context. 580 - */ 581 - mutex_lock(&s->efr_lock); 582 - 583 - lcr = sc16is7xx_port_read(port, SC16IS7XX_LCR_REG); 584 - 585 - /* Open the LCR divisors for configuration */ 586 - sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, 587 - SC16IS7XX_LCR_CONF_MODE_B); 588 - 589 522 /* Enable enhanced features */ 590 - regcache_cache_bypass(s->regmap, true); 523 + sc16is7xx_efr_lock(port); 591 524 sc16is7xx_port_update(port, SC16IS7XX_EFR_REG, 592 525 SC16IS7XX_EFR_ENABLE_BIT, 593 526 SC16IS7XX_EFR_ENABLE_BIT); 594 - 595 - regcache_cache_bypass(s->regmap, false); 596 - 597 - /* Put LCR back to the normal mode */ 598 - sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, lcr); 599 - 600 - mutex_unlock(&s->efr_lock); 527 + sc16is7xx_efr_unlock(port); 601 528 602 529 sc16is7xx_port_update(port, SC16IS7XX_MCR_REG, 603 530 SC16IS7XX_MCR_CLKSEL_BIT, 604 531 prescaler); 605 532 606 - /* Open the LCR divisors for configuration */ 533 + /* Backup LCR and access special register set (DLL/DLH) */ 534 + lcr = sc16is7xx_port_read(port, SC16IS7XX_LCR_REG); 607 535 sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, 608 536 SC16IS7XX_LCR_CONF_MODE_A); 609 537 610 538 /* Write the new divisor */ 611 - regcache_cache_bypass(s->regmap, true); 539 + regcache_cache_bypass(one->regmap, true); 612 540 sc16is7xx_port_write(port, SC16IS7XX_DLH_REG, div / 256); 613 541 sc16is7xx_port_write(port, SC16IS7XX_DLL_REG, div % 256); 614 - regcache_cache_bypass(s->regmap, false); 542 + regcache_cache_bypass(one->regmap, false); 615 543 616 - /* Put LCR back to the normal mode */ 544 + /* Restore LCR and access to general register set */ 617 545 sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, lcr); 618 546 619 547 return DIV_ROUND_CLOSEST(clk / 16, div); ··· 624 602 s->buf[0] = sc16is7xx_port_read(port, SC16IS7XX_RHR_REG); 625 603 bytes_read = 1; 626 604 } else { 627 - sc16is7xx_fifo_read(port, rxlen); 605 + sc16is7xx_fifo_read(port, s->buf, rxlen); 628 606 bytes_read = rxlen; 629 607 } 630 608 ··· 697 675 /* Get length of data pending in circular buffer */ 698 676 to_send = uart_circ_chars_pending(xmit); 699 677 if (likely(to_send)) { 700 - /* Limit to size of TX FIFO */ 678 + /* Limit to space available in TX FIFO */ 701 679 txlen = sc16is7xx_port_read(port, SC16IS7XX_TXLVL_REG); 702 680 if (txlen > SC16IS7XX_FIFO_SIZE) { 703 681 dev_err_ratelimited(port->dev, ··· 713 691 uart_xmit_advance(port, 1); 714 692 } 715 693 716 - sc16is7xx_fifo_write(port, to_send); 694 + sc16is7xx_fifo_write(port, s->buf, to_send); 717 695 } 718 696 719 697 uart_port_lock_irqsave(port, &flags); ··· 722 700 723 701 if (uart_circ_empty(xmit)) 724 702 sc16is7xx_stop_tx(port); 703 + else 704 + sc16is7xx_ier_set(port, SC16IS7XX_IER_THRI_BIT); 725 705 uart_port_unlock_irqrestore(port, flags); 726 706 } 727 707 ··· 742 718 static void sc16is7xx_update_mlines(struct sc16is7xx_one *one) 743 719 { 744 720 struct uart_port *port = &one->port; 745 - struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 746 721 unsigned long flags; 747 722 unsigned int status, changed; 748 723 749 - lockdep_assert_held_once(&s->efr_lock); 724 + lockdep_assert_held_once(&one->efr_lock); 750 725 751 726 status = sc16is7xx_get_hwmctrl(port); 752 727 changed = status ^ one->old_mctrl; ··· 771 748 772 749 static bool sc16is7xx_port_irq(struct sc16is7xx_port *s, int portno) 773 750 { 751 + bool rc = true; 752 + unsigned int iir, rxlen; 774 753 struct uart_port *port = &s->p[portno].port; 754 + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 775 755 776 - do { 777 - unsigned int iir, rxlen; 778 - struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 756 + mutex_lock(&one->efr_lock); 779 757 780 - iir = sc16is7xx_port_read(port, SC16IS7XX_IIR_REG); 781 - if (iir & SC16IS7XX_IIR_NO_INT_BIT) 782 - return false; 758 + iir = sc16is7xx_port_read(port, SC16IS7XX_IIR_REG); 759 + if (iir & SC16IS7XX_IIR_NO_INT_BIT) { 760 + rc = false; 761 + goto out_port_irq; 762 + } 783 763 784 - iir &= SC16IS7XX_IIR_ID_MASK; 764 + iir &= SC16IS7XX_IIR_ID_MASK; 785 765 786 - switch (iir) { 787 - case SC16IS7XX_IIR_RDI_SRC: 788 - case SC16IS7XX_IIR_RLSE_SRC: 789 - case SC16IS7XX_IIR_RTOI_SRC: 790 - case SC16IS7XX_IIR_XOFFI_SRC: 791 - rxlen = sc16is7xx_port_read(port, SC16IS7XX_RXLVL_REG); 766 + switch (iir) { 767 + case SC16IS7XX_IIR_RDI_SRC: 768 + case SC16IS7XX_IIR_RLSE_SRC: 769 + case SC16IS7XX_IIR_RTOI_SRC: 770 + case SC16IS7XX_IIR_XOFFI_SRC: 771 + rxlen = sc16is7xx_port_read(port, SC16IS7XX_RXLVL_REG); 792 772 793 - /* 794 - * There is a silicon bug that makes the chip report a 795 - * time-out interrupt but no data in the FIFO. This is 796 - * described in errata section 18.1.4. 797 - * 798 - * When this happens, read one byte from the FIFO to 799 - * clear the interrupt. 800 - */ 801 - if (iir == SC16IS7XX_IIR_RTOI_SRC && !rxlen) 802 - rxlen = 1; 773 + /* 774 + * There is a silicon bug that makes the chip report a 775 + * time-out interrupt but no data in the FIFO. This is 776 + * described in errata section 18.1.4. 777 + * 778 + * When this happens, read one byte from the FIFO to 779 + * clear the interrupt. 780 + */ 781 + if (iir == SC16IS7XX_IIR_RTOI_SRC && !rxlen) 782 + rxlen = 1; 803 783 804 - if (rxlen) 805 - sc16is7xx_handle_rx(port, rxlen, iir); 806 - break; 784 + if (rxlen) 785 + sc16is7xx_handle_rx(port, rxlen, iir); 786 + break; 807 787 /* CTSRTS interrupt comes only when CTS goes inactive */ 808 - case SC16IS7XX_IIR_CTSRTS_SRC: 809 - case SC16IS7XX_IIR_MSI_SRC: 810 - sc16is7xx_update_mlines(one); 811 - break; 812 - case SC16IS7XX_IIR_THRI_SRC: 813 - sc16is7xx_handle_tx(port); 814 - break; 815 - default: 816 - dev_err_ratelimited(port->dev, 817 - "ttySC%i: Unexpected interrupt: %x", 818 - port->line, iir); 819 - break; 820 - } 821 - } while (0); 822 - return true; 788 + case SC16IS7XX_IIR_CTSRTS_SRC: 789 + case SC16IS7XX_IIR_MSI_SRC: 790 + sc16is7xx_update_mlines(one); 791 + break; 792 + case SC16IS7XX_IIR_THRI_SRC: 793 + sc16is7xx_handle_tx(port); 794 + break; 795 + default: 796 + dev_err_ratelimited(port->dev, 797 + "ttySC%i: Unexpected interrupt: %x", 798 + port->line, iir); 799 + break; 800 + } 801 + 802 + out_port_irq: 803 + mutex_unlock(&one->efr_lock); 804 + 805 + return rc; 823 806 } 824 807 825 808 static irqreturn_t sc16is7xx_irq(int irq, void *dev_id) 826 809 { 810 + bool keep_polling; 811 + 827 812 struct sc16is7xx_port *s = (struct sc16is7xx_port *)dev_id; 828 813 829 - mutex_lock(&s->efr_lock); 830 - 831 - while (1) { 832 - bool keep_polling = false; 814 + do { 833 815 int i; 816 + 817 + keep_polling = false; 834 818 835 819 for (i = 0; i < s->devtype->nr_uart; ++i) 836 820 keep_polling |= sc16is7xx_port_irq(s, i); 837 - if (!keep_polling) 838 - break; 839 - } 840 - 841 - mutex_unlock(&s->efr_lock); 821 + } while (keep_polling); 842 822 843 823 return IRQ_HANDLED; 844 824 } ··· 849 823 static void sc16is7xx_tx_proc(struct kthread_work *ws) 850 824 { 851 825 struct uart_port *port = &(to_sc16is7xx_one(ws, tx_work)->port); 852 - struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 853 - unsigned long flags; 826 + struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 854 827 855 828 if ((port->rs485.flags & SER_RS485_ENABLED) && 856 829 (port->rs485.delay_rts_before_send > 0)) 857 830 msleep(port->rs485.delay_rts_before_send); 858 831 859 - mutex_lock(&s->efr_lock); 832 + mutex_lock(&one->efr_lock); 860 833 sc16is7xx_handle_tx(port); 861 - mutex_unlock(&s->efr_lock); 862 - 863 - uart_port_lock_irqsave(port, &flags); 864 - sc16is7xx_ier_set(port, SC16IS7XX_IER_THRI_BIT); 865 - uart_port_unlock_irqrestore(port, flags); 834 + mutex_unlock(&one->efr_lock); 866 835 } 867 836 868 837 static void sc16is7xx_reconf_rs485(struct uart_port *port) ··· 918 897 sc16is7xx_reconf_rs485(&one->port); 919 898 } 920 899 921 - static void sc16is7xx_ier_clear(struct uart_port *port, u8 bit) 922 - { 923 - struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 924 - struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 925 - 926 - lockdep_assert_held_once(&port->lock); 927 - 928 - one->config.flags |= SC16IS7XX_RECONF_IER; 929 - one->config.ier_mask |= bit; 930 - one->config.ier_val &= ~bit; 931 - kthread_queue_work(&s->kworker, &one->reg_work); 932 - } 933 - 934 - static void sc16is7xx_ier_set(struct uart_port *port, u8 bit) 935 - { 936 - struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 937 - struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 938 - 939 - lockdep_assert_held_once(&port->lock); 940 - 941 - one->config.flags |= SC16IS7XX_RECONF_IER; 942 - one->config.ier_mask |= bit; 943 - one->config.ier_val |= bit; 944 - kthread_queue_work(&s->kworker, &one->reg_work); 945 - } 946 - 947 - static void sc16is7xx_stop_tx(struct uart_port *port) 948 - { 949 - sc16is7xx_ier_clear(port, SC16IS7XX_IER_THRI_BIT); 950 - } 951 - 952 - static void sc16is7xx_stop_rx(struct uart_port *port) 953 - { 954 - sc16is7xx_ier_clear(port, SC16IS7XX_IER_RDI_BIT); 955 - } 956 - 957 900 static void sc16is7xx_ms_proc(struct kthread_work *ws) 958 901 { 959 902 struct sc16is7xx_one *one = to_sc16is7xx_one(ws, ms_work.work); 960 903 struct sc16is7xx_port *s = dev_get_drvdata(one->port.dev); 961 904 962 905 if (one->port.state) { 963 - mutex_lock(&s->efr_lock); 906 + mutex_lock(&one->efr_lock); 964 907 sc16is7xx_update_mlines(one); 965 - mutex_unlock(&s->efr_lock); 908 + mutex_unlock(&one->efr_lock); 966 909 967 910 kthread_queue_delayed_work(&s->kworker, &one->ms_work, HZ); 968 911 } ··· 1010 1025 struct ktermios *termios, 1011 1026 const struct ktermios *old) 1012 1027 { 1013 - struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 1014 1028 struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 1015 1029 unsigned int lcr, flow = 0; 1016 1030 int baud; ··· 1067 1083 if (!(termios->c_cflag & CREAD)) 1068 1084 port->ignore_status_mask |= SC16IS7XX_LSR_BRK_ERROR_MASK; 1069 1085 1070 - /* As above, claim the mutex while accessing the EFR. */ 1071 - mutex_lock(&s->efr_lock); 1072 - 1073 - sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, 1074 - SC16IS7XX_LCR_CONF_MODE_B); 1075 - 1076 1086 /* Configure flow control */ 1077 - regcache_cache_bypass(s->regmap, true); 1078 - sc16is7xx_port_write(port, SC16IS7XX_XON1_REG, termios->c_cc[VSTART]); 1079 - sc16is7xx_port_write(port, SC16IS7XX_XOFF1_REG, termios->c_cc[VSTOP]); 1080 - 1081 1087 port->status &= ~(UPSTAT_AUTOCTS | UPSTAT_AUTORTS); 1082 1088 if (termios->c_cflag & CRTSCTS) { 1083 1089 flow |= SC16IS7XX_EFR_AUTOCTS_BIT | ··· 1079 1105 if (termios->c_iflag & IXOFF) 1080 1106 flow |= SC16IS7XX_EFR_SWFLOW1_BIT; 1081 1107 1082 - sc16is7xx_port_update(port, 1083 - SC16IS7XX_EFR_REG, 1084 - SC16IS7XX_EFR_FLOWCTRL_BITS, 1085 - flow); 1086 - regcache_cache_bypass(s->regmap, false); 1087 - 1088 1108 /* Update LCR register */ 1089 1109 sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, lcr); 1090 1110 1091 - mutex_unlock(&s->efr_lock); 1111 + /* Update EFR registers */ 1112 + sc16is7xx_efr_lock(port); 1113 + sc16is7xx_port_write(port, SC16IS7XX_XON1_REG, termios->c_cc[VSTART]); 1114 + sc16is7xx_port_write(port, SC16IS7XX_XOFF1_REG, termios->c_cc[VSTOP]); 1115 + sc16is7xx_port_update(port, SC16IS7XX_EFR_REG, 1116 + SC16IS7XX_EFR_FLOWCTRL_BITS, flow); 1117 + sc16is7xx_efr_unlock(port); 1092 1118 1093 1119 /* Get baud rate generator configuration */ 1094 1120 baud = uart_get_baud_rate(port, termios, old, ··· 1134 1160 static int sc16is7xx_startup(struct uart_port *port) 1135 1161 { 1136 1162 struct sc16is7xx_one *one = to_sc16is7xx_one(port, port); 1137 - struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 1138 1163 unsigned int val; 1139 1164 unsigned long flags; 1140 1165 ··· 1150 1177 sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, 1151 1178 SC16IS7XX_LCR_CONF_MODE_B); 1152 1179 1153 - regcache_cache_bypass(s->regmap, true); 1180 + regcache_cache_bypass(one->regmap, true); 1154 1181 1155 1182 /* Enable write access to enhanced features and internal clock div */ 1156 1183 sc16is7xx_port_update(port, SC16IS7XX_EFR_REG, ··· 1168 1195 SC16IS7XX_TCR_RX_RESUME(24) | 1169 1196 SC16IS7XX_TCR_RX_HALT(48)); 1170 1197 1171 - regcache_cache_bypass(s->regmap, false); 1198 + regcache_cache_bypass(one->regmap, false); 1172 1199 1173 1200 /* Now, initialize the UART */ 1174 1201 sc16is7xx_port_write(port, SC16IS7XX_LCR_REG, SC16IS7XX_LCR_WORD_LEN_8); ··· 1398 1425 int i; 1399 1426 int ret; 1400 1427 int count; 1401 - u32 irda_port[2]; 1428 + u32 irda_port[SC16IS7XX_MAX_PORTS]; 1402 1429 struct device *dev = s->p[0].port.dev; 1403 1430 1404 1431 count = device_property_count_u32(dev, "irda-mode-ports"); ··· 1419 1446 /* 1420 1447 * Configure ports designated to operate as modem control lines. 1421 1448 */ 1422 - static int sc16is7xx_setup_mctrl_ports(struct sc16is7xx_port *s) 1449 + static int sc16is7xx_setup_mctrl_ports(struct sc16is7xx_port *s, 1450 + struct regmap *regmap) 1423 1451 { 1424 1452 int i; 1425 1453 int ret; 1426 1454 int count; 1427 - u32 mctrl_port[2]; 1455 + u32 mctrl_port[SC16IS7XX_MAX_PORTS]; 1428 1456 struct device *dev = s->p[0].port.dev; 1429 1457 1430 1458 count = device_property_count_u32(dev, "nxp,modem-control-line-ports"); ··· 1449 1475 1450 1476 if (s->mctrl_mask) 1451 1477 regmap_update_bits( 1452 - s->regmap, 1453 - SC16IS7XX_IOCONTROL_REG << SC16IS7XX_REG_SHIFT, 1478 + regmap, 1479 + SC16IS7XX_IOCONTROL_REG, 1454 1480 SC16IS7XX_IOCONTROL_MODEM_A_BIT | 1455 1481 SC16IS7XX_IOCONTROL_MODEM_B_BIT, s->mctrl_mask); 1456 1482 ··· 1465 1491 1466 1492 static int sc16is7xx_probe(struct device *dev, 1467 1493 const struct sc16is7xx_devtype *devtype, 1468 - struct regmap *regmap, int irq) 1494 + struct regmap *regmaps[], int irq) 1469 1495 { 1470 1496 unsigned long freq = 0, *pfreq = dev_get_platdata(dev); 1471 1497 unsigned int val; ··· 1473 1499 int i, ret; 1474 1500 struct sc16is7xx_port *s; 1475 1501 1476 - if (IS_ERR(regmap)) 1477 - return PTR_ERR(regmap); 1502 + for (i = 0; i < devtype->nr_uart; i++) 1503 + if (IS_ERR(regmaps[i])) 1504 + return PTR_ERR(regmaps[i]); 1478 1505 1479 1506 /* 1480 1507 * This device does not have an identification register that would 1481 1508 * tell us if we are really connected to the correct device. 1482 1509 * The best we can do is to check if communication is at all possible. 1510 + * 1511 + * Note: regmap[0] is used in the probe function to access registers 1512 + * common to all channels/ports, as it is guaranteed to be present on 1513 + * all variants. 1483 1514 */ 1484 - ret = regmap_read(regmap, 1485 - SC16IS7XX_LSR_REG << SC16IS7XX_REG_SHIFT, &val); 1515 + ret = regmap_read(regmaps[0], SC16IS7XX_LSR_REG, &val); 1486 1516 if (ret < 0) 1487 1517 return -EPROBE_DEFER; 1488 1518 ··· 1520 1542 return -EINVAL; 1521 1543 } 1522 1544 1523 - s->regmap = regmap; 1524 1545 s->devtype = devtype; 1525 1546 dev_set_drvdata(dev, s); 1526 - mutex_init(&s->efr_lock); 1527 1547 1528 1548 kthread_init_worker(&s->kworker); 1529 1549 s->kworker_task = kthread_run(kthread_worker_fn, &s->kworker, ··· 1533 1557 sched_set_fifo(s->kworker_task); 1534 1558 1535 1559 /* reset device, purging any pending irq / data */ 1536 - regmap_write(s->regmap, SC16IS7XX_IOCONTROL_REG << SC16IS7XX_REG_SHIFT, 1537 - SC16IS7XX_IOCONTROL_SRESET_BIT); 1560 + regmap_write(regmaps[0], SC16IS7XX_IOCONTROL_REG, 1561 + SC16IS7XX_IOCONTROL_SRESET_BIT); 1538 1562 1539 1563 for (i = 0; i < devtype->nr_uart; ++i) { 1540 - s->p[i].line = i; 1564 + s->p[i].port.line = find_first_zero_bit(sc16is7xx_lines, 1565 + SC16IS7XX_MAX_DEVS); 1566 + if (s->p[i].port.line >= SC16IS7XX_MAX_DEVS) { 1567 + ret = -ERANGE; 1568 + goto out_ports; 1569 + } 1570 + 1541 1571 /* Initialize port data */ 1542 1572 s->p[i].port.dev = dev; 1543 1573 s->p[i].port.irq = irq; ··· 1563 1581 s->p[i].port.rs485_supported = sc16is7xx_rs485_supported; 1564 1582 s->p[i].port.ops = &sc16is7xx_ops; 1565 1583 s->p[i].old_mctrl = 0; 1566 - s->p[i].port.line = sc16is7xx_alloc_line(); 1584 + s->p[i].regmap = regmaps[i]; 1567 1585 1568 - if (s->p[i].port.line >= SC16IS7XX_MAX_DEVS) { 1569 - ret = -ENOMEM; 1570 - goto out_ports; 1571 - } 1586 + mutex_init(&s->p[i].efr_lock); 1572 1587 1573 1588 ret = uart_get_rs485_mode(&s->p[i].port); 1574 1589 if (ret) ··· 1582 1603 kthread_init_work(&s->p[i].tx_work, sc16is7xx_tx_proc); 1583 1604 kthread_init_work(&s->p[i].reg_work, sc16is7xx_reg_proc); 1584 1605 kthread_init_delayed_work(&s->p[i].ms_work, sc16is7xx_ms_proc); 1606 + 1585 1607 /* Register port */ 1586 - uart_add_one_port(&sc16is7xx_uart, &s->p[i].port); 1608 + ret = uart_add_one_port(&sc16is7xx_uart, &s->p[i].port); 1609 + if (ret) 1610 + goto out_ports; 1611 + 1612 + set_bit(s->p[i].port.line, sc16is7xx_lines); 1587 1613 1588 1614 /* Enable EFR */ 1589 1615 sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_LCR_REG, 1590 1616 SC16IS7XX_LCR_CONF_MODE_B); 1591 1617 1592 - regcache_cache_bypass(s->regmap, true); 1618 + regcache_cache_bypass(regmaps[i], true); 1593 1619 1594 1620 /* Enable write access to enhanced features */ 1595 1621 sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_EFR_REG, 1596 1622 SC16IS7XX_EFR_ENABLE_BIT); 1597 1623 1598 - regcache_cache_bypass(s->regmap, false); 1624 + regcache_cache_bypass(regmaps[i], false); 1599 1625 1600 1626 /* Restore access to general registers */ 1601 1627 sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_LCR_REG, 0x00); ··· 1611 1627 1612 1628 sc16is7xx_setup_irda_ports(s); 1613 1629 1614 - ret = sc16is7xx_setup_mctrl_ports(s); 1630 + ret = sc16is7xx_setup_mctrl_ports(s, regmaps[0]); 1615 1631 if (ret) 1616 1632 goto out_ports; 1617 1633 ··· 1646 1662 #endif 1647 1663 1648 1664 out_ports: 1649 - for (i--; i >= 0; i--) { 1650 - uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port); 1651 - clear_bit(s->p[i].port.line, &sc16is7xx_lines); 1652 - } 1665 + for (i = 0; i < devtype->nr_uart; i++) 1666 + if (test_and_clear_bit(s->p[i].port.line, sc16is7xx_lines)) 1667 + uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port); 1653 1668 1654 1669 kthread_stop(s->kworker_task); 1655 1670 ··· 1670 1687 1671 1688 for (i = 0; i < s->devtype->nr_uart; i++) { 1672 1689 kthread_cancel_delayed_work_sync(&s->p[i].ms_work); 1673 - uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port); 1674 - clear_bit(s->p[i].port.line, &sc16is7xx_lines); 1690 + if (test_and_clear_bit(s->p[i].port.line, sc16is7xx_lines)) 1691 + uart_remove_one_port(&sc16is7xx_uart, &s->p[i].port); 1675 1692 sc16is7xx_power(&s->p[i].port, 0); 1676 1693 } 1677 1694 ··· 1693 1710 MODULE_DEVICE_TABLE(of, sc16is7xx_dt_ids); 1694 1711 1695 1712 static struct regmap_config regcfg = { 1696 - .reg_bits = 7, 1697 - .pad_bits = 1, 1713 + .reg_bits = 5, 1714 + .pad_bits = 3, 1698 1715 .val_bits = 8, 1699 1716 .cache_type = REGCACHE_RBTREE, 1700 1717 .volatile_reg = sc16is7xx_regmap_volatile, 1701 1718 .precious_reg = sc16is7xx_regmap_precious, 1719 + .writeable_noinc_reg = sc16is7xx_regmap_noinc, 1720 + .readable_noinc_reg = sc16is7xx_regmap_noinc, 1721 + .max_raw_read = SC16IS7XX_FIFO_SIZE, 1722 + .max_raw_write = SC16IS7XX_FIFO_SIZE, 1723 + .max_register = SC16IS7XX_EFCR_REG, 1702 1724 }; 1725 + 1726 + static const char *sc16is7xx_regmap_name(u8 port_id) 1727 + { 1728 + switch (port_id) { 1729 + case 0: return "port0"; 1730 + case 1: return "port1"; 1731 + default: 1732 + WARN_ON(true); 1733 + return NULL; 1734 + } 1735 + } 1736 + 1737 + static unsigned int sc16is7xx_regmap_port_mask(unsigned int port_id) 1738 + { 1739 + /* CH1,CH0 are at bits 2:1. */ 1740 + return port_id << 1; 1741 + } 1703 1742 1704 1743 #ifdef CONFIG_SERIAL_SC16IS7XX_SPI 1705 1744 static int sc16is7xx_spi_probe(struct spi_device *spi) 1706 1745 { 1707 1746 const struct sc16is7xx_devtype *devtype; 1708 - struct regmap *regmap; 1747 + struct regmap *regmaps[SC16IS7XX_MAX_PORTS]; 1748 + unsigned int i; 1709 1749 int ret; 1710 1750 1711 1751 /* Setup SPI bus */ 1712 1752 spi->bits_per_word = 8; 1713 - /* only supports mode 0 on SC16IS762 */ 1753 + /* For all variants, only mode 0 is supported */ 1754 + if ((spi->mode & SPI_MODE_X_MASK) != SPI_MODE_0) 1755 + return dev_err_probe(&spi->dev, -EINVAL, "Unsupported SPI mode\n"); 1756 + 1714 1757 spi->mode = spi->mode ? : SPI_MODE_0; 1715 - spi->max_speed_hz = spi->max_speed_hz ? : 15000000; 1758 + spi->max_speed_hz = spi->max_speed_hz ? : 4 * HZ_PER_MHZ; 1716 1759 ret = spi_setup(spi); 1717 1760 if (ret) 1718 1761 return ret; 1719 1762 1720 - if (spi->dev.of_node) { 1721 - devtype = device_get_match_data(&spi->dev); 1722 - if (!devtype) 1723 - return -ENODEV; 1724 - } else { 1725 - const struct spi_device_id *id_entry = spi_get_device_id(spi); 1763 + devtype = spi_get_device_match_data(spi); 1764 + if (!devtype) 1765 + return dev_err_probe(&spi->dev, -ENODEV, "Failed to match device\n"); 1726 1766 1727 - devtype = (struct sc16is7xx_devtype *)id_entry->driver_data; 1767 + for (i = 0; i < devtype->nr_uart; i++) { 1768 + regcfg.name = sc16is7xx_regmap_name(i); 1769 + /* 1770 + * If read_flag_mask is 0, the regmap code sets it to a default 1771 + * of 0x80. Since we specify our own mask, we must add the READ 1772 + * bit ourselves: 1773 + */ 1774 + regcfg.read_flag_mask = sc16is7xx_regmap_port_mask(i) | 1775 + SC16IS7XX_SPI_READ_BIT; 1776 + regcfg.write_flag_mask = sc16is7xx_regmap_port_mask(i); 1777 + regmaps[i] = devm_regmap_init_spi(spi, &regcfg); 1728 1778 } 1729 1779 1730 - regcfg.max_register = (0xf << SC16IS7XX_REG_SHIFT) | 1731 - (devtype->nr_uart - 1); 1732 - regmap = devm_regmap_init_spi(spi, &regcfg); 1733 - 1734 - return sc16is7xx_probe(&spi->dev, devtype, regmap, spi->irq); 1780 + return sc16is7xx_probe(&spi->dev, devtype, regmaps, spi->irq); 1735 1781 } 1736 1782 1737 1783 static void sc16is7xx_spi_remove(struct spi_device *spi) ··· 1790 1778 .remove = sc16is7xx_spi_remove, 1791 1779 .id_table = sc16is7xx_spi_id_table, 1792 1780 }; 1793 - 1794 - MODULE_ALIAS("spi:sc16is7xx"); 1795 1781 #endif 1796 1782 1797 1783 #ifdef CONFIG_SERIAL_SC16IS7XX_I2C 1798 1784 static int sc16is7xx_i2c_probe(struct i2c_client *i2c) 1799 1785 { 1800 - const struct i2c_device_id *id = i2c_client_get_device_id(i2c); 1801 1786 const struct sc16is7xx_devtype *devtype; 1802 - struct regmap *regmap; 1787 + struct regmap *regmaps[SC16IS7XX_MAX_PORTS]; 1788 + unsigned int i; 1803 1789 1804 - if (i2c->dev.of_node) { 1805 - devtype = device_get_match_data(&i2c->dev); 1806 - if (!devtype) 1807 - return -ENODEV; 1808 - } else { 1809 - devtype = (struct sc16is7xx_devtype *)id->driver_data; 1790 + devtype = i2c_get_match_data(i2c); 1791 + if (!devtype) 1792 + return dev_err_probe(&i2c->dev, -ENODEV, "Failed to match device\n"); 1793 + 1794 + for (i = 0; i < devtype->nr_uart; i++) { 1795 + regcfg.name = sc16is7xx_regmap_name(i); 1796 + regcfg.read_flag_mask = sc16is7xx_regmap_port_mask(i); 1797 + regcfg.write_flag_mask = sc16is7xx_regmap_port_mask(i); 1798 + regmaps[i] = devm_regmap_init_i2c(i2c, &regcfg); 1810 1799 } 1811 1800 1812 - regcfg.max_register = (0xf << SC16IS7XX_REG_SHIFT) | 1813 - (devtype->nr_uart - 1); 1814 - regmap = devm_regmap_init_i2c(i2c, &regcfg); 1815 - 1816 - return sc16is7xx_probe(&i2c->dev, devtype, regmap, i2c->irq); 1801 + return sc16is7xx_probe(&i2c->dev, devtype, regmaps, i2c->irq); 1817 1802 } 1818 1803 1819 1804 static void sc16is7xx_i2c_remove(struct i2c_client *client)
+7 -6
drivers/tty/serial/sccnxp.c
··· 1021 1021 return ret; 1022 1022 } 1023 1023 1024 - static int sccnxp_remove(struct platform_device *pdev) 1024 + static void sccnxp_remove(struct platform_device *pdev) 1025 1025 { 1026 1026 int i; 1027 1027 struct sccnxp_port *s = platform_get_drvdata(pdev); ··· 1036 1036 1037 1037 uart_unregister_driver(&s->uart); 1038 1038 1039 - if (!IS_ERR(s->regulator)) 1040 - return regulator_disable(s->regulator); 1041 - 1042 - return 0; 1039 + if (!IS_ERR(s->regulator)) { 1040 + int ret = regulator_disable(s->regulator); 1041 + if (ret) 1042 + dev_err(&pdev->dev, "Failed to disable regulator\n"); 1043 + } 1043 1044 } 1044 1045 1045 1046 static struct platform_driver sccnxp_uart_driver = { ··· 1048 1047 .name = SCCNXP_NAME, 1049 1048 }, 1050 1049 .probe = sccnxp_probe, 1051 - .remove = sccnxp_remove, 1050 + .remove_new = sccnxp_remove, 1052 1051 .id_table = sccnxp_id_table, 1053 1052 }; 1054 1053 module_platform_driver(sccnxp_uart_driver);
+2 -3
drivers/tty/serial/serial-tegra.c
··· 1611 1611 return ret; 1612 1612 } 1613 1613 1614 - static int tegra_uart_remove(struct platform_device *pdev) 1614 + static void tegra_uart_remove(struct platform_device *pdev) 1615 1615 { 1616 1616 struct tegra_uart_port *tup = platform_get_drvdata(pdev); 1617 1617 struct uart_port *u = &tup->uport; 1618 1618 1619 1619 uart_remove_one_port(&tegra_uart_driver, u); 1620 - return 0; 1621 1620 } 1622 1621 1623 1622 #ifdef CONFIG_PM_SLEEP ··· 1643 1644 1644 1645 static struct platform_driver tegra_uart_platform_driver = { 1645 1646 .probe = tegra_uart_probe, 1646 - .remove = tegra_uart_remove, 1647 + .remove_new = tegra_uart_remove, 1647 1648 .driver = { 1648 1649 .name = "serial-tegra", 1649 1650 .of_match_table = tegra_uart_of_match,
+65 -23
drivers/tty/serial/serial_core.c
··· 156 156 * enabled, serial_port_runtime_resume() calls start_tx() again 157 157 * after enabling the device. 158 158 */ 159 - if (!pm_runtime_enabled(port->dev) || pm_runtime_active(port->dev)) 159 + if (pm_runtime_active(&port_dev->dev)) 160 160 port->ops->start_tx(port); 161 161 pm_runtime_mark_last_busy(&port_dev->dev); 162 162 pm_runtime_put_autosuspend(&port_dev->dev); ··· 410 410 uart_update_timeout(struct uart_port *port, unsigned int cflag, 411 411 unsigned int baud) 412 412 { 413 - unsigned int size = tty_get_frame_size(cflag); 414 - u64 frame_time; 413 + u64 temp = tty_get_frame_size(cflag); 415 414 416 - frame_time = (u64)size * NSEC_PER_SEC; 417 - port->frame_time = DIV64_U64_ROUND_UP(frame_time, baud); 415 + temp *= NSEC_PER_SEC; 416 + port->frame_time = (unsigned int)DIV64_U64_ROUND_UP(temp, baud); 418 417 } 419 418 EXPORT_SYMBOL(uart_update_timeout); 420 419 ··· 686 687 * This function is used to send a high-priority XON/XOFF character to 687 688 * the device 688 689 */ 689 - static void uart_send_xchar(struct tty_struct *tty, char ch) 690 + static void uart_send_xchar(struct tty_struct *tty, u8 ch) 690 691 { 691 692 struct uart_state *state = tty->driver_data; 692 693 struct uart_port *port; ··· 1370 1371 return; 1371 1372 } 1372 1373 1373 - /* Pick sane settings if the user hasn't */ 1374 - if ((supported_flags & (SER_RS485_RTS_ON_SEND|SER_RS485_RTS_AFTER_SEND)) && 1375 - !(rs485->flags & SER_RS485_RTS_ON_SEND) == 1376 - !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) { 1377 - dev_warn_ratelimited(port->dev, 1378 - "%s (%d): invalid RTS setting, using RTS_ON_SEND instead\n", 1379 - port->name, port->line); 1380 - rs485->flags |= SER_RS485_RTS_ON_SEND; 1381 - rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; 1382 - supported_flags |= SER_RS485_RTS_ON_SEND|SER_RS485_RTS_AFTER_SEND; 1374 + /* Clear other RS485 flags but SER_RS485_TERMINATE_BUS and return if enabling RS422 */ 1375 + if (rs485->flags & SER_RS485_MODE_RS422) { 1376 + rs485->flags &= (SER_RS485_ENABLED | SER_RS485_MODE_RS422 | SER_RS485_TERMINATE_BUS); 1377 + return; 1383 1378 } 1384 1379 1385 1380 rs485->flags &= supported_flags; 1381 + 1382 + /* Pick sane settings if the user hasn't */ 1383 + if (!(rs485->flags & SER_RS485_RTS_ON_SEND) == 1384 + !(rs485->flags & SER_RS485_RTS_AFTER_SEND)) { 1385 + if (supported_flags & SER_RS485_RTS_ON_SEND) { 1386 + rs485->flags |= SER_RS485_RTS_ON_SEND; 1387 + rs485->flags &= ~SER_RS485_RTS_AFTER_SEND; 1388 + 1389 + dev_warn_ratelimited(port->dev, 1390 + "%s (%d): invalid RTS setting, using RTS_ON_SEND instead\n", 1391 + port->name, port->line); 1392 + } else { 1393 + rs485->flags |= SER_RS485_RTS_AFTER_SEND; 1394 + rs485->flags &= ~SER_RS485_RTS_ON_SEND; 1395 + 1396 + dev_warn_ratelimited(port->dev, 1397 + "%s (%d): invalid RTS setting, using RTS_AFTER_SEND instead\n", 1398 + port->name, port->line); 1399 + } 1400 + } 1386 1401 1387 1402 uart_sanitize_serial_rs485_delays(port, rs485); 1388 1403 ··· 1415 1402 !!(rs485->flags & SER_RS485_TERMINATE_BUS)); 1416 1403 } 1417 1404 1405 + static void uart_set_rs485_rx_during_tx(struct uart_port *port, 1406 + const struct serial_rs485 *rs485) 1407 + { 1408 + if (!(rs485->flags & SER_RS485_ENABLED)) 1409 + return; 1410 + 1411 + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 1412 + !!(rs485->flags & SER_RS485_RX_DURING_TX)); 1413 + } 1414 + 1418 1415 static int uart_rs485_config(struct uart_port *port) 1419 1416 { 1420 1417 struct serial_rs485 *rs485 = &port->rs485; ··· 1436 1413 1437 1414 uart_sanitize_serial_rs485(port, rs485); 1438 1415 uart_set_rs485_termination(port, rs485); 1416 + uart_set_rs485_rx_during_tx(port, rs485); 1439 1417 1440 1418 uart_port_lock_irqsave(port, &flags); 1441 1419 ret = port->rs485_config(port, NULL, rs485); 1442 1420 uart_port_unlock_irqrestore(port, flags); 1443 - if (ret) 1421 + if (ret) { 1444 1422 memset(rs485, 0, sizeof(*rs485)); 1423 + /* unset GPIOs */ 1424 + gpiod_set_value_cansleep(port->rs485_term_gpio, 0); 1425 + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 0); 1426 + } 1445 1427 1446 1428 return ret; 1447 1429 } ··· 1474 1446 int ret; 1475 1447 unsigned long flags; 1476 1448 1477 - if (!port->rs485_config) 1449 + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) 1478 1450 return -ENOTTY; 1479 1451 1480 1452 if (copy_from_user(&rs485, rs485_user, sizeof(*rs485_user))) ··· 1485 1457 return ret; 1486 1458 uart_sanitize_serial_rs485(port, &rs485); 1487 1459 uart_set_rs485_termination(port, &rs485); 1460 + uart_set_rs485_rx_during_tx(port, &rs485); 1488 1461 1489 1462 uart_port_lock_irqsave(port, &flags); 1490 1463 ret = port->rs485_config(port, &tty->termios, &rs485); ··· 1497 1468 port->ops->set_mctrl(port, port->mctrl); 1498 1469 } 1499 1470 uart_port_unlock_irqrestore(port, flags); 1500 - if (ret) 1471 + if (ret) { 1472 + /* restore old GPIO settings */ 1473 + gpiod_set_value_cansleep(port->rs485_term_gpio, 1474 + !!(port->rs485.flags & SER_RS485_TERMINATE_BUS)); 1475 + gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 1476 + !!(port->rs485.flags & SER_RS485_RX_DURING_TX)); 1501 1477 return ret; 1478 + } 1502 1479 1503 1480 if (copy_to_user(rs485_user, &port->rs485, sizeof(port->rs485))) 1504 1481 return -EFAULT; ··· 2377 2342 2378 2343 mutex_lock(&port->mutex); 2379 2344 2380 - tty_dev = device_find_child(uport->dev, &match, serial_match_port); 2345 + tty_dev = device_find_child(&uport->port_dev->dev, &match, serial_match_port); 2381 2346 if (tty_dev && device_may_wakeup(tty_dev)) { 2382 2347 enable_irq_wake(uport->irq); 2383 2348 put_device(tty_dev); ··· 2458 2423 2459 2424 mutex_lock(&port->mutex); 2460 2425 2461 - tty_dev = device_find_child(uport->dev, &match, serial_match_port); 2426 + tty_dev = device_find_child(&uport->port_dev->dev, &match, serial_match_port); 2462 2427 if (!uport->suspended && device_may_wakeup(tty_dev)) { 2463 2428 if (irqd_is_wakeup_set(irq_get_irq_data((uport->irq)))) 2464 2429 disable_irq_wake(uport->irq); ··· 2668 2633 mutex_lock(&tport->mutex); 2669 2634 2670 2635 port = uart_port_check(state); 2671 - if (!port || !(port->ops->poll_get_char && port->ops->poll_put_char)) { 2636 + if (!port || port->type == PORT_UNKNOWN || 2637 + !(port->ops->poll_get_char && port->ops->poll_put_char)) { 2672 2638 ret = -1; 2673 2639 goto out; 2674 2640 } ··· 3189 3153 * setserial to be used to alter this port's parameters. 3190 3154 */ 3191 3155 tty_dev = tty_port_register_device_attr_serdev(port, drv->tty_driver, 3192 - uport->line, uport->dev, port, uport->tty_groups); 3156 + uport->line, uport->dev, &uport->port_dev->dev, port, 3157 + uport->tty_groups); 3193 3158 if (!IS_ERR(tty_dev)) { 3194 3159 device_set_wakeup_capable(tty_dev, 1); 3195 3160 } else { ··· 3607 3570 u32 rs485_delay[2]; 3608 3571 int ret; 3609 3572 3573 + if (!(port->rs485_supported.flags & SER_RS485_ENABLED)) 3574 + return 0; 3575 + 3610 3576 ret = device_property_read_u32_array(dev, "rs485-rts-delay", 3611 3577 rs485_delay, 2); 3612 3578 if (!ret) { ··· 3660 3620 if (IS_ERR(desc)) 3661 3621 return dev_err_probe(dev, PTR_ERR(desc), "Cannot get rs485-rx-during-tx-gpios\n"); 3662 3622 port->rs485_rx_during_tx_gpio = desc; 3623 + if (port->rs485_rx_during_tx_gpio) 3624 + port->rs485_supported.flags |= SER_RS485_RX_DURING_TX; 3663 3625 3664 3626 return 0; 3665 3627 }
+2 -3
drivers/tty/serial/serial_txx9.c
··· 1052 1052 /* 1053 1053 * Remove serial ports registered against a platform device. 1054 1054 */ 1055 - static int serial_txx9_remove(struct platform_device *dev) 1055 + static void serial_txx9_remove(struct platform_device *dev) 1056 1056 { 1057 1057 int i; 1058 1058 ··· 1062 1062 if (up->dev == &dev->dev) 1063 1063 serial_txx9_unregister_port(i); 1064 1064 } 1065 - return 0; 1066 1065 } 1067 1066 1068 1067 #ifdef CONFIG_PM ··· 1096 1097 1097 1098 static struct platform_driver serial_txx9_plat_driver = { 1098 1099 .probe = serial_txx9_probe, 1099 - .remove = serial_txx9_remove, 1100 + .remove_new = serial_txx9_remove, 1100 1101 #ifdef CONFIG_PM 1101 1102 .suspend = serial_txx9_suspend, 1102 1103 .resume = serial_txx9_resume,
+5 -8
drivers/tty/serial/sh-sci.c
··· 1558 1558 struct dma_slave_config cfg; 1559 1559 int ret; 1560 1560 1561 - chan = dma_request_slave_channel(port->dev, 1562 - dir == DMA_MEM_TO_DEV ? "tx" : "rx"); 1563 - if (!chan) { 1564 - dev_dbg(port->dev, "dma_request_slave_channel failed\n"); 1561 + chan = dma_request_chan(port->dev, dir == DMA_MEM_TO_DEV ? "tx" : "rx"); 1562 + if (IS_ERR(chan)) { 1563 + dev_dbg(port->dev, "dma_request_chan failed\n"); 1565 1564 return NULL; 1566 1565 } 1567 1566 ··· 3189 3190 .cons = SCI_CONSOLE, 3190 3191 }; 3191 3192 3192 - static int sci_remove(struct platform_device *dev) 3193 + static void sci_remove(struct platform_device *dev) 3193 3194 { 3194 3195 struct sci_port *port = platform_get_drvdata(dev); 3195 3196 unsigned int type = port->port.type; /* uart_remove_... clears it */ ··· 3203 3204 device_remove_file(&dev->dev, &dev_attr_rx_fifo_trigger); 3204 3205 if (type == PORT_SCIFA || type == PORT_SCIFB || type == PORT_HSCIF) 3205 3206 device_remove_file(&dev->dev, &dev_attr_rx_fifo_timeout); 3206 - 3207 - return 0; 3208 3207 } 3209 3208 3210 3209 ··· 3467 3470 3468 3471 static struct platform_driver sci_driver = { 3469 3472 .probe = sci_probe, 3470 - .remove = sci_remove, 3473 + .remove_new = sci_remove, 3471 3474 .driver = { 3472 3475 .name = "sh-sci", 3473 3476 .pm = &sci_dev_pm_ops,
+4 -6
drivers/tty/serial/sifive.c
··· 1007 1007 return r; 1008 1008 } 1009 1009 1010 - static int sifive_serial_remove(struct platform_device *dev) 1010 + static void sifive_serial_remove(struct platform_device *dev) 1011 1011 { 1012 1012 struct sifive_serial_port *ssp = platform_get_drvdata(dev); 1013 1013 ··· 1015 1015 uart_remove_one_port(&sifive_serial_uart_driver, &ssp->port); 1016 1016 free_irq(ssp->port.irq, ssp); 1017 1017 clk_notifier_unregister(ssp->clk, &ssp->clk_notifier); 1018 - 1019 - return 0; 1020 1018 } 1021 1019 1022 1020 static int sifive_serial_suspend(struct device *dev) ··· 1031 1033 return uart_resume_port(&sifive_serial_uart_driver, &ssp->port); 1032 1034 } 1033 1035 1034 - DEFINE_SIMPLE_DEV_PM_OPS(sifive_uart_pm_ops, sifive_serial_suspend, 1035 - sifive_serial_resume); 1036 + static DEFINE_SIMPLE_DEV_PM_OPS(sifive_uart_pm_ops, sifive_serial_suspend, 1037 + sifive_serial_resume); 1036 1038 1037 1039 static const struct of_device_id sifive_serial_of_match[] = { 1038 1040 { .compatible = "sifive,fu540-c000-uart0" }, ··· 1043 1045 1044 1046 static struct platform_driver sifive_serial_platform_driver = { 1045 1047 .probe = sifive_serial_probe, 1046 - .remove = sifive_serial_remove, 1048 + .remove_new = sifive_serial_remove, 1047 1049 .driver = { 1048 1050 .name = SIFIVE_SERIAL_NAME, 1049 1051 .pm = pm_sleep_ptr(&sifive_uart_pm_ops),
+2 -4
drivers/tty/serial/sprd_serial.c
··· 1076 1076 .cons = SPRD_CONSOLE, 1077 1077 }; 1078 1078 1079 - static int sprd_remove(struct platform_device *dev) 1079 + static void sprd_remove(struct platform_device *dev) 1080 1080 { 1081 1081 struct sprd_uart_port *sup = platform_get_drvdata(dev); 1082 1082 ··· 1089 1089 1090 1090 if (!sprd_ports_num) 1091 1091 uart_unregister_driver(&sprd_uart_driver); 1092 - 1093 - return 0; 1094 1092 } 1095 1093 1096 1094 static bool sprd_uart_is_console(struct uart_port *uport) ··· 1255 1257 1256 1258 static struct platform_driver sprd_platform_driver = { 1257 1259 .probe = sprd_probe, 1258 - .remove = sprd_remove, 1260 + .remove_new = sprd_remove, 1259 1261 .driver = { 1260 1262 .name = "sprd_serial", 1261 1263 .of_match_table = serial_ids,
+2 -4
drivers/tty/serial/st-asc.c
··· 793 793 return 0; 794 794 } 795 795 796 - static int asc_serial_remove(struct platform_device *pdev) 796 + static void asc_serial_remove(struct platform_device *pdev) 797 797 { 798 798 struct uart_port *port = platform_get_drvdata(pdev); 799 799 800 800 uart_remove_one_port(&asc_uart_driver, port); 801 - 802 - return 0; 803 801 } 804 802 805 803 #ifdef CONFIG_PM_SLEEP ··· 930 932 931 933 static struct platform_driver asc_serial_driver = { 932 934 .probe = asc_serial_probe, 933 - .remove = asc_serial_remove, 935 + .remove_new = asc_serial_remove, 934 936 .driver = { 935 937 .name = DRIVER_NAME, 936 938 .pm = &asc_serial_pm_ops,
+4 -10
drivers/tty/serial/stm32-usart.c
··· 226 226 227 227 stm32_usart_clr_bits(port, ofs->cr1, BIT(cfg->uart_enable_bit)); 228 228 229 - if (port->rs485_rx_during_tx_gpio) 230 - gpiod_set_value_cansleep(port->rs485_rx_during_tx_gpio, 231 - !!(rs485conf->flags & SER_RS485_RX_DURING_TX)); 232 - else 233 - rs485conf->flags |= SER_RS485_RX_DURING_TX; 234 - 235 229 if (rs485conf->flags & SER_RS485_ENABLED) { 236 230 cr1 = readl_relaxed(port->membase + ofs->cr1); 237 231 cr3 = readl_relaxed(port->membase + ofs->cr3); ··· 250 256 251 257 writel_relaxed(cr3, port->membase + ofs->cr3); 252 258 writel_relaxed(cr1, port->membase + ofs->cr1); 259 + 260 + rs485conf->flags |= SER_RS485_RX_DURING_TX; 253 261 } else { 254 262 stm32_usart_clr_bits(port, ofs->cr3, 255 263 USART_CR3_DEM | USART_CR3_DEP); ··· 1818 1822 return ret; 1819 1823 } 1820 1824 1821 - static int stm32_usart_serial_remove(struct platform_device *pdev) 1825 + static void stm32_usart_serial_remove(struct platform_device *pdev) 1822 1826 { 1823 1827 struct uart_port *port = platform_get_drvdata(pdev); 1824 1828 struct stm32_port *stm32_port = to_stm32_port(port); ··· 1857 1861 } 1858 1862 1859 1863 stm32_usart_deinit_port(stm32_port); 1860 - 1861 - return 0; 1862 1864 } 1863 1865 1864 1866 static void __maybe_unused stm32_usart_console_putchar(struct uart_port *port, unsigned char ch) ··· 2140 2146 2141 2147 static struct platform_driver stm32_serial_driver = { 2142 2148 .probe = stm32_usart_serial_probe, 2143 - .remove = stm32_usart_serial_remove, 2149 + .remove_new = stm32_usart_serial_remove, 2144 2150 .driver = { 2145 2151 .name = DRIVER_NAME, 2146 2152 .pm = &stm32_serial_pm_ops,
+2 -4
drivers/tty/serial/sunhv.c
··· 595 595 return err; 596 596 } 597 597 598 - static int hv_remove(struct platform_device *dev) 598 + static void hv_remove(struct platform_device *dev) 599 599 { 600 600 struct uart_port *port = platform_get_drvdata(dev); 601 601 ··· 608 608 kfree(con_write_page); 609 609 kfree(port); 610 610 sunhv_port = NULL; 611 - 612 - return 0; 613 611 } 614 612 615 613 static const struct of_device_id hv_match[] = { ··· 628 630 .of_match_table = hv_match, 629 631 }, 630 632 .probe = hv_probe, 631 - .remove = hv_remove, 633 + .remove_new = hv_remove, 632 634 }; 633 635 634 636 static int __init sunhv_init(void)
+2 -4
drivers/tty/serial/sunplus-uart.c
··· 662 662 return ret; 663 663 } 664 664 665 - static int sunplus_uart_remove(struct platform_device *pdev) 665 + static void sunplus_uart_remove(struct platform_device *pdev) 666 666 { 667 667 struct sunplus_uart_port *sup = platform_get_drvdata(pdev); 668 668 669 669 uart_remove_one_port(&sunplus_uart_driver, &sup->port); 670 - 671 - return 0; 672 670 } 673 671 674 672 static int __maybe_unused sunplus_uart_suspend(struct device *dev) ··· 701 703 702 704 static struct platform_driver sunplus_uart_platform_driver = { 703 705 .probe = sunplus_uart_probe, 704 - .remove = sunplus_uart_remove, 706 + .remove_new = sunplus_uart_remove, 705 707 .driver = { 706 708 .name = "sunplus_uart", 707 709 .of_match_table = sp_uart_of_match,
+10 -12
drivers/tty/serial/sunsab.c
··· 443 443 444 444 up->interrupt_mask1 &= ~(SAB82532_IMR1_ALLS|SAB82532_IMR1_XPR); 445 445 writeb(up->interrupt_mask1, &up->regs->w.imr1); 446 - 446 + 447 447 if (!test_bit(SAB82532_XPR, &up->irqflags)) 448 448 return; 449 449 ··· 549 549 (void) readb(&up->regs->r.isr1); 550 550 551 551 /* 552 - * Now, initialize the UART 552 + * Now, initialize the UART 553 553 */ 554 554 writeb(0, &up->regs->w.ccr0); /* power-down */ 555 555 writeb(SAB82532_CCR0_MCE | SAB82532_CCR0_SC_NRZ | ··· 563 563 SAB82532_MODE_RAC); 564 564 writeb(up->cached_mode, &up->regs->w.mode); 565 565 writeb(SAB82532_RFC_DPS|SAB82532_RFC_RFTH_32, &up->regs->w.rfc); 566 - 566 + 567 567 tmp = readb(&up->regs->rw.ccr0); 568 568 tmp |= SAB82532_CCR0_PU; /* power-up */ 569 569 writeb(tmp, &up->regs->rw.ccr0); ··· 607 607 up->cached_dafo &= ~SAB82532_DAFO_XBRK; 608 608 writeb(up->cached_dafo, &up->regs->rw.dafo); 609 609 610 - /* Disable Receiver */ 610 + /* Disable Receiver */ 611 611 up->cached_mode &= ~SAB82532_MODE_RAC; 612 612 writeb(up->cached_mode, &up->regs->rw.mode); 613 613 ··· 622 622 * speed the chip was configured for when the port was open). 623 623 */ 624 624 #if 0 625 - /* Power Down */ 625 + /* Power Down */ 626 626 tmp = readb(&up->regs->rw.ccr0); 627 627 tmp &= ~SAB82532_CCR0_PU; 628 628 writeb(tmp, &up->regs->rw.ccr0); ··· 649 649 *m_ret = 0; 650 650 return; 651 651 } 652 - 652 + 653 653 /* 654 654 * We scale numbers by 10 so that we get better accuracy 655 655 * without having to use floating point. Here we increment m ··· 788 788 { 789 789 struct uart_sunsab_port *up = (void *)port; 790 790 static char buf[36]; 791 - 791 + 792 792 sprintf(buf, "SAB82532 %s", sab82532_version[up->type]); 793 793 return buf; 794 794 } ··· 933 933 sunsab_set_mctrl(&up->port, TIOCM_DTR | TIOCM_RTS); 934 934 935 935 uart_port_unlock_irqrestore(&up->port, flags); 936 - 936 + 937 937 return 0; 938 938 } 939 939 ··· 1066 1066 return err; 1067 1067 } 1068 1068 1069 - static int sab_remove(struct platform_device *op) 1069 + static void sab_remove(struct platform_device *op) 1070 1070 { 1071 1071 struct uart_sunsab_port *up = platform_get_drvdata(op); 1072 1072 ··· 1078 1078 of_iounmap(&op->resource[0], 1079 1079 up[0].port.membase, 1080 1080 sizeof(union sab82532_async_regs)); 1081 - 1082 - return 0; 1083 1081 } 1084 1082 1085 1083 static const struct of_device_id sab_match[] = { ··· 1098 1100 .of_match_table = sab_match, 1099 1101 }, 1100 1102 .probe = sab_probe, 1101 - .remove = sab_remove, 1103 + .remove_new = sab_remove, 1102 1104 }; 1103 1105 1104 1106 static int __init sunsab_init(void)
+2 -4
drivers/tty/serial/sunsu.c
··· 1515 1515 return err; 1516 1516 } 1517 1517 1518 - static int su_remove(struct platform_device *op) 1518 + static void su_remove(struct platform_device *op) 1519 1519 { 1520 1520 struct uart_sunsu_port *up = platform_get_drvdata(op); 1521 1521 bool kbdms = false; ··· 1536 1536 1537 1537 if (kbdms) 1538 1538 kfree(up); 1539 - 1540 - return 0; 1541 1539 } 1542 1540 1543 1541 static const struct of_device_id su_match[] = { ··· 1563 1565 .of_match_table = su_match, 1564 1566 }, 1565 1567 .probe = su_probe, 1566 - .remove = su_remove, 1568 + .remove_new = su_remove, 1567 1569 }; 1568 1570 1569 1571 static int __init sunsu_init(void)
+2 -4
drivers/tty/serial/sunzilog.c
··· 1513 1513 uart_remove_one_port(&sunzilog_reg, &up->port); 1514 1514 } 1515 1515 1516 - static int zs_remove(struct platform_device *op) 1516 + static void zs_remove(struct platform_device *op) 1517 1517 { 1518 1518 struct uart_sunzilog_port *up = platform_get_drvdata(op); 1519 1519 struct zilog_layout __iomem *regs; ··· 1523 1523 1524 1524 regs = sunzilog_chip_regs[up[0].port.line / 2]; 1525 1525 of_iounmap(&op->resource[0], regs, sizeof(struct zilog_layout)); 1526 - 1527 - return 0; 1528 1526 } 1529 1527 1530 1528 static const struct of_device_id zs_match[] = { ··· 1539 1541 .of_match_table = zs_match, 1540 1542 }, 1541 1543 .probe = zs_probe, 1542 - .remove = zs_remove, 1544 + .remove_new = zs_remove, 1543 1545 }; 1544 1546 1545 1547 static int __init sunzilog_init(void)
+2 -4
drivers/tty/serial/tegra-tcu.c
··· 266 266 return err; 267 267 } 268 268 269 - static int tegra_tcu_remove(struct platform_device *pdev) 269 + static void tegra_tcu_remove(struct platform_device *pdev) 270 270 { 271 271 struct tegra_tcu *tcu = platform_get_drvdata(pdev); 272 272 ··· 277 277 uart_remove_one_port(&tcu->driver, &tcu->port); 278 278 uart_unregister_driver(&tcu->driver); 279 279 mbox_free_channel(tcu->tx); 280 - 281 - return 0; 282 280 } 283 281 284 282 static const struct of_device_id tegra_tcu_match[] = { ··· 291 293 .of_match_table = tegra_tcu_match, 292 294 }, 293 295 .probe = tegra_tcu_probe, 294 - .remove = tegra_tcu_remove, 296 + .remove_new = tegra_tcu_remove, 295 297 }; 296 298 module_platform_driver(tegra_tcu_driver); 297 299
+2 -4
drivers/tty/serial/timbuart.c
··· 473 473 return err; 474 474 } 475 475 476 - static int timbuart_remove(struct platform_device *dev) 476 + static void timbuart_remove(struct platform_device *dev) 477 477 { 478 478 struct timbuart_port *uart = platform_get_drvdata(dev); 479 479 ··· 481 481 uart_remove_one_port(&timbuart_driver, &uart->port); 482 482 uart_unregister_driver(&timbuart_driver); 483 483 kfree(uart); 484 - 485 - return 0; 486 484 } 487 485 488 486 static struct platform_driver timbuart_platform_driver = { ··· 488 490 .name = "timb-uart", 489 491 }, 490 492 .probe = timbuart_probe, 491 - .remove = timbuart_remove, 493 + .remove_new = timbuart_remove, 492 494 }; 493 495 494 496 module_platform_driver(timbuart_platform_driver);
+12 -8
drivers/tty/serial/uartlite.c
··· 24 24 #include <linux/pm_runtime.h> 25 25 26 26 #define ULITE_NAME "ttyUL" 27 + #if CONFIG_SERIAL_UARTLITE_NR_UARTS > 4 28 + #define ULITE_MAJOR 0 /* use dynamic node allocation */ 29 + #define ULITE_MINOR 0 30 + #else 27 31 #define ULITE_MAJOR 204 28 32 #define ULITE_MINOR 187 33 + #endif 29 34 #define ULITE_NR_UARTS CONFIG_SERIAL_UARTLITE_NR_UARTS 30 35 31 36 /* --------------------------------------------------------------------- ··· 67 62 #endif 68 63 69 64 /** 70 - * struct uartlite_data: Driver private data 71 - * reg_ops: Functions to read/write registers 72 - * clk: Our parent clock, if present 73 - * baud: The baud rate configured when this device was synthesized 74 - * cflags: The cflags for parity and data bits 65 + * struct uartlite_data - Driver private data 66 + * @reg_ops: Functions to read/write registers 67 + * @clk: Our parent clock, if present 68 + * @baud: The baud rate configured when this device was synthesized 69 + * @cflags: The cflags for parity and data bits 75 70 */ 76 71 struct uartlite_data { 77 72 const struct uartlite_reg_ops *reg_ops; ··· 895 890 return ret; 896 891 } 897 892 898 - static int ulite_remove(struct platform_device *pdev) 893 + static void ulite_remove(struct platform_device *pdev) 899 894 { 900 895 struct uart_port *port = dev_get_drvdata(&pdev->dev); 901 896 struct uartlite_data *pdata = port->private_data; ··· 905 900 pm_runtime_disable(&pdev->dev); 906 901 pm_runtime_set_suspended(&pdev->dev); 907 902 pm_runtime_dont_use_autosuspend(&pdev->dev); 908 - return 0; 909 903 } 910 904 911 905 /* work with hotplug and coldplug */ ··· 912 908 913 909 static struct platform_driver ulite_platform_driver = { 914 910 .probe = ulite_probe, 915 - .remove = ulite_remove, 911 + .remove_new = ulite_remove, 916 912 .driver = { 917 913 .name = "uartlite", 918 914 .of_match_table = of_match_ptr(ulite_of_match),
+16 -18
drivers/tty/serial/ucc_uart.c
··· 189 189 u16 tx_fifosize; 190 190 int wait_closing; 191 191 u32 flags; 192 - struct qe_bd *rx_bd_base; 193 - struct qe_bd *rx_cur; 194 - struct qe_bd *tx_bd_base; 195 - struct qe_bd *tx_cur; 192 + struct qe_bd __iomem *rx_bd_base; 193 + struct qe_bd __iomem *rx_cur; 194 + struct qe_bd __iomem *tx_bd_base; 195 + struct qe_bd __iomem *tx_cur; 196 196 unsigned char *tx_buf; 197 197 unsigned char *rx_buf; 198 198 void *bd_virt; /* virtual address of the BD buffers */ ··· 258 258 { 259 259 struct uart_qe_port *qe_port = 260 260 container_of(port, struct uart_qe_port, port); 261 - struct qe_bd *bdp = qe_port->tx_bd_base; 261 + struct qe_bd __iomem *bdp = qe_port->tx_bd_base; 262 262 263 263 while (1) { 264 264 if (ioread16be(&bdp->status) & BD_SC_READY) ··· 330 330 */ 331 331 static int qe_uart_tx_pump(struct uart_qe_port *qe_port) 332 332 { 333 - struct qe_bd *bdp; 333 + struct qe_bd __iomem *bdp; 334 334 unsigned char *p; 335 335 unsigned int count; 336 336 struct uart_port *port = &qe_port->port; ··· 341 341 /* Pick next descriptor and fill from buffer */ 342 342 bdp = qe_port->tx_cur; 343 343 344 - p = qe2cpu_addr(be32_to_cpu(bdp->buf), qe_port); 344 + p = qe2cpu_addr(ioread32be(&bdp->buf), qe_port); 345 345 346 346 *p++ = port->x_char; 347 347 iowrite16be(1, &bdp->length); ··· 368 368 369 369 while (!(ioread16be(&bdp->status) & BD_SC_READY) && !uart_circ_empty(xmit)) { 370 370 count = 0; 371 - p = qe2cpu_addr(be32_to_cpu(bdp->buf), qe_port); 371 + p = qe2cpu_addr(ioread32be(&bdp->buf), qe_port); 372 372 while (count < qe_port->tx_fifosize) { 373 373 *p++ = xmit->buf[xmit->tail]; 374 374 uart_xmit_advance(port, 1); ··· 460 460 unsigned char ch, *cp; 461 461 struct uart_port *port = &qe_port->port; 462 462 struct tty_port *tport = &port->state->port; 463 - struct qe_bd *bdp; 463 + struct qe_bd __iomem *bdp; 464 464 u16 status; 465 465 unsigned int flg; 466 466 ··· 487 487 } 488 488 489 489 /* get pointer */ 490 - cp = qe2cpu_addr(be32_to_cpu(bdp->buf), qe_port); 490 + cp = qe2cpu_addr(ioread32be(&bdp->buf), qe_port); 491 491 492 492 /* loop through the buffer */ 493 493 while (i-- > 0) { ··· 590 590 { 591 591 int i; 592 592 void *bd_virt; 593 - struct qe_bd *bdp; 593 + struct qe_bd __iomem *bdp; 594 594 595 595 /* Set the physical address of the host memory buffers in the buffer 596 596 * descriptors, and the virtual address for us to work with. ··· 648 648 { 649 649 u32 cecr_subblock; 650 650 struct ucc_slow __iomem *uccp = qe_port->uccp; 651 - struct ucc_uart_pram *uccup = qe_port->uccup; 651 + struct ucc_uart_pram __iomem *uccup = qe_port->uccup; 652 652 653 653 unsigned int i; 654 654 ··· 983 983 984 984 qe_port->us_private = uccs; 985 985 qe_port->uccp = uccs->us_regs; 986 - qe_port->uccup = (struct ucc_uart_pram *) uccs->us_pram; 986 + qe_port->uccup = (struct ucc_uart_pram __iomem *)uccs->us_pram; 987 987 qe_port->rx_bd_base = uccs->rx_bd; 988 988 qe_port->tx_bd_base = uccs->tx_bd; 989 989 ··· 1156 1156 1157 1157 firmware = (struct qe_firmware *) fw->data; 1158 1158 1159 - if (firmware->header.length != fw->size) { 1159 + if (be32_to_cpu(firmware->header.length) != fw->size) { 1160 1160 dev_err(dev, "invalid firmware\n"); 1161 1161 goto out; 1162 1162 } ··· 1459 1459 return ret; 1460 1460 } 1461 1461 1462 - static int ucc_uart_remove(struct platform_device *ofdev) 1462 + static void ucc_uart_remove(struct platform_device *ofdev) 1463 1463 { 1464 1464 struct uart_qe_port *qe_port = platform_get_drvdata(ofdev); 1465 1465 ··· 1470 1470 of_node_put(qe_port->np); 1471 1471 1472 1472 kfree(qe_port); 1473 - 1474 - return 0; 1475 1473 } 1476 1474 1477 1475 static const struct of_device_id ucc_uart_match[] = { ··· 1490 1492 .of_match_table = ucc_uart_match, 1491 1493 }, 1492 1494 .probe = ucc_uart_probe, 1493 - .remove = ucc_uart_remove, 1495 + .remove_new = ucc_uart_remove, 1494 1496 }; 1495 1497 1496 1498 static int __init ucc_uart_init(void)
+2 -5
drivers/tty/serial/xilinx_uartps.c
··· 1663 1663 /** 1664 1664 * cdns_uart_remove - called when the platform driver is unregistered 1665 1665 * @pdev: Pointer to the platform device structure 1666 - * 1667 - * Return: 0 on success, negative errno otherwise 1668 1666 */ 1669 - static int cdns_uart_remove(struct platform_device *pdev) 1667 + static void cdns_uart_remove(struct platform_device *pdev) 1670 1668 { 1671 1669 struct uart_port *port = platform_get_drvdata(pdev); 1672 1670 struct cdns_uart *cdns_uart_data = port->private_data; ··· 1690 1692 1691 1693 if (!--instances) 1692 1694 uart_unregister_driver(cdns_uart_data->cdns_uart_driver); 1693 - return 0; 1694 1695 } 1695 1696 1696 1697 static struct platform_driver cdns_uart_platform_driver = { 1697 1698 .probe = cdns_uart_probe, 1698 - .remove = cdns_uart_remove, 1699 + .remove_new = cdns_uart_remove, 1699 1700 .driver = { 1700 1701 .name = CDNS_UART_NAME, 1701 1702 .of_match_table = cdns_uart_of_match,
+16 -3
drivers/tty/sysrq.c
··· 1150 1150 #ifdef CONFIG_PROC_FS 1151 1151 /* 1152 1152 * writing 'C' to /proc/sysrq-trigger is like sysrq-C 1153 + * Normally, only the first character written is processed. 1154 + * However, if the first character is an underscore, 1155 + * all characters are processed. 1153 1156 */ 1154 1157 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf, 1155 1158 size_t count, loff_t *ppos) 1156 1159 { 1157 - if (count) { 1160 + bool bulk = false; 1161 + size_t i; 1162 + 1163 + for (i = 0; i < count; i++) { 1158 1164 char c; 1159 1165 1160 - if (get_user(c, buf)) 1166 + if (get_user(c, buf + i)) 1161 1167 return -EFAULT; 1162 - __handle_sysrq(c, false); 1168 + 1169 + if (c == '_') 1170 + bulk = true; 1171 + else 1172 + __handle_sysrq(c, false); 1173 + 1174 + if (!bulk) 1175 + break; 1163 1176 } 1164 1177 1165 1178 return count;
+11 -7
drivers/tty/tty_io.c
··· 852 852 { 853 853 void *cookie = NULL; 854 854 unsigned long offset = 0; 855 - char kernel_buf[64]; 856 855 ssize_t retval = 0; 857 856 size_t copied, count = iov_iter_count(to); 857 + u8 kernel_buf[64]; 858 858 859 859 do { 860 860 ssize_t size = min(count, sizeof(kernel_buf)); ··· 995 995 996 996 /* write_buf/write_cnt is protected by the atomic_write_lock mutex */ 997 997 if (tty->write_cnt < chunk) { 998 - unsigned char *buf_chunk; 998 + u8 *buf_chunk; 999 999 1000 1000 if (chunk < 1024) 1001 1001 chunk = 1024; ··· 1047 1047 return ret; 1048 1048 } 1049 1049 1050 + #ifdef CONFIG_PRINT_QUOTA_WARNING 1050 1051 /** 1051 1052 * tty_write_message - write a message to a certain tty, not just the console. 1052 1053 * @tty: the destination tty_struct ··· 1058 1057 * needed. 1059 1058 * 1060 1059 * We must still hold the BTM and test the CLOSING flag for the moment. 1060 + * 1061 + * This function is DEPRECATED, do not use in new code. 1061 1062 */ 1062 1063 void tty_write_message(struct tty_struct *tty, char *msg) 1063 1064 { ··· 1072 1069 tty_write_unlock(tty); 1073 1070 } 1074 1071 } 1072 + #endif 1075 1073 1076 1074 static ssize_t file_tty_write(struct file *file, struct kiocb *iocb, struct iov_iter *from) 1077 1075 { ··· 1149 1145 * 1150 1146 * Locking: none for xchar method, write ordering for write method. 1151 1147 */ 1152 - int tty_send_xchar(struct tty_struct *tty, char ch) 1148 + int tty_send_xchar(struct tty_struct *tty, u8 ch) 1153 1149 { 1154 1150 bool was_stopped = tty->flow.stopped; 1155 1151 ··· 2278 2274 * * Called functions take tty_ldiscs_lock 2279 2275 * * current->signal->tty check is safe without locks 2280 2276 */ 2281 - static int tiocsti(struct tty_struct *tty, char __user *p) 2277 + static int tiocsti(struct tty_struct *tty, u8 __user *p) 2282 2278 { 2283 - char ch, mbz = 0; 2284 2279 struct tty_ldisc *ld; 2280 + u8 ch; 2285 2281 2286 2282 if (!tty_legacy_tiocsti && !capable(CAP_SYS_ADMIN)) 2287 2283 return -EIO; ··· 2296 2292 return -EIO; 2297 2293 tty_buffer_lock_exclusive(tty->port); 2298 2294 if (ld->ops->receive_buf) 2299 - ld->ops->receive_buf(tty, &ch, &mbz, 1); 2295 + ld->ops->receive_buf(tty, &ch, NULL, 1); 2300 2296 tty_buffer_unlock_exclusive(tty->port); 2301 2297 tty_ldisc_deref(ld); 2302 2298 return 0; ··· 3158 3154 * 3159 3155 * Return: the number of characters successfully output. 3160 3156 */ 3161 - int tty_put_char(struct tty_struct *tty, unsigned char ch) 3157 + int tty_put_char(struct tty_struct *tty, u8 ch) 3162 3158 { 3163 3159 if (tty->ops->put_char) 3164 3160 return tty->ops->put_char(tty, ch);
+2 -2
drivers/tty/tty_ioctl.c
··· 844 844 ret = -EFAULT; 845 845 return ret; 846 846 case TIOCSLCKTRMIOS: 847 - if (!capable(CAP_SYS_ADMIN)) 847 + if (!checkpoint_restore_ns_capable(&init_user_ns)) 848 848 return -EPERM; 849 849 copy_termios_locked(real_tty, &kterm); 850 850 if (user_termios_to_kernel_termios(&kterm, ··· 861 861 ret = -EFAULT; 862 862 return ret; 863 863 case TIOCSLCKTRMIOS: 864 - if (!capable(CAP_SYS_ADMIN)) 864 + if (!checkpoint_restore_ns_capable(&init_user_ns)) 865 865 return -EPERM; 866 866 copy_termios_locked(real_tty, &kterm); 867 867 if (user_termios_to_kernel_termios_1(&kterm,
+10 -8
drivers/tty/tty_port.c
··· 171 171 * @port: tty_port of the device 172 172 * @driver: tty_driver for this device 173 173 * @index: index of the tty 174 - * @device: parent if exists, otherwise NULL 174 + * @host: serial port hardware device 175 + * @parent: parent if exists, otherwise NULL 175 176 * @drvdata: driver data for the device 176 177 * @attr_grp: attribute group for the device 177 178 * ··· 181 180 */ 182 181 struct device *tty_port_register_device_attr_serdev(struct tty_port *port, 183 182 struct tty_driver *driver, unsigned index, 184 - struct device *device, void *drvdata, 183 + struct device *host, struct device *parent, void *drvdata, 185 184 const struct attribute_group **attr_grp) 186 185 { 187 186 struct device *dev; 188 187 189 188 tty_port_link_device(port, driver, index); 190 189 191 - dev = serdev_tty_port_register(port, device, driver, index); 190 + dev = serdev_tty_port_register(port, host, parent, driver, index); 192 191 if (PTR_ERR(dev) != -ENODEV) { 193 192 /* Skip creating cdev if we registered a serdev device */ 194 193 return dev; 195 194 } 196 195 197 - return tty_register_device_attr(driver, index, device, drvdata, 196 + return tty_register_device_attr(driver, index, parent, drvdata, 198 197 attr_grp); 199 198 } 200 199 EXPORT_SYMBOL_GPL(tty_port_register_device_attr_serdev); ··· 204 203 * @port: tty_port of the device 205 204 * @driver: tty_driver for this device 206 205 * @index: index of the tty 207 - * @device: parent if exists, otherwise NULL 206 + * @host: serial port hardware controller device 207 + * @parent: parent if exists, otherwise NULL 208 208 * 209 209 * Register a serdev or tty device depending on if the parent device has any 210 210 * defined serdev clients or not. 211 211 */ 212 212 struct device *tty_port_register_device_serdev(struct tty_port *port, 213 213 struct tty_driver *driver, unsigned index, 214 - struct device *device) 214 + struct device *host, struct device *parent) 215 215 { 216 216 return tty_port_register_device_attr_serdev(port, driver, index, 217 - device, NULL, NULL); 217 + host, parent, NULL, NULL); 218 218 } 219 219 EXPORT_SYMBOL_GPL(tty_port_register_device_serdev); 220 220 ··· 247 245 /* We may sleep in get_zeroed_page() */ 248 246 mutex_lock(&port->buf_mutex); 249 247 if (port->xmit_buf == NULL) { 250 - port->xmit_buf = (unsigned char *)get_zeroed_page(GFP_KERNEL); 248 + port->xmit_buf = (u8 *)get_zeroed_page(GFP_KERNEL); 251 249 if (port->xmit_buf) 252 250 kfifo_init(&port->xmit_fifo, port->xmit_buf, PAGE_SIZE); 253 251 }
+1 -1
drivers/tty/vt/consolemap.c
··· 644 644 if (!ct) 645 645 return 0; 646 646 647 - unilist = vmemdup_user(list, array_size(sizeof(*unilist), ct)); 647 + unilist = vmemdup_array_user(list, ct, sizeof(*unilist)); 648 648 if (IS_ERR(unilist)) 649 649 return PTR_ERR(unilist); 650 650
+4 -6
drivers/tty/vt/keyboard.c
··· 1772 1772 return -EINVAL; 1773 1773 1774 1774 if (ct) { 1775 - 1776 - dia = memdup_user(a->kbdiacr, 1777 - sizeof(struct kbdiacr) * ct); 1775 + dia = memdup_array_user(a->kbdiacr, 1776 + ct, sizeof(struct kbdiacr)); 1778 1777 if (IS_ERR(dia)) 1779 1778 return PTR_ERR(dia); 1780 - 1781 1779 } 1782 1780 1783 1781 spin_lock_irqsave(&kbd_event_lock, flags); ··· 1809 1811 return -EINVAL; 1810 1812 1811 1813 if (ct) { 1812 - buf = memdup_user(a->kbdiacruc, 1813 - ct * sizeof(struct kbdiacruc)); 1814 + buf = memdup_array_user(a->kbdiacruc, 1815 + ct, sizeof(struct kbdiacruc)); 1814 1816 if (IS_ERR(buf)) 1815 1817 return PTR_ERR(buf); 1816 1818 }
+124 -115
include/linux/amba/serial.h
··· 10 10 #ifndef ASM_ARM_HARDWARE_SERIAL_AMBA_H 11 11 #define ASM_ARM_HARDWARE_SERIAL_AMBA_H 12 12 13 + #ifndef __ASSEMBLY__ 14 + #include <linux/bitfield.h> 15 + #include <linux/bits.h> 16 + #endif 17 + 13 18 #include <linux/types.h> 14 19 15 20 /* ------------------------------------------------------------------------------- ··· 75 70 #define ZX_UART011_ICR 0x4c 76 71 #define ZX_UART011_DMACR 0x50 77 72 78 - #define UART011_DR_OE (1 << 11) 79 - #define UART011_DR_BE (1 << 10) 80 - #define UART011_DR_PE (1 << 9) 81 - #define UART011_DR_FE (1 << 8) 73 + #define UART011_DR_OE BIT(11) 74 + #define UART011_DR_BE BIT(10) 75 + #define UART011_DR_PE BIT(9) 76 + #define UART011_DR_FE BIT(8) 82 77 83 - #define UART01x_RSR_OE 0x08 84 - #define UART01x_RSR_BE 0x04 85 - #define UART01x_RSR_PE 0x02 86 - #define UART01x_RSR_FE 0x01 78 + #define UART01x_RSR_OE BIT(3) 79 + #define UART01x_RSR_BE BIT(2) 80 + #define UART01x_RSR_PE BIT(1) 81 + #define UART01x_RSR_FE BIT(0) 87 82 88 - #define UART011_FR_RI 0x100 89 - #define UART011_FR_TXFE 0x080 90 - #define UART011_FR_RXFF 0x040 91 - #define UART01x_FR_TXFF 0x020 92 - #define UART01x_FR_RXFE 0x010 93 - #define UART01x_FR_BUSY 0x008 94 - #define UART01x_FR_DCD 0x004 95 - #define UART01x_FR_DSR 0x002 96 - #define UART01x_FR_CTS 0x001 83 + #define UART011_FR_RI BIT(8) 84 + #define UART011_FR_TXFE BIT(7) 85 + #define UART011_FR_RXFF BIT(6) 86 + #define UART01x_FR_TXFF (1 << 5) /* used in ASM */ 87 + #define UART01x_FR_RXFE BIT(4) 88 + #define UART01x_FR_BUSY (1 << 3) /* used in ASM */ 89 + #define UART01x_FR_DCD BIT(2) 90 + #define UART01x_FR_DSR BIT(1) 91 + #define UART01x_FR_CTS BIT(0) 97 92 #define UART01x_FR_TMSK (UART01x_FR_TXFF + UART01x_FR_BUSY) 98 93 99 94 /* 100 95 * Some bits of Flag Register on ZTE device have different position from 101 96 * standard ones. 102 97 */ 103 - #define ZX_UART01x_FR_BUSY 0x100 104 - #define ZX_UART01x_FR_DSR 0x008 105 - #define ZX_UART01x_FR_CTS 0x002 106 - #define ZX_UART011_FR_RI 0x001 98 + #define ZX_UART01x_FR_BUSY BIT(8) 99 + #define ZX_UART01x_FR_DSR BIT(3) 100 + #define ZX_UART01x_FR_CTS BIT(1) 101 + #define ZX_UART011_FR_RI BIT(0) 107 102 108 - #define UART011_CR_CTSEN 0x8000 /* CTS hardware flow control */ 109 - #define UART011_CR_RTSEN 0x4000 /* RTS hardware flow control */ 110 - #define UART011_CR_OUT2 0x2000 /* OUT2 */ 111 - #define UART011_CR_OUT1 0x1000 /* OUT1 */ 112 - #define UART011_CR_RTS 0x0800 /* RTS */ 113 - #define UART011_CR_DTR 0x0400 /* DTR */ 114 - #define UART011_CR_RXE 0x0200 /* receive enable */ 115 - #define UART011_CR_TXE 0x0100 /* transmit enable */ 116 - #define UART011_CR_LBE 0x0080 /* loopback enable */ 117 - #define UART010_CR_RTIE 0x0040 118 - #define UART010_CR_TIE 0x0020 119 - #define UART010_CR_RIE 0x0010 120 - #define UART010_CR_MSIE 0x0008 121 - #define ST_UART011_CR_OVSFACT 0x0008 /* Oversampling factor */ 122 - #define UART01x_CR_IIRLP 0x0004 /* SIR low power mode */ 123 - #define UART01x_CR_SIREN 0x0002 /* SIR enable */ 124 - #define UART01x_CR_UARTEN 0x0001 /* UART enable */ 125 - 126 - #define UART011_LCRH_SPS 0x80 103 + #define UART011_CR_CTSEN BIT(15) /* CTS hardware flow control */ 104 + #define UART011_CR_RTSEN BIT(14) /* RTS hardware flow control */ 105 + #define UART011_CR_OUT2 BIT(13) /* OUT2 */ 106 + #define UART011_CR_OUT1 BIT(12) /* OUT1 */ 107 + #define UART011_CR_RTS BIT(11) /* RTS */ 108 + #define UART011_CR_DTR BIT(10) /* DTR */ 109 + #define UART011_CR_RXE BIT(9) /* receive enable */ 110 + #define UART011_CR_TXE BIT(8) /* transmit enable */ 111 + #define UART011_CR_LBE BIT(7) /* loopback enable */ 112 + #define UART010_CR_RTIE BIT(6) 113 + #define UART010_CR_TIE BIT(5) 114 + #define UART010_CR_RIE BIT(4) 115 + #define UART010_CR_MSIE BIT(3) 116 + #define ST_UART011_CR_OVSFACT BIT(3) /* Oversampling factor */ 117 + #define UART01x_CR_IIRLP BIT(2) /* SIR low power mode */ 118 + #define UART01x_CR_SIREN BIT(1) /* SIR enable */ 119 + #define UART01x_CR_UARTEN BIT(0) /* UART enable */ 120 + 121 + #define UART011_LCRH_SPS BIT(7) 127 122 #define UART01x_LCRH_WLEN_8 0x60 128 123 #define UART01x_LCRH_WLEN_7 0x40 129 124 #define UART01x_LCRH_WLEN_6 0x20 130 125 #define UART01x_LCRH_WLEN_5 0x00 131 - #define UART01x_LCRH_FEN 0x10 132 - #define UART01x_LCRH_STP2 0x08 133 - #define UART01x_LCRH_EPS 0x04 134 - #define UART01x_LCRH_PEN 0x02 135 - #define UART01x_LCRH_BRK 0x01 126 + #define UART01x_LCRH_FEN BIT(4) 127 + #define UART01x_LCRH_STP2 BIT(3) 128 + #define UART01x_LCRH_EPS BIT(2) 129 + #define UART01x_LCRH_PEN BIT(1) 130 + #define UART01x_LCRH_BRK BIT(0) 136 131 137 - #define ST_UART011_DMAWM_RX_1 (0 << 3) 138 - #define ST_UART011_DMAWM_RX_2 (1 << 3) 139 - #define ST_UART011_DMAWM_RX_4 (2 << 3) 140 - #define ST_UART011_DMAWM_RX_8 (3 << 3) 141 - #define ST_UART011_DMAWM_RX_16 (4 << 3) 142 - #define ST_UART011_DMAWM_RX_32 (5 << 3) 143 - #define ST_UART011_DMAWM_RX_48 (6 << 3) 144 - #define ST_UART011_DMAWM_TX_1 0 145 - #define ST_UART011_DMAWM_TX_2 1 146 - #define ST_UART011_DMAWM_TX_4 2 147 - #define ST_UART011_DMAWM_TX_8 3 148 - #define ST_UART011_DMAWM_TX_16 4 149 - #define ST_UART011_DMAWM_TX_32 5 150 - #define ST_UART011_DMAWM_TX_48 6 132 + #define ST_UART011_DMAWM_RX GENMASK(5, 3) 133 + #define ST_UART011_DMAWM_RX_1 FIELD_PREP_CONST(ST_UART011_DMAWM_RX, 0) 134 + #define ST_UART011_DMAWM_RX_2 FIELD_PREP_CONST(ST_UART011_DMAWM_RX, 1) 135 + #define ST_UART011_DMAWM_RX_4 FIELD_PREP_CONST(ST_UART011_DMAWM_RX, 2) 136 + #define ST_UART011_DMAWM_RX_8 FIELD_PREP_CONST(ST_UART011_DMAWM_RX, 3) 137 + #define ST_UART011_DMAWM_RX_16 FIELD_PREP_CONST(ST_UART011_DMAWM_RX, 4) 138 + #define ST_UART011_DMAWM_RX_32 FIELD_PREP_CONST(ST_UART011_DMAWM_RX, 5) 139 + #define ST_UART011_DMAWM_RX_48 FIELD_PREP_CONST(ST_UART011_DMAWM_RX, 6) 140 + #define ST_UART011_DMAWM_TX GENMASK(2, 0) 141 + #define ST_UART011_DMAWM_TX_1 FIELD_PREP_CONST(ST_UART011_DMAWM_TX, 0) 142 + #define ST_UART011_DMAWM_TX_2 FIELD_PREP_CONST(ST_UART011_DMAWM_TX, 1) 143 + #define ST_UART011_DMAWM_TX_4 FIELD_PREP_CONST(ST_UART011_DMAWM_TX, 2) 144 + #define ST_UART011_DMAWM_TX_8 FIELD_PREP_CONST(ST_UART011_DMAWM_TX, 3) 145 + #define ST_UART011_DMAWM_TX_16 FIELD_PREP_CONST(ST_UART011_DMAWM_TX, 4) 146 + #define ST_UART011_DMAWM_TX_32 FIELD_PREP_CONST(ST_UART011_DMAWM_TX, 5) 147 + #define ST_UART011_DMAWM_TX_48 FIELD_PREP_CONST(ST_UART011_DMAWM_TX, 6) 151 148 152 - #define UART010_IIR_RTIS 0x08 153 - #define UART010_IIR_TIS 0x04 154 - #define UART010_IIR_RIS 0x02 155 - #define UART010_IIR_MIS 0x01 149 + #define UART010_IIR_RTIS BIT(3) 150 + #define UART010_IIR_TIS BIT(2) 151 + #define UART010_IIR_RIS BIT(1) 152 + #define UART010_IIR_MIS BIT(0) 156 153 157 - #define UART011_IFLS_RX1_8 (0 << 3) 158 - #define UART011_IFLS_RX2_8 (1 << 3) 159 - #define UART011_IFLS_RX4_8 (2 << 3) 160 - #define UART011_IFLS_RX6_8 (3 << 3) 161 - #define UART011_IFLS_RX7_8 (4 << 3) 162 - #define UART011_IFLS_TX1_8 (0 << 0) 163 - #define UART011_IFLS_TX2_8 (1 << 0) 164 - #define UART011_IFLS_TX4_8 (2 << 0) 165 - #define UART011_IFLS_TX6_8 (3 << 0) 166 - #define UART011_IFLS_TX7_8 (4 << 0) 154 + #define UART011_IFLS_RXIFLSEL GENMASK(5, 3) 155 + #define UART011_IFLS_RX1_8 FIELD_PREP_CONST(UART011_IFLS_RXIFLSEL, 0) 156 + #define UART011_IFLS_RX2_8 FIELD_PREP_CONST(UART011_IFLS_RXIFLSEL, 1) 157 + #define UART011_IFLS_RX4_8 FIELD_PREP_CONST(UART011_IFLS_RXIFLSEL, 2) 158 + #define UART011_IFLS_RX6_8 FIELD_PREP_CONST(UART011_IFLS_RXIFLSEL, 3) 159 + #define UART011_IFLS_RX7_8 FIELD_PREP_CONST(UART011_IFLS_RXIFLSEL, 4) 160 + #define UART011_IFLS_TXIFLSEL GENMASK(2, 0) 161 + #define UART011_IFLS_TX1_8 FIELD_PREP_CONST(UART011_IFLS_TXIFLSEL, 0) 162 + #define UART011_IFLS_TX2_8 FIELD_PREP_CONST(UART011_IFLS_TXIFLSEL, 1) 163 + #define UART011_IFLS_TX4_8 FIELD_PREP_CONST(UART011_IFLS_TXIFLSEL, 2) 164 + #define UART011_IFLS_TX6_8 FIELD_PREP_CONST(UART011_IFLS_TXIFLSEL, 3) 165 + #define UART011_IFLS_TX7_8 FIELD_PREP_CONST(UART011_IFLS_TXIFLSEL, 4) 167 166 /* special values for ST vendor with deeper fifo */ 168 - #define UART011_IFLS_RX_HALF (5 << 3) 169 - #define UART011_IFLS_TX_HALF (5 << 0) 167 + #define UART011_IFLS_RX_HALF FIELD_PREP_CONST(UART011_IFLS_RXIFLSEL, 5) 168 + #define UART011_IFLS_TX_HALF FIELD_PREP_CONST(UART011_IFLS_TXIFLSEL, 5) 170 169 171 - #define UART011_OEIM (1 << 10) /* overrun error interrupt mask */ 172 - #define UART011_BEIM (1 << 9) /* break error interrupt mask */ 173 - #define UART011_PEIM (1 << 8) /* parity error interrupt mask */ 174 - #define UART011_FEIM (1 << 7) /* framing error interrupt mask */ 175 - #define UART011_RTIM (1 << 6) /* receive timeout interrupt mask */ 176 - #define UART011_TXIM (1 << 5) /* transmit interrupt mask */ 177 - #define UART011_RXIM (1 << 4) /* receive interrupt mask */ 178 - #define UART011_DSRMIM (1 << 3) /* DSR interrupt mask */ 179 - #define UART011_DCDMIM (1 << 2) /* DCD interrupt mask */ 180 - #define UART011_CTSMIM (1 << 1) /* CTS interrupt mask */ 181 - #define UART011_RIMIM (1 << 0) /* RI interrupt mask */ 170 + #define UART011_OEIM BIT(10) /* overrun error interrupt mask */ 171 + #define UART011_BEIM BIT(9) /* break error interrupt mask */ 172 + #define UART011_PEIM BIT(8) /* parity error interrupt mask */ 173 + #define UART011_FEIM BIT(7) /* framing error interrupt mask */ 174 + #define UART011_RTIM BIT(6) /* receive timeout interrupt mask */ 175 + #define UART011_TXIM BIT(5) /* transmit interrupt mask */ 176 + #define UART011_RXIM BIT(4) /* receive interrupt mask */ 177 + #define UART011_DSRMIM BIT(3) /* DSR interrupt mask */ 178 + #define UART011_DCDMIM BIT(2) /* DCD interrupt mask */ 179 + #define UART011_CTSMIM BIT(1) /* CTS interrupt mask */ 180 + #define UART011_RIMIM BIT(0) /* RI interrupt mask */ 182 181 183 - #define UART011_OEIS (1 << 10) /* overrun error interrupt status */ 184 - #define UART011_BEIS (1 << 9) /* break error interrupt status */ 185 - #define UART011_PEIS (1 << 8) /* parity error interrupt status */ 186 - #define UART011_FEIS (1 << 7) /* framing error interrupt status */ 187 - #define UART011_RTIS (1 << 6) /* receive timeout interrupt status */ 188 - #define UART011_TXIS (1 << 5) /* transmit interrupt status */ 189 - #define UART011_RXIS (1 << 4) /* receive interrupt status */ 190 - #define UART011_DSRMIS (1 << 3) /* DSR interrupt status */ 191 - #define UART011_DCDMIS (1 << 2) /* DCD interrupt status */ 192 - #define UART011_CTSMIS (1 << 1) /* CTS interrupt status */ 193 - #define UART011_RIMIS (1 << 0) /* RI interrupt status */ 182 + #define UART011_OEIS BIT(10) /* overrun error interrupt status */ 183 + #define UART011_BEIS BIT(9) /* break error interrupt status */ 184 + #define UART011_PEIS BIT(8) /* parity error interrupt status */ 185 + #define UART011_FEIS BIT(7) /* framing error interrupt status */ 186 + #define UART011_RTIS BIT(6) /* receive timeout interrupt status */ 187 + #define UART011_TXIS BIT(5) /* transmit interrupt status */ 188 + #define UART011_RXIS BIT(4) /* receive interrupt status */ 189 + #define UART011_DSRMIS BIT(3) /* DSR interrupt status */ 190 + #define UART011_DCDMIS BIT(2) /* DCD interrupt status */ 191 + #define UART011_CTSMIS BIT(1) /* CTS interrupt status */ 192 + #define UART011_RIMIS BIT(0) /* RI interrupt status */ 194 193 195 - #define UART011_OEIC (1 << 10) /* overrun error interrupt clear */ 196 - #define UART011_BEIC (1 << 9) /* break error interrupt clear */ 197 - #define UART011_PEIC (1 << 8) /* parity error interrupt clear */ 198 - #define UART011_FEIC (1 << 7) /* framing error interrupt clear */ 199 - #define UART011_RTIC (1 << 6) /* receive timeout interrupt clear */ 200 - #define UART011_TXIC (1 << 5) /* transmit interrupt clear */ 201 - #define UART011_RXIC (1 << 4) /* receive interrupt clear */ 202 - #define UART011_DSRMIC (1 << 3) /* DSR interrupt clear */ 203 - #define UART011_DCDMIC (1 << 2) /* DCD interrupt clear */ 204 - #define UART011_CTSMIC (1 << 1) /* CTS interrupt clear */ 205 - #define UART011_RIMIC (1 << 0) /* RI interrupt clear */ 194 + #define UART011_OEIC BIT(10) /* overrun error interrupt clear */ 195 + #define UART011_BEIC BIT(9) /* break error interrupt clear */ 196 + #define UART011_PEIC BIT(8) /* parity error interrupt clear */ 197 + #define UART011_FEIC BIT(7) /* framing error interrupt clear */ 198 + #define UART011_RTIC BIT(6) /* receive timeout interrupt clear */ 199 + #define UART011_TXIC BIT(5) /* transmit interrupt clear */ 200 + #define UART011_RXIC BIT(4) /* receive interrupt clear */ 201 + #define UART011_DSRMIC BIT(3) /* DSR interrupt clear */ 202 + #define UART011_DCDMIC BIT(2) /* DCD interrupt clear */ 203 + #define UART011_CTSMIC BIT(1) /* CTS interrupt clear */ 204 + #define UART011_RIMIC BIT(0) /* RI interrupt clear */ 206 205 207 - #define UART011_DMAONERR (1 << 2) /* disable dma on error */ 208 - #define UART011_TXDMAE (1 << 1) /* enable transmit dma */ 209 - #define UART011_RXDMAE (1 << 0) /* enable receive dma */ 206 + #define UART011_DMAONERR BIT(2) /* disable dma on error */ 207 + #define UART011_TXDMAE BIT(1) /* enable transmit dma */ 208 + #define UART011_RXDMAE BIT(0) /* enable receive dma */ 210 209 211 - #define UART01x_RSR_ANY (UART01x_RSR_OE|UART01x_RSR_BE|UART01x_RSR_PE|UART01x_RSR_FE) 212 - #define UART01x_FR_MODEM_ANY (UART01x_FR_DCD|UART01x_FR_DSR|UART01x_FR_CTS) 210 + #define UART01x_RSR_ANY (UART01x_RSR_OE | UART01x_RSR_BE | UART01x_RSR_PE | UART01x_RSR_FE) 211 + #define UART01x_FR_MODEM_ANY (UART01x_FR_DCD | UART01x_FR_DSR | UART01x_FR_CTS) 213 212 214 213 #ifndef __ASSEMBLY__ 215 214 struct amba_device; /* in uncompress this is included but amba/bus.h is not */ ··· 229 220 bool dma_rx_poll_enable; 230 221 unsigned int dma_rx_poll_rate; 231 222 unsigned int dma_rx_poll_timeout; 232 - void (*init) (void); 233 - void (*exit) (void); 223 + void (*init)(void); 224 + void (*exit)(void); 234 225 }; 235 226 #endif 236 227
+18 -11
include/linux/serdev.h
··· 27 27 * not sleep. 28 28 */ 29 29 struct serdev_device_ops { 30 - int (*receive_buf)(struct serdev_device *, const unsigned char *, size_t); 30 + ssize_t (*receive_buf)(struct serdev_device *, const u8 *, size_t); 31 31 void (*write_wakeup)(struct serdev_device *); 32 32 }; 33 33 ··· 82 82 * serdev controller structures 83 83 */ 84 84 struct serdev_controller_ops { 85 - int (*write_buf)(struct serdev_controller *, const unsigned char *, size_t); 85 + ssize_t (*write_buf)(struct serdev_controller *, const u8 *, size_t); 86 86 void (*write_flush)(struct serdev_controller *); 87 87 int (*write_room)(struct serdev_controller *); 88 88 int (*open)(struct serdev_controller *); ··· 99 99 /** 100 100 * struct serdev_controller - interface to the serdev controller 101 101 * @dev: Driver model representation of the device. 102 + * @host: Serial port hardware controller device 102 103 * @nr: number identifier for this controller/bus. 103 104 * @serdev: Pointer to slave device for this controller. 104 105 * @ops: Controller operations. 105 106 */ 106 107 struct serdev_controller { 107 108 struct device dev; 109 + struct device *host; 108 110 unsigned int nr; 109 111 struct serdev_device *serdev; 110 112 const struct serdev_controller_ops *ops; ··· 169 167 int serdev_device_add(struct serdev_device *); 170 168 void serdev_device_remove(struct serdev_device *); 171 169 172 - struct serdev_controller *serdev_controller_alloc(struct device *, size_t); 170 + struct serdev_controller *serdev_controller_alloc(struct device *host, 171 + struct device *parent, 172 + size_t size); 173 173 int serdev_controller_add(struct serdev_controller *); 174 174 void serdev_controller_remove(struct serdev_controller *); 175 175 ··· 185 181 serdev->ops->write_wakeup(serdev); 186 182 } 187 183 188 - static inline int serdev_controller_receive_buf(struct serdev_controller *ctrl, 189 - const unsigned char *data, 190 - size_t count) 184 + static inline ssize_t serdev_controller_receive_buf(struct serdev_controller *ctrl, 185 + const u8 *data, 186 + size_t count) 191 187 { 192 188 struct serdev_device *serdev = ctrl->serdev; 193 189 ··· 204 200 int devm_serdev_device_open(struct device *, struct serdev_device *); 205 201 unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int); 206 202 void serdev_device_set_flow_control(struct serdev_device *, bool); 207 - int serdev_device_write_buf(struct serdev_device *, const unsigned char *, size_t); 203 + int serdev_device_write_buf(struct serdev_device *, const u8 *, size_t); 208 204 void serdev_device_wait_until_sent(struct serdev_device *, long); 209 205 int serdev_device_get_tiocm(struct serdev_device *); 210 206 int serdev_device_set_tiocm(struct serdev_device *, int, int); 211 207 int serdev_device_break_ctl(struct serdev_device *serdev, int break_state); 212 208 void serdev_device_write_wakeup(struct serdev_device *); 213 - int serdev_device_write(struct serdev_device *, const unsigned char *, size_t, long); 209 + ssize_t serdev_device_write(struct serdev_device *, const u8 *, size_t, long); 214 210 void serdev_device_write_flush(struct serdev_device *); 215 211 int serdev_device_write_room(struct serdev_device *); 216 212 ··· 248 244 } 249 245 static inline void serdev_device_set_flow_control(struct serdev_device *sdev, bool enable) {} 250 246 static inline int serdev_device_write_buf(struct serdev_device *serdev, 251 - const unsigned char *buf, 247 + const u8 *buf, 252 248 size_t count) 253 249 { 254 250 return -ENODEV; ··· 266 262 { 267 263 return -EOPNOTSUPP; 268 264 } 269 - static inline int serdev_device_write(struct serdev_device *sdev, const unsigned char *buf, 270 - size_t count, unsigned long timeout) 265 + static inline ssize_t serdev_device_write(struct serdev_device *sdev, 266 + const u8 *buf, size_t count, 267 + unsigned long timeout) 271 268 { 272 269 return -ENODEV; 273 270 } ··· 316 311 317 312 #ifdef CONFIG_SERIAL_DEV_CTRL_TTYPORT 318 313 struct device *serdev_tty_port_register(struct tty_port *port, 314 + struct device *host, 319 315 struct device *parent, 320 316 struct tty_driver *drv, int idx); 321 317 int serdev_tty_port_unregister(struct tty_port *port); 322 318 #else 323 319 static inline struct device *serdev_tty_port_register(struct tty_port *port, 320 + struct device *host, 324 321 struct device *parent, 325 322 struct tty_driver *drv, int idx) 326 323 {
+2 -2
include/linux/serial_core.h
··· 852 852 } 853 853 854 854 /* Base timer interval for polling */ 855 - static inline int uart_poll_timeout(struct uart_port *port) 855 + static inline unsigned long uart_poll_timeout(struct uart_port *port) 856 856 { 857 - int timeout = uart_fifo_timeout(port); 857 + unsigned long timeout = uart_fifo_timeout(port); 858 858 859 859 return timeout > 6 ? (timeout / 2 - 2) : 1; 860 860 }
+10 -9
include/linux/tty.h
··· 242 242 void *driver_data; 243 243 spinlock_t files_lock; 244 244 int write_cnt; 245 - unsigned char *write_buf; 245 + u8 *write_buf; 246 246 247 247 struct list_head tty_files; 248 248 ··· 393 393 * tty_kref_get - get a tty reference 394 394 * @tty: tty device 395 395 * 396 - * Returns: a new reference to a tty object. The caller must hold sufficient 397 - * locks/counts to ensure that their existing reference cannot go away 396 + * Returns: a new reference to a tty object 397 + * 398 + * Locking: The caller must hold sufficient locks/counts to ensure that their 399 + * existing reference cannot go away. 398 400 */ 399 401 static inline struct tty_struct *tty_kref_get(struct tty_struct *tty) 400 402 { ··· 410 408 void stop_tty(struct tty_struct *tty); 411 409 void start_tty(struct tty_struct *tty); 412 410 void tty_write_message(struct tty_struct *tty, char *msg); 413 - int tty_send_xchar(struct tty_struct *tty, char ch); 414 - int tty_put_char(struct tty_struct *tty, unsigned char c); 411 + int tty_send_xchar(struct tty_struct *tty, u8 ch); 412 + int tty_put_char(struct tty_struct *tty, u8 c); 415 413 unsigned int tty_chars_in_buffer(struct tty_struct *tty); 416 414 unsigned int tty_write_room(struct tty_struct *tty); 417 415 void tty_driver_flush_buffer(struct tty_struct *tty); ··· 439 437 * tty_get_baud_rate - get tty bit rates 440 438 * @tty: tty to query 441 439 * 442 - * Returns: the baud rate as an integer for this terminal. The termios lock 443 - * must be held by the caller and the terminal bit flags may be updated. 440 + * Returns: the baud rate as an integer for this terminal 444 441 * 445 - * Locking: none 442 + * Locking: The termios lock must be held by the caller. 446 443 */ 447 - static inline speed_t tty_get_baud_rate(struct tty_struct *tty) 444 + static inline speed_t tty_get_baud_rate(const struct tty_struct *tty) 448 445 { 449 446 return tty_termios_baud_rate(&tty->termios); 450 447 }
+4 -5
include/linux/tty_driver.h
··· 72 72 * is closed for the last time freeing up the resources. This is 73 73 * actually the second part of shutdown for routines that might sleep. 74 74 * 75 - * @write: ``ssize_t ()(struct tty_struct *tty, const unsigned char *buf, 76 - * size_t count)`` 75 + * @write: ``ssize_t ()(struct tty_struct *tty, const u8 *buf, size_t count)`` 77 76 * 78 77 * This routine is called by the kernel to write a series (@count) of 79 78 * characters (@buf) to the @tty device. The characters may come from ··· 84 85 * 85 86 * Optional: Required for writable devices. May not sleep. 86 87 * 87 - * @put_char: ``int ()(struct tty_struct *tty, unsigned char ch)`` 88 + * @put_char: ``int ()(struct tty_struct *tty, u8 ch)`` 88 89 * 89 90 * This routine is called by the kernel to write a single character @ch to 90 91 * the @tty device. If the kernel uses this routine, it must call the ··· 242 243 * Optional: If not provided, the device is assumed to have no FIFO. 243 244 * Usually correct to invoke via tty_wait_until_sent(). May sleep. 244 245 * 245 - * @send_xchar: ``void ()(struct tty_struct *tty, char ch)`` 246 + * @send_xchar: ``void ()(struct tty_struct *tty, u8 ch)`` 246 247 * 247 248 * This routine is used to send a high-priority XON/XOFF character (@ch) 248 249 * to the @tty device. ··· 374 375 void (*flush_buffer)(struct tty_struct *tty); 375 376 void (*set_ldisc)(struct tty_struct *tty); 376 377 void (*wait_until_sent)(struct tty_struct *tty, int timeout); 377 - void (*send_xchar)(struct tty_struct *tty, char ch); 378 + void (*send_xchar)(struct tty_struct *tty, u8 ch); 378 379 int (*tiocmget)(struct tty_struct *tty); 379 380 int (*tiocmset)(struct tty_struct *tty, 380 381 unsigned int set, unsigned int clear);
+4 -4
include/linux/tty_port.h
··· 114 114 unsigned char console:1; 115 115 struct mutex mutex; 116 116 struct mutex buf_mutex; 117 - unsigned char *xmit_buf; 118 - DECLARE_KFIFO_PTR(xmit_fifo, unsigned char); 117 + u8 *xmit_buf; 118 + DECLARE_KFIFO_PTR(xmit_fifo, u8); 119 119 unsigned int close_delay; 120 120 unsigned int closing_wait; 121 121 int drain_delay; ··· 149 149 const struct attribute_group **attr_grp); 150 150 struct device *tty_port_register_device_serdev(struct tty_port *port, 151 151 struct tty_driver *driver, unsigned index, 152 - struct device *device); 152 + struct device *host, struct device *parent); 153 153 struct device *tty_port_register_device_attr_serdev(struct tty_port *port, 154 154 struct tty_driver *driver, unsigned index, 155 - struct device *device, void *drvdata, 155 + struct device *host, struct device *parent, void *drvdata, 156 156 const struct attribute_group **attr_grp); 157 157 void tty_port_unregister_device(struct tty_port *port, 158 158 struct tty_driver *driver, unsigned index);
-38
include/linux/virtio_console.h
··· 1 - /* 2 - * This header, excluding the #ifdef __KERNEL__ part, is BSD licensed so 3 - * anyone can use the definitions to implement compatible drivers/servers: 4 - * 5 - * 6 - * Redistribution and use in source and binary forms, with or without 7 - * modification, are permitted provided that the following conditions 8 - * are met: 9 - * 1. Redistributions of source code must retain the above copyright 10 - * notice, this list of conditions and the following disclaimer. 11 - * 2. Redistributions in binary form must reproduce the above copyright 12 - * notice, this list of conditions and the following disclaimer in the 13 - * documentation and/or other materials provided with the distribution. 14 - * 3. Neither the name of IBM nor the names of its contributors 15 - * may be used to endorse or promote products derived from this software 16 - * without specific prior written permission. 17 - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 18 - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 - * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 21 - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 - * SUCH DAMAGE. 28 - * 29 - * Copyright (C) Red Hat, Inc., 2009, 2010, 2011 30 - * Copyright (C) Amit Shah <amit.shah@redhat.com>, 2009, 2010, 2011 31 - */ 32 - #ifndef _LINUX_VIRTIO_CONSOLE_H 33 - #define _LINUX_VIRTIO_CONSOLE_H 34 - 35 - #include <uapi/linux/virtio_console.h> 36 - 37 - int __init virtio_cons_early_init(int (*put_chars)(u32, const char *, int)); 38 - #endif /* _LINUX_VIRTIO_CONSOLE_H */
+11 -8
include/uapi/linux/serial.h
··· 11 11 #ifndef _UAPI_LINUX_SERIAL_H 12 12 #define _UAPI_LINUX_SERIAL_H 13 13 14 + #include <linux/const.h> 14 15 #include <linux/types.h> 15 16 16 17 #include <linux/tty_flags.h> ··· 138 137 * * %SER_RS485_ADDRB - Enable RS485 addressing mode. 139 138 * * %SER_RS485_ADDR_RECV - Receive address filter (enables @addr_recv). Requires %SER_RS485_ADDRB. 140 139 * * %SER_RS485_ADDR_DEST - Destination address (enables @addr_dest). Requires %SER_RS485_ADDRB. 140 + * * %SER_RS485_MODE_RS422 - Enable RS422. Requires %SER_RS485_ENABLED. 141 141 */ 142 142 struct serial_rs485 { 143 143 __u32 flags; 144 - #define SER_RS485_ENABLED (1 << 0) 145 - #define SER_RS485_RTS_ON_SEND (1 << 1) 146 - #define SER_RS485_RTS_AFTER_SEND (1 << 2) 147 - #define SER_RS485_RX_DURING_TX (1 << 4) 148 - #define SER_RS485_TERMINATE_BUS (1 << 5) 149 - #define SER_RS485_ADDRB (1 << 6) 150 - #define SER_RS485_ADDR_RECV (1 << 7) 151 - #define SER_RS485_ADDR_DEST (1 << 8) 144 + #define SER_RS485_ENABLED _BITUL(0) 145 + #define SER_RS485_RTS_ON_SEND _BITUL(1) 146 + #define SER_RS485_RTS_AFTER_SEND _BITUL(2) 147 + #define SER_RS485_RX_DURING_TX _BITUL(3) 148 + #define SER_RS485_TERMINATE_BUS _BITUL(4) 149 + #define SER_RS485_ADDRB _BITUL(5) 150 + #define SER_RS485_ADDR_RECV _BITUL(6) 151 + #define SER_RS485_ADDR_DEST _BITUL(7) 152 + #define SER_RS485_MODE_RS422 _BITUL(8) 152 153 153 154 __u32 delay_rts_before_send; 154 155 __u32 delay_rts_after_send;
+1 -1
net/bluetooth/rfcomm/tty.c
··· 1041 1041 tty_wakeup(tty); 1042 1042 } 1043 1043 1044 - static void rfcomm_tty_send_xchar(struct tty_struct *tty, char ch) 1044 + static void rfcomm_tty_send_xchar(struct tty_struct *tty, u8 ch) 1045 1045 { 1046 1046 BT_DBG("tty %p ch %c", tty, ch); 1047 1047 }
+2 -2
sound/drivers/serial-generic.c
··· 100 100 snd_serial_generic_tx_wakeup(drvdata); 101 101 } 102 102 103 - static int snd_serial_generic_receive_buf(struct serdev_device *serdev, 104 - const unsigned char *buf, size_t count) 103 + static ssize_t snd_serial_generic_receive_buf(struct serdev_device *serdev, 104 + const u8 *buf, size_t count) 105 105 { 106 106 int ret; 107 107 struct snd_serial_generic *drvdata = serdev_device_get_drvdata(serdev);