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

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

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

Lots of cleanups in here this cycle, and some driver updates. Short
summary is:

- Jiri's continued work to make the tty code and apis be a bit more
sane with regards to modern kernel coding style and types

- cpm_uart driver updates

- n_gsm updates and fixes

- meson driver updates

- sc16is7xx driver updates

- 8250 driver updates for different hardware types

- qcom-geni driver fixes

- tegra serial driver change

- stm32 driver updates

- synclink_gt driver cleanups

- tty structure size reduction

All of these have been in linux-next this week with no reported
issues. The last bit of cleanups from Jiri and the tty structure size
reduction came in last week, a bit late but as they were just style
changes and size reductions, I figured they should get into this merge
cycle so that others can work on top of them with no merge conflicts"

* tag 'tty-6.6-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty: (199 commits)
tty: shrink the size of struct tty_struct by 40 bytes
tty: n_tty: deduplicate copy code in n_tty_receive_buf_real_raw()
tty: n_tty: extract ECHO_OP processing to a separate function
tty: n_tty: unify counts to size_t
tty: n_tty: use u8 for chars and flags
tty: n_tty: simplify chars_in_buffer()
tty: n_tty: remove unsigned char casts from character constants
tty: n_tty: move newline handling to a separate function
tty: n_tty: move canon handling to a separate function
tty: n_tty: use MASK() for masking out size bits
tty: n_tty: make n_tty_data::num_overrun unsigned
tty: n_tty: use time_is_before_jiffies() in n_tty_receive_overrun()
tty: n_tty: use 'num' for writes' counts
tty: n_tty: use output character directly
tty: n_tty: make flow of n_tty_receive_buf_common() a bool
Revert "tty: serial: meson: Add a earlycon for the T7 SoC"
Documentation: devices.txt: Fix minors for ttyCPM*
Documentation: devices.txt: Remove ttySIOC*
Documentation: devices.txt: Remove ttyIOC*
serial: 8250_bcm7271: improve bcm7271 8250 port
...

+2104 -2173
+2 -14
Documentation/admin-guide/devices.txt
··· 2691 2691 45 = /dev/ttyMM1 Marvell MPSC - port 1 (obsolete unused) 2692 2692 46 = /dev/ttyCPM0 PPC CPM (SCC or SMC) - port 0 2693 2693 ... 2694 - 49 = /dev/ttyCPM5 PPC CPM (SCC or SMC) - port 3 2695 - 50 = /dev/ttyIOC0 Altix serial card 2696 - ... 2697 - 81 = /dev/ttyIOC31 Altix serial card 2694 + 51 = /dev/ttyCPM5 PPC CPM (SCC or SMC) - port 5 2698 2695 82 = /dev/ttyVR0 NEC VR4100 series SIU 2699 2696 83 = /dev/ttyVR1 NEC VR4100 series DSIU 2700 - 84 = /dev/ttyIOC84 Altix ioc4 serial card 2701 - ... 2702 - 115 = /dev/ttyIOC115 Altix ioc4 serial card 2703 - 116 = /dev/ttySIOC0 Altix ioc3 serial card 2704 - ... 2705 - 147 = /dev/ttySIOC31 Altix ioc3 serial card 2706 2697 148 = /dev/ttyPSC0 PPC PSC - port 0 2707 2698 ... 2708 2699 153 = /dev/ttyPSC5 PPC PSC - port 5 ··· 2752 2761 43 = /dev/ttycusmx2 Callout device for ttySMX2 2753 2762 46 = /dev/cucpm0 Callout device for ttyCPM0 2754 2763 ... 2755 - 49 = /dev/cucpm5 Callout device for ttyCPM5 2756 - 50 = /dev/cuioc40 Callout device for ttyIOC40 2757 - ... 2758 - 81 = /dev/cuioc431 Callout device for ttyIOC431 2764 + 51 = /dev/cucpm5 Callout device for ttyCPM5 2759 2765 82 = /dev/cuvr0 Callout device for ttyVR0 2760 2766 83 = /dev/cuvr1 Callout device for ttyVR1 2761 2767
+6
Documentation/devicetree/bindings/serial/amlogic,meson-uart.yaml
··· 33 33 - amlogic,meson8b-uart 34 34 - amlogic,meson-gx-uart 35 35 - amlogic,meson-s4-uart 36 + - amlogic,meson-a1-uart 36 37 - const: amlogic,meson-ao-uart 37 38 - description: Always-on power domain UART controller on G12A SoCs 38 39 items: ··· 47 46 - amlogic,meson8b-uart 48 47 - amlogic,meson-gx-uart 49 48 - amlogic,meson-s4-uart 49 + - amlogic,meson-a1-uart 50 50 - description: Everything-Else power domain UART controller on G12A SoCs 51 51 items: 52 52 - const: amlogic,meson-g12a-uart 53 53 - const: amlogic,meson-gx-uart 54 + - description: UART controller on S4 compatible SoCs 55 + items: 56 + - const: amlogic,t7-uart 57 + - const: amlogic,meson-s4-uart 54 58 55 59 reg: 56 60 maxItems: 1
+5 -1
Documentation/devicetree/bindings/serial/fsl-lpuart.yaml
··· 25 25 - fsl,imxrt1050-lpuart 26 26 - items: 27 27 - enum: 28 - - fsl,imx93-lpuart 29 28 - fsl,imx8ulp-lpuart 29 + - const: fsl,imx7ulp-lpuart 30 + - items: 31 + - enum: 32 + - fsl,imx93-lpuart 33 + - const: fsl,imx8ulp-lpuart 30 34 - const: fsl,imx7ulp-lpuart 31 35 - items: 32 36 - enum:
+46
Documentation/devicetree/bindings/serial/nxp,sc16is7xx.txt
··· 23 23 1 = active low. 24 24 - irda-mode-ports: An array that lists the indices of the port that 25 25 should operate in IrDA mode. 26 + - nxp,modem-control-line-ports: An array that lists the indices of the port that 27 + should have shared GPIO lines configured as 28 + modem control lines. 26 29 27 30 Example: 28 31 sc16is750: sc16is750@51 { ··· 37 34 gpio-controller; 38 35 #gpio-cells = <2>; 39 36 }; 37 + 38 + sc16is752: sc16is752@53 { 39 + compatible = "nxp,sc16is752"; 40 + reg = <0x53>; 41 + clocks = <&clk20m>; 42 + interrupt-parent = <&gpio3>; 43 + interrupts = <7 IRQ_TYPE_EDGE_FALLING>; 44 + nxp,modem-control-line-ports = <1>; /* Port 1 as modem control lines */ 45 + gpio-controller; /* Port 0 as GPIOs */ 46 + #gpio-cells = <2>; 47 + }; 48 + 49 + sc16is752: sc16is752@54 { 50 + compatible = "nxp,sc16is752"; 51 + reg = <0x54>; 52 + clocks = <&clk20m>; 53 + interrupt-parent = <&gpio3>; 54 + interrupts = <7 IRQ_TYPE_EDGE_FALLING>; 55 + nxp,modem-control-line-ports = <0 1>; /* Ports 0 and 1 as modem control lines */ 56 + }; 40 57 41 58 * spi as bus 42 59 ··· 82 59 1 = active low. 83 60 - irda-mode-ports: An array that lists the indices of the port that 84 61 should operate in IrDA mode. 62 + - nxp,modem-control-line-ports: An array that lists the indices of the port that 63 + should have shared GPIO lines configured as 64 + modem control lines. 85 65 86 66 Example: 87 67 sc16is750: sc16is750@0 { ··· 95 69 interrupts = <7 IRQ_TYPE_EDGE_FALLING>; 96 70 gpio-controller; 97 71 #gpio-cells = <2>; 72 + }; 73 + 74 + sc16is752: sc16is752@1 { 75 + compatible = "nxp,sc16is752"; 76 + reg = <1>; 77 + clocks = <&clk20m>; 78 + interrupt-parent = <&gpio3>; 79 + interrupts = <7 IRQ_TYPE_EDGE_FALLING>; 80 + nxp,modem-control-line-ports = <1>; /* Port 1 as modem control lines */ 81 + gpio-controller; /* Port 0 as GPIOs */ 82 + #gpio-cells = <2>; 83 + }; 84 + 85 + sc16is752: sc16is752@2 { 86 + compatible = "nxp,sc16is752"; 87 + reg = <2>; 88 + clocks = <&clk20m>; 89 + interrupt-parent = <&gpio3>; 90 + interrupts = <7 IRQ_TYPE_EDGE_FALLING>; 91 + nxp,modem-control-line-ports = <0 1>; /* Ports 0 and 1 as modem control lines */ 98 92 };
-1
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
··· 117 117 required: 118 118 - compatible 119 119 - reg 120 - - interrupts 121 120 122 121 unevaluatedProperties: false 123 122
+5 -2
Documentation/driver-api/tty/tty_buffer.rst
··· 15 15 ====================== 16 16 17 17 .. kernel-doc:: drivers/tty/tty_buffer.c 18 - :identifiers: tty_prepare_flip_string tty_insert_flip_string_fixed_flag 19 - tty_insert_flip_string_flags __tty_insert_flip_char 18 + :identifiers: tty_prepare_flip_string 20 19 tty_flip_buffer_push tty_ldisc_receive_buf 20 + 21 + .. kernel-doc:: include/linux/tty_flip.h 22 + :identifiers: tty_insert_flip_string_fixed_flag tty_insert_flip_string_flags 23 + tty_insert_flip_char 21 24 22 25 ---- 23 26
+1 -1
arch/alpha/kernel/setup.c
··· 421 421 arch_initcall(register_cpus); 422 422 423 423 #ifdef CONFIG_MAGIC_SYSRQ 424 - static void sysrq_reboot_handler(int unused) 424 + static void sysrq_reboot_handler(u8 unused) 425 425 { 426 426 machine_halt(); 427 427 }
+2 -3
arch/alpha/kernel/srmcons.c
··· 129 129 return count; 130 130 } 131 131 132 - static int 133 - srmcons_write(struct tty_struct *tty, 134 - const unsigned char *buf, int count) 132 + static ssize_t 133 + srmcons_write(struct tty_struct *tty, const u8 *buf, size_t count) 135 134 { 136 135 unsigned long flags; 137 136
+2 -2
arch/arm64/boot/dts/amlogic/meson-a1.dtsi
··· 108 108 }; 109 109 110 110 uart_AO: serial@1c00 { 111 - compatible = "amlogic,meson-gx-uart", 111 + compatible = "amlogic,meson-a1-uart", 112 112 "amlogic,meson-ao-uart"; 113 113 reg = <0x0 0x1c00 0x0 0x18>; 114 114 interrupts = <GIC_SPI 25 IRQ_TYPE_EDGE_RISING>; ··· 118 118 }; 119 119 120 120 uart_AO_B: serial@2000 { 121 - compatible = "amlogic,meson-gx-uart", 121 + compatible = "amlogic,meson-a1-uart", 122 122 "amlogic,meson-ao-uart"; 123 123 reg = <0x0 0x2000 0x0 0x18>; 124 124 interrupts = <GIC_SPI 26 IRQ_TYPE_EDGE_RISING>;
+1 -1
arch/loongarch/kernel/sysrq.c
··· 43 43 static DECLARE_WORK(sysrq_tlbdump, sysrq_tlbdump_othercpus); 44 44 #endif 45 45 46 - static void sysrq_handle_tlbdump(int key) 46 + static void sysrq_handle_tlbdump(u8 key) 47 47 { 48 48 sysrq_tlbdump_single(NULL); 49 49 #ifdef CONFIG_SMP
+4 -4
arch/m68k/emu/nfcon.c
··· 70 70 { 71 71 } 72 72 73 - static int nfcon_tty_write(struct tty_struct *tty, const unsigned char *buf, 74 - int count) 73 + static ssize_t nfcon_tty_write(struct tty_struct *tty, const u8 *buf, 74 + size_t count) 75 75 { 76 76 nfputs(buf, count); 77 77 return count; 78 78 } 79 79 80 - static int nfcon_tty_put_char(struct tty_struct *tty, unsigned char ch) 80 + static int nfcon_tty_put_char(struct tty_struct *tty, u8 ch) 81 81 { 82 - char temp[2] = { ch, 0 }; 82 + u8 temp[2] = { ch, 0 }; 83 83 84 84 nf_call(stderr_id, virt_to_phys(temp)); 85 85 return 1;
+1 -1
arch/mips/kernel/sysrq.c
··· 44 44 static DECLARE_WORK(sysrq_tlbdump, sysrq_tlbdump_othercpus); 45 45 #endif 46 46 47 - static void sysrq_handle_tlbdump(int key) 47 + static void sysrq_handle_tlbdump(u8 key) 48 48 { 49 49 sysrq_tlbdump_single(NULL); 50 50 #ifdef CONFIG_SMP
-27
arch/powerpc/include/asm/fs_pd.h
··· 1 - /* 2 - * Platform information definitions. 3 - * 4 - * 2006 (c) MontaVista Software, Inc. 5 - * Vitaly Bordug <vbordug@ru.mvista.com> 6 - * 7 - * This file is licensed under the terms of the GNU General Public License 8 - * version 2. This program is licensed "as is" without any warranty of any 9 - * kind, whether express or implied. 10 - */ 11 - 12 - #ifndef FS_PD_H 13 - #define FS_PD_H 14 - #include <sysdev/fsl_soc.h> 15 - #include <asm/time.h> 16 - 17 - static inline int uart_baudrate(void) 18 - { 19 - return get_baudrate(); 20 - } 21 - 22 - static inline int uart_clock(void) 23 - { 24 - return ppc_proc_freq; 25 - } 26 - 27 - #endif
-1
arch/powerpc/platforms/8xx/mpc885ads_setup.c
··· 21 21 #include <linux/device.h> 22 22 #include <linux/delay.h> 23 23 24 - #include <linux/fs_uart_pd.h> 25 24 #include <linux/fsl_devices.h> 26 25 #include <linux/mii.h> 27 26 #include <linux/of_address.h>
-1
arch/powerpc/platforms/8xx/tqm8xx_setup.c
··· 24 24 #include <linux/device.h> 25 25 #include <linux/delay.h> 26 26 27 - #include <linux/fs_uart_pd.h> 28 27 #include <linux/fsl_devices.h> 29 28 #include <linux/mii.h> 30 29 #include <linux/of_fdt.h>
-2
arch/powerpc/sysdev/fsl_soc.c
··· 22 22 #include <linux/phy.h> 23 23 #include <linux/spi/spi.h> 24 24 #include <linux/fsl_devices.h> 25 - #include <linux/fs_uart_pd.h> 26 25 #include <linux/reboot.h> 27 26 28 27 #include <linux/atomic.h> ··· 34 35 #include <asm/cpm2.h> 35 36 #include <asm/fsl_hcalls.h> /* For the Freescale hypervisor */ 36 37 37 - extern void init_smc_ioports(struct fs_uart_platform_info*); 38 38 static phys_addr_t immrbase = -1; 39 39 40 40 phys_addr_t get_immrbase(void)
+1 -1
arch/powerpc/xmon/xmon.c
··· 3988 3988 } 3989 3989 3990 3990 #ifdef CONFIG_MAGIC_SYSRQ 3991 - static void sysrq_handle_xmon(int key) 3991 + static void sysrq_handle_xmon(u8 key) 3992 3992 { 3993 3993 if (xmon_is_locked_down()) { 3994 3994 clear_all_bpt();
+1 -1
arch/sparc/include/asm/vio.h
··· 284 284 struct ldc_trans_cookie cookies[VIO_MAX_RING_COOKIES]; 285 285 }; 286 286 287 - #define VIO_TAG_SIZE ((int)sizeof(struct vio_msg_tag)) 287 + #define VIO_TAG_SIZE (sizeof(struct vio_msg_tag)) 288 288 #define VIO_VCC_MTU_SIZE (LDC_PACKET_SIZE - VIO_TAG_SIZE) 289 289 290 290 struct vio_vcc {
+2 -2
arch/sparc/kernel/process_64.c
··· 295 295 296 296 #ifdef CONFIG_MAGIC_SYSRQ 297 297 298 - static void sysrq_handle_globreg(int key) 298 + static void sysrq_handle_globreg(u8 key) 299 299 { 300 300 trigger_all_cpu_backtrace(); 301 301 } ··· 370 370 spin_unlock_irqrestore(&global_cpu_snapshot_lock, flags); 371 371 } 372 372 373 - static void sysrq_handle_globpmu(int key) 373 + static void sysrq_handle_globpmu(u8 key) 374 374 { 375 375 pmu_snapshot_all_cpus(); 376 376 }
+1 -1
arch/um/drivers/line.c
··· 184 184 line_flush_buffer(tty); 185 185 } 186 186 187 - int line_write(struct tty_struct *tty, const unsigned char *buf, int len) 187 + ssize_t line_write(struct tty_struct *tty, const u8 *buf, size_t len) 188 188 { 189 189 struct line *line = tty->driver_data; 190 190 unsigned long flags;
+1 -2
arch/um/drivers/line.h
··· 64 64 extern void line_hangup(struct tty_struct *tty); 65 65 extern int line_setup(char **conf, unsigned nlines, char **def, 66 66 char *init, char *name); 67 - extern int line_write(struct tty_struct *tty, const unsigned char *buf, 68 - int len); 67 + extern ssize_t line_write(struct tty_struct *tty, const u8 *buf, size_t len); 69 68 extern unsigned int line_chars_in_buffer(struct tty_struct *tty); 70 69 extern void line_flush_buffer(struct tty_struct *tty); 71 70 extern void line_flush_chars(struct tty_struct *tty);
+1 -26
arch/xtensa/platforms/iss/console.c
··· 52 52 } 53 53 54 54 55 - static int rs_write(struct tty_struct * tty, 56 - const unsigned char *buf, int count) 55 + static ssize_t rs_write(struct tty_struct * tty, const u8 *buf, size_t count) 57 56 { 58 57 /* see drivers/char/serialX.c to reference original version */ 59 58 ··· 81 82 mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE); 82 83 } 83 84 84 - 85 - static int rs_put_char(struct tty_struct *tty, unsigned char ch) 86 - { 87 - return rs_write(tty, &ch, 1); 88 - } 89 - 90 - static void rs_flush_chars(struct tty_struct *tty) 91 - { 92 - } 93 - 94 85 static unsigned int rs_write_room(struct tty_struct *tty) 95 86 { 96 87 /* Let's say iss can always accept 2K characters.. */ 97 88 return 2 * 1024; 98 - } 99 - 100 - static void rs_hangup(struct tty_struct *tty) 101 - { 102 - /* Stub, once again.. */ 103 - } 104 - 105 - static void rs_wait_until_sent(struct tty_struct *tty, int timeout) 106 - { 107 - /* Stub, once again.. */ 108 89 } 109 90 110 91 static int rs_proc_show(struct seq_file *m, void *v) ··· 97 118 .open = rs_open, 98 119 .close = rs_close, 99 120 .write = rs_write, 100 - .put_char = rs_put_char, 101 - .flush_chars = rs_flush_chars, 102 121 .write_room = rs_write_room, 103 - .hangup = rs_hangup, 104 - .wait_until_sent = rs_wait_until_sent, 105 122 .proc_show = rs_proc_show, 106 123 }; 107 124
+3 -4
drivers/accessibility/speakup/spk_ttyio.c
··· 71 71 kfree(tty->disc_data); 72 72 } 73 73 74 - static int spk_ttyio_receive_buf2(struct tty_struct *tty, 75 - const unsigned char *cp, 76 - const char *fp, int count) 74 + static size_t spk_ttyio_receive_buf2(struct tty_struct *tty, const u8 *cp, 75 + const u8 *fp, size_t count) 77 76 { 78 77 struct spk_ldisc_data *ldisc_data = tty->disc_data; 79 78 struct spk_synth *synth = ldisc_data->synth; 80 79 81 80 if (synth->read_buff_add) { 82 - int i; 81 + unsigned int i; 83 82 84 83 for (i = 0; i < count; i++) 85 84 synth->read_buff_add(cp[i]);
+4 -11
drivers/bluetooth/hci_ldisc.c
··· 599 599 * Return Value: None 600 600 */ 601 601 static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data, 602 - const char *flags, int count) 602 + const u8 *flags, size_t count) 603 603 { 604 604 struct hci_uart *hu = tty->disc_data; 605 605 ··· 807 807 * We don't provide read/write/poll interface for user space. 808 808 */ 809 809 static ssize_t hci_uart_tty_read(struct tty_struct *tty, struct file *file, 810 - unsigned char *buf, size_t nr, 811 - void **cookie, unsigned long offset) 810 + u8 *buf, size_t nr, void **cookie, 811 + unsigned long offset) 812 812 { 813 813 return 0; 814 814 } 815 815 816 816 static ssize_t hci_uart_tty_write(struct tty_struct *tty, struct file *file, 817 - const unsigned char *data, size_t count) 818 - { 819 - return 0; 820 - } 821 - 822 - static __poll_t hci_uart_tty_poll(struct tty_struct *tty, 823 - struct file *filp, poll_table *wait) 817 + const u8 *data, size_t count) 824 818 { 825 819 return 0; 826 820 } ··· 829 835 .write = hci_uart_tty_write, 830 836 .ioctl = hci_uart_tty_ioctl, 831 837 .compat_ioctl = hci_uart_tty_ioctl, 832 - .poll = hci_uart_tty_poll, 833 838 .receive_buf = hci_uart_tty_receive, 834 839 .write_wakeup = hci_uart_tty_wakeup, 835 840 };
+2 -3
drivers/char/ttyprintk.c
··· 51 51 } 52 52 } 53 53 54 - static int tpk_printk(const unsigned char *buf, int count) 54 + static int tpk_printk(const u8 *buf, int count) 55 55 { 56 56 int i; 57 57 ··· 103 103 /* 104 104 * TTY operations write function. 105 105 */ 106 - static int tpk_write(struct tty_struct *tty, 107 - const unsigned char *buf, int count) 106 + static ssize_t tpk_write(struct tty_struct *tty, const u8 *buf, size_t count) 108 107 { 109 108 struct ttyprintk_port *tpkp = tty->driver_data; 110 109 unsigned long flags;
+1 -1
drivers/gpu/drm/drm_fb_helper.c
··· 301 301 302 302 static DECLARE_WORK(drm_fb_helper_restore_work, drm_fb_helper_restore_work_fn); 303 303 304 - static void drm_fb_helper_sysrq(int dummy1) 304 + static void drm_fb_helper_sysrq(u8 dummy1) 305 305 { 306 306 schedule_work(&drm_fb_helper_restore_work); 307 307 }
+9 -9
drivers/input/serio/serport.c
··· 103 103 104 104 static void serport_ldisc_close(struct tty_struct *tty) 105 105 { 106 - struct serport *serport = (struct serport *) tty->disc_data; 106 + struct serport *serport = tty->disc_data; 107 107 108 108 kfree(serport); 109 109 } ··· 114 114 * 'interrupt' routine. 115 115 */ 116 116 117 - static void serport_ldisc_receive(struct tty_struct *tty, 118 - const unsigned char *cp, const char *fp, int count) 117 + static void serport_ldisc_receive(struct tty_struct *tty, const u8 *cp, 118 + const u8 *fp, size_t count) 119 119 { 120 - struct serport *serport = (struct serport*) tty->disc_data; 120 + struct serport *serport = tty->disc_data; 121 121 unsigned long flags; 122 122 unsigned int ch_flags = 0; 123 123 int i; ··· 158 158 */ 159 159 160 160 static ssize_t serport_ldisc_read(struct tty_struct * tty, struct file * file, 161 - unsigned char *kbuf, size_t nr, 162 - void **cookie, unsigned long offset) 161 + u8 *kbuf, size_t nr, void **cookie, 162 + unsigned long offset) 163 163 { 164 - struct serport *serport = (struct serport*) tty->disc_data; 164 + struct serport *serport = tty->disc_data; 165 165 struct serio *serio; 166 166 167 167 if (test_and_set_bit(SERPORT_BUSY, &serport->flags)) ··· 245 245 246 246 static void serport_ldisc_hangup(struct tty_struct *tty) 247 247 { 248 - struct serport *serport = (struct serport *) tty->disc_data; 248 + struct serport *serport = tty->disc_data; 249 249 unsigned long flags; 250 250 251 251 spin_lock_irqsave(&serport->lock, flags); ··· 257 257 258 258 static void serport_ldisc_write_wakeup(struct tty_struct * tty) 259 259 { 260 - struct serport *serport = (struct serport *) tty->disc_data; 260 + struct serport *serport = tty->disc_data; 261 261 unsigned long flags; 262 262 263 263 spin_lock_irqsave(&serport->lock, flags);
+3 -4
drivers/ipack/devices/ipoctal.c
··· 437 437 } 438 438 439 439 static inline int ipoctal_copy_write_buffer(struct ipoctal_channel *channel, 440 - const unsigned char *buf, 441 - int count) 440 + const u8 *buf, int count) 442 441 { 443 442 unsigned long flags; 444 443 int i; ··· 458 459 return i; 459 460 } 460 461 461 - static int ipoctal_write_tty(struct tty_struct *tty, 462 - const unsigned char *buf, int count) 462 + static ssize_t ipoctal_write_tty(struct tty_struct *tty, const u8 *buf, 463 + size_t count) 463 464 { 464 465 struct ipoctal_channel *channel = tty->driver_data; 465 466 unsigned int char_copied;
+4 -4
drivers/isdn/capi/capi.c
··· 1077 1077 tty_port_close(&mp->port, tty, filp); 1078 1078 } 1079 1079 1080 - static int capinc_tty_write(struct tty_struct *tty, 1081 - const unsigned char *buf, int count) 1080 + static ssize_t capinc_tty_write(struct tty_struct *tty, const u8 *buf, 1081 + size_t count) 1082 1082 { 1083 1083 struct capiminor *mp = tty->driver_data; 1084 1084 struct sk_buff *skb; 1085 1085 1086 - pr_debug("capinc_tty_write(count=%d)\n", count); 1086 + pr_debug("capinc_tty_write(count=%zu)\n", count); 1087 1087 1088 1088 spin_lock_bh(&mp->outlock); 1089 1089 skb = mp->outskb; ··· 1112 1112 return count; 1113 1113 } 1114 1114 1115 - static int capinc_tty_put_char(struct tty_struct *tty, unsigned char ch) 1115 + static int capinc_tty_put_char(struct tty_struct *tty, u8 ch) 1116 1116 { 1117 1117 struct capiminor *mp = tty->driver_data; 1118 1118 bool invoke_send = false;
+2 -3
drivers/misc/bcm-vk/bcm_vk_tty.c
··· 186 186 VK_BAR0_REGSEG_DB_BASE + VK_BAR0_REGSEG_TTY_DB_OFFSET); 187 187 } 188 188 189 - static int bcm_vk_tty_write(struct tty_struct *tty, 190 - const unsigned char *buffer, 191 - int count) 189 + static ssize_t bcm_vk_tty_write(struct tty_struct *tty, const u8 *buffer, 190 + size_t count) 192 191 { 193 192 int index; 194 193 struct bcm_vk *vk;
+6 -12
drivers/misc/ti-st/st_core.c
··· 16 16 17 17 #include <linux/ti_wilink_st.h> 18 18 19 - extern void st_kim_recv(void *, const unsigned char *, long); 20 - void st_int_recv(void *, const unsigned char *, long); 21 19 /* 22 20 * function pointer pointing to either, 23 21 * st_kim_recv during registration to receive fw download responses 24 22 * st_int_recv after registration to receive proto stack responses 25 23 */ 26 - static void (*st_recv) (void *, const unsigned char *, long); 24 + static void (*st_recv)(void *disc_data, const u8 *ptr, size_t count); 27 25 28 26 /********************************************************************/ 29 27 static void add_channel_to_table(struct st_data_s *st_gdata, ··· 223 225 * HCI-Events, ACL, SCO, 4 types of HCI-LL PM packets 224 226 * CH-8 packets from FM, CH-9 packets from GPS cores. 225 227 */ 226 - void st_int_recv(void *disc_data, 227 - const unsigned char *data, long count) 228 + static void st_int_recv(void *disc_data, const u8 *ptr, size_t count) 228 229 { 229 - char *ptr; 230 230 struct st_proto_s *proto; 231 231 unsigned short payload_len = 0; 232 232 int len = 0; ··· 233 237 struct st_data_s *st_gdata = (struct st_data_s *)disc_data; 234 238 unsigned long flags; 235 239 236 - ptr = (char *)data; 237 - /* tty_receive sent null ? */ 238 - if (unlikely(ptr == NULL) || (st_gdata == NULL)) { 240 + if (st_gdata == NULL) { 239 241 pr_err(" received null from TTY "); 240 242 return; 241 243 } 242 244 243 - pr_debug("count %ld rx_state %ld" 245 + pr_debug("count %zu rx_state %ld" 244 246 "rx_count %ld", count, st_gdata->rx_state, 245 247 st_gdata->rx_count); 246 248 ··· 790 796 pr_debug("%s: done ", __func__); 791 797 } 792 798 793 - static void st_tty_receive(struct tty_struct *tty, const unsigned char *data, 794 - const char *tty_flags, int count) 799 + static void st_tty_receive(struct tty_struct *tty, const u8 *data, 800 + const u8 *tty_flags, size_t count) 795 801 { 796 802 #ifdef VERBOSE 797 803 print_hex_dump(KERN_DEBUG, ">in>", DUMP_PREFIX_NONE,
+3 -10
drivers/misc/ti-st/st_kim.c
··· 127 127 * have been observed to come in bursts of different 128 128 * tty_receive and hence the logic 129 129 */ 130 - static void kim_int_recv(struct kim_data_s *kim_gdata, 131 - const unsigned char *data, long count) 130 + static void kim_int_recv(struct kim_data_s *kim_gdata, const u8 *ptr, 131 + size_t count) 132 132 { 133 - const unsigned char *ptr; 134 133 int len = 0; 135 134 unsigned char *plen; 136 135 137 136 pr_debug("%s", __func__); 138 137 /* Decode received bytes here */ 139 - ptr = data; 140 - if (unlikely(ptr == NULL)) { 141 - pr_err(" received null from TTY "); 142 - return; 143 - } 144 - 145 138 while (count) { 146 139 if (kim_gdata->rx_count) { 147 140 len = min_t(unsigned int, kim_gdata->rx_count, count); ··· 417 424 * 1. response to read local version 418 425 * 2. during send/recv's of firmware download 419 426 */ 420 - void st_kim_recv(void *disc_data, const unsigned char *data, long count) 427 + void st_kim_recv(void *disc_data, const u8 *data, size_t count) 421 428 { 422 429 struct st_data_s *st_gdata = (struct st_data_s *)disc_data; 423 430 struct kim_data_s *kim_gdata = st_gdata->kim_data;
+2 -2
drivers/mmc/core/sdio_uart.c
··· 760 760 tty_port_hangup(&port->port); 761 761 } 762 762 763 - static int sdio_uart_write(struct tty_struct *tty, const unsigned char *buf, 764 - int count) 763 + static ssize_t sdio_uart_write(struct tty_struct *tty, const u8 *buf, 764 + size_t count) 765 765 { 766 766 struct sdio_uart_port *port = tty->driver_data; 767 767 int ret;
+1 -1
drivers/net/caif/caif_serial.c
··· 159 159 #endif 160 160 161 161 static void ldisc_receive(struct tty_struct *tty, const u8 *data, 162 - const char *flags, int count) 162 + const u8 *flags, size_t count) 163 163 { 164 164 struct sk_buff *skb = NULL; 165 165 struct ser_device *ser;
+20 -27
drivers/net/can/can327.c
··· 885 885 * This will not be re-entered while running, but other ldisc 886 886 * functions may be called in parallel. 887 887 */ 888 - static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp, 889 - const char *fp, int count) 888 + static void can327_ldisc_rx(struct tty_struct *tty, const u8 *cp, 889 + const u8 *fp, size_t count) 890 890 { 891 - struct can327 *elm = (struct can327 *)tty->disc_data; 891 + struct can327 *elm = tty->disc_data; 892 892 size_t first_new_char_idx; 893 893 894 894 if (elm->uart_side_failure) ··· 901 901 */ 902 902 first_new_char_idx = elm->rxfill; 903 903 904 - while (count-- && elm->rxfill < CAN327_SIZE_RXBUF) { 904 + while (count--) { 905 + if (elm->rxfill >= CAN327_SIZE_RXBUF) { 906 + netdev_err(elm->dev, 907 + "Receive buffer overflowed. Bad chip or wiring? count = %zu", 908 + count); 909 + goto uart_failure; 910 + } 905 911 if (fp && *fp++) { 906 912 netdev_err(elm->dev, 907 913 "Error in received character stream. Check your wiring."); 908 - 909 - can327_uart_side_failure(elm); 910 - 911 - spin_unlock_bh(&elm->lock); 912 - return; 914 + goto uart_failure; 913 915 } 914 916 915 917 /* Ignore NUL characters, which the PIC microcontroller may ··· 927 925 netdev_err(elm->dev, 928 926 "Received illegal character %02x.\n", 929 927 *cp); 930 - can327_uart_side_failure(elm); 931 - 932 - spin_unlock_bh(&elm->lock); 933 - return; 928 + goto uart_failure; 934 929 } 935 930 936 931 elm->rxbuf[elm->rxfill++] = *cp; ··· 936 937 cp++; 937 938 } 938 939 939 - if (count >= 0) { 940 - netdev_err(elm->dev, 941 - "Receive buffer overflowed. Bad chip or wiring? count = %i", 942 - count); 943 - 944 - can327_uart_side_failure(elm); 945 - 946 - spin_unlock_bh(&elm->lock); 947 - return; 948 - } 949 - 950 940 can327_parse_rxbuf(elm, first_new_char_idx); 941 + spin_unlock_bh(&elm->lock); 942 + 943 + return; 944 + uart_failure: 945 + can327_uart_side_failure(elm); 951 946 spin_unlock_bh(&elm->lock); 952 947 } 953 948 ··· 983 990 /* Called by the driver when there's room for more data. */ 984 991 static void can327_ldisc_tx_wakeup(struct tty_struct *tty) 985 992 { 986 - struct can327 *elm = (struct can327 *)tty->disc_data; 993 + struct can327 *elm = tty->disc_data; 987 994 988 995 schedule_work(&elm->tx_work); 989 996 } ··· 1060 1067 */ 1061 1068 static void can327_ldisc_close(struct tty_struct *tty) 1062 1069 { 1063 - struct can327 *elm = (struct can327 *)tty->disc_data; 1070 + struct can327 *elm = tty->disc_data; 1064 1071 1065 1072 /* unregister_netdev() calls .ndo_stop() so we don't have to. */ 1066 1073 unregister_candev(elm->dev); ··· 1085 1092 static int can327_ldisc_ioctl(struct tty_struct *tty, unsigned int cmd, 1086 1093 unsigned long arg) 1087 1094 { 1088 - struct can327 *elm = (struct can327 *)tty->disc_data; 1095 + struct can327 *elm = tty->disc_data; 1089 1096 unsigned int tmp; 1090 1097 1091 1098 switch (cmd) {
+1 -6
drivers/net/can/sja1000/ems_pci.c
··· 108 108 109 109 #define EMS_PCI_BASE_SIZE 4096 /* size of controller area */ 110 110 111 - #ifndef PCI_VENDOR_ID_ASIX 112 - #define PCI_VENDOR_ID_ASIX 0x125b 113 - #define PCI_DEVICE_ID_ASIX_9110 0x9110 114 - #define PCI_SUBVENDOR_ID_ASIX 0xa000 115 - #endif 116 111 #define PCI_SUBDEVICE_ID_EMS 0x4010 117 112 118 113 static const struct pci_device_id ems_pci_tbl[] = { ··· 118 123 /* CPC-104P v2 */ 119 124 {PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9030, PCI_VENDOR_ID_PLX, 0x4002}, 120 125 /* CPC-PCIe v3 */ 121 - {PCI_VENDOR_ID_ASIX, PCI_DEVICE_ID_ASIX_9110, PCI_SUBVENDOR_ID_ASIX, PCI_SUBDEVICE_ID_EMS}, 126 + {PCI_VENDOR_ID_ASIX, PCI_DEVICE_ID_ASIX_AX99100_LB, 0xa000, PCI_SUBDEVICE_ID_EMS}, 122 127 {0,} 123 128 }; 124 129 MODULE_DEVICE_TABLE(pci, ems_pci_tbl);
+6 -7
drivers/net/can/slcan/slcan-core.c
··· 583 583 */ 584 584 static void slcan_write_wakeup(struct tty_struct *tty) 585 585 { 586 - struct slcan *sl = (struct slcan *)tty->disc_data; 586 + struct slcan *sl = tty->disc_data; 587 587 588 588 schedule_work(&sl->tx_work); 589 589 } ··· 774 774 * be re-entered while running but other ldisc functions may be called 775 775 * in parallel 776 776 */ 777 - static void slcan_receive_buf(struct tty_struct *tty, 778 - const unsigned char *cp, const char *fp, 779 - int count) 777 + static void slcan_receive_buf(struct tty_struct *tty, const u8 *cp, 778 + const u8 *fp, size_t count) 780 779 { 781 - struct slcan *sl = (struct slcan *)tty->disc_data; 780 + struct slcan *sl = tty->disc_data; 782 781 783 782 if (!netif_running(sl->dev)) 784 783 return; ··· 861 862 */ 862 863 static void slcan_close(struct tty_struct *tty) 863 864 { 864 - struct slcan *sl = (struct slcan *)tty->disc_data; 865 + struct slcan *sl = tty->disc_data; 865 866 866 867 unregister_candev(sl->dev); 867 868 ··· 885 886 static int slcan_ioctl(struct tty_struct *tty, unsigned int cmd, 886 887 unsigned long arg) 887 888 { 888 - struct slcan *sl = (struct slcan *)tty->disc_data; 889 + struct slcan *sl = tty->disc_data; 889 890 unsigned int tmp; 890 891 891 892 switch (cmd) {
+2 -2
drivers/net/hamradio/6pack.c
··· 427 427 * a block of 6pack data has been received, which can now be decapsulated 428 428 * and sent on to some IP layer for further processing. 429 429 */ 430 - static void sixpack_receive_buf(struct tty_struct *tty, 431 - const unsigned char *cp, const char *fp, int count) 430 + static void sixpack_receive_buf(struct tty_struct *tty, const u8 *cp, 431 + const u8 *fp, size_t count) 432 432 { 433 433 struct sixpack *sp; 434 434 int count1;
+2 -2
drivers/net/hamradio/mkiss.c
··· 874 874 * a block of data has been received, which can now be decapsulated 875 875 * and sent on to the AX.25 layer for further processing. 876 876 */ 877 - static void mkiss_receive_buf(struct tty_struct *tty, const unsigned char *cp, 878 - const char *fp, int count) 877 + static void mkiss_receive_buf(struct tty_struct *tty, const u8 *cp, 878 + const u8 *fp, size_t count) 879 879 { 880 880 struct mkiss *ax = mkiss_get(tty); 881 881
+2 -3
drivers/net/mctp/mctp-serial.c
··· 390 390 } 391 391 } 392 392 393 - static void mctp_serial_tty_receive_buf(struct tty_struct *tty, 394 - const unsigned char *c, 395 - const char *f, int len) 393 + static void mctp_serial_tty_receive_buf(struct tty_struct *tty, const u8 *c, 394 + const u8 *f, size_t len) 396 395 { 397 396 struct mctp_serial *dev = tty->disc_data; 398 397 int i;
+8 -18
drivers/net/ppp/ppp_async.c
··· 98 98 static int ppp_async_push(struct asyncppp *ap); 99 99 static void ppp_async_flush_output(struct asyncppp *ap); 100 100 static void ppp_async_input(struct asyncppp *ap, const unsigned char *buf, 101 - const char *flags, int count); 101 + const u8 *flags, int count); 102 102 static int ppp_async_ioctl(struct ppp_channel *chan, unsigned int cmd, 103 103 unsigned long arg); 104 104 static void ppp_async_process(struct tasklet_struct *t); ··· 257 257 * Pppd reads and writes packets via /dev/ppp instead. 258 258 */ 259 259 static ssize_t 260 - ppp_asynctty_read(struct tty_struct *tty, struct file *file, 261 - unsigned char *buf, size_t count, 262 - void **cookie, unsigned long offset) 260 + ppp_asynctty_read(struct tty_struct *tty, struct file *file, u8 *buf, 261 + size_t count, void **cookie, unsigned long offset) 263 262 { 264 263 return -EAGAIN; 265 264 } ··· 268 269 * from the ppp generic stuff. 269 270 */ 270 271 static ssize_t 271 - ppp_asynctty_write(struct tty_struct *tty, struct file *file, 272 - const unsigned char *buf, size_t count) 272 + ppp_asynctty_write(struct tty_struct *tty, struct file *file, const u8 *buf, 273 + size_t count) 273 274 { 274 275 return -EAGAIN; 275 276 } ··· 327 328 return err; 328 329 } 329 330 330 - /* No kernel lock - fine */ 331 - static __poll_t 332 - ppp_asynctty_poll(struct tty_struct *tty, struct file *file, poll_table *wait) 333 - { 334 - return 0; 335 - } 336 - 337 331 /* May sleep, don't call from interrupt level or with interrupts disabled */ 338 332 static void 339 - ppp_asynctty_receive(struct tty_struct *tty, const unsigned char *buf, 340 - const char *cflags, int count) 333 + ppp_asynctty_receive(struct tty_struct *tty, const u8 *buf, const u8 *cflags, 334 + size_t count) 341 335 { 342 336 struct asyncppp *ap = ap_get(tty); 343 337 unsigned long flags; ··· 370 378 .read = ppp_asynctty_read, 371 379 .write = ppp_asynctty_write, 372 380 .ioctl = ppp_asynctty_ioctl, 373 - .poll = ppp_asynctty_poll, 374 381 .receive_buf = ppp_asynctty_receive, 375 382 .write_wakeup = ppp_asynctty_wakeup, 376 383 }; ··· 818 827 other ldisc functions but will not be re-entered */ 819 828 820 829 static void 821 - ppp_async_input(struct asyncppp *ap, const unsigned char *buf, 822 - const char *flags, int count) 830 + ppp_async_input(struct asyncppp *ap, const u8 *buf, const u8 *flags, int count) 823 831 { 824 832 struct sk_buff *skb; 825 833 int c, i, j, n, s, f;
+8 -18
drivers/net/ppp/ppp_synctty.c
··· 93 93 static void ppp_sync_process(struct tasklet_struct *t); 94 94 static int ppp_sync_push(struct syncppp *ap); 95 95 static void ppp_sync_flush_output(struct syncppp *ap); 96 - static void ppp_sync_input(struct syncppp *ap, const unsigned char *buf, 97 - const char *flags, int count); 96 + static void ppp_sync_input(struct syncppp *ap, const u8 *buf, const u8 *flags, 97 + int count); 98 98 99 99 static const struct ppp_channel_ops sync_ops = { 100 100 .start_xmit = ppp_sync_send, ··· 255 255 * Pppd reads and writes packets via /dev/ppp instead. 256 256 */ 257 257 static ssize_t 258 - ppp_sync_read(struct tty_struct *tty, struct file *file, 259 - unsigned char *buf, size_t count, 258 + ppp_sync_read(struct tty_struct *tty, struct file *file, u8 *buf, size_t count, 260 259 void **cookie, unsigned long offset) 261 260 { 262 261 return -EAGAIN; ··· 266 267 * from the ppp generic stuff. 267 268 */ 268 269 static ssize_t 269 - ppp_sync_write(struct tty_struct *tty, struct file *file, 270 - const unsigned char *buf, size_t count) 270 + ppp_sync_write(struct tty_struct *tty, struct file *file, const u8 *buf, 271 + size_t count) 271 272 { 272 273 return -EAGAIN; 273 274 } ··· 320 321 return err; 321 322 } 322 323 323 - /* No kernel lock - fine */ 324 - static __poll_t 325 - ppp_sync_poll(struct tty_struct *tty, struct file *file, poll_table *wait) 326 - { 327 - return 0; 328 - } 329 - 330 324 /* May sleep, don't call from interrupt level or with interrupts disabled */ 331 325 static void 332 - ppp_sync_receive(struct tty_struct *tty, const unsigned char *buf, 333 - const char *cflags, int count) 326 + ppp_sync_receive(struct tty_struct *tty, const u8 *buf, const u8 *cflags, 327 + size_t count) 334 328 { 335 329 struct syncppp *ap = sp_get(tty); 336 330 unsigned long flags; ··· 363 371 .read = ppp_sync_read, 364 372 .write = ppp_sync_write, 365 373 .ioctl = ppp_synctty_ioctl, 366 - .poll = ppp_sync_poll, 367 374 .receive_buf = ppp_sync_receive, 368 375 .write_wakeup = ppp_sync_wakeup, 369 376 }; ··· 654 663 * frame is considered to be in error and is tossed. 655 664 */ 656 665 static void 657 - ppp_sync_input(struct syncppp *ap, const unsigned char *buf, 658 - const char *flags, int count) 666 + ppp_sync_input(struct syncppp *ap, const u8 *buf, const u8 *flags, int count) 659 667 { 660 668 struct sk_buff *skb; 661 669 unsigned char *p;
+2 -2
drivers/net/slip/slip.c
··· 685 685 * in parallel 686 686 */ 687 687 688 - static void slip_receive_buf(struct tty_struct *tty, const unsigned char *cp, 689 - const char *fp, int count) 688 + static void slip_receive_buf(struct tty_struct *tty, const u8 *cp, const u8 *fp, 689 + size_t count) 690 690 { 691 691 struct slip *sl = tty->disc_data; 692 692
+7 -13
drivers/net/usb/hso.c
··· 1322 1322 } 1323 1323 1324 1324 /* close the requested serial port */ 1325 - static int hso_serial_write(struct tty_struct *tty, const unsigned char *buf, 1326 - int count) 1325 + static ssize_t hso_serial_write(struct tty_struct *tty, const u8 *buf, 1326 + size_t count) 1327 1327 { 1328 1328 struct hso_serial *serial = tty->driver_data; 1329 - int space, tx_bytes; 1330 1329 unsigned long flags; 1331 1330 1332 1331 /* sanity check */ ··· 1336 1337 1337 1338 spin_lock_irqsave(&serial->serial_lock, flags); 1338 1339 1339 - space = serial->tx_data_length - serial->tx_buffer_count; 1340 - tx_bytes = (count < space) ? count : space; 1340 + count = min_t(size_t, serial->tx_data_length - serial->tx_buffer_count, 1341 + count); 1342 + memcpy(serial->tx_buffer + serial->tx_buffer_count, buf, count); 1343 + serial->tx_buffer_count += count; 1341 1344 1342 - if (!tx_bytes) 1343 - goto out; 1344 - 1345 - memcpy(serial->tx_buffer + serial->tx_buffer_count, buf, tx_bytes); 1346 - serial->tx_buffer_count += tx_bytes; 1347 - 1348 - out: 1349 1345 spin_unlock_irqrestore(&serial->serial_lock, flags); 1350 1346 1351 1347 hso_kick_transmit(serial); 1352 1348 /* done */ 1353 - return tx_bytes; 1349 + return count; 1354 1350 } 1355 1351 1356 1352 /* how much room is there for writing */
+5
drivers/parport/parport_pc.c
··· 2655 2655 netmos_9815, 2656 2656 netmos_9901, 2657 2657 netmos_9865, 2658 + asix_ax99100, 2658 2659 quatech_sppxp100, 2659 2660 wch_ch382l, 2660 2661 }; ··· 2734 2733 /* netmos_9815 */ { 2, { { 0, 1 }, { 2, 3 }, } }, 2735 2734 /* netmos_9901 */ { 1, { { 0, -1 }, } }, 2736 2735 /* netmos_9865 */ { 1, { { 0, -1 }, } }, 2736 + /* asix_ax99100 */ { 1, { { 0, 1 }, } }, 2737 2737 /* quatech_sppxp100 */ { 1, { { 0, 1 }, } }, 2738 2738 /* wch_ch382l */ { 1, { { 2, -1 }, } }, 2739 2739 }; ··· 2825 2823 0xA000, 0x1000, 0, 0, netmos_9865 }, 2826 2824 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9865, 2827 2825 0xA000, 0x2000, 0, 0, netmos_9865 }, 2826 + /* ASIX AX99100 PCIe to Multi I/O Controller */ 2827 + { PCI_VENDOR_ID_ASIX, PCI_DEVICE_ID_ASIX_AX99100, 2828 + 0xA000, 0x2000, 0, 0, asix_ax99100 }, 2828 2829 /* Quatech SPPXP-100 Parallel port PCI ExpressCard */ 2829 2830 { PCI_VENDOR_ID_QUATECH, PCI_DEVICE_ID_QUATECH_SPPXP_100, 2830 2831 PCI_ANY_ID, PCI_ANY_ID, 0, 0, quatech_sppxp100 },
+3 -3
drivers/s390/char/con3215.c
··· 1021 1021 /* 1022 1022 * String write routine for 3215 ttys 1023 1023 */ 1024 - static int tty3215_write(struct tty_struct *tty, 1025 - const unsigned char *buf, int count) 1024 + static ssize_t tty3215_write(struct tty_struct *tty, const u8 *buf, 1025 + size_t count) 1026 1026 { 1027 1027 handle_write(tty->driver_data, buf, count); 1028 1028 return count; ··· 1031 1031 /* 1032 1032 * Put character routine for 3215 ttys 1033 1033 */ 1034 - static int tty3215_put_char(struct tty_struct *tty, unsigned char ch) 1034 + static int tty3215_put_char(struct tty_struct *tty, u8 ch) 1035 1035 { 1036 1036 struct raw3215_info *raw = tty->driver_data; 1037 1037
+3 -3
drivers/s390/char/con3270.c
··· 1803 1803 /* 1804 1804 * String write routine for 3270 ttys 1805 1805 */ 1806 - static int tty3270_write(struct tty_struct *tty, 1807 - const unsigned char *buf, int count) 1806 + static ssize_t tty3270_write(struct tty_struct *tty, const u8 *buf, 1807 + size_t count) 1808 1808 { 1809 1809 struct tty3270 *tp; 1810 1810 ··· 1822 1822 /* 1823 1823 * Put single characters to the ttys character buffer 1824 1824 */ 1825 - static int tty3270_put_char(struct tty_struct *tty, unsigned char ch) 1825 + static int tty3270_put_char(struct tty_struct *tty, u8 ch) 1826 1826 { 1827 1827 struct tty3270 *tp; 1828 1828
+5 -5
drivers/s390/char/sclp_tty.c
··· 48 48 static struct timer_list sclp_tty_timer; 49 49 50 50 static struct tty_port sclp_port; 51 - static unsigned char sclp_tty_chars[SCLP_TTY_BUF_SIZE]; 51 + static u8 sclp_tty_chars[SCLP_TTY_BUF_SIZE]; 52 52 static unsigned short int sclp_tty_chars_count; 53 53 54 54 struct tty_driver *sclp_tty_driver; ··· 168 168 /* 169 169 * Write a string to the sclp tty. 170 170 */ 171 - static int sclp_tty_write_string(const unsigned char *str, int count, int may_fail) 171 + static int sclp_tty_write_string(const u8 *str, int count, int may_fail) 172 172 { 173 173 unsigned long flags; 174 174 void *page; ··· 229 229 * tty device. The characters may come from user space or kernel space. This 230 230 * routine will return the number of characters actually accepted for writing. 231 231 */ 232 - static int 233 - sclp_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) 232 + static ssize_t 233 + sclp_tty_write(struct tty_struct *tty, const u8 *buf, size_t count) 234 234 { 235 235 if (sclp_tty_chars_count > 0) { 236 236 sclp_tty_write_string(sclp_tty_chars, sclp_tty_chars_count, 0); ··· 250 250 * sclp_write() without final '\n' - will be written. 251 251 */ 252 252 static int 253 - sclp_tty_put_char(struct tty_struct *tty, unsigned char ch) 253 + sclp_tty_put_char(struct tty_struct *tty, u8 ch) 254 254 { 255 255 sclp_tty_chars[sclp_tty_chars_count++] = ch; 256 256 if (ch == '\n' || sclp_tty_chars_count >= SCLP_TTY_BUF_SIZE) {
+3 -3
drivers/s390/char/sclp_vt220.c
··· 462 462 * user space or kernel space. This routine will return the 463 463 * number of characters actually accepted for writing. 464 464 */ 465 - static int 466 - sclp_vt220_write(struct tty_struct *tty, const unsigned char *buf, int count) 465 + static ssize_t 466 + sclp_vt220_write(struct tty_struct *tty, const u8 *buf, size_t count) 467 467 { 468 468 return __sclp_vt220_write(buf, count, 1, 0, 1); 469 469 } ··· 579 579 * done stuffing characters into the driver. 580 580 */ 581 581 static int 582 - sclp_vt220_put_char(struct tty_struct *tty, unsigned char ch) 582 + sclp_vt220_put_char(struct tty_struct *tty, u8 ch) 583 583 { 584 584 return __sclp_vt220_write(&ch, 1, 0, 0, 1); 585 585 }
+5 -12
drivers/staging/gdm724x/gdm_tty.c
··· 149 149 tty_port_tty_wakeup(&gdm->port); 150 150 } 151 151 152 - static int gdm_tty_write(struct tty_struct *tty, const unsigned char *buf, 153 - int len) 152 + static ssize_t gdm_tty_write(struct tty_struct *tty, const u8 *buf, size_t len) 154 153 { 155 154 struct gdm *gdm = tty->driver_data; 156 - int remain = len; 157 - int sent_len = 0; 158 - int sending_len = 0; 155 + size_t remain = len; 156 + size_t sent_len = 0; 159 157 160 158 if (!gdm_tty_ready(gdm)) 161 159 return -ENODEV; 162 160 163 - if (!len) 164 - return 0; 165 - 166 - while (1) { 167 - sending_len = min(MUX_TX_MAX_SIZE, remain); 161 + while (remain) { 162 + size_t sending_len = min_t(size_t, MUX_TX_MAX_SIZE, remain); 168 163 gdm->tty_dev->send_func(gdm->tty_dev->priv_dev, 169 164 (void *)(buf + sent_len), 170 165 sending_len, ··· 168 173 gdm); 169 174 sent_len += sending_len; 170 175 remain -= sending_len; 171 - if (remain <= 0) 172 - break; 173 176 } 174 177 175 178 return len;
+1 -2
drivers/staging/greybus/uart.c
··· 427 427 tty_port_hangup(&gb_tty->port); 428 428 } 429 429 430 - static int gb_tty_write(struct tty_struct *tty, const unsigned char *buf, 431 - int count) 430 + static ssize_t gb_tty_write(struct tty_struct *tty, const u8 *buf, size_t count) 432 431 { 433 432 struct gb_tty *gb_tty = tty->driver_data; 434 433
+1
drivers/tty/Kconfig
··· 239 239 config SYNCLINK_GT 240 240 tristate "SyncLink GT/AC support" 241 241 depends on SERIAL_NONSTANDARD && PCI 242 + depends on BROKEN 242 243 help 243 244 Support for SyncLink GT and SyncLink AC families of 244 245 synchronous and asynchronous serial adapters
+2 -2
drivers/tty/amiserial.c
··· 696 696 local_irq_restore(flags); 697 697 } 698 698 699 - static int rs_put_char(struct tty_struct *tty, unsigned char ch) 699 + static int rs_put_char(struct tty_struct *tty, u8 ch) 700 700 { 701 701 struct serial_state *info; 702 702 unsigned long flags; ··· 741 741 local_irq_restore(flags); 742 742 } 743 743 744 - static int rs_write(struct tty_struct * tty, const unsigned char *buf, int count) 744 + static ssize_t rs_write(struct tty_struct * tty, const u8 *buf, size_t count) 745 745 { 746 746 int c, ret = 0; 747 747 struct serial_state *info = tty->driver_data;
+2 -2
drivers/tty/ehv_bytechan.c
··· 466 466 * ehv_bc_tty_write_room() will never lie, so the tty layer will never send us 467 467 * too much data. 468 468 */ 469 - static int ehv_bc_tty_write(struct tty_struct *ttys, const unsigned char *s, 470 - int count) 469 + static ssize_t ehv_bc_tty_write(struct tty_struct *ttys, const u8 *s, 470 + size_t count) 471 471 { 472 472 struct ehv_bc_data *bc = ttys->driver_data; 473 473 unsigned long flags;
+3 -4
drivers/tty/goldfish.c
··· 125 125 } 126 126 } 127 127 128 - static void goldfish_tty_do_write(int line, const char *buf, 129 - unsigned int count) 128 + static void goldfish_tty_do_write(int line, const u8 *buf, unsigned int count) 130 129 { 131 130 struct goldfish_tty *qtty = &goldfish_ttys[line]; 132 131 unsigned long address = (unsigned long)(void *)buf; ··· 185 186 tty_port_hangup(tty->port); 186 187 } 187 188 188 - static int goldfish_tty_write(struct tty_struct *tty, const unsigned char *buf, 189 - int count) 189 + static ssize_t goldfish_tty_write(struct tty_struct *tty, const u8 *buf, 190 + size_t count) 190 191 { 191 192 goldfish_tty_do_write(tty->index, buf, count); 192 193 return count;
+2 -2
drivers/tty/hvc/hvc_console.c
··· 496 496 return n; 497 497 } 498 498 499 - static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count) 499 + static ssize_t hvc_write(struct tty_struct *tty, const u8 *buf, size_t count) 500 500 { 501 501 struct hvc_struct *hp = tty->driver_data; 502 502 unsigned long flags; 503 - int rsize, written = 0; 503 + size_t rsize, written = 0; 504 504 505 505 /* This write was probably executed during a tty close. */ 506 506 if (!hp)
+1 -1
drivers/tty/hvc/hvc_opal.c
··· 14 14 #include <linux/console.h> 15 15 #include <linux/of.h> 16 16 #include <linux/of_irq.h> 17 - #include <linux/of_platform.h> 17 + #include <linux/platform_device.h> 18 18 #include <linux/export.h> 19 19 #include <linux/interrupt.h> 20 20
+5 -5
drivers/tty/hvc/hvcs.c
··· 1257 1257 * tty_hangup will allow hvcs_write time to complete execution before it 1258 1258 * terminates our device. 1259 1259 */ 1260 - static int hvcs_write(struct tty_struct *tty, 1261 - const unsigned char *buf, int count) 1260 + static ssize_t hvcs_write(struct tty_struct *tty, const u8 *buf, size_t count) 1262 1261 { 1263 1262 struct hvcs_struct *hvcsd = tty->driver_data; 1264 1263 unsigned int unit_address; 1265 1264 const unsigned char *charbuf; 1266 1265 unsigned long flags; 1267 - int total_sent = 0; 1268 - int tosend = 0; 1266 + size_t total_sent = 0; 1267 + size_t tosend = 0; 1269 1268 int result = 0; 1270 1269 1271 1270 /* ··· 1299 1300 unit_address = hvcsd->vdev->unit_address; 1300 1301 1301 1302 while (count > 0) { 1302 - tosend = min(count, (HVCS_BUFF_LEN - hvcsd->chars_in_buffer)); 1303 + tosend = min_t(size_t, count, 1304 + (HVCS_BUFF_LEN - hvcsd->chars_in_buffer)); 1303 1305 /* 1304 1306 * No more space, this probably means that the last call to 1305 1307 * hvcs_write() didn't succeed and the buffer was filled up.
+7 -8
drivers/tty/hvc/hvsi.c
··· 904 904 return hp->n_outbuf; 905 905 } 906 906 907 - static int hvsi_write(struct tty_struct *tty, 908 - const unsigned char *buf, int count) 907 + static ssize_t hvsi_write(struct tty_struct *tty, const u8 *source, 908 + size_t count) 909 909 { 910 910 struct hvsi_struct *hp = tty->driver_data; 911 - const char *source = buf; 912 911 unsigned long flags; 913 - int total = 0; 914 - int origcount = count; 912 + size_t total = 0; 913 + size_t origcount = count; 915 914 916 915 spin_lock_irqsave(&hp->lock, flags); 917 916 ··· 928 929 * will see there is no room in outbuf and return. 929 930 */ 930 931 while ((count > 0) && (hvsi_write_room(tty) > 0)) { 931 - int chunksize = min_t(int, count, hvsi_write_room(tty)); 932 + size_t chunksize = min_t(size_t, count, hvsi_write_room(tty)); 932 933 933 934 BUG_ON(hp->n_outbuf < 0); 934 935 memcpy(hp->outbuf + hp->n_outbuf, source, chunksize); ··· 952 953 spin_unlock_irqrestore(&hp->lock, flags); 953 954 954 955 if (total != origcount) 955 - pr_debug("%s: wanted %i, only wrote %i\n", __func__, origcount, 956 - total); 956 + pr_debug("%s: wanted %zu, only wrote %zu\n", __func__, 957 + origcount, total); 957 958 958 959 return total; 959 960 }
+1 -1
drivers/tty/ipwireless/hardware.c
··· 1292 1292 } 1293 1293 1294 1294 int ipwireless_send_packet(struct ipw_hardware *hw, unsigned int channel_idx, 1295 - const unsigned char *data, unsigned int length, 1295 + const u8 *data, unsigned int length, 1296 1296 void (*callback) (void *cb, unsigned int length), 1297 1297 void *callback_data) 1298 1298 {
+2 -2
drivers/tty/ipwireless/tty.c
··· 186 186 tty->tx_bytes_queued -= packet_length; 187 187 } 188 188 189 - static int ipw_write(struct tty_struct *linux_tty, 190 - const unsigned char *buf, int count) 189 + static ssize_t ipw_write(struct tty_struct *linux_tty, const u8 *buf, 190 + size_t count) 191 191 { 192 192 struct ipw_tty *tty = linux_tty->driver_data; 193 193 int room, ret;
+3 -3
drivers/tty/mips_ejtag_fdc.c
··· 796 796 tty_port_hangup(tty->port); 797 797 } 798 798 799 - static int mips_ejtag_fdc_tty_write(struct tty_struct *tty, 800 - const unsigned char *buf, int total) 799 + static ssize_t mips_ejtag_fdc_tty_write(struct tty_struct *tty, const u8 *buf, 800 + size_t total) 801 801 { 802 802 int count, block; 803 803 struct mips_ejtag_fdc_tty_port *dport = tty->driver_data; ··· 816 816 */ 817 817 spin_lock(&dport->xmit_lock); 818 818 /* Work out how many bytes we can write to the xmit buffer */ 819 - total = min(total, (int)(priv->xmit_size - dport->xmit_cnt)); 819 + total = min_t(size_t, total, priv->xmit_size - dport->xmit_cnt); 820 820 atomic_add(total, &priv->xmit_total); 821 821 dport->xmit_cnt += total; 822 822 /* Write the actual bytes (may need splitting if it wraps) */
+3 -5
drivers/tty/moxa.c
··· 487 487 */ 488 488 static int moxa_open(struct tty_struct *, struct file *); 489 489 static void moxa_close(struct tty_struct *, struct file *); 490 - static int moxa_write(struct tty_struct *, const unsigned char *, int); 490 + static ssize_t moxa_write(struct tty_struct *, const u8 *, size_t); 491 491 static unsigned int moxa_write_room(struct tty_struct *); 492 492 static void moxa_flush_buffer(struct tty_struct *); 493 493 static unsigned int moxa_chars_in_buffer(struct tty_struct *); ··· 1499 1499 tty_port_close(&ch->port, tty, filp); 1500 1500 } 1501 1501 1502 - static int moxa_write(struct tty_struct *tty, 1503 - const unsigned char *buf, int count) 1502 + static ssize_t moxa_write(struct tty_struct *tty, const u8 *buf, size_t count) 1504 1503 { 1505 1504 struct moxa_port *ch = tty->driver_data; 1506 1505 unsigned long flags; ··· 2163 2164 return val; 2164 2165 } 2165 2166 2166 - static int MoxaPortWriteData(struct tty_struct *tty, 2167 - const unsigned char *buffer, int len) 2167 + static int MoxaPortWriteData(struct tty_struct *tty, const u8 *buffer, int len) 2168 2168 { 2169 2169 struct moxa_port *port = tty->driver_data; 2170 2170 void __iomem *baseAddr, *ofsAddr, *ofs;
+2 -2
drivers/tty/mxser.c
··· 901 901 tty_port_close(tty->port, tty, filp); 902 902 } 903 903 904 - static int mxser_write(struct tty_struct *tty, const unsigned char *buf, int count) 904 + static ssize_t mxser_write(struct tty_struct *tty, const u8 *buf, size_t count) 905 905 { 906 906 struct mxser_port *info = tty->driver_data; 907 907 unsigned long flags; ··· 920 920 return written; 921 921 } 922 922 923 - static int mxser_put_char(struct tty_struct *tty, unsigned char ch) 923 + static int mxser_put_char(struct tty_struct *tty, u8 ch) 924 924 { 925 925 struct mxser_port *info = tty->driver_data; 926 926 unsigned long flags;
+69 -20
drivers/tty/n_gsm.c
··· 339 339 unsigned long bad_fcs; 340 340 unsigned long malformed; 341 341 unsigned long io_error; 342 + unsigned long open_error; 342 343 unsigned long bad_size; 343 344 unsigned long unsupported; 344 345 }; ··· 1451 1450 int dlen) 1452 1451 { 1453 1452 struct gsm_msg *msg; 1453 + struct gsm_dlci *dlci = gsm->dlci[0]; 1454 1454 1455 - msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->dlci[0]->ftype); 1455 + msg = gsm_data_alloc(gsm, 0, dlen + 2, dlci->ftype); 1456 1456 if (msg == NULL) 1457 1457 return -ENOMEM; 1458 1458 1459 1459 msg->data[0] = (cmd << 1) | CR | EA; /* Set C/R */ 1460 1460 msg->data[1] = (dlen << 1) | EA; 1461 1461 memcpy(msg->data + 2, data, dlen); 1462 - gsm_data_queue(gsm->dlci[0], msg); 1462 + gsm_data_queue(dlci, msg); 1463 1463 1464 1464 return 0; 1465 1465 } ··· 1479 1477 int dlen) 1480 1478 { 1481 1479 struct gsm_msg *msg; 1480 + struct gsm_dlci *dlci = gsm->dlci[0]; 1482 1481 1483 - msg = gsm_data_alloc(gsm, 0, dlen + 2, gsm->dlci[0]->ftype); 1482 + msg = gsm_data_alloc(gsm, 0, dlen + 2, dlci->ftype); 1484 1483 if (msg == NULL) 1485 1484 return; 1486 1485 msg->data[0] = (cmd & 0xFE) << 1 | EA; /* Clear C/R */ 1487 1486 msg->data[1] = (dlen << 1) | EA; 1488 1487 memcpy(msg->data + 2, data, dlen); 1489 - gsm_data_queue(gsm->dlci[0], msg); 1488 + gsm_data_queue(dlci, msg); 1490 1489 } 1491 1490 1492 1491 /** ··· 1592 1589 if (debug & DBG_ERRORS) 1593 1590 pr_info("%s unsupported I frame request in PN\n", 1594 1591 __func__); 1592 + gsm->unsupported++; 1595 1593 return -EINVAL; 1596 1594 default: 1597 1595 if (debug & DBG_ERRORS) ··· 1734 1730 struct gsm_dlci *dlci; 1735 1731 struct gsm_dlci_param_bits *params; 1736 1732 1737 - if (dlen < sizeof(struct gsm_dlci_param_bits)) 1733 + if (dlen < sizeof(struct gsm_dlci_param_bits)) { 1734 + gsm->open_error++; 1738 1735 return; 1736 + } 1739 1737 1740 1738 /* Invalid DLCI? */ 1741 1739 params = (struct gsm_dlci_param_bits *)data; 1742 1740 addr = FIELD_GET(PN_D_FIELD_DLCI, params->d_bits); 1743 - if (addr == 0 || addr >= NUM_DLCI || !gsm->dlci[addr]) 1741 + if (addr == 0 || addr >= NUM_DLCI || !gsm->dlci[addr]) { 1742 + gsm->open_error++; 1744 1743 return; 1744 + } 1745 1745 dlci = gsm->dlci[addr]; 1746 1746 1747 1747 /* Too late for parameter negotiation? */ 1748 - if ((!cr && dlci->state == DLCI_OPENING) || dlci->state == DLCI_OPEN) 1748 + if ((!cr && dlci->state == DLCI_OPENING) || dlci->state == DLCI_OPEN) { 1749 + gsm->open_error++; 1749 1750 return; 1751 + } 1750 1752 1751 1753 /* Process the received parameters */ 1752 1754 if (gsm_process_negotiation(gsm, addr, cr, params) != 0) { 1753 1755 /* Negotiation failed. Close the link. */ 1754 1756 if (debug & DBG_ERRORS) 1755 1757 pr_info("%s PN failed\n", __func__); 1758 + gsm->open_error++; 1756 1759 gsm_dlci_close(dlci); 1757 1760 return; 1758 1761 } ··· 1779 1768 } else { 1780 1769 if (debug & DBG_ERRORS) 1781 1770 pr_info("%s PN in invalid state\n", __func__); 1771 + gsm->open_error++; 1782 1772 } 1783 1773 } 1784 1774 ··· 1900 1888 /* Optional unsupported commands */ 1901 1889 case CMD_RPN: /* Remote port negotiation */ 1902 1890 case CMD_SNC: /* Service negotiation command */ 1891 + gsm->unsupported++; 1892 + fallthrough; 1903 1893 default: 1904 1894 /* Reply to bad commands with an NSC */ 1905 1895 buf[0] = command; ··· 2235 2221 dlci->retries--; 2236 2222 mod_timer(&dlci->t1, jiffies + gsm->t1 * HZ / 100); 2237 2223 } else { 2224 + gsm->open_error++; 2238 2225 gsm_dlci_begin_close(dlci); /* prevent half open link */ 2239 2226 } 2240 2227 break; ··· 2251 2236 dlci->mode = DLCI_MODE_ADM; 2252 2237 gsm_dlci_open(dlci); 2253 2238 } else { 2239 + gsm->open_error++; 2254 2240 gsm_dlci_begin_close(dlci); /* prevent half open link */ 2255 2241 } 2256 2242 ··· 2460 2444 data += dlen; 2461 2445 2462 2446 /* Malformed command? */ 2463 - if (clen > len) 2447 + if (clen > len) { 2448 + dlci->gsm->malformed++; 2464 2449 return; 2450 + } 2465 2451 2466 2452 if (command & 1) 2467 2453 gsm_control_message(dlci->gsm, command, data, clen); ··· 2550 2532 return -EINVAL; 2551 2533 if (dc->k > 7) 2552 2534 return -EINVAL; 2535 + if (dc->flags & ~GSM_FL_RESTART) /* allow future extensions */ 2536 + return -EINVAL; 2553 2537 2554 2538 /* 2555 2539 * See what is needed for reconfiguration ··· 2565 2545 need_restart = true; 2566 2546 /* Requires care */ 2567 2547 if (dc->priority != dlci->prio) 2548 + need_restart = true; 2549 + if (dc->flags & GSM_FL_RESTART) 2568 2550 need_restart = true; 2569 2551 2570 2552 if ((open && gsm->wait_config) || need_restart) ··· 2775 2753 2776 2754 switch (gsm->control) { 2777 2755 case SABM|PF: 2778 - if (cr == 1) 2756 + if (cr == 1) { 2757 + gsm->open_error++; 2779 2758 goto invalid; 2759 + } 2780 2760 if (dlci == NULL) 2781 2761 dlci = gsm_dlci_alloc(gsm, address); 2782 - if (dlci == NULL) 2762 + if (dlci == NULL) { 2763 + gsm->open_error++; 2783 2764 return; 2765 + } 2784 2766 if (dlci->dead) 2785 2767 gsm_response(gsm, address, DM|PF); 2786 2768 else { ··· 3302 3276 3303 3277 static int gsm_config(struct gsm_mux *gsm, struct gsm_config *c) 3304 3278 { 3305 - int ret = 0; 3306 3279 int need_close = 0; 3307 3280 int need_restart = 0; 3308 3281 ··· 3380 3355 * and removing from the mux array 3381 3356 */ 3382 3357 if (gsm->dead) { 3383 - ret = gsm_activate_mux(gsm); 3358 + int ret = gsm_activate_mux(gsm); 3384 3359 if (ret) 3385 3360 return ret; 3386 3361 if (gsm->initiator) ··· 3399 3374 3400 3375 static int gsm_config_ext(struct gsm_mux *gsm, struct gsm_config_ext *ce) 3401 3376 { 3377 + bool need_restart = false; 3402 3378 unsigned int i; 3403 3379 3404 3380 /* ··· 3409 3383 for (i = 0; i < ARRAY_SIZE(ce->reserved); i++) 3410 3384 if (ce->reserved[i]) 3411 3385 return -EINVAL; 3386 + if (ce->flags & ~GSM_FL_RESTART) 3387 + return -EINVAL; 3388 + 3389 + /* Requires care */ 3390 + if (ce->flags & GSM_FL_RESTART) 3391 + need_restart = true; 3392 + 3393 + /* 3394 + * Close down what is needed, restart and initiate the new 3395 + * configuration. On the first time there is no DLCI[0] 3396 + * and closing or cleaning up is not necessary. 3397 + */ 3398 + if (need_restart) 3399 + gsm_cleanup_mux(gsm, true); 3412 3400 3413 3401 /* 3414 3402 * Setup the new configuration values 3415 3403 */ 3416 3404 gsm->wait_config = ce->wait_config ? true : false; 3417 3405 gsm->keep_alive = ce->keep_alive; 3406 + 3407 + if (gsm->dead) { 3408 + int ret = gsm_activate_mux(gsm); 3409 + if (ret) 3410 + return ret; 3411 + if (gsm->initiator) 3412 + gsm_dlci_begin_open(gsm->dlci[0]); 3413 + } 3418 3414 3419 3415 return 0; 3420 3416 } ··· 3538 3490 gsm->tty = NULL; 3539 3491 } 3540 3492 3541 - static void gsmld_receive_buf(struct tty_struct *tty, const unsigned char *cp, 3542 - const char *fp, int count) 3493 + static void gsmld_receive_buf(struct tty_struct *tty, const u8 *cp, 3494 + const u8 *fp, size_t count) 3543 3495 { 3544 3496 struct gsm_mux *gsm = tty->disc_data; 3545 3497 char flags = TTY_NORMAL; ··· 3625 3577 { 3626 3578 struct gsm_mux *gsm; 3627 3579 3580 + if (!capable(CAP_NET_ADMIN)) 3581 + return -EPERM; 3582 + 3628 3583 if (tty->ops->write == NULL) 3629 3584 return -EINVAL; 3630 3585 ··· 3687 3636 * This code must be sure never to sleep through a hangup. 3688 3637 */ 3689 3638 3690 - static ssize_t gsmld_read(struct tty_struct *tty, struct file *file, 3691 - unsigned char *buf, size_t nr, 3692 - void **cookie, unsigned long offset) 3639 + static ssize_t gsmld_read(struct tty_struct *tty, struct file *file, u8 *buf, 3640 + size_t nr, void **cookie, unsigned long offset) 3693 3641 { 3694 3642 return -EOPNOTSUPP; 3695 3643 } ··· 3708 3658 */ 3709 3659 3710 3660 static ssize_t gsmld_write(struct tty_struct *tty, struct file *file, 3711 - const unsigned char *buf, size_t nr) 3661 + const u8 *buf, size_t nr) 3712 3662 { 3713 3663 struct gsm_mux *gsm = tty->disc_data; 3714 3664 unsigned long flags; ··· 4304 4254 gsm_dlci_begin_close(dlci); 4305 4255 } 4306 4256 4307 - static int gsmtty_write(struct tty_struct *tty, const unsigned char *buf, 4308 - int len) 4257 + static ssize_t gsmtty_write(struct tty_struct *tty, const u8 *buf, size_t len) 4309 4258 { 4310 4259 int sent; 4311 4260 struct gsm_dlci *dlci = tty->driver_data;
+6 -6
drivers/tty/n_hdlc.c
··· 369 369 * Called by tty low level driver when receive data is available. Data is 370 370 * interpreted as one HDLC frame. 371 371 */ 372 - static void n_hdlc_tty_receive(struct tty_struct *tty, const __u8 *data, 373 - const char *flags, int count) 372 + static void n_hdlc_tty_receive(struct tty_struct *tty, const u8 *data, 373 + const u8 *flags, size_t count) 374 374 { 375 375 register struct n_hdlc *n_hdlc = tty->disc_data; 376 376 register struct n_hdlc_buf *buf; 377 377 378 - pr_debug("%s() called count=%d\n", __func__, count); 378 + pr_debug("%s() called count=%zu\n", __func__, count); 379 379 380 380 if (count > maxframe) { 381 381 pr_debug("rx count>maxframesize, data discarded\n"); ··· 425 425 * Returns the number of bytes returned or error code. 426 426 */ 427 427 static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file, 428 - __u8 *kbuf, size_t nr, 429 - void **cookie, unsigned long offset) 428 + u8 *kbuf, size_t nr, void **cookie, 429 + unsigned long offset) 430 430 { 431 431 struct n_hdlc *n_hdlc = tty->disc_data; 432 432 int ret = 0; ··· 518 518 * Returns the number of bytes written (or error code). 519 519 */ 520 520 static ssize_t n_hdlc_tty_write(struct tty_struct *tty, struct file *file, 521 - const unsigned char *data, size_t count) 521 + const u8 *data, size_t count) 522 522 { 523 523 struct n_hdlc *n_hdlc = tty->disc_data; 524 524 int error = 0;
+3 -22
drivers/tty/n_null.c
··· 10 10 * Copyright (C) Intel 2017 11 11 */ 12 12 13 - static int n_null_open(struct tty_struct *tty) 14 - { 15 - return 0; 16 - } 17 - 18 - static void n_null_close(struct tty_struct *tty) 19 - { 20 - } 21 - 22 - static ssize_t n_null_read(struct tty_struct *tty, struct file *file, 23 - unsigned char *buf, size_t nr, 24 - void **cookie, unsigned long offset) 13 + static ssize_t n_null_read(struct tty_struct *tty, struct file *file, u8 *buf, 14 + size_t nr, void **cookie, unsigned long offset) 25 15 { 26 16 return -EOPNOTSUPP; 27 17 } 28 18 29 19 static ssize_t n_null_write(struct tty_struct *tty, struct file *file, 30 - const unsigned char *buf, size_t nr) 20 + const u8 *buf, size_t nr) 31 21 { 32 22 return -EOPNOTSUPP; 33 - } 34 - 35 - static void n_null_receivebuf(struct tty_struct *tty, 36 - const unsigned char *cp, const char *fp, 37 - int cnt) 38 - { 39 23 } 40 24 41 25 static struct tty_ldisc_ops null_ldisc = { 42 26 .owner = THIS_MODULE, 43 27 .num = N_NULL, 44 28 .name = "n_null", 45 - .open = n_null_open, 46 - .close = n_null_close, 47 29 .read = n_null_read, 48 30 .write = n_null_write, 49 - .receive_buf = n_null_receivebuf 50 31 }; 51 32 52 33 static int __init n_null_init(void)
+315 -298
drivers/tty/n_tty.c
··· 99 99 100 100 /* private to n_tty_receive_overrun (single-threaded) */ 101 101 unsigned long overrun_time; 102 - int num_overrun; 102 + unsigned int num_overrun; 103 103 104 104 /* non-atomic */ 105 105 bool no_room; ··· 109 109 unsigned char push:1; 110 110 111 111 /* shared by producer and consumer */ 112 - char read_buf[N_TTY_BUF_SIZE]; 112 + u8 read_buf[N_TTY_BUF_SIZE]; 113 113 DECLARE_BITMAP(read_flags, N_TTY_BUF_SIZE); 114 - unsigned char echo_buf[N_TTY_BUF_SIZE]; 114 + u8 echo_buf[N_TTY_BUF_SIZE]; 115 115 116 116 /* consumer-published */ 117 117 size_t read_tail; ··· 136 136 return ldata->read_head - ldata->read_tail; 137 137 } 138 138 139 - static inline unsigned char read_buf(struct n_tty_data *ldata, size_t i) 139 + static inline u8 read_buf(struct n_tty_data *ldata, size_t i) 140 140 { 141 - return ldata->read_buf[i & (N_TTY_BUF_SIZE - 1)]; 141 + return ldata->read_buf[MASK(i)]; 142 142 } 143 143 144 - static inline unsigned char *read_buf_addr(struct n_tty_data *ldata, size_t i) 144 + static inline u8 *read_buf_addr(struct n_tty_data *ldata, size_t i) 145 145 { 146 - return &ldata->read_buf[i & (N_TTY_BUF_SIZE - 1)]; 146 + return &ldata->read_buf[MASK(i)]; 147 147 } 148 148 149 - static inline unsigned char echo_buf(struct n_tty_data *ldata, size_t i) 149 + static inline u8 echo_buf(struct n_tty_data *ldata, size_t i) 150 150 { 151 151 smp_rmb(); /* Matches smp_wmb() in add_echo_byte(). */ 152 - return ldata->echo_buf[i & (N_TTY_BUF_SIZE - 1)]; 152 + return ldata->echo_buf[MASK(i)]; 153 153 } 154 154 155 - static inline unsigned char *echo_buf_addr(struct n_tty_data *ldata, size_t i) 155 + static inline u8 *echo_buf_addr(struct n_tty_data *ldata, size_t i) 156 156 { 157 - return &ldata->echo_buf[i & (N_TTY_BUF_SIZE - 1)]; 157 + return &ldata->echo_buf[MASK(i)]; 158 158 } 159 159 160 160 /* If we are not echoing the data, perhaps this is a secret so erase it */ 161 - static void zero_buffer(struct tty_struct *tty, u8 *buffer, int size) 161 + static void zero_buffer(const struct tty_struct *tty, u8 *buffer, size_t size) 162 162 { 163 - bool icanon = !!L_ICANON(tty); 164 - bool no_echo = !L_ECHO(tty); 165 - 166 - if (icanon && no_echo) 167 - memset(buffer, 0x00, size); 163 + if (L_ICANON(tty) && !L_ECHO(tty)) 164 + memset(buffer, 0, size); 168 165 } 169 166 170 - static void tty_copy(struct tty_struct *tty, void *to, size_t tail, size_t n) 167 + static void tty_copy(const struct tty_struct *tty, void *to, size_t tail, 168 + size_t n) 171 169 { 172 170 struct n_tty_data *ldata = tty->disc_data; 173 171 size_t size = N_TTY_BUF_SIZE - tail; ··· 196 198 * * n_tty_read()/consumer path: 197 199 * holds non-exclusive %termios_rwsem 198 200 */ 199 - static void n_tty_kick_worker(struct tty_struct *tty) 201 + static void n_tty_kick_worker(const struct tty_struct *tty) 200 202 { 201 203 struct n_tty_data *ldata = tty->disc_data; 202 204 ··· 216 218 } 217 219 } 218 220 219 - static ssize_t chars_in_buffer(struct tty_struct *tty) 221 + static ssize_t chars_in_buffer(const struct tty_struct *tty) 220 222 { 221 - struct n_tty_data *ldata = tty->disc_data; 222 - ssize_t n = 0; 223 + const struct n_tty_data *ldata = tty->disc_data; 224 + size_t head = ldata->icanon ? ldata->canon_head : ldata->commit_head; 223 225 224 - if (!ldata->icanon) 225 - n = ldata->commit_head - ldata->read_tail; 226 - else 227 - n = ldata->canon_head - ldata->read_tail; 228 - return n; 226 + return head - ldata->read_tail; 229 227 } 230 228 231 229 /** ··· 303 309 * * n_tty_receive_buf()/producer path: 304 310 * caller holds non-exclusive %termios_rwsem 305 311 */ 306 - static inline void put_tty_queue(unsigned char c, struct n_tty_data *ldata) 312 + static inline void put_tty_queue(u8 c, struct n_tty_data *ldata) 307 313 { 308 314 *read_buf_addr(ldata, ldata->read_head) = c; 309 315 ldata->read_head++; ··· 377 383 * character. We use this to correctly compute the on-screen size of the 378 384 * character when printing. 379 385 */ 380 - static inline int is_utf8_continuation(unsigned char c) 386 + static inline int is_utf8_continuation(u8 c) 381 387 { 382 388 return (c & 0xc0) == 0x80; 383 389 } ··· 390 396 * Returns: true if the utf8 character @c is a multibyte continuation character 391 397 * and the terminal is in unicode mode. 392 398 */ 393 - static inline int is_continuation(unsigned char c, struct tty_struct *tty) 399 + static inline int is_continuation(u8 c, const struct tty_struct *tty) 394 400 { 395 401 return I_IUTF8(tty) && is_utf8_continuation(c); 396 402 } ··· 414 420 * Locking: should be called under the %output_lock to protect the column state 415 421 * and space left in the buffer. 416 422 */ 417 - static int do_output_char(unsigned char c, struct tty_struct *tty, int space) 423 + static int do_output_char(u8 c, struct tty_struct *tty, int space) 418 424 { 419 425 struct n_tty_data *ldata = tty->disc_data; 420 426 int spaces; ··· 488 494 * Locking: %output_lock to protect column state and space left (also, this is 489 495 *called from n_tty_write() under the tty layer write lock). 490 496 */ 491 - static int process_output(unsigned char c, struct tty_struct *tty) 497 + static int process_output(u8 c, struct tty_struct *tty) 492 498 { 493 499 struct n_tty_data *ldata = tty->disc_data; 494 500 int space, retval; ··· 524 530 * called from n_tty_write() under the tty layer write lock). 525 531 */ 526 532 static ssize_t process_output_block(struct tty_struct *tty, 527 - const unsigned char *buf, unsigned int nr) 533 + const u8 *buf, unsigned int nr) 528 534 { 529 535 struct n_tty_data *ldata = tty->disc_data; 530 536 int space; 531 537 int i; 532 - const unsigned char *cp; 538 + const u8 *cp; 533 539 534 540 mutex_lock(&ldata->output_lock); 535 541 ··· 542 548 nr = space; 543 549 544 550 for (i = 0, cp = buf; i < nr; i++, cp++) { 545 - unsigned char c = *cp; 551 + u8 c = *cp; 546 552 547 553 switch (c) { 548 554 case '\n': ··· 582 588 return i; 583 589 } 584 590 591 + static int n_tty_process_echo_ops(struct tty_struct *tty, size_t *tail, 592 + int space) 593 + { 594 + struct n_tty_data *ldata = tty->disc_data; 595 + u8 op; 596 + 597 + /* 598 + * Since add_echo_byte() is called without holding output_lock, we 599 + * might see only portion of multi-byte operation. 600 + */ 601 + if (MASK(ldata->echo_commit) == MASK(*tail + 1)) 602 + return -ENODATA; 603 + 604 + /* 605 + * If the buffer byte is the start of a multi-byte operation, get the 606 + * next byte, which is either the op code or a control character value. 607 + */ 608 + op = echo_buf(ldata, *tail + 1); 609 + 610 + switch (op) { 611 + case ECHO_OP_ERASE_TAB: { 612 + unsigned int num_chars, num_bs; 613 + 614 + if (MASK(ldata->echo_commit) == MASK(*tail + 2)) 615 + return -ENODATA; 616 + 617 + num_chars = echo_buf(ldata, *tail + 2); 618 + 619 + /* 620 + * Determine how many columns to go back in order to erase the 621 + * tab. This depends on the number of columns used by other 622 + * characters within the tab area. If this (modulo 8) count is 623 + * from the start of input rather than from a previous tab, we 624 + * offset by canon column. Otherwise, tab spacing is normal. 625 + */ 626 + if (!(num_chars & 0x80)) 627 + num_chars += ldata->canon_column; 628 + num_bs = 8 - (num_chars & 7); 629 + 630 + if (num_bs > space) 631 + return -ENOSPC; 632 + 633 + space -= num_bs; 634 + while (num_bs--) { 635 + tty_put_char(tty, '\b'); 636 + if (ldata->column > 0) 637 + ldata->column--; 638 + } 639 + *tail += 3; 640 + break; 641 + } 642 + case ECHO_OP_SET_CANON_COL: 643 + ldata->canon_column = ldata->column; 644 + *tail += 2; 645 + break; 646 + 647 + case ECHO_OP_MOVE_BACK_COL: 648 + if (ldata->column > 0) 649 + ldata->column--; 650 + *tail += 2; 651 + break; 652 + 653 + case ECHO_OP_START: 654 + /* This is an escaped echo op start code */ 655 + if (!space) 656 + return -ENOSPC; 657 + 658 + tty_put_char(tty, ECHO_OP_START); 659 + ldata->column++; 660 + space--; 661 + *tail += 2; 662 + break; 663 + 664 + default: 665 + /* 666 + * If the op is not a special byte code, it is a ctrl char 667 + * tagged to be echoed as "^X" (where X is the letter 668 + * representing the control char). Note that we must ensure 669 + * there is enough space for the whole ctrl pair. 670 + */ 671 + if (space < 2) 672 + return -ENOSPC; 673 + 674 + tty_put_char(tty, '^'); 675 + tty_put_char(tty, op ^ 0100); 676 + ldata->column += 2; 677 + space -= 2; 678 + *tail += 2; 679 + break; 680 + } 681 + 682 + return space; 683 + } 684 + 585 685 /** 586 686 * __process_echoes - write pending echo characters 587 687 * @tty: terminal device ··· 703 615 struct n_tty_data *ldata = tty->disc_data; 704 616 int space, old_space; 705 617 size_t tail; 706 - unsigned char c; 618 + u8 c; 707 619 708 620 old_space = space = tty_write_room(tty); 709 621 ··· 711 623 while (MASK(ldata->echo_commit) != MASK(tail)) { 712 624 c = echo_buf(ldata, tail); 713 625 if (c == ECHO_OP_START) { 714 - unsigned char op; 715 - bool space_left = true; 716 - 717 - /* 718 - * Since add_echo_byte() is called without holding 719 - * output_lock, we might see only portion of multi-byte 720 - * operation. 721 - */ 722 - if (MASK(ldata->echo_commit) == MASK(tail + 1)) 626 + int ret = n_tty_process_echo_ops(tty, &tail, space); 627 + if (ret == -ENODATA) 723 628 goto not_yet_stored; 724 - /* 725 - * If the buffer byte is the start of a multi-byte 726 - * operation, get the next byte, which is either the 727 - * op code or a control character value. 728 - */ 729 - op = echo_buf(ldata, tail + 1); 730 - 731 - switch (op) { 732 - case ECHO_OP_ERASE_TAB: { 733 - unsigned int num_chars, num_bs; 734 - 735 - if (MASK(ldata->echo_commit) == MASK(tail + 2)) 736 - goto not_yet_stored; 737 - num_chars = echo_buf(ldata, tail + 2); 738 - 739 - /* 740 - * Determine how many columns to go back 741 - * in order to erase the tab. 742 - * This depends on the number of columns 743 - * used by other characters within the tab 744 - * area. If this (modulo 8) count is from 745 - * the start of input rather than from a 746 - * previous tab, we offset by canon column. 747 - * Otherwise, tab spacing is normal. 748 - */ 749 - if (!(num_chars & 0x80)) 750 - num_chars += ldata->canon_column; 751 - num_bs = 8 - (num_chars & 7); 752 - 753 - if (num_bs > space) { 754 - space_left = false; 755 - break; 756 - } 757 - space -= num_bs; 758 - while (num_bs--) { 759 - tty_put_char(tty, '\b'); 760 - if (ldata->column > 0) 761 - ldata->column--; 762 - } 763 - tail += 3; 629 + if (ret < 0) 764 630 break; 765 - } 766 - case ECHO_OP_SET_CANON_COL: 767 - ldata->canon_column = ldata->column; 768 - tail += 2; 769 - break; 770 - 771 - case ECHO_OP_MOVE_BACK_COL: 772 - if (ldata->column > 0) 773 - ldata->column--; 774 - tail += 2; 775 - break; 776 - 777 - case ECHO_OP_START: 778 - /* This is an escaped echo op start code */ 779 - if (!space) { 780 - space_left = false; 781 - break; 782 - } 783 - tty_put_char(tty, ECHO_OP_START); 784 - ldata->column++; 785 - space--; 786 - tail += 2; 787 - break; 788 - 789 - default: 790 - /* 791 - * If the op is not a special byte code, 792 - * it is a ctrl char tagged to be echoed 793 - * as "^X" (where X is the letter 794 - * representing the control char). 795 - * Note that we must ensure there is 796 - * enough space for the whole ctrl pair. 797 - * 798 - */ 799 - if (space < 2) { 800 - space_left = false; 801 - break; 802 - } 803 - tty_put_char(tty, '^'); 804 - tty_put_char(tty, op ^ 0100); 805 - ldata->column += 2; 806 - space -= 2; 807 - tail += 2; 808 - } 809 - 810 - if (!space_left) 811 - break; 631 + space = ret; 812 632 } else { 813 633 if (O_OPOST(tty)) { 814 634 int retval = do_output_char(c, tty, space); ··· 820 824 * 821 825 * Add a character or operation byte to the echo buffer. 822 826 */ 823 - static inline void add_echo_byte(unsigned char c, struct n_tty_data *ldata) 827 + static inline void add_echo_byte(u8 c, struct n_tty_data *ldata) 824 828 { 825 829 *echo_buf_addr(ldata, ldata->echo_head) = c; 826 830 smp_wmb(); /* Matches smp_rmb() in echo_buf(). */ ··· 891 895 * 892 896 * This variant does not treat control characters specially. 893 897 */ 894 - static void echo_char_raw(unsigned char c, struct n_tty_data *ldata) 898 + static void echo_char_raw(u8 c, struct n_tty_data *ldata) 895 899 { 896 900 if (c == ECHO_OP_START) { 897 901 add_echo_byte(ECHO_OP_START, ldata); ··· 912 916 * This variant tags control characters to be echoed as "^X" (where X is the 913 917 * letter representing the control char). 914 918 */ 915 - static void echo_char(unsigned char c, struct tty_struct *tty) 919 + static void echo_char(u8 c, const struct tty_struct *tty) 916 920 { 917 921 struct n_tty_data *ldata = tty->disc_data; 918 922 ··· 950 954 * Locking: n_tty_receive_buf()/producer path: 951 955 * caller holds non-exclusive %termios_rwsem 952 956 */ 953 - static void eraser(unsigned char c, struct tty_struct *tty) 957 + static void eraser(u8 c, const struct tty_struct *tty) 954 958 { 955 959 struct n_tty_data *ldata = tty->disc_data; 956 960 enum { ERASE, WERASE, KILL } kill_type; ··· 1166 1170 * Called from the receive_buf path so single threaded. Does not need locking 1167 1171 * as num_overrun and overrun_time are function private. 1168 1172 */ 1169 - static void n_tty_receive_overrun(struct tty_struct *tty) 1173 + static void n_tty_receive_overrun(const struct tty_struct *tty) 1170 1174 { 1171 1175 struct n_tty_data *ldata = tty->disc_data; 1172 1176 1173 1177 ldata->num_overrun++; 1174 - if (time_after(jiffies, ldata->overrun_time + HZ) || 1175 - time_after(ldata->overrun_time, jiffies)) { 1176 - tty_warn(tty, "%d input overrun(s)\n", ldata->num_overrun); 1178 + if (time_is_before_jiffies(ldata->overrun_time + HZ)) { 1179 + tty_warn(tty, "%u input overrun(s)\n", ldata->num_overrun); 1177 1180 ldata->overrun_time = jiffies; 1178 1181 ldata->num_overrun = 0; 1179 1182 } ··· 1189 1194 * Locking: n_tty_receive_buf()/producer path: 1190 1195 * caller holds non-exclusive %termios_rwsem 1191 1196 */ 1192 - static void n_tty_receive_parity_error(struct tty_struct *tty, unsigned char c) 1197 + static void n_tty_receive_parity_error(const struct tty_struct *tty, 1198 + u8 c) 1193 1199 { 1194 1200 struct n_tty_data *ldata = tty->disc_data; 1195 1201 ··· 1208 1212 } 1209 1213 1210 1214 static void 1211 - n_tty_receive_signal_char(struct tty_struct *tty, int signal, unsigned char c) 1215 + n_tty_receive_signal_char(struct tty_struct *tty, int signal, u8 c) 1212 1216 { 1213 1217 isig(signal, tty); 1214 1218 if (I_IXON(tty)) ··· 1220 1224 process_echoes(tty); 1221 1225 } 1222 1226 1223 - static bool n_tty_is_char_flow_ctrl(struct tty_struct *tty, unsigned char c) 1227 + static bool n_tty_is_char_flow_ctrl(struct tty_struct *tty, u8 c) 1224 1228 { 1225 1229 return c == START_CHAR(tty) || c == STOP_CHAR(tty); 1226 1230 } ··· 1240 1244 * Returns true if @c is consumed as flow-control character, the character 1241 1245 * must not be treated as normal character. 1242 1246 */ 1243 - static bool n_tty_receive_char_flow_ctrl(struct tty_struct *tty, unsigned char c, 1247 + static bool n_tty_receive_char_flow_ctrl(struct tty_struct *tty, u8 c, 1244 1248 bool lookahead_done) 1245 1249 { 1246 1250 if (!n_tty_is_char_flow_ctrl(tty, c)) ··· 1260 1264 return true; 1261 1265 } 1262 1266 1263 - static void n_tty_receive_char_special(struct tty_struct *tty, unsigned char c, 1267 + static void n_tty_receive_handle_newline(struct tty_struct *tty, u8 c) 1268 + { 1269 + struct n_tty_data *ldata = tty->disc_data; 1270 + 1271 + set_bit(MASK(ldata->read_head), ldata->read_flags); 1272 + put_tty_queue(c, ldata); 1273 + smp_store_release(&ldata->canon_head, ldata->read_head); 1274 + kill_fasync(&tty->fasync, SIGIO, POLL_IN); 1275 + wake_up_interruptible_poll(&tty->read_wait, EPOLLIN | EPOLLRDNORM); 1276 + } 1277 + 1278 + static bool n_tty_receive_char_canon(struct tty_struct *tty, u8 c) 1279 + { 1280 + struct n_tty_data *ldata = tty->disc_data; 1281 + 1282 + if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || 1283 + (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { 1284 + eraser(c, tty); 1285 + commit_echoes(tty); 1286 + 1287 + return true; 1288 + } 1289 + 1290 + if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) { 1291 + ldata->lnext = 1; 1292 + if (L_ECHO(tty)) { 1293 + finish_erasing(ldata); 1294 + if (L_ECHOCTL(tty)) { 1295 + echo_char_raw('^', ldata); 1296 + echo_char_raw('\b', ldata); 1297 + commit_echoes(tty); 1298 + } 1299 + } 1300 + 1301 + return true; 1302 + } 1303 + 1304 + if (c == REPRINT_CHAR(tty) && L_ECHO(tty) && L_IEXTEN(tty)) { 1305 + size_t tail = ldata->canon_head; 1306 + 1307 + finish_erasing(ldata); 1308 + echo_char(c, tty); 1309 + echo_char_raw('\n', ldata); 1310 + while (MASK(tail) != MASK(ldata->read_head)) { 1311 + echo_char(read_buf(ldata, tail), tty); 1312 + tail++; 1313 + } 1314 + commit_echoes(tty); 1315 + 1316 + return true; 1317 + } 1318 + 1319 + if (c == '\n') { 1320 + if (L_ECHO(tty) || L_ECHONL(tty)) { 1321 + echo_char_raw('\n', ldata); 1322 + commit_echoes(tty); 1323 + } 1324 + n_tty_receive_handle_newline(tty, c); 1325 + 1326 + return true; 1327 + } 1328 + 1329 + if (c == EOF_CHAR(tty)) { 1330 + c = __DISABLED_CHAR; 1331 + n_tty_receive_handle_newline(tty, c); 1332 + 1333 + return true; 1334 + } 1335 + 1336 + if ((c == EOL_CHAR(tty)) || 1337 + (c == EOL2_CHAR(tty) && L_IEXTEN(tty))) { 1338 + /* 1339 + * XXX are EOL_CHAR and EOL2_CHAR echoed?!? 1340 + */ 1341 + if (L_ECHO(tty)) { 1342 + /* Record the column of first canon char. */ 1343 + if (ldata->canon_head == ldata->read_head) 1344 + echo_set_canon_col(ldata); 1345 + echo_char(c, tty); 1346 + commit_echoes(tty); 1347 + } 1348 + /* 1349 + * XXX does PARMRK doubling happen for 1350 + * EOL_CHAR and EOL2_CHAR? 1351 + */ 1352 + if (c == '\377' && I_PARMRK(tty)) 1353 + put_tty_queue(c, ldata); 1354 + 1355 + n_tty_receive_handle_newline(tty, c); 1356 + 1357 + return true; 1358 + } 1359 + 1360 + return false; 1361 + } 1362 + 1363 + static void n_tty_receive_char_special(struct tty_struct *tty, u8 c, 1264 1364 bool lookahead_done) 1265 1365 { 1266 1366 struct n_tty_data *ldata = tty->disc_data; ··· 1390 1298 } else if (c == '\n' && I_INLCR(tty)) 1391 1299 c = '\r'; 1392 1300 1393 - if (ldata->icanon) { 1394 - if (c == ERASE_CHAR(tty) || c == KILL_CHAR(tty) || 1395 - (c == WERASE_CHAR(tty) && L_IEXTEN(tty))) { 1396 - eraser(c, tty); 1397 - commit_echoes(tty); 1398 - return; 1399 - } 1400 - if (c == LNEXT_CHAR(tty) && L_IEXTEN(tty)) { 1401 - ldata->lnext = 1; 1402 - if (L_ECHO(tty)) { 1403 - finish_erasing(ldata); 1404 - if (L_ECHOCTL(tty)) { 1405 - echo_char_raw('^', ldata); 1406 - echo_char_raw('\b', ldata); 1407 - commit_echoes(tty); 1408 - } 1409 - } 1410 - return; 1411 - } 1412 - if (c == REPRINT_CHAR(tty) && L_ECHO(tty) && L_IEXTEN(tty)) { 1413 - size_t tail = ldata->canon_head; 1414 - 1415 - finish_erasing(ldata); 1416 - echo_char(c, tty); 1417 - echo_char_raw('\n', ldata); 1418 - while (MASK(tail) != MASK(ldata->read_head)) { 1419 - echo_char(read_buf(ldata, tail), tty); 1420 - tail++; 1421 - } 1422 - commit_echoes(tty); 1423 - return; 1424 - } 1425 - if (c == '\n') { 1426 - if (L_ECHO(tty) || L_ECHONL(tty)) { 1427 - echo_char_raw('\n', ldata); 1428 - commit_echoes(tty); 1429 - } 1430 - goto handle_newline; 1431 - } 1432 - if (c == EOF_CHAR(tty)) { 1433 - c = __DISABLED_CHAR; 1434 - goto handle_newline; 1435 - } 1436 - if ((c == EOL_CHAR(tty)) || 1437 - (c == EOL2_CHAR(tty) && L_IEXTEN(tty))) { 1438 - /* 1439 - * XXX are EOL_CHAR and EOL2_CHAR echoed?!? 1440 - */ 1441 - if (L_ECHO(tty)) { 1442 - /* Record the column of first canon char. */ 1443 - if (ldata->canon_head == ldata->read_head) 1444 - echo_set_canon_col(ldata); 1445 - echo_char(c, tty); 1446 - commit_echoes(tty); 1447 - } 1448 - /* 1449 - * XXX does PARMRK doubling happen for 1450 - * EOL_CHAR and EOL2_CHAR? 1451 - */ 1452 - if (c == (unsigned char) '\377' && I_PARMRK(tty)) 1453 - put_tty_queue(c, ldata); 1454 - 1455 - handle_newline: 1456 - set_bit(ldata->read_head & (N_TTY_BUF_SIZE - 1), ldata->read_flags); 1457 - put_tty_queue(c, ldata); 1458 - smp_store_release(&ldata->canon_head, ldata->read_head); 1459 - kill_fasync(&tty->fasync, SIGIO, POLL_IN); 1460 - wake_up_interruptible_poll(&tty->read_wait, EPOLLIN | EPOLLRDNORM); 1461 - return; 1462 - } 1463 - } 1301 + if (ldata->icanon && n_tty_receive_char_canon(tty, c)) 1302 + return; 1464 1303 1465 1304 if (L_ECHO(tty)) { 1466 1305 finish_erasing(ldata); ··· 1407 1384 } 1408 1385 1409 1386 /* PARMRK doubling check */ 1410 - if (c == (unsigned char) '\377' && I_PARMRK(tty)) 1387 + if (c == '\377' && I_PARMRK(tty)) 1411 1388 put_tty_queue(c, ldata); 1412 1389 1413 1390 put_tty_queue(c, ldata); ··· 1425 1402 * caller holds non-exclusive %termios_rwsem 1426 1403 * publishes canon_head if canonical mode is active 1427 1404 */ 1428 - static void n_tty_receive_char(struct tty_struct *tty, unsigned char c) 1405 + static void n_tty_receive_char(struct tty_struct *tty, u8 c) 1429 1406 { 1430 1407 struct n_tty_data *ldata = tty->disc_data; 1431 1408 ··· 1442 1419 commit_echoes(tty); 1443 1420 } 1444 1421 /* PARMRK doubling check */ 1445 - if (c == (unsigned char) '\377' && I_PARMRK(tty)) 1422 + if (c == '\377' && I_PARMRK(tty)) 1446 1423 put_tty_queue(c, ldata); 1447 1424 put_tty_queue(c, ldata); 1448 1425 } 1449 1426 1450 - static void n_tty_receive_char_closing(struct tty_struct *tty, unsigned char c, 1427 + static void n_tty_receive_char_closing(struct tty_struct *tty, u8 c, 1451 1428 bool lookahead_done) 1452 1429 { 1453 1430 if (I_ISTRIP(tty)) ··· 1467 1444 } 1468 1445 1469 1446 static void 1470 - n_tty_receive_char_flagged(struct tty_struct *tty, unsigned char c, char flag) 1447 + n_tty_receive_char_flagged(struct tty_struct *tty, u8 c, u8 flag) 1471 1448 { 1472 1449 switch (flag) { 1473 1450 case TTY_BREAK: ··· 1481 1458 n_tty_receive_overrun(tty); 1482 1459 break; 1483 1460 default: 1484 - tty_err(tty, "unknown flag %d\n", flag); 1461 + tty_err(tty, "unknown flag %u\n", flag); 1485 1462 break; 1486 1463 } 1487 1464 } 1488 1465 1489 1466 static void 1490 - n_tty_receive_char_lnext(struct tty_struct *tty, unsigned char c, char flag) 1467 + n_tty_receive_char_lnext(struct tty_struct *tty, u8 c, u8 flag) 1491 1468 { 1492 1469 struct n_tty_data *ldata = tty->disc_data; 1493 1470 ··· 1503 1480 } 1504 1481 1505 1482 /* Caller must ensure count > 0 */ 1506 - static void n_tty_lookahead_flow_ctrl(struct tty_struct *tty, const unsigned char *cp, 1507 - const unsigned char *fp, unsigned int count) 1483 + static void n_tty_lookahead_flow_ctrl(struct tty_struct *tty, const u8 *cp, 1484 + const u8 *fp, size_t count) 1508 1485 { 1509 1486 struct n_tty_data *ldata = tty->disc_data; 1510 - unsigned char flag = TTY_NORMAL; 1487 + u8 flag = TTY_NORMAL; 1511 1488 1512 1489 ldata->lookahead_count += count; 1513 1490 ··· 1524 1501 } 1525 1502 1526 1503 static void 1527 - n_tty_receive_buf_real_raw(struct tty_struct *tty, const unsigned char *cp, 1528 - const char *fp, int count) 1504 + n_tty_receive_buf_real_raw(const struct tty_struct *tty, const u8 *cp, 1505 + size_t count) 1529 1506 { 1530 1507 struct n_tty_data *ldata = tty->disc_data; 1531 - size_t n, head; 1532 1508 1533 - head = ldata->read_head & (N_TTY_BUF_SIZE - 1); 1534 - n = min_t(size_t, count, N_TTY_BUF_SIZE - head); 1535 - memcpy(read_buf_addr(ldata, head), cp, n); 1536 - ldata->read_head += n; 1537 - cp += n; 1538 - count -= n; 1509 + /* handle buffer wrap-around by a loop */ 1510 + for (unsigned int i = 0; i < 2; i++) { 1511 + size_t head = MASK(ldata->read_head); 1512 + size_t n = min(count, N_TTY_BUF_SIZE - head); 1539 1513 1540 - head = ldata->read_head & (N_TTY_BUF_SIZE - 1); 1541 - n = min_t(size_t, count, N_TTY_BUF_SIZE - head); 1542 - memcpy(read_buf_addr(ldata, head), cp, n); 1543 - ldata->read_head += n; 1514 + memcpy(read_buf_addr(ldata, head), cp, n); 1515 + 1516 + ldata->read_head += n; 1517 + cp += n; 1518 + count -= n; 1519 + } 1544 1520 } 1545 1521 1546 1522 static void 1547 - n_tty_receive_buf_raw(struct tty_struct *tty, const unsigned char *cp, 1548 - const char *fp, int count) 1523 + n_tty_receive_buf_raw(struct tty_struct *tty, const u8 *cp, const u8 *fp, 1524 + size_t count) 1549 1525 { 1550 1526 struct n_tty_data *ldata = tty->disc_data; 1551 - char flag = TTY_NORMAL; 1527 + u8 flag = TTY_NORMAL; 1552 1528 1553 1529 while (count--) { 1554 1530 if (fp) ··· 1560 1538 } 1561 1539 1562 1540 static void 1563 - n_tty_receive_buf_closing(struct tty_struct *tty, const unsigned char *cp, 1564 - const char *fp, int count, bool lookahead_done) 1541 + n_tty_receive_buf_closing(struct tty_struct *tty, const u8 *cp, const u8 *fp, 1542 + size_t count, bool lookahead_done) 1565 1543 { 1566 - char flag = TTY_NORMAL; 1544 + u8 flag = TTY_NORMAL; 1567 1545 1568 1546 while (count--) { 1569 1547 if (fp) ··· 1573 1551 } 1574 1552 } 1575 1553 1576 - static void n_tty_receive_buf_standard(struct tty_struct *tty, 1577 - const unsigned char *cp, const char *fp, int count, bool lookahead_done) 1554 + static void n_tty_receive_buf_standard(struct tty_struct *tty, const u8 *cp, 1555 + const u8 *fp, size_t count, 1556 + bool lookahead_done) 1578 1557 { 1579 1558 struct n_tty_data *ldata = tty->disc_data; 1580 - char flag = TTY_NORMAL; 1559 + u8 flag = TTY_NORMAL; 1581 1560 1582 1561 while (count--) { 1583 - unsigned char c = *cp++; 1562 + u8 c = *cp++; 1584 1563 1585 1564 if (fp) 1586 1565 flag = *fp++; ··· 1612 1589 } 1613 1590 } 1614 1591 1615 - static void __receive_buf(struct tty_struct *tty, const unsigned char *cp, 1616 - const char *fp, int count) 1592 + static void __receive_buf(struct tty_struct *tty, const u8 *cp, const u8 *fp, 1593 + size_t count) 1617 1594 { 1618 1595 struct n_tty_data *ldata = tty->disc_data; 1619 1596 bool preops = I_ISTRIP(tty) || (I_IUCLC(tty) && L_IEXTEN(tty)); 1620 - size_t la_count = min_t(size_t, ldata->lookahead_count, count); 1597 + size_t la_count = min(ldata->lookahead_count, count); 1621 1598 1622 1599 if (ldata->real_raw) 1623 - n_tty_receive_buf_real_raw(tty, cp, fp, count); 1600 + n_tty_receive_buf_real_raw(tty, cp, count); 1624 1601 else if (ldata->raw || (L_EXTPROC(tty) && !preops)) 1625 1602 n_tty_receive_buf_raw(tty, cp, fp, count); 1626 1603 else if (tty->closing && !L_EXTPROC(tty)) { ··· 1686 1663 * claims non-exclusive %termios_rwsem 1687 1664 * publishes commit_head or canon_head 1688 1665 */ 1689 - static int 1690 - n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp, 1691 - const char *fp, int count, int flow) 1666 + static size_t 1667 + n_tty_receive_buf_common(struct tty_struct *tty, const u8 *cp, const u8 *fp, 1668 + size_t count, bool flow) 1692 1669 { 1693 1670 struct n_tty_data *ldata = tty->disc_data; 1694 - int room, n, rcvd = 0, overflow; 1671 + size_t n, rcvd = 0; 1672 + int room, overflow; 1695 1673 1696 1674 down_read(&tty->termios_rwsem); 1697 1675 ··· 1725 1701 } else 1726 1702 overflow = 0; 1727 1703 1728 - n = min(count, room); 1704 + n = min_t(size_t, count, room); 1729 1705 if (!n) 1730 1706 break; 1731 1707 ··· 1768 1744 return rcvd; 1769 1745 } 1770 1746 1771 - static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, 1772 - const char *fp, int count) 1747 + static void n_tty_receive_buf(struct tty_struct *tty, const u8 *cp, 1748 + const u8 *fp, size_t count) 1773 1749 { 1774 - n_tty_receive_buf_common(tty, cp, fp, count, 0); 1750 + n_tty_receive_buf_common(tty, cp, fp, count, false); 1775 1751 } 1776 1752 1777 - static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp, 1778 - const char *fp, int count) 1753 + static size_t n_tty_receive_buf2(struct tty_struct *tty, const u8 *cp, 1754 + const u8 *fp, size_t count) 1779 1755 { 1780 - return n_tty_receive_buf_common(tty, cp, fp, count, 1); 1756 + return n_tty_receive_buf_common(tty, cp, fp, count, true); 1781 1757 } 1782 1758 1783 1759 /** ··· 1803 1779 ldata->canon_head = ldata->read_tail; 1804 1780 ldata->push = 0; 1805 1781 } else { 1806 - set_bit((ldata->read_head - 1) & (N_TTY_BUF_SIZE - 1), 1807 - ldata->read_flags); 1782 + set_bit(MASK(ldata->read_head - 1), ldata->read_flags); 1808 1783 ldata->canon_head = ldata->read_head; 1809 1784 ldata->push = 1; 1810 1785 } ··· 1926 1903 return 0; 1927 1904 } 1928 1905 1929 - static inline int input_available_p(struct tty_struct *tty, int poll) 1906 + static inline int input_available_p(const struct tty_struct *tty, int poll) 1930 1907 { 1931 - struct n_tty_data *ldata = tty->disc_data; 1908 + const struct n_tty_data *ldata = tty->disc_data; 1932 1909 int amt = poll && !TIME_CHAR(tty) && MIN_CHAR(tty) ? MIN_CHAR(tty) : 1; 1933 1910 1934 1911 if (ldata->icanon && !L_EXTPROC(tty)) ··· 1955 1932 * caller holds non-exclusive %termios_rwsem; 1956 1933 * read_tail published 1957 1934 */ 1958 - static bool copy_from_read_buf(struct tty_struct *tty, 1959 - unsigned char **kbp, 1960 - size_t *nr) 1935 + static bool copy_from_read_buf(const struct tty_struct *tty, u8 **kbp, 1936 + size_t *nr) 1961 1937 1962 1938 { 1963 1939 struct n_tty_data *ldata = tty->disc_data; 1964 1940 size_t n; 1965 1941 bool is_eof; 1966 1942 size_t head = smp_load_acquire(&ldata->commit_head); 1967 - size_t tail = ldata->read_tail & (N_TTY_BUF_SIZE - 1); 1943 + size_t tail = MASK(ldata->read_tail); 1968 1944 1969 1945 n = min(head - ldata->read_tail, N_TTY_BUF_SIZE - tail); 1970 1946 n = min(*nr, n); 1971 1947 if (n) { 1972 - unsigned char *from = read_buf_addr(ldata, tail); 1948 + u8 *from = read_buf_addr(ldata, tail); 1973 1949 memcpy(*kbp, from, n); 1974 1950 is_eof = n == 1 && *from == EOF_CHAR(tty); 1975 1951 tty_audit_add_data(tty, from, n); ··· 2009 1987 * caller holds non-exclusive %termios_rwsem; 2010 1988 * read_tail published 2011 1989 */ 2012 - static bool canon_copy_from_read_buf(struct tty_struct *tty, 2013 - unsigned char **kbp, 1990 + static bool canon_copy_from_read_buf(const struct tty_struct *tty, u8 **kbp, 2014 1991 size_t *nr) 2015 1992 { 2016 1993 struct n_tty_data *ldata = tty->disc_data; ··· 2025 2004 canon_head = smp_load_acquire(&ldata->canon_head); 2026 2005 n = min(*nr, canon_head - ldata->read_tail); 2027 2006 2028 - tail = ldata->read_tail & (N_TTY_BUF_SIZE - 1); 2007 + tail = MASK(ldata->read_tail); 2029 2008 size = min_t(size_t, tail + n, N_TTY_BUF_SIZE); 2030 2009 2031 2010 n_tty_trace("%s: nr:%zu tail:%zu n:%zu size:%zu\n", ··· 2077 2056 * EOF (special EOL character that's a __DISABLED_CHAR) 2078 2057 * in the stream, silently eat the EOF. 2079 2058 */ 2080 - static void canon_skip_eof(struct tty_struct *tty) 2059 + static void canon_skip_eof(struct n_tty_data *ldata) 2081 2060 { 2082 - struct n_tty_data *ldata = tty->disc_data; 2083 2061 size_t tail, canon_head; 2084 2062 2085 2063 canon_head = smp_load_acquire(&ldata->canon_head); ··· 2148 2128 * claims non-exclusive termios_rwsem; 2149 2129 * publishes read_tail 2150 2130 */ 2151 - static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, 2152 - unsigned char *kbuf, size_t nr, 2153 - void **cookie, unsigned long offset) 2131 + static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, u8 *kbuf, 2132 + size_t nr, void **cookie, unsigned long offset) 2154 2133 { 2155 2134 struct n_tty_data *ldata = tty->disc_data; 2156 - unsigned char *kb = kbuf; 2135 + u8 *kb = kbuf; 2157 2136 DEFINE_WAIT_FUNC(wait, woken_wake_function); 2158 2137 int c; 2159 2138 int minimum, time; ··· 2175 2156 * releasing the lock and returning done. 2176 2157 */ 2177 2158 if (!nr) 2178 - canon_skip_eof(tty); 2159 + canon_skip_eof(ldata); 2179 2160 else if (canon_copy_from_read_buf(tty, &kb, &nr)) 2180 2161 return kb - kbuf; 2181 2162 } else { ··· 2228 2209 while (nr) { 2229 2210 /* First test for status change. */ 2230 2211 if (packet && tty->link->ctrl.pktstatus) { 2231 - unsigned char cs; 2212 + u8 cs; 2232 2213 if (kb != kbuf) 2233 2214 break; 2234 2215 spin_lock_irq(&tty->link->ctrl.lock); ··· 2351 2332 */ 2352 2333 2353 2334 static ssize_t n_tty_write(struct tty_struct *tty, struct file *file, 2354 - const unsigned char *buf, size_t nr) 2335 + const u8 *buf, size_t nr) 2355 2336 { 2356 - const unsigned char *b = buf; 2337 + const u8 *b = buf; 2357 2338 DEFINE_WAIT_FUNC(wait, woken_wake_function); 2358 - int c; 2359 - ssize_t retval = 0; 2339 + ssize_t num, retval = 0; 2360 2340 2361 2341 /* Job control check -- must be done at start (POSIX.1 7.1.1.4). */ 2362 2342 if (L_TOSTOP(tty) && file->f_op->write_iter != redirected_tty_write) { ··· 2381 2363 } 2382 2364 if (O_OPOST(tty)) { 2383 2365 while (nr > 0) { 2384 - ssize_t num = process_output_block(tty, b, nr); 2366 + num = process_output_block(tty, b, nr); 2385 2367 if (num < 0) { 2386 2368 if (num == -EAGAIN) 2387 2369 break; ··· 2392 2374 nr -= num; 2393 2375 if (nr == 0) 2394 2376 break; 2395 - c = *b; 2396 - if (process_output(c, tty) < 0) 2377 + if (process_output(*b, tty) < 0) 2397 2378 break; 2398 2379 b++; nr--; 2399 2380 } ··· 2403 2386 2404 2387 while (nr > 0) { 2405 2388 mutex_lock(&ldata->output_lock); 2406 - c = tty->ops->write(tty, b, nr); 2389 + num = tty->ops->write(tty, b, nr); 2407 2390 mutex_unlock(&ldata->output_lock); 2408 - if (c < 0) { 2409 - retval = c; 2391 + if (num < 0) { 2392 + retval = num; 2410 2393 goto break_out; 2411 2394 } 2412 - if (!c) 2395 + if (!num) 2413 2396 break; 2414 - b += c; 2415 - nr -= c; 2397 + b += num; 2398 + nr -= num; 2416 2399 } 2417 2400 } 2418 2401 if (!nr) ··· 2487 2470 nr = head - tail; 2488 2471 /* Skip EOF-chars.. */ 2489 2472 while (MASK(head) != MASK(tail)) { 2490 - if (test_bit(tail & (N_TTY_BUF_SIZE - 1), ldata->read_flags) && 2473 + if (test_bit(MASK(tail), ldata->read_flags) && 2491 2474 read_buf(ldata, tail) == __DISABLED_CHAR) 2492 2475 nr--; 2493 2476 tail++;
+3 -3
drivers/tty/nozomi.c
··· 1599 1599 * called when the userspace process writes to the tty (/dev/noz*). 1600 1600 * Data is inserted into a fifo, which is then read and transferred to the modem. 1601 1601 */ 1602 - static int ntty_write(struct tty_struct *tty, const unsigned char *buffer, 1603 - int count) 1602 + static ssize_t ntty_write(struct tty_struct *tty, const u8 *buffer, 1603 + size_t count) 1604 1604 { 1605 1605 int rval = -EINVAL; 1606 1606 struct nozomi *dc = get_dc_by_tty(tty); ··· 1610 1610 if (!dc || !port) 1611 1611 return -ENODEV; 1612 1612 1613 - rval = kfifo_in(&port->fifo_ul, (unsigned char *)buffer, count); 1613 + rval = kfifo_in(&port->fifo_ul, buffer, count); 1614 1614 1615 1615 spin_lock_irqsave(&dc->spin_mutex, flags); 1616 1616 /* CTS is only valid on the modem channel */
+1 -1
drivers/tty/pty.c
··· 108 108 * the other side of the pty/tty pair. 109 109 */ 110 110 111 - static int pty_write(struct tty_struct *tty, const unsigned char *buf, int c) 111 + static ssize_t pty_write(struct tty_struct *tty, const u8 *buf, size_t c) 112 112 { 113 113 struct tty_struct *to = tty->link; 114 114
+3 -2
drivers/tty/rpmsg_tty.c
··· 73 73 return tty_port_close(tty->port, tty, filp); 74 74 } 75 75 76 - static int rpmsg_tty_write(struct tty_struct *tty, const u8 *buf, int len) 76 + static ssize_t rpmsg_tty_write(struct tty_struct *tty, const u8 *buf, 77 + size_t len) 77 78 { 78 79 struct rpmsg_tty_port *cport = tty->driver_data; 79 80 struct rpmsg_device *rpdev; ··· 87 86 if (msg_max_size < 0) 88 87 return msg_max_size; 89 88 90 - msg_size = min(len, msg_max_size); 89 + msg_size = min_t(unsigned int, len, msg_max_size); 91 90 92 91 /* 93 92 * Use rpmsg_trysend instead of rpmsg_send to send the message so the caller is not
+2 -2
drivers/tty/serdev/serdev-ttyport.c
··· 22 22 * Callback functions from the tty port. 23 23 */ 24 24 25 - static int ttyport_receive_buf(struct tty_port *port, const unsigned char *cp, 26 - const unsigned char *fp, size_t count) 25 + static size_t ttyport_receive_buf(struct tty_port *port, const u8 *cp, 26 + const u8 *fp, size_t count) 27 27 { 28 28 struct serdev_controller *ctrl = port->client_data; 29 29 struct serport *serport = serdev_controller_get_drvdata(ctrl);
+2 -1
drivers/tty/serial/21285.c
··· 117 117 static irqreturn_t serial21285_rx_chars(int irq, void *dev_id) 118 118 { 119 119 struct uart_port *port = dev_id; 120 - unsigned int status, ch, flag, rxs, max_count = 256; 120 + unsigned int status, rxs, max_count = 256; 121 + u8 ch, flag; 121 122 122 123 status = *CSR_UARTFLG; 123 124 while (!(status & 0x10) && max_count--) {
+1 -3
drivers/tty/serial/8250/8250_bcm7271.c
··· 1042 1042 dev_dbg(dev, "DMA is %senabled\n", priv->dma_enabled ? "" : "not "); 1043 1043 1044 1044 memset(&up, 0, sizeof(up)); 1045 - up.port.type = PORT_16550A; 1045 + up.port.type = PORT_BCM7271; 1046 1046 up.port.uartclk = clk_rate; 1047 1047 up.port.dev = dev; 1048 1048 up.port.mapbase = mapbase; ··· 1056 1056 | UPF_FIXED_PORT | UPF_FIXED_TYPE; 1057 1057 up.port.dev = dev; 1058 1058 up.port.private_data = priv; 1059 - up.capabilities = UART_CAP_FIFO | UART_CAP_AFE; 1060 - up.port.fifosize = 32; 1061 1059 1062 1060 /* Check for a fixed line number */ 1063 1061 ret = of_alias_get_id(np, "serial");
+4 -1
drivers/tty/serial/8250/8250_dw.c
··· 523 523 if (!regs) 524 524 return dev_err_probe(dev, -EINVAL, "no registers defined\n"); 525 525 526 - irq = platform_get_irq(pdev, 0); 526 + irq = platform_get_irq_optional(pdev, 0); 527 + /* no interrupt -> fall back to polling */ 528 + if (irq == -ENXIO) 529 + irq = 0; 527 530 if (irq < 0) 528 531 return irq; 529 532
-1
drivers/tty/serial/8250/8250_early.c
··· 27 27 #include <linux/init.h> 28 28 #include <linux/console.h> 29 29 #include <linux/of.h> 30 - #include <linux/of_device.h> 31 30 #include <linux/serial_reg.h> 32 31 #include <linux/serial.h> 33 32 #include <linux/serial_8250.h>
-1
drivers/tty/serial/8250/8250_ingenic.c
··· 13 13 #include <linux/module.h> 14 14 #include <linux/of.h> 15 15 #include <linux/of_fdt.h> 16 - #include <linux/of_device.h> 17 16 #include <linux/platform_device.h> 18 17 #include <linux/serial_8250.h> 19 18 #include <linux/serial_core.h>
+154 -56
drivers/tty/serial/8250/8250_men_mcb.c
··· 12 12 #define MEN_UART_ID_Z057 0x39 13 13 #define MEN_UART_ID_Z125 0x7d 14 14 15 - #define MEN_UART_MEM_SIZE 0x10 15 + /* 16 + * IP Cores Z025 and Z057 can have up to 4 UART 17 + * The UARTs available are stored in a global 18 + * register saved in physical address + 0x40 19 + * Is saved as follows: 20 + * 21 + * 7 0 22 + * +------+-------+-------+-------+-------+-------+-------+-------+ 23 + * |UART4 | UART3 | UART2 | UART1 | U4irq | U3irq | U2irq | U1irq | 24 + * +------+-------+-------+-------+-------+-------+-------+-------+ 25 + */ 26 + #define MEN_UART1_MASK 0x01 27 + #define MEN_UART2_MASK 0x02 28 + #define MEN_UART3_MASK 0x04 29 + #define MEN_UART4_MASK 0x08 30 + 31 + #define MEN_Z125_UARTS_AVAILABLE 0x01 32 + 33 + #define MEN_Z025_MAX_UARTS 4 34 + #define MEN_UART_MEM_SIZE 0x10 35 + #define MEM_UART_REGISTER_SIZE 0x01 36 + #define MEN_Z025_REGISTER_OFFSET 0x40 37 + 38 + #define MEN_UART1_OFFSET 0 39 + #define MEN_UART2_OFFSET (MEN_UART1_OFFSET + MEN_UART_MEM_SIZE) 40 + #define MEN_UART3_OFFSET (MEN_UART2_OFFSET + MEN_UART_MEM_SIZE) 41 + #define MEN_UART4_OFFSET (MEN_UART3_OFFSET + MEN_UART_MEM_SIZE) 42 + 43 + #define MEN_READ_REGISTER(addr) readb(addr) 44 + 45 + #define MAX_PORTS 4 16 46 17 47 struct serial_8250_men_mcb_data { 18 - struct uart_8250_port uart; 19 - int line; 48 + int num_ports; 49 + int line[MAX_PORTS]; 50 + unsigned int offset[MAX_PORTS]; 20 51 }; 21 52 22 53 /* ··· 68 37 clkval = 1041666; 69 38 else if (strncmp(mdev->bus->name, "F216", 4) == 0) 70 39 clkval = 1843200; 71 - else if (strncmp(mdev->bus->name, "G215", 4) == 0) 72 - clkval = 1843200; 73 40 else if (strncmp(mdev->bus->name, "F210", 4) == 0) 74 41 clkval = 115200; 42 + else if (strstr(mdev->bus->name, "215")) 43 + clkval = 1843200; 75 44 else 76 45 dev_info(&mdev->dev, 77 46 "board not detected, using default uartclk\n"); ··· 81 50 return clkval; 82 51 } 83 52 84 - static int get_num_ports(struct mcb_device *mdev, 85 - void __iomem *membase) 53 + static int read_uarts_available_from_register(struct resource *mem_res, 54 + u8 *uarts_available) 55 + { 56 + void __iomem *mem; 57 + int reg_value; 58 + 59 + if (!request_mem_region(mem_res->start + MEN_Z025_REGISTER_OFFSET, 60 + MEM_UART_REGISTER_SIZE, KBUILD_MODNAME)) { 61 + return -EBUSY; 62 + } 63 + 64 + mem = ioremap(mem_res->start + MEN_Z025_REGISTER_OFFSET, 65 + MEM_UART_REGISTER_SIZE); 66 + if (!mem) { 67 + release_mem_region(mem_res->start + MEN_Z025_REGISTER_OFFSET, 68 + MEM_UART_REGISTER_SIZE); 69 + return -ENOMEM; 70 + } 71 + 72 + reg_value = MEN_READ_REGISTER(mem); 73 + 74 + iounmap(mem); 75 + 76 + release_mem_region(mem_res->start + MEN_Z025_REGISTER_OFFSET, 77 + MEM_UART_REGISTER_SIZE); 78 + 79 + *uarts_available = reg_value >> 4; 80 + 81 + return 0; 82 + } 83 + 84 + static int read_serial_data(struct mcb_device *mdev, 85 + struct resource *mem_res, 86 + struct serial_8250_men_mcb_data *serial_data) 87 + { 88 + u8 uarts_available; 89 + int count = 0; 90 + int mask; 91 + int res; 92 + int i; 93 + 94 + res = read_uarts_available_from_register(mem_res, &uarts_available); 95 + if (res < 0) 96 + return res; 97 + 98 + for (i = 0; i < MAX_PORTS; i++) { 99 + mask = 0x1 << i; 100 + switch (uarts_available & mask) { 101 + case MEN_UART1_MASK: 102 + serial_data->offset[count] = MEN_UART1_OFFSET; 103 + count++; 104 + break; 105 + case MEN_UART2_MASK: 106 + serial_data->offset[count] = MEN_UART2_OFFSET; 107 + count++; 108 + break; 109 + case MEN_UART3_MASK: 110 + serial_data->offset[count] = MEN_UART3_OFFSET; 111 + count++; 112 + break; 113 + case MEN_UART4_MASK: 114 + serial_data->offset[count] = MEN_UART4_OFFSET; 115 + count++; 116 + break; 117 + default: 118 + return -EINVAL; 119 + } 120 + } 121 + 122 + if (count <= 0 || count > MAX_PORTS) { 123 + dev_err(&mdev->dev, "unexpected number of ports: %u\n", 124 + count); 125 + return -ENODEV; 126 + } 127 + 128 + serial_data->num_ports = count; 129 + 130 + return 0; 131 + } 132 + 133 + static int init_serial_data(struct mcb_device *mdev, 134 + struct resource *mem_res, 135 + struct serial_8250_men_mcb_data *serial_data) 86 136 { 87 137 switch (mdev->id) { 88 138 case MEN_UART_ID_Z125: 89 - return 1U; 139 + serial_data->num_ports = 1; 140 + serial_data->offset[0] = 0; 141 + return 0; 90 142 case MEN_UART_ID_Z025: 91 - return readb(membase) >> 4; 92 143 case MEN_UART_ID_Z057: 93 - return 4U; 144 + return read_serial_data(mdev, mem_res, serial_data); 94 145 default: 95 146 dev_err(&mdev->dev, "no supported device!\n"); 96 147 return -ENODEV; ··· 182 69 static int serial_8250_men_mcb_probe(struct mcb_device *mdev, 183 70 const struct mcb_device_id *id) 184 71 { 72 + struct uart_8250_port uart; 185 73 struct serial_8250_men_mcb_data *data; 186 74 struct resource *mem; 187 - int num_ports; 188 75 int i; 189 - void __iomem *membase; 76 + int res; 190 77 191 78 mem = mcb_get_resource(mdev, IORESOURCE_MEM); 192 79 if (mem == NULL) 193 80 return -ENXIO; 194 - membase = devm_ioremap_resource(&mdev->dev, mem); 195 - if (IS_ERR(membase)) 196 - return PTR_ERR_OR_ZERO(membase); 197 81 198 - num_ports = get_num_ports(mdev, membase); 199 - 200 - dev_dbg(&mdev->dev, "found a 16z%03u with %u ports\n", 201 - mdev->id, num_ports); 202 - 203 - if (num_ports <= 0 || num_ports > 4) { 204 - dev_err(&mdev->dev, "unexpected number of ports: %u\n", 205 - num_ports); 206 - return -ENODEV; 207 - } 208 - 209 - data = devm_kcalloc(&mdev->dev, num_ports, 82 + data = devm_kzalloc(&mdev->dev, 210 83 sizeof(struct serial_8250_men_mcb_data), 211 84 GFP_KERNEL); 212 85 if (!data) 213 86 return -ENOMEM; 214 87 88 + res = init_serial_data(mdev, mem, data); 89 + if (res < 0) 90 + return res; 91 + 92 + dev_dbg(&mdev->dev, "found a 16z%03u with %u ports\n", 93 + mdev->id, data->num_ports); 94 + 215 95 mcb_set_drvdata(mdev, data); 216 96 217 - for (i = 0; i < num_ports; i++) { 218 - data[i].uart.port.dev = mdev->dma_dev; 219 - spin_lock_init(&data[i].uart.port.lock); 97 + for (i = 0; i < data->num_ports; i++) { 98 + memset(&uart, 0, sizeof(struct uart_8250_port)); 99 + spin_lock_init(&uart.port.lock); 220 100 221 - data[i].uart.port.type = PORT_16550; 222 - data[i].uart.port.flags = UPF_SKIP_TEST | UPF_SHARE_IRQ 223 - | UPF_FIXED_TYPE; 224 - data[i].uart.port.iotype = UPIO_MEM; 225 - data[i].uart.port.uartclk = men_lookup_uartclk(mdev); 226 - data[i].uart.port.regshift = 0; 227 - data[i].uart.port.irq = mcb_get_irq(mdev); 228 - data[i].uart.port.membase = membase; 229 - data[i].uart.port.fifosize = 60; 230 - data[i].uart.port.mapbase = (unsigned long) mem->start 231 - + i * MEN_UART_MEM_SIZE; 232 - data[i].uart.port.iobase = data[i].uart.port.mapbase; 101 + uart.port.flags = UPF_SKIP_TEST | 102 + UPF_SHARE_IRQ | 103 + UPF_BOOT_AUTOCONF | 104 + UPF_IOREMAP; 105 + uart.port.iotype = UPIO_MEM; 106 + uart.port.uartclk = men_lookup_uartclk(mdev); 107 + uart.port.irq = mcb_get_irq(mdev); 108 + uart.port.mapbase = (unsigned long) mem->start 109 + + data->offset[i]; 233 110 234 111 /* ok, register the port */ 235 - data[i].line = serial8250_register_8250_port(&data[i].uart); 236 - if (data[i].line < 0) { 112 + res = serial8250_register_8250_port(&uart); 113 + if (res < 0) { 237 114 dev_err(&mdev->dev, "unable to register UART port\n"); 238 - return data[i].line; 115 + return res; 239 116 } 240 - dev_info(&mdev->dev, "found MCB UART: ttyS%d\n", data[i].line); 117 + 118 + data->line[i] = res; 119 + dev_info(&mdev->dev, "found MCB UART: ttyS%d\n", data->line[i]); 241 120 } 242 121 243 122 return 0; ··· 237 132 238 133 static void serial_8250_men_mcb_remove(struct mcb_device *mdev) 239 134 { 240 - int num_ports, i; 135 + int i; 241 136 struct serial_8250_men_mcb_data *data = mcb_get_drvdata(mdev); 242 137 243 138 if (!data) 244 139 return; 245 140 246 - num_ports = get_num_ports(mdev, data[0].uart.port.membase); 247 - if (num_ports <= 0 || num_ports > 4) { 248 - dev_err(&mdev->dev, "error retrieving number of ports!\n"); 249 - return; 250 - } 251 - 252 - for (i = 0; i < num_ports; i++) 253 - serial8250_unregister_port(data[i].line); 141 + for (i = 0; i < data->num_ports; i++) 142 + serial8250_unregister_port(data->line[i]); 254 143 } 255 144 256 145 static const struct mcb_device_id serial_8250_men_mcb_ids[] = { ··· 258 159 static struct mcb_driver mcb_driver = { 259 160 .driver = { 260 161 .name = "8250_men_mcb", 261 - .owner = THIS_MODULE, 262 162 }, 263 163 .probe = serial_8250_men_mcb_probe, 264 164 .remove = serial_8250_men_mcb_remove,
-1
drivers/tty/serial/8250/8250_omap.c
··· 18 18 #include <linux/platform_device.h> 19 19 #include <linux/slab.h> 20 20 #include <linux/of.h> 21 - #include <linux/of_device.h> 22 21 #include <linux/of_gpio.h> 23 22 #include <linux/of_irq.h> 24 23 #include <linux/delay.h>
+10
drivers/tty/serial/8250/8250_pci.c
··· 67 67 0xA000, 0x1000) }, 68 68 { PCI_DEVICE_SUB(PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9922, 69 69 0xA000, 0x1000) }, 70 + { PCI_DEVICE_SUB(PCI_VENDOR_ID_ASIX, PCI_DEVICE_ID_ASIX_AX99100, 71 + 0xA000, 0x1000) }, 70 72 { PCI_DEVICE_SUB(PCI_VENDOR_ID_HP_3PAR, PCI_DEVICE_ID_HPE_PCI_SERIAL, 71 73 PCI_ANY_ID, PCI_ANY_ID) }, 72 74 { } ··· 5559 5557 { PCI_VENDOR_ID_NETMOS, PCI_DEVICE_ID_NETMOS_9865, 5560 5558 0xA000, 0x3004, 5561 5559 0, 0, pbn_b0_bt_4_115200 }, 5560 + 5561 + /* 5562 + * ASIX AX99100 PCIe to Multi I/O Controller 5563 + */ 5564 + { PCI_VENDOR_ID_ASIX, PCI_DEVICE_ID_ASIX_AX99100, 5565 + 0xA000, 0x1000, 5566 + 0, 0, pbn_b0_1_115200 }, 5567 + 5562 5568 /* Intel CE4100 */ 5563 5569 { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_CE4100_UART, 5564 5570 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
+9 -2
drivers/tty/serial/8250/8250_port.c
··· 322 322 .rxtrig_bytes = {2, 66, 130, 194}, 323 323 .flags = UART_CAP_FIFO, 324 324 }, 325 + [PORT_BCM7271] = { 326 + .name = "Broadcom BCM7271 UART", 327 + .fifo_size = 32, 328 + .tx_loadsz = 32, 329 + .fcr = UART_FCR_ENABLE_FIFO | UART_FCR_R_TRIG_01, 330 + .rxtrig_bytes = {1, 8, 16, 30}, 331 + .flags = UART_CAP_FIFO | UART_CAP_AFE, 332 + }, 325 333 }; 326 334 327 335 /* Uart divisor latch read */ ··· 1711 1703 void serial8250_read_char(struct uart_8250_port *up, u16 lsr) 1712 1704 { 1713 1705 struct uart_port *port = &up->port; 1714 - unsigned char ch; 1715 - char flag = TTY_NORMAL; 1706 + u8 ch, flag = TTY_NORMAL; 1716 1707 1717 1708 if (likely(lsr & UART_LSR_DR)) 1718 1709 ch = serial_in(up, UART_RX);
+1
drivers/tty/serial/8250/8250_pxa.c
··· 183 183 return early_serial8250_setup(device, NULL); 184 184 } 185 185 OF_EARLYCON_DECLARE(early_pxa, "mrvl,pxa-uart", early_serial_pxa_setup); 186 + OF_EARLYCON_DECLARE(mmp, "mrvl,mmp-uart", early_serial_pxa_setup); 186 187 #endif 187 188 188 189 MODULE_AUTHOR("Sergei Ianovich");
+1 -1
drivers/tty/serial/Makefile
··· 41 41 obj-$(CONFIG_SERIAL_DZ) += dz.o 42 42 obj-$(CONFIG_SERIAL_ZS) += zs.o 43 43 obj-$(CONFIG_SERIAL_SH_SCI) += sh-sci.o 44 - obj-$(CONFIG_SERIAL_CPM) += cpm_uart/ 44 + obj-$(CONFIG_SERIAL_CPM) += cpm_uart.o 45 45 obj-$(CONFIG_SERIAL_IMX) += imx.o 46 46 obj-$(CONFIG_SERIAL_IMX_EARLYCON) += imx_earlycon.o 47 47 obj-$(CONFIG_SERIAL_MPC52xx) += mpc52xx_uart.o
+2 -2
drivers/tty/serial/altera_jtaguart.c
··· 110 110 111 111 static void altera_jtaguart_rx_chars(struct uart_port *port) 112 112 { 113 - unsigned char ch; 114 - unsigned long status; 113 + u32 status; 114 + u8 ch; 115 115 116 116 while ((status = readl(port->membase + ALTERA_JTAGUART_DATA_REG)) & 117 117 ALTERA_JTAGUART_DATA_RVALID_MSK) {
+1 -1
drivers/tty/serial/altera_uart.c
··· 201 201 202 202 static void altera_uart_rx_chars(struct uart_port *port) 203 203 { 204 - unsigned char ch, flag; 205 204 unsigned short status; 205 + u8 ch, flag; 206 206 207 207 while ((status = altera_uart_readl(port, ALTERA_UART_STATUS_REG)) & 208 208 ALTERA_UART_STATUS_RRDY_MSK) {
+2 -1
drivers/tty/serial/amba-pl010.c
··· 112 112 113 113 static void pl010_rx_chars(struct uart_port *port) 114 114 { 115 - unsigned int status, ch, flag, rsr, max_count = 256; 115 + unsigned int status, rsr, max_count = 256; 116 + u8 ch, flag; 116 117 117 118 status = readb(port->membase + UART01x_FR); 118 119 while (UART_RX_DATA(status) && max_count--) {
+3 -2
drivers/tty/serial/amba-pl011.c
··· 20 20 #include <linux/ioport.h> 21 21 #include <linux/init.h> 22 22 #include <linux/console.h> 23 + #include <linux/platform_device.h> 23 24 #include <linux/sysrq.h> 24 25 #include <linux/device.h> 25 26 #include <linux/tty.h> ··· 37 36 #include <linux/delay.h> 38 37 #include <linux/types.h> 39 38 #include <linux/of.h> 40 - #include <linux/of_device.h> 41 39 #include <linux/pinctrl/consumer.h> 42 40 #include <linux/sizes.h> 43 41 #include <linux/io.h> ··· 307 307 */ 308 308 static int pl011_fifo_to_tty(struct uart_amba_port *uap) 309 309 { 310 - unsigned int ch, flag, fifotaken; 310 + unsigned int ch, fifotaken; 311 311 int sysrq; 312 312 u16 status; 313 + u8 flag; 313 314 314 315 for (fifotaken = 0; fifotaken != 256; fifotaken++) { 315 316 status = pl011_read(uap, REG_FR);
+2 -4
drivers/tty/serial/apbuart.c
··· 22 22 #include <linux/kthread.h> 23 23 #include <linux/device.h> 24 24 #include <linux/of.h> 25 - #include <linux/of_device.h> 26 - #include <linux/of_platform.h> 27 - #include <linux/of_irq.h> 28 25 #include <linux/platform_device.h> 29 26 #include <linux/io.h> 30 27 #include <linux/serial_core.h> ··· 67 70 68 71 static void apbuart_rx_chars(struct uart_port *port) 69 72 { 70 - unsigned int status, ch, rsr, flag; 73 + unsigned int status, rsr; 71 74 unsigned int max_chars = port->fifosize; 75 + u8 ch, flag; 72 76 73 77 status = UART_GET_STATUS(port); 74 78
+1 -2
drivers/tty/serial/ar933x_uart.c
··· 749 749 750 750 port = &up->port; 751 751 752 - mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 753 - port->membase = devm_ioremap_resource(&pdev->dev, mem_res); 752 + port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &mem_res); 754 753 if (IS_ERR(port->membase)) 755 754 return PTR_ERR(port->membase); 756 755
+12 -15
drivers/tty/serial/arc_uart.c
··· 195 195 196 196 static void arc_serial_rx_chars(struct uart_port *port, unsigned int status) 197 197 { 198 - unsigned int ch, flg = 0; 199 - 200 198 /* 201 199 * UART has 4 deep RX-FIFO. Driver's recongnition of this fact 202 200 * is very subtle. Here's how ... ··· 205 207 * controller, which is indeed the Rx-FIFO. 206 208 */ 207 209 do { 210 + u8 ch, flg = TTY_NORMAL; 211 + 208 212 /* 209 213 * This could be an Rx Intr for err (no data), 210 214 * so check err and clear that Intr first 211 215 */ 212 - if (unlikely(status & (RXOERR | RXFERR))) { 213 - if (status & RXOERR) { 214 - port->icount.overrun++; 215 - flg = TTY_OVERRUN; 216 - UART_CLR_STATUS(port, RXOERR); 217 - } 216 + if (status & RXOERR) { 217 + port->icount.overrun++; 218 + flg = TTY_OVERRUN; 219 + UART_CLR_STATUS(port, RXOERR); 220 + } 218 221 219 - if (status & RXFERR) { 220 - port->icount.frame++; 221 - flg = TTY_FRAME; 222 - UART_CLR_STATUS(port, RXFERR); 223 - } 224 - } else 225 - flg = TTY_NORMAL; 222 + if (status & RXFERR) { 223 + port->icount.frame++; 224 + flg = TTY_FRAME; 225 + UART_CLR_STATUS(port, RXFERR); 226 + } 226 227 227 228 if (status & RXEMPTY) 228 229 continue;
+1 -2
drivers/tty/serial/atmel_serial.c
··· 21 21 #include <linux/tty_flip.h> 22 22 #include <linux/platform_device.h> 23 23 #include <linux/of.h> 24 - #include <linux/of_device.h> 25 24 #include <linux/dma-mapping.h> 26 25 #include <linux/dmaengine.h> 27 26 #include <linux/atmel_pdc.h> ··· 1515 1516 { 1516 1517 struct atmel_uart_port *atmel_port = to_atmel_uart_port(port); 1517 1518 struct circ_buf *ring = &atmel_port->rx_ring; 1518 - unsigned int flg; 1519 1519 unsigned int status; 1520 + u8 flg; 1520 1521 1521 1522 while (ring->head != ring->tail) { 1522 1523 struct atmel_uart_char c;
+2 -6
drivers/tty/serial/bcm63xx_uart.c
··· 832 832 return -EBUSY; 833 833 memset(port, 0, sizeof(*port)); 834 834 835 - res_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 836 - if (!res_mem) 837 - return -ENODEV; 838 - 839 - port->mapbase = res_mem->start; 840 - port->membase = devm_ioremap_resource(&pdev->dev, res_mem); 835 + port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res_mem); 841 836 if (IS_ERR(port->membase)) 842 837 return PTR_ERR(port->membase); 838 + port->mapbase = res_mem->start; 843 839 844 840 ret = platform_get_irq(pdev, 0); 845 841 if (ret < 0)
+3 -3
drivers/tty/serial/clps711x.c
··· 92 92 { 93 93 struct uart_port *port = dev_id; 94 94 struct clps711x_port *s = dev_get_drvdata(port->dev); 95 - unsigned int status, flg; 95 + unsigned int status; 96 96 u16 ch; 97 + u8 flg; 97 98 98 99 for (;;) { 99 100 u32 sysflg = 0; ··· 451 450 if (IS_ERR(uart_clk)) 452 451 return PTR_ERR(uart_clk); 453 452 454 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 455 - s->port.membase = devm_ioremap_resource(&pdev->dev, res); 453 + s->port.membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 456 454 if (IS_ERR(s->port.membase)) 457 455 return PTR_ERR(s->port.membase); 458 456
-12
drivers/tty/serial/cpm_uart/Makefile
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - # 3 - # Makefile for the Motorola 8xx FEC ethernet controller 4 - # 5 - 6 - obj-$(CONFIG_SERIAL_CPM) += cpm_uart.o 7 - 8 - # Select the correct platform objects. 9 - cpm_uart-objs-$(CONFIG_CPM2) += cpm_uart_cpm2.o 10 - cpm_uart-objs-$(CONFIG_CPM1) += cpm_uart_cpm1.o 11 - 12 - cpm_uart-objs := cpm_uart_core.o $(cpm_uart-objs-y)
+5 -33
drivers/tty/serial/cpm_uart/cpm_uart.h drivers/tty/serial/cpm_uart.h
··· 11 11 #define CPM_UART_H 12 12 13 13 #include <linux/platform_device.h> 14 - #include <linux/fs_uart_pd.h> 15 14 16 15 struct gpio_desc; 17 16 18 17 #if defined(CONFIG_CPM2) 19 - #include "cpm_uart_cpm2.h" 18 + #include "asm/cpm2.h" 20 19 #elif defined(CONFIG_CPM1) 21 - #include "cpm_uart_cpm1.h" 20 + #include "asm/cpm1.h" 22 21 #endif 22 + 23 + #define DPRAM_BASE ((u8 __iomem *)cpm_muram_addr(0)) 23 24 24 25 #define SERIAL_CPM_MAJOR 204 25 26 #define SERIAL_CPM_MINOR 46 26 27 27 28 #define IS_SMC(pinfo) (pinfo->flags & FLAG_SMC) 28 - #define IS_DISCARDING(pinfo) (pinfo->flags & FLAG_DISCARDING) 29 - #define FLAG_DISCARDING 0x00000004 /* when set, don't discard */ 30 29 #define FLAG_SMC 0x00000002 31 30 #define FLAG_CONSOLE 0x00000001 32 31 33 - #define UART_SMC1 fsid_smc1_uart 34 - #define UART_SMC2 fsid_smc2_uart 35 - #define UART_SCC1 fsid_scc1_uart 36 - #define UART_SCC2 fsid_scc2_uart 37 - #define UART_SCC3 fsid_scc3_uart 38 - #define UART_SCC4 fsid_scc4_uart 39 - 40 - #define UART_NR fs_uart_nr 32 + #define UART_NR 6 41 33 42 34 #define RX_NUM_FIFO 4 43 35 #define RX_BUF_SIZE 32 44 36 #define TX_NUM_FIFO 4 45 37 #define TX_BUF_SIZE 32 46 - 47 - #define SCC_WAIT_CLOSING 100 48 38 49 39 #define GPIO_CTS 0 50 40 #define GPIO_RTS 1 ··· 74 84 u32 command; 75 85 struct gpio_desc *gpios[NUM_GPIOS]; 76 86 }; 77 - 78 - extern struct uart_cpm_port cpm_uart_ports[UART_NR]; 79 - 80 - /* these are located in their respective files */ 81 - void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd); 82 - void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port, 83 - struct device_node *np); 84 - void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram); 85 - int cpm_uart_init_portdesc(void); 86 - int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con); 87 - void cpm_uart_freebuf(struct uart_cpm_port *pinfo); 88 - 89 - void smc1_lineif(struct uart_cpm_port *pinfo); 90 - void smc2_lineif(struct uart_cpm_port *pinfo); 91 - void scc1_lineif(struct uart_cpm_port *pinfo); 92 - void scc2_lineif(struct uart_cpm_port *pinfo); 93 - void scc3_lineif(struct uart_cpm_port *pinfo); 94 - void scc4_lineif(struct uart_cpm_port *pinfo); 95 87 96 88 /* 97 89 virtual to phys transtalion
+139 -18
drivers/tty/serial/cpm_uart/cpm_uart_core.c drivers/tty/serial/cpm_uart.c
··· 26 26 #include <linux/device.h> 27 27 #include <linux/memblock.h> 28 28 #include <linux/dma-mapping.h> 29 - #include <linux/fs_uart_pd.h> 30 29 #include <linux/of_address.h> 31 30 #include <linux/of_irq.h> 32 31 #include <linux/of_platform.h> 33 32 #include <linux/gpio/consumer.h> 34 33 #include <linux/clk.h> 35 34 35 + #include <sysdev/fsl_soc.h> 36 + 36 37 #include <asm/io.h> 37 38 #include <asm/irq.h> 38 39 #include <asm/delay.h> 39 - #include <asm/fs_pd.h> 40 40 #include <asm/udbg.h> 41 41 42 42 #include <linux/serial_core.h> ··· 48 48 /**************************************************************/ 49 49 50 50 static int cpm_uart_tx_pump(struct uart_port *port); 51 - static void cpm_uart_init_smc(struct uart_cpm_port *pinfo); 52 - static void cpm_uart_init_scc(struct uart_cpm_port *pinfo); 53 51 static void cpm_uart_initbd(struct uart_cpm_port *pinfo); 54 52 55 53 /**************************************************************/ 56 54 57 55 #define HW_BUF_SPD_THRESHOLD 2400 56 + 57 + static void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd) 58 + { 59 + cpm_command(port->command, cmd); 60 + } 58 61 59 62 /* 60 63 * Check, if transmit buffers are processed ··· 608 605 if (pinfo->clk) 609 606 clk_set_rate(pinfo->clk, baud); 610 607 else 611 - cpm_set_brg(pinfo->brg - 1, baud); 608 + cpm_setbrg(pinfo->brg - 1, baud); 612 609 spin_unlock_irqrestore(&port->lock, flags); 613 610 } 614 611 ··· 774 771 * parameter ram. 775 772 */ 776 773 777 - cpm_set_scc_fcr(sup); 774 + out_8(&sup->scc_genscc.scc_rfcr, CPMFCR_GBL | CPMFCR_EB); 775 + out_8(&sup->scc_genscc.scc_tfcr, CPMFCR_GBL | CPMFCR_EB); 778 776 779 777 out_be16(&sup->scc_genscc.scc_mrblr, pinfo->rx_fifosize); 780 778 out_be16(&sup->scc_maxidl, 0x10); ··· 846 842 /* Set up the uart parameters in the 847 843 * parameter ram. 848 844 */ 849 - cpm_set_smc_fcr(up); 845 + out_8(&up->smc_rfcr, CPMFCR_GBL | CPMFCR_EB); 846 + out_8(&up->smc_tfcr, CPMFCR_GBL | CPMFCR_EB); 850 847 851 848 /* Using idle character time requires some additional tuning. */ 852 849 out_be16(&up->smc_mrblr, pinfo->rx_fifosize); ··· 866 861 out_8(&sp->smc_smce, 0xff); 867 862 868 863 setbits16(&sp->smc_smcmr, SMCMR_REN | SMCMR_TEN); 864 + } 865 + 866 + /* 867 + * Allocate DP-Ram and memory buffers. We need to allocate a transmit and 868 + * receive buffer descriptors from dual port ram, and a character 869 + * buffer area from host mem. If we are allocating for the console we need 870 + * to do it from bootmem 871 + */ 872 + static int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con) 873 + { 874 + int dpmemsz, memsz; 875 + u8 __iomem *dp_mem; 876 + unsigned long dp_offset; 877 + u8 *mem_addr; 878 + dma_addr_t dma_addr = 0; 879 + 880 + pr_debug("CPM uart[%d]:allocbuf\n", pinfo->port.line); 881 + 882 + dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos); 883 + dp_offset = cpm_muram_alloc(dpmemsz, 8); 884 + if (IS_ERR_VALUE(dp_offset)) { 885 + pr_err("%s: could not allocate buffer descriptors\n", __func__); 886 + return -ENOMEM; 887 + } 888 + 889 + dp_mem = cpm_muram_addr(dp_offset); 890 + 891 + memsz = L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize) + 892 + L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize); 893 + if (IS_ENABLED(CONFIG_CPM1) && is_con) { 894 + /* was hostalloc but changed cause it blows away the */ 895 + /* large tlb mapping when pinning the kernel area */ 896 + mem_addr = (u8 __force *)cpm_muram_addr(cpm_muram_alloc(memsz, 8)); 897 + dma_addr = cpm_muram_dma((void __iomem *)mem_addr); 898 + } else if (is_con) { 899 + mem_addr = kzalloc(memsz, GFP_NOWAIT); 900 + dma_addr = virt_to_bus(mem_addr); 901 + } else { 902 + mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, &dma_addr, 903 + GFP_KERNEL); 904 + } 905 + 906 + if (!mem_addr) { 907 + cpm_muram_free(dp_offset); 908 + pr_err("%s: could not allocate coherent memory\n", __func__); 909 + return -ENOMEM; 910 + } 911 + 912 + pinfo->dp_addr = dp_offset; 913 + pinfo->mem_addr = mem_addr; 914 + pinfo->dma_addr = dma_addr; 915 + pinfo->mem_size = memsz; 916 + 917 + pinfo->rx_buf = mem_addr; 918 + pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos 919 + * pinfo->rx_fifosize); 920 + 921 + pinfo->rx_bd_base = (cbd_t __iomem *)dp_mem; 922 + pinfo->tx_bd_base = pinfo->rx_bd_base + pinfo->rx_nrfifos; 923 + 924 + return 0; 925 + } 926 + 927 + static void cpm_uart_freebuf(struct uart_cpm_port *pinfo) 928 + { 929 + dma_free_coherent(pinfo->port.dev, L1_CACHE_ALIGN(pinfo->rx_nrfifos * 930 + pinfo->rx_fifosize) + 931 + L1_CACHE_ALIGN(pinfo->tx_nrfifos * 932 + pinfo->tx_fifosize), (void __force *)pinfo->mem_addr, 933 + pinfo->dma_addr); 934 + 935 + cpm_muram_free(pinfo->dp_addr); 869 936 } 870 937 871 938 /* ··· 1205 1128 #endif 1206 1129 }; 1207 1130 1208 - struct uart_cpm_port cpm_uart_ports[UART_NR]; 1131 + static struct uart_cpm_port cpm_uart_ports[UART_NR]; 1132 + 1133 + static void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port, 1134 + struct device_node *np) 1135 + { 1136 + void __iomem *pram; 1137 + unsigned long offset; 1138 + struct resource res; 1139 + resource_size_t len; 1140 + 1141 + /* Don't remap parameter RAM if it has already been initialized 1142 + * during console setup. 1143 + */ 1144 + if (IS_SMC(port) && port->smcup) 1145 + return port->smcup; 1146 + else if (!IS_SMC(port) && port->sccup) 1147 + return port->sccup; 1148 + 1149 + if (of_address_to_resource(np, 1, &res)) 1150 + return NULL; 1151 + 1152 + len = resource_size(&res); 1153 + pram = ioremap(res.start, len); 1154 + if (!pram) 1155 + return NULL; 1156 + 1157 + if (!IS_ENABLED(CONFIG_CPM2) || !IS_SMC(port)) 1158 + return pram; 1159 + 1160 + if (len != 2) { 1161 + pr_warn("cpm_uart[%d]: device tree references " 1162 + "SMC pram, using boot loader/wrapper pram mapping. " 1163 + "Please fix your device tree to reference the pram " 1164 + "base register instead.\n", 1165 + port->port.line); 1166 + return pram; 1167 + } 1168 + 1169 + offset = cpm_muram_alloc(64, 64); 1170 + out_be16(pram, offset); 1171 + iounmap(pram); 1172 + return cpm_muram_addr(offset); 1173 + } 1174 + 1175 + static void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram) 1176 + { 1177 + if (!IS_ENABLED(CONFIG_CPM2) || !IS_SMC(port)) 1178 + iounmap(pram); 1179 + } 1209 1180 1210 1181 static int cpm_uart_init_port(struct device_node *np, 1211 1182 struct uart_cpm_port *pinfo) ··· 1380 1255 { 1381 1256 struct uart_cpm_port *pinfo = &cpm_uart_ports[co->index]; 1382 1257 unsigned long flags; 1383 - int nolock = oops_in_progress; 1384 1258 1385 - if (unlikely(nolock)) { 1259 + if (unlikely(oops_in_progress)) { 1386 1260 local_irq_save(flags); 1387 - } else { 1388 - spin_lock_irqsave(&pinfo->port.lock, flags); 1389 - } 1390 - 1391 - cpm_uart_early_write(pinfo, s, count, true); 1392 - 1393 - if (unlikely(nolock)) { 1261 + cpm_uart_early_write(pinfo, s, count, true); 1394 1262 local_irq_restore(flags); 1395 1263 } else { 1264 + spin_lock_irqsave(&pinfo->port.lock, flags); 1265 + cpm_uart_early_write(pinfo, s, count, true); 1396 1266 spin_unlock_irqrestore(&pinfo->port.lock, flags); 1397 1267 } 1398 1268 } ··· 1439 1319 if (options) { 1440 1320 uart_parse_options(options, &baud, &parity, &bits, &flow); 1441 1321 } else { 1442 - if ((baud = uart_baudrate()) == -1) 1322 + baud = get_baudrate(); 1323 + if (baud == -1) 1443 1324 baud = 9600; 1444 1325 } 1445 1326
-122
drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 2 - /* 3 - * Driver for CPM (SCC/SMC) serial ports; CPM1 definitions 4 - * 5 - * Maintainer: Kumar Gala (galak@kernel.crashing.org) (CPM2) 6 - * Pantelis Antoniou (panto@intracom.gr) (CPM1) 7 - * 8 - * Copyright (C) 2004 Freescale Semiconductor, Inc. 9 - * (C) 2004 Intracom, S.A. 10 - * (C) 2006 MontaVista Software, Inc. 11 - * Vitaly Bordug <vbordug@ru.mvista.com> 12 - */ 13 - 14 - #include <linux/module.h> 15 - #include <linux/tty.h> 16 - #include <linux/gfp.h> 17 - #include <linux/ioport.h> 18 - #include <linux/serial.h> 19 - #include <linux/console.h> 20 - #include <linux/sysrq.h> 21 - #include <linux/device.h> 22 - #include <linux/memblock.h> 23 - #include <linux/dma-mapping.h> 24 - 25 - #include <asm/io.h> 26 - #include <asm/irq.h> 27 - #include <asm/fs_pd.h> 28 - 29 - #include <linux/serial_core.h> 30 - #include <linux/kernel.h> 31 - 32 - #include <linux/of.h> 33 - #include <linux/of_address.h> 34 - 35 - #include "cpm_uart.h" 36 - 37 - /**************************************************************/ 38 - 39 - void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd) 40 - { 41 - cpm_command(port->command, cmd); 42 - } 43 - 44 - void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port, 45 - struct device_node *np) 46 - { 47 - return of_iomap(np, 1); 48 - } 49 - 50 - void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram) 51 - { 52 - iounmap(pram); 53 - } 54 - 55 - /* 56 - * Allocate DP-Ram and memory buffers. We need to allocate a transmit and 57 - * receive buffer descriptors from dual port ram, and a character 58 - * buffer area from host mem. If we are allocating for the console we need 59 - * to do it from bootmem 60 - */ 61 - int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con) 62 - { 63 - int dpmemsz, memsz; 64 - u8 *dp_mem; 65 - unsigned long dp_offset; 66 - u8 *mem_addr; 67 - dma_addr_t dma_addr = 0; 68 - 69 - pr_debug("CPM uart[%d]:allocbuf\n", pinfo->port.line); 70 - 71 - dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos); 72 - dp_offset = cpm_dpalloc(dpmemsz, 8); 73 - if (IS_ERR_VALUE(dp_offset)) { 74 - printk(KERN_ERR 75 - "cpm_uart_cpm1.c: could not allocate buffer descriptors\n"); 76 - return -ENOMEM; 77 - } 78 - dp_mem = cpm_dpram_addr(dp_offset); 79 - 80 - memsz = L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize) + 81 - L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize); 82 - if (is_con) { 83 - /* was hostalloc but changed cause it blows away the */ 84 - /* large tlb mapping when pinning the kernel area */ 85 - mem_addr = (u8 *) cpm_dpram_addr(cpm_dpalloc(memsz, 8)); 86 - dma_addr = (u32)cpm_dpram_phys(mem_addr); 87 - } else 88 - mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, &dma_addr, 89 - GFP_KERNEL); 90 - 91 - if (mem_addr == NULL) { 92 - cpm_dpfree(dp_offset); 93 - printk(KERN_ERR 94 - "cpm_uart_cpm1.c: could not allocate coherent memory\n"); 95 - return -ENOMEM; 96 - } 97 - 98 - pinfo->dp_addr = dp_offset; 99 - pinfo->mem_addr = mem_addr; /* virtual address*/ 100 - pinfo->dma_addr = dma_addr; /* physical address*/ 101 - pinfo->mem_size = memsz; 102 - 103 - pinfo->rx_buf = mem_addr; 104 - pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos 105 - * pinfo->rx_fifosize); 106 - 107 - pinfo->rx_bd_base = (cbd_t __iomem __force *)dp_mem; 108 - pinfo->tx_bd_base = pinfo->rx_bd_base + pinfo->rx_nrfifos; 109 - 110 - return 0; 111 - } 112 - 113 - void cpm_uart_freebuf(struct uart_cpm_port *pinfo) 114 - { 115 - dma_free_coherent(pinfo->port.dev, L1_CACHE_ALIGN(pinfo->rx_nrfifos * 116 - pinfo->rx_fifosize) + 117 - L1_CACHE_ALIGN(pinfo->tx_nrfifos * 118 - pinfo->tx_fifosize), pinfo->mem_addr, 119 - pinfo->dma_addr); 120 - 121 - cpm_dpfree(pinfo->dp_addr); 122 - }
-33
drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * Driver for CPM (SCC/SMC) serial ports 4 - * 5 - * definitions for cpm1 6 - * 7 - */ 8 - 9 - #ifndef CPM_UART_CPM1_H 10 - #define CPM_UART_CPM1_H 11 - 12 - #include <asm/cpm1.h> 13 - 14 - static inline void cpm_set_brg(int brg, int baud) 15 - { 16 - cpm_setbrg(brg, baud); 17 - } 18 - 19 - static inline void cpm_set_scc_fcr(scc_uart_t __iomem * sup) 20 - { 21 - out_8(&sup->scc_genscc.scc_rfcr, SMC_EB); 22 - out_8(&sup->scc_genscc.scc_tfcr, SMC_EB); 23 - } 24 - 25 - static inline void cpm_set_smc_fcr(smc_uart_t __iomem * up) 26 - { 27 - out_8(&up->smc_rfcr, SMC_EB); 28 - out_8(&up->smc_tfcr, SMC_EB); 29 - } 30 - 31 - #define DPRAM_BASE ((u8 __iomem __force *)cpm_dpram_addr(0)) 32 - 33 - #endif
-156
drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
··· 1 - // SPDX-License-Identifier: GPL-2.0+ 2 - /* 3 - * Driver for CPM (SCC/SMC) serial ports; CPM2 definitions 4 - * 5 - * Maintainer: Kumar Gala (galak@kernel.crashing.org) (CPM2) 6 - * Pantelis Antoniou (panto@intracom.gr) (CPM1) 7 - * 8 - * Copyright (C) 2004 Freescale Semiconductor, Inc. 9 - * (C) 2004 Intracom, S.A. 10 - * (C) 2006 MontaVista Software, Inc. 11 - * Vitaly Bordug <vbordug@ru.mvista.com> 12 - */ 13 - 14 - #include <linux/module.h> 15 - #include <linux/tty.h> 16 - #include <linux/ioport.h> 17 - #include <linux/slab.h> 18 - #include <linux/serial.h> 19 - #include <linux/console.h> 20 - #include <linux/sysrq.h> 21 - #include <linux/device.h> 22 - #include <linux/memblock.h> 23 - #include <linux/dma-mapping.h> 24 - 25 - #include <asm/io.h> 26 - #include <asm/irq.h> 27 - #include <asm/fs_pd.h> 28 - 29 - #include <linux/serial_core.h> 30 - #include <linux/kernel.h> 31 - 32 - #include "cpm_uart.h" 33 - 34 - /**************************************************************/ 35 - 36 - void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd) 37 - { 38 - cpm_command(port->command, cmd); 39 - } 40 - 41 - void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port, 42 - struct device_node *np) 43 - { 44 - void __iomem *pram; 45 - unsigned long offset; 46 - struct resource res; 47 - resource_size_t len; 48 - 49 - /* Don't remap parameter RAM if it has already been initialized 50 - * during console setup. 51 - */ 52 - if (IS_SMC(port) && port->smcup) 53 - return port->smcup; 54 - else if (!IS_SMC(port) && port->sccup) 55 - return port->sccup; 56 - 57 - if (of_address_to_resource(np, 1, &res)) 58 - return NULL; 59 - 60 - len = resource_size(&res); 61 - pram = ioremap(res.start, len); 62 - if (!pram) 63 - return NULL; 64 - 65 - if (!IS_SMC(port)) 66 - return pram; 67 - 68 - if (len != 2) { 69 - printk(KERN_WARNING "cpm_uart[%d]: device tree references " 70 - "SMC pram, using boot loader/wrapper pram mapping. " 71 - "Please fix your device tree to reference the pram " 72 - "base register instead.\n", 73 - port->port.line); 74 - return pram; 75 - } 76 - 77 - offset = cpm_dpalloc(PROFF_SMC_SIZE, 64); 78 - out_be16(pram, offset); 79 - iounmap(pram); 80 - return cpm_muram_addr(offset); 81 - } 82 - 83 - void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram) 84 - { 85 - if (!IS_SMC(port)) 86 - iounmap(pram); 87 - } 88 - 89 - /* 90 - * Allocate DP-Ram and memory buffers. We need to allocate a transmit and 91 - * receive buffer descriptors from dual port ram, and a character 92 - * buffer area from host mem. If we are allocating for the console we need 93 - * to do it from bootmem 94 - */ 95 - int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con) 96 - { 97 - int dpmemsz, memsz; 98 - u8 __iomem *dp_mem; 99 - unsigned long dp_offset; 100 - u8 *mem_addr; 101 - dma_addr_t dma_addr = 0; 102 - 103 - pr_debug("CPM uart[%d]:allocbuf\n", pinfo->port.line); 104 - 105 - dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos); 106 - dp_offset = cpm_dpalloc(dpmemsz, 8); 107 - if (IS_ERR_VALUE(dp_offset)) { 108 - printk(KERN_ERR 109 - "cpm_uart_cpm.c: could not allocate buffer descriptors\n"); 110 - return -ENOMEM; 111 - } 112 - 113 - dp_mem = cpm_dpram_addr(dp_offset); 114 - 115 - memsz = L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize) + 116 - L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize); 117 - if (is_con) { 118 - mem_addr = kzalloc(memsz, GFP_NOWAIT); 119 - dma_addr = virt_to_bus(mem_addr); 120 - } 121 - else 122 - mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, &dma_addr, 123 - GFP_KERNEL); 124 - 125 - if (mem_addr == NULL) { 126 - cpm_dpfree(dp_offset); 127 - printk(KERN_ERR 128 - "cpm_uart_cpm.c: could not allocate coherent memory\n"); 129 - return -ENOMEM; 130 - } 131 - 132 - pinfo->dp_addr = dp_offset; 133 - pinfo->mem_addr = mem_addr; 134 - pinfo->dma_addr = dma_addr; 135 - pinfo->mem_size = memsz; 136 - 137 - pinfo->rx_buf = mem_addr; 138 - pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos 139 - * pinfo->rx_fifosize); 140 - 141 - pinfo->rx_bd_base = (cbd_t __iomem *)dp_mem; 142 - pinfo->tx_bd_base = pinfo->rx_bd_base + pinfo->rx_nrfifos; 143 - 144 - return 0; 145 - } 146 - 147 - void cpm_uart_freebuf(struct uart_cpm_port *pinfo) 148 - { 149 - dma_free_coherent(pinfo->port.dev, L1_CACHE_ALIGN(pinfo->rx_nrfifos * 150 - pinfo->rx_fifosize) + 151 - L1_CACHE_ALIGN(pinfo->tx_nrfifos * 152 - pinfo->tx_fifosize), (void __force *)pinfo->mem_addr, 153 - pinfo->dma_addr); 154 - 155 - cpm_dpfree(pinfo->dp_addr); 156 - }
-33
drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * Driver for CPM (SCC/SMC) serial ports 4 - * 5 - * definitions for cpm2 6 - * 7 - */ 8 - 9 - #ifndef CPM_UART_CPM2_H 10 - #define CPM_UART_CPM2_H 11 - 12 - #include <asm/cpm2.h> 13 - 14 - static inline void cpm_set_brg(int brg, int baud) 15 - { 16 - cpm_setbrg(brg, baud); 17 - } 18 - 19 - static inline void cpm_set_scc_fcr(scc_uart_t __iomem *sup) 20 - { 21 - out_8(&sup->scc_genscc.scc_rfcr, CPMFCR_GBL | CPMFCR_EB); 22 - out_8(&sup->scc_genscc.scc_tfcr, CPMFCR_GBL | CPMFCR_EB); 23 - } 24 - 25 - static inline void cpm_set_smc_fcr(smc_uart_t __iomem *up) 26 - { 27 - out_8(&up->smc_rfcr, CPMFCR_GBL | CPMFCR_EB); 28 - out_8(&up->smc_tfcr, CPMFCR_GBL | CPMFCR_EB); 29 - } 30 - 31 - #define DPRAM_BASE ((u8 __iomem __force *)cpm_dpram_addr(0)) 32 - 33 - #endif
+1 -2
drivers/tty/serial/digicolor-usart.c
··· 136 136 spin_lock_irqsave(&port->lock, flags); 137 137 138 138 while (1) { 139 - u8 status, ch; 140 - unsigned int ch_flag; 139 + u8 status, ch, ch_flag; 141 140 142 141 if (digicolor_uart_rx_empty(port)) 143 142 break;
+1 -1
drivers/tty/serial/dz.c
··· 181 181 struct dz_port *dport = &mux->dport[0]; 182 182 struct uart_icount *icount; 183 183 int lines_rx[DZ_NB_PORT] = { [0 ... DZ_NB_PORT - 1] = 0 }; 184 - unsigned char ch, flag; 185 184 u16 status; 185 + u8 ch, flag; 186 186 int i; 187 187 188 188 while ((status = dz_in(dport, DZ_RBUF)) & DZ_DVAL) {
+3 -7
drivers/tty/serial/fsl_linflexuart.c
··· 11 11 #include <linux/irq.h> 12 12 #include <linux/module.h> 13 13 #include <linux/of.h> 14 - #include <linux/of_device.h> 14 + #include <linux/platform_device.h> 15 15 #include <linux/serial_core.h> 16 16 #include <linux/slab.h> 17 17 #include <linux/tty_flip.h> ··· 827 827 828 828 sport->line = ret; 829 829 830 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 831 - if (!res) 832 - return -ENODEV; 833 - 834 - sport->mapbase = res->start; 835 - sport->membase = devm_ioremap_resource(&pdev->dev, res); 830 + sport->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 836 831 if (IS_ERR(sport->membase)) 837 832 return PTR_ERR(sport->membase); 833 + sport->mapbase = res->start; 838 834 839 835 sport->dev = &pdev->dev; 840 836 sport->type = PORT_LINFLEXUART;
+63 -25
drivers/tty/serial/fsl_lpuart.c
··· 18 18 #include <linux/irq.h> 19 19 #include <linux/module.h> 20 20 #include <linux/of.h> 21 - #include <linux/of_device.h> 22 21 #include <linux/of_dma.h> 23 22 #include <linux/pinctrl/consumer.h> 23 + #include <linux/platform_device.h> 24 24 #include <linux/pm_runtime.h> 25 25 #include <linux/serial_core.h> 26 26 #include <linux/slab.h> ··· 288 288 wait_queue_head_t dma_wait; 289 289 bool is_cs7; /* Set to true when character size is 7 */ 290 290 /* and the parity is enabled */ 291 + bool dma_idle_int; 291 292 }; 292 293 293 294 struct lpuart_soc_data { ··· 1065 1064 return IRQ_HANDLED; 1066 1065 } 1067 1066 1068 - static irqreturn_t lpuart32_int(int irq, void *dev_id) 1069 - { 1070 - struct lpuart_port *sport = dev_id; 1071 - unsigned long sts, rxcount; 1072 - 1073 - sts = lpuart32_read(&sport->port, UARTSTAT); 1074 - rxcount = lpuart32_read(&sport->port, UARTWATER); 1075 - rxcount = rxcount >> UARTWATER_RXCNT_OFF; 1076 - 1077 - if ((sts & UARTSTAT_RDRF || rxcount > 0) && !sport->lpuart_dma_rx_use) 1078 - lpuart32_rxint(sport); 1079 - 1080 - if ((sts & UARTSTAT_TDRE) && !sport->lpuart_dma_tx_use) 1081 - lpuart32_txint(sport); 1082 - 1083 - lpuart32_write(&sport->port, sts, UARTSTAT); 1084 - return IRQ_HANDLED; 1085 - } 1086 - 1087 - 1088 1067 static inline void lpuart_handle_sysrq_chars(struct uart_port *port, 1089 1068 unsigned char *p, int count) 1090 1069 { ··· 1247 1266 spin_unlock_irqrestore(&sport->port.lock, flags); 1248 1267 1249 1268 tty_flip_buffer_push(port); 1250 - mod_timer(&sport->lpuart_timer, jiffies + sport->dma_rx_timeout); 1269 + if (!sport->dma_idle_int) 1270 + mod_timer(&sport->lpuart_timer, jiffies + sport->dma_rx_timeout); 1251 1271 } 1252 1272 1253 1273 static void lpuart_dma_rx_complete(void *arg) ··· 1256 1274 struct lpuart_port *sport = arg; 1257 1275 1258 1276 lpuart_copy_rx_to_tty(sport); 1277 + } 1278 + 1279 + static void lpuart32_dma_idleint(struct lpuart_port *sport) 1280 + { 1281 + enum dma_status dmastat; 1282 + struct dma_chan *chan = sport->dma_rx_chan; 1283 + struct circ_buf *ring = &sport->rx_ring; 1284 + struct dma_tx_state state; 1285 + int count = 0; 1286 + 1287 + dmastat = dmaengine_tx_status(chan, sport->dma_rx_cookie, &state); 1288 + if (dmastat == DMA_ERROR) { 1289 + dev_err(sport->port.dev, "Rx DMA transfer failed!\n"); 1290 + return; 1291 + } 1292 + 1293 + ring->head = sport->rx_sgl.length - state.residue; 1294 + count = CIRC_CNT(ring->head, ring->tail, sport->rx_sgl.length); 1295 + 1296 + /* Check if new data received before copying */ 1297 + if (count) 1298 + lpuart_copy_rx_to_tty(sport); 1299 + } 1300 + 1301 + static irqreturn_t lpuart32_int(int irq, void *dev_id) 1302 + { 1303 + struct lpuart_port *sport = dev_id; 1304 + unsigned long sts, rxcount; 1305 + 1306 + sts = lpuart32_read(&sport->port, UARTSTAT); 1307 + rxcount = lpuart32_read(&sport->port, UARTWATER); 1308 + rxcount = rxcount >> UARTWATER_RXCNT_OFF; 1309 + 1310 + if ((sts & UARTSTAT_RDRF || rxcount > 0) && !sport->lpuart_dma_rx_use) 1311 + lpuart32_rxint(sport); 1312 + 1313 + if ((sts & UARTSTAT_TDRE) && !sport->lpuart_dma_tx_use) 1314 + lpuart32_txint(sport); 1315 + 1316 + if ((sts & UARTSTAT_IDLE) && sport->lpuart_dma_rx_use && sport->dma_idle_int) 1317 + lpuart32_dma_idleint(sport); 1318 + 1319 + lpuart32_write(&sport->port, sts, UARTSTAT); 1320 + return IRQ_HANDLED; 1259 1321 } 1260 1322 1261 1323 /* ··· 1418 1392 unsigned long temp = lpuart32_read(&sport->port, UARTBAUD); 1419 1393 1420 1394 lpuart32_write(&sport->port, temp | UARTBAUD_RDMAE, UARTBAUD); 1395 + 1396 + if (sport->dma_idle_int) { 1397 + unsigned long ctrl = lpuart32_read(&sport->port, UARTCTRL); 1398 + 1399 + lpuart32_write(&sport->port, ctrl | UARTCTRL_ILIE, UARTCTRL); 1400 + } 1421 1401 } else { 1422 1402 writeb(readb(sport->port.membase + UARTCR5) | UARTCR5_RDMAS, 1423 1403 sport->port.membase + UARTCR5); ··· 1439 1407 struct dma_chan *chan = sport->dma_rx_chan; 1440 1408 1441 1409 dmaengine_terminate_sync(chan); 1442 - del_timer_sync(&sport->lpuart_timer); 1410 + if (!sport->dma_idle_int) 1411 + del_timer_sync(&sport->lpuart_timer); 1412 + 1443 1413 dma_unmap_sg(chan->device->dev, &sport->rx_sgl, 1, DMA_FROM_DEVICE); 1444 1414 kfree(sport->rx_ring.buf); 1445 1415 sport->rx_ring.tail = 0; ··· 1703 1669 1704 1670 static void rx_dma_timer_init(struct lpuart_port *sport) 1705 1671 { 1672 + if (sport->dma_idle_int) 1673 + return; 1674 + 1706 1675 timer_setup(&sport->lpuart_timer, lpuart_timer_func, 0); 1707 1676 sport->lpuart_timer.expires = jiffies + sport->dma_rx_timeout; 1708 1677 add_timer(&sport->lpuart_timer); ··· 2848 2811 if (!sport) 2849 2812 return -ENOMEM; 2850 2813 2851 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2852 - sport->port.membase = devm_ioremap_resource(&pdev->dev, res); 2814 + sport->port.membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 2853 2815 if (IS_ERR(sport->port.membase)) 2854 2816 return PTR_ERR(sport->port.membase); 2855 2817 ··· 2858 2822 sport->port.type = PORT_LPUART; 2859 2823 sport->devtype = sdata->devtype; 2860 2824 sport->rx_watermark = sdata->rx_watermark; 2825 + sport->dma_idle_int = is_imx7ulp_lpuart(sport) || is_imx8ulp_lpuart(sport) || 2826 + is_imx8qxp_lpuart(sport); 2861 2827 ret = platform_get_irq(pdev, 0); 2862 2828 if (ret < 0) 2863 2829 return ret;
+1 -3
drivers/tty/serial/imx.c
··· 25 25 #include <linux/rational.h> 26 26 #include <linux/slab.h> 27 27 #include <linux/of.h> 28 - #include <linux/of_device.h> 29 28 #include <linux/io.h> 30 29 #include <linux/dma-mapping.h> 31 30 ··· 2275 2276 return -EINVAL; 2276 2277 } 2277 2278 2278 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 2279 - base = devm_ioremap_resource(&pdev->dev, res); 2279 + base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 2280 2280 if (IS_ERR(base)) 2281 2281 return PTR_ERR(base); 2282 2282
+1 -1
drivers/tty/serial/ip22zilog.c
··· 248 248 static bool ip22zilog_receive_chars(struct uart_ip22zilog_port *up, 249 249 struct zilog_channel *channel) 250 250 { 251 - unsigned char ch, flag; 252 251 unsigned int r1; 252 + u8 ch, flag; 253 253 bool push = up->port.state != NULL; 254 254 255 255 for (;;) {
+2 -1
drivers/tty/serial/kgdb_nmi.c
··· 304 304 return 2048; 305 305 } 306 306 307 - static int kgdb_nmi_tty_write(struct tty_struct *tty, const unchar *buf, int c) 307 + static ssize_t kgdb_nmi_tty_write(struct tty_struct *tty, const u8 *buf, 308 + size_t c) 308 309 { 309 310 int i; 310 311
+2 -1
drivers/tty/serial/lantiq.c
··· 17 17 #include <linux/ioport.h> 18 18 #include <linux/lantiq.h> 19 19 #include <linux/module.h> 20 - #include <linux/of_platform.h> 20 + #include <linux/of.h> 21 + #include <linux/platform_device.h> 21 22 #include <linux/serial.h> 22 23 #include <linux/serial_core.h> 23 24 #include <linux/slab.h>
+1 -2
drivers/tty/serial/liteuart.c
··· 11 11 #include <linux/litex.h> 12 12 #include <linux/module.h> 13 13 #include <linux/of.h> 14 - #include <linux/of_address.h> 15 - #include <linux/of_platform.h> 14 + #include <linux/platform_device.h> 16 15 #include <linux/serial.h> 17 16 #include <linux/serial_core.h> 18 17 #include <linux/slab.h>
+1 -2
drivers/tty/serial/ma35d1_serial.c
··· 8 8 #include <linux/clk.h> 9 9 #include <linux/delay.h> 10 10 #include <linux/of.h> 11 - #include <linux/of_platform.h> 11 + #include <linux/platform_device.h> 12 12 #include <linux/iopoll.h> 13 13 #include <linux/serial_core.h> 14 14 #include <linux/slab.h> ··· 788 788 .resume = ma35d1serial_resume, 789 789 .driver = { 790 790 .name = "ma35d1-uart", 791 - .owner = THIS_MODULE, 792 791 .of_match_table = of_match_ptr(ma35d1_serial_of_match), 793 792 }, 794 793 };
+2 -1
drivers/tty/serial/max3100.c
··· 215 215 216 216 static int max3100_handlerx(struct max3100_port *s, u16 rx) 217 217 { 218 - unsigned int ch, flg, status = 0; 218 + unsigned int status = 0; 219 219 int ret = 0, cts; 220 + u8 ch, flg; 220 221 221 222 if (rx & MAX3100_R && s->rx_enabled) { 222 223 dev_dbg(&s->spi->dev, "%s\n", __func__);
+8 -2
drivers/tty/serial/max310x.c
··· 669 669 static void max310x_handle_rx(struct uart_port *port, unsigned int rxlen) 670 670 { 671 671 struct max310x_one *one = to_max310x_port(port); 672 - unsigned int sts, ch, flag, i; 672 + unsigned int sts, i; 673 + u8 ch, flag; 673 674 674 675 if (port->read_status_mask == MAX310X_LSR_RXOVR_BIT) { 675 676 /* We are just reading, happily ignoring any error conditions. ··· 1369 1368 s->p[i].port.flags = UPF_FIXED_TYPE | UPF_LOW_LATENCY; 1370 1369 s->p[i].port.iotype = UPIO_PORT; 1371 1370 s->p[i].port.iobase = i; 1371 + /* 1372 + * Use all ones as membase to make sure uart_configure_port() in 1373 + * serial_core.c does not abort for SPI/I2C devices where the 1374 + * membase address is not applicable. 1375 + */ 1372 1376 s->p[i].port.membase = (void __iomem *)~0; 1373 1377 s->p[i].port.uartclk = uartclk; 1374 1378 s->p[i].port.rs485_config = max310x_rs485_config; ··· 1405 1399 } 1406 1400 1407 1401 #ifdef CONFIG_GPIOLIB 1408 - /* Setup GPIO cotroller */ 1402 + /* Setup GPIO controller */ 1409 1403 s->gpio.owner = THIS_MODULE; 1410 1404 s->gpio.parent = dev; 1411 1405 s->gpio.label = devtype->name;
+1 -1
drivers/tty/serial/mcf.c
··· 281 281 static void mcf_rx_chars(struct mcf_uart *pp) 282 282 { 283 283 struct uart_port *port = &pp->port; 284 - unsigned char status, ch, flag; 284 + u8 status, ch, flag; 285 285 286 286 while ((status = readb(port->membase + MCFUART_USR)) & MCFUART_USR_RXREADY) { 287 287 ch = readb(port->membase + MCFUART_URB);
+77 -61
drivers/tty/serial/meson_uart.c
··· 72 72 73 73 #define AML_UART_PORT_NUM 12 74 74 #define AML_UART_PORT_OFFSET 6 75 - #define AML_UART_DEV_NAME "ttyAML" 76 75 77 76 #define AML_UART_POLL_USEC 5 78 77 #define AML_UART_TIMEOUT_USEC 10000 79 78 80 - static struct uart_driver meson_uart_driver; 79 + static struct uart_driver meson_uart_driver_ttyAML; 80 + static struct uart_driver meson_uart_driver_ttyS; 81 81 82 82 static struct uart_port *meson_ports[AML_UART_PORT_NUM]; 83 83 84 84 struct meson_uart_data { 85 + struct uart_driver *uart_driver; 85 86 bool has_xtal_div2; 86 87 }; 87 88 ··· 612 611 return uart_set_options(port, co, baud, parity, bits, flow); 613 612 } 614 613 615 - static struct console meson_serial_console = { 616 - .name = AML_UART_DEV_NAME, 617 - .write = meson_serial_console_write, 618 - .device = uart_console_device, 619 - .setup = meson_serial_console_setup, 620 - .flags = CON_PRINTBUFFER, 621 - .index = -1, 622 - .data = &meson_uart_driver, 623 - }; 614 + #define MESON_SERIAL_CONSOLE(_devname) \ 615 + static struct console meson_serial_console_##_devname = { \ 616 + .name = __stringify(_devname), \ 617 + .write = meson_serial_console_write, \ 618 + .device = uart_console_device, \ 619 + .setup = meson_serial_console_setup, \ 620 + .flags = CON_PRINTBUFFER, \ 621 + .index = -1, \ 622 + .data = &meson_uart_driver_##_devname, \ 623 + } 624 624 625 - static int __init meson_serial_console_init(void) 626 - { 627 - register_console(&meson_serial_console); 628 - return 0; 629 - } 625 + MESON_SERIAL_CONSOLE(ttyAML); 626 + MESON_SERIAL_CONSOLE(ttyS); 630 627 631 628 static void meson_serial_early_console_write(struct console *co, 632 629 const char *s, ··· 649 650 OF_EARLYCON_DECLARE(meson, "amlogic,meson-ao-uart", 650 651 meson_serial_early_console_setup); 651 652 652 - #define MESON_SERIAL_CONSOLE (&meson_serial_console) 653 + #define MESON_SERIAL_CONSOLE_PTR(_devname) (&meson_serial_console_##_devname) 653 654 #else 654 - static int __init meson_serial_console_init(void) { 655 - return 0; 656 - } 657 - #define MESON_SERIAL_CONSOLE NULL 655 + #define MESON_SERIAL_CONSOLE_PTR(_devname) (NULL) 658 656 #endif 659 657 660 - static struct uart_driver meson_uart_driver = { 661 - .owner = THIS_MODULE, 662 - .driver_name = "meson_uart", 663 - .dev_name = AML_UART_DEV_NAME, 664 - .nr = AML_UART_PORT_NUM, 665 - .cons = MESON_SERIAL_CONSOLE, 666 - }; 658 + #define MESON_UART_DRIVER(_devname) \ 659 + static struct uart_driver meson_uart_driver_##_devname = { \ 660 + .owner = THIS_MODULE, \ 661 + .driver_name = "meson_uart", \ 662 + .dev_name = __stringify(_devname), \ 663 + .nr = AML_UART_PORT_NUM, \ 664 + .cons = MESON_SERIAL_CONSOLE_PTR(_devname), \ 665 + } 666 + 667 + MESON_UART_DRIVER(ttyAML); 668 + MESON_UART_DRIVER(ttyS); 667 669 668 670 static int meson_uart_probe_clocks(struct platform_device *pdev, 669 671 struct uart_port *port) ··· 690 690 return 0; 691 691 } 692 692 693 + static struct uart_driver *meson_uart_current(const struct meson_uart_data *pd) 694 + { 695 + return (pd && pd->uart_driver) ? 696 + pd->uart_driver : &meson_uart_driver_ttyAML; 697 + } 698 + 693 699 static int meson_uart_probe(struct platform_device *pdev) 694 700 { 701 + const struct meson_uart_data *priv_data; 702 + struct uart_driver *uart_driver; 695 703 struct resource *res_mem; 696 704 struct uart_port *port; 697 705 u32 fifosize = 64; /* Default is 64, 128 for EE UART_0 */ ··· 734 726 of_property_read_u32(pdev->dev.of_node, "fifo-size", &fifosize); 735 727 736 728 if (meson_ports[pdev->id]) { 737 - dev_err(&pdev->dev, "port %d already allocated\n", pdev->id); 738 - return -EBUSY; 729 + return dev_err_probe(&pdev->dev, -EBUSY, 730 + "port %d already allocated\n", pdev->id); 739 731 } 740 732 741 733 port = devm_kzalloc(&pdev->dev, sizeof(struct uart_port), GFP_KERNEL); ··· 745 737 ret = meson_uart_probe_clocks(pdev, port); 746 738 if (ret) 747 739 return ret; 740 + 741 + priv_data = device_get_match_data(&pdev->dev); 742 + 743 + uart_driver = meson_uart_current(priv_data); 744 + 745 + if (!uart_driver->state) { 746 + ret = uart_register_driver(uart_driver); 747 + if (ret) 748 + return dev_err_probe(&pdev->dev, ret, 749 + "can't register uart driver\n"); 750 + } 748 751 749 752 port->iotype = UPIO_MEM; 750 753 port->mapbase = res_mem->start; ··· 769 750 port->x_char = 0; 770 751 port->ops = &meson_uart_ops; 771 752 port->fifosize = fifosize; 772 - port->private_data = (void *)device_get_match_data(&pdev->dev); 753 + port->private_data = (void *)priv_data; 773 754 774 755 meson_ports[pdev->id] = port; 775 756 platform_set_drvdata(pdev, port); ··· 780 761 meson_uart_release_port(port); 781 762 } 782 763 783 - ret = uart_add_one_port(&meson_uart_driver, port); 764 + ret = uart_add_one_port(uart_driver, port); 784 765 if (ret) 785 766 meson_ports[pdev->id] = NULL; 786 767 ··· 789 770 790 771 static int meson_uart_remove(struct platform_device *pdev) 791 772 { 773 + struct uart_driver *uart_driver; 792 774 struct uart_port *port; 793 775 794 776 port = platform_get_drvdata(pdev); 795 - uart_remove_one_port(&meson_uart_driver, port); 777 + uart_driver = meson_uart_current(port->private_data); 778 + uart_remove_one_port(uart_driver, port); 796 779 meson_ports[pdev->id] = NULL; 780 + 781 + for (int id = 0; id < AML_UART_PORT_NUM; id++) 782 + if (meson_ports[id]) 783 + return 0; 784 + 785 + /* No more available uart ports, unregister uart driver */ 786 + uart_unregister_driver(uart_driver); 797 787 798 788 return 0; 799 789 } 800 790 801 791 static struct meson_uart_data meson_g12a_uart_data = { 792 + .has_xtal_div2 = true, 793 + }; 794 + 795 + static struct meson_uart_data meson_a1_uart_data = { 796 + .uart_driver = &meson_uart_driver_ttyS, 797 + .has_xtal_div2 = false, 798 + }; 799 + 800 + static struct meson_uart_data meson_s4_uart_data = { 801 + .uart_driver = &meson_uart_driver_ttyS, 802 802 .has_xtal_div2 = true, 803 803 }; 804 804 ··· 832 794 }, 833 795 { 834 796 .compatible = "amlogic,meson-s4-uart", 835 - .data = (void *)&meson_g12a_uart_data, 797 + .data = (void *)&meson_s4_uart_data, 798 + }, 799 + { 800 + .compatible = "amlogic,meson-a1-uart", 801 + .data = (void *)&meson_a1_uart_data, 836 802 }, 837 803 { /* sentinel */ }, 838 804 }; ··· 851 809 }, 852 810 }; 853 811 854 - static int __init meson_uart_init(void) 855 - { 856 - int ret; 857 - 858 - ret = meson_serial_console_init(); 859 - if (ret) 860 - return ret; 861 - 862 - ret = uart_register_driver(&meson_uart_driver); 863 - if (ret) 864 - return ret; 865 - 866 - ret = platform_driver_register(&meson_uart_platform_driver); 867 - if (ret) 868 - uart_unregister_driver(&meson_uart_driver); 869 - 870 - return ret; 871 - } 872 - 873 - static void __exit meson_uart_exit(void) 874 - { 875 - platform_driver_unregister(&meson_uart_platform_driver); 876 - uart_unregister_driver(&meson_uart_driver); 877 - } 878 - 879 - module_init(meson_uart_init); 880 - module_exit(meson_uart_exit); 812 + module_platform_driver(meson_uart_platform_driver); 881 813 882 814 MODULE_AUTHOR("Carlo Caione <carlo@caione.org>"); 883 815 MODULE_DESCRIPTION("Amlogic Meson serial port driver");
+1 -2
drivers/tty/serial/milbeaut_usio.c
··· 148 148 static void mlb_usio_rx_chars(struct uart_port *port) 149 149 { 150 150 struct tty_port *ttyport = &port->state->port; 151 - unsigned long flag = 0; 152 - char ch = 0; 151 + u8 flag = 0, ch = 0; 153 152 u8 status; 154 153 int max_count = 2; 155 154
+1 -1
drivers/tty/serial/mpc52xx_uart.c
··· 40 40 #include <linux/of.h> 41 41 #include <linux/of_address.h> 42 42 #include <linux/of_irq.h> 43 - #include <linux/of_platform.h> 43 + #include <linux/platform_device.h> 44 44 #include <linux/clk.h> 45 45 46 46 #include <asm/mpc52xx.h>
+1 -3
drivers/tty/serial/mps2-uart.c
··· 16 16 #include <linux/console.h> 17 17 #include <linux/io.h> 18 18 #include <linux/kernel.h> 19 - #include <linux/of_device.h> 20 19 #include <linux/of.h> 21 20 #include <linux/platform_device.h> 22 21 #include <linux/serial_core.h> ··· 538 539 struct resource *res; 539 540 int ret; 540 541 541 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 542 - mps_port->port.membase = devm_ioremap_resource(&pdev->dev, res); 542 + mps_port->port.membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 543 543 if (IS_ERR(mps_port->port.membase)) 544 544 return PTR_ERR(mps_port->port.membase); 545 545
+3 -8
drivers/tty/serial/mvebu-uart.c
··· 876 876 877 877 static int mvebu_uart_probe(struct platform_device *pdev) 878 878 { 879 - struct resource *reg = platform_get_resource(pdev, IORESOURCE_MEM, 0); 880 879 const struct of_device_id *match = of_match_device(mvebu_uart_of_match, 881 880 &pdev->dev); 882 881 struct uart_port *port; 883 882 struct mvebu_uart *mvuart; 883 + struct resource *reg; 884 884 int id, irq; 885 - 886 - if (!reg) { 887 - dev_err(&pdev->dev, "no registers defined\n"); 888 - return -EINVAL; 889 - } 890 885 891 886 /* Assume that all UART ports have a DT alias or none has */ 892 887 id = of_alias_get_id(pdev->dev.of_node, "serial"); ··· 917 922 */ 918 923 port->irq = 0; 919 924 port->irqflags = 0; 920 - port->mapbase = reg->start; 921 925 922 - port->membase = devm_ioremap_resource(&pdev->dev, reg); 926 + port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &reg); 923 927 if (IS_ERR(port->membase)) 924 928 return PTR_ERR(port->membase); 929 + port->mapbase = reg->start; 925 930 926 931 mvuart = devm_kzalloc(&pdev->dev, sizeof(struct mvebu_uart), 927 932 GFP_KERNEL);
+2 -3
drivers/tty/serial/mxs-auart.c
··· 30 30 #include <linux/clk.h> 31 31 #include <linux/delay.h> 32 32 #include <linux/io.h> 33 - #include <linux/of_device.h> 33 + #include <linux/of.h> 34 34 #include <linux/dma-mapping.h> 35 35 #include <linux/dmaengine.h> 36 36 ··· 616 616 617 617 static void mxs_auart_rx_char(struct mxs_auart_port *s) 618 618 { 619 - int flag; 620 619 u32 stat; 621 - u8 c; 620 + u8 c, flag; 622 621 623 622 c = mxs_read(s, REG_DATA); 624 623 stat = mxs_read(s, REG_STAT);
+4 -7
drivers/tty/serial/omap-serial.c
··· 437 437 438 438 static void serial_omap_rlsi(struct uart_omap_port *up, unsigned int lsr) 439 439 { 440 - unsigned int flag; 440 + u8 flag; 441 441 442 442 /* 443 443 * Read one data character out to avoid stalling the receiver according ··· 493 493 494 494 static void serial_omap_rdi(struct uart_omap_port *up, unsigned int lsr) 495 495 { 496 - unsigned char ch = 0; 497 - unsigned int flag; 496 + u8 ch; 498 497 499 498 if (!(lsr & UART_LSR_DR)) 500 499 return; ··· 506 507 return; 507 508 } 508 509 509 - flag = TTY_NORMAL; 510 510 up->port.icount.rx++; 511 511 512 512 if (uart_handle_sysrq_char(&up->port, ch)) 513 513 return; 514 514 515 - uart_insert_char(&up->port, lsr, UART_LSR_OE, ch, flag); 515 + uart_insert_char(&up->port, lsr, UART_LSR_OE, ch, TTY_NORMAL); 516 516 } 517 517 518 518 /** ··· 1566 1568 if (!up) 1567 1569 return -ENOMEM; 1568 1570 1569 - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1570 - base = devm_ioremap_resource(&pdev->dev, mem); 1571 + base = devm_platform_get_and_ioremap_resource(pdev, 0, &mem); 1571 1572 if (IS_ERR(base)) 1572 1573 return PTR_ERR(base); 1573 1574
-1
drivers/tty/serial/pic32_uart.c
··· 11 11 #include <linux/kernel.h> 12 12 #include <linux/platform_device.h> 13 13 #include <linux/of.h> 14 - #include <linux/of_device.h> 15 14 #include <linux/of_irq.h> 16 15 #include <linux/of_gpio.h> 17 16 #include <linux/init.h>
+1 -1
drivers/tty/serial/pxa.c
··· 90 90 91 91 static inline void receive_chars(struct uart_pxa_port *up, int *status) 92 92 { 93 - unsigned int ch, flag; 93 + u8 ch, flag; 94 94 int max_count = 256; 95 95 96 96 do {
+9 -8
drivers/tty/serial/qcom_geni_serial.c
··· 11 11 #include <linux/irq.h> 12 12 #include <linux/module.h> 13 13 #include <linux/of.h> 14 - #include <linux/of_device.h> 15 14 #include <linux/pm_opp.h> 16 15 #include <linux/platform_device.h> 17 16 #include <linux/pm_runtime.h> ··· 125 126 dma_addr_t rx_dma_addr; 126 127 bool setup; 127 128 unsigned int baud; 129 + unsigned long clk_rate; 128 130 void *rx_buf; 129 131 u32 loopback; 130 132 bool brk; ··· 591 591 { 592 592 struct qcom_geni_serial_port *port = to_dev_port(uport); 593 593 bool done; 594 - u32 m_irq_en; 595 594 596 595 if (!qcom_geni_serial_main_active(uport)) 597 596 return; ··· 602 603 port->tx_remaining = 0; 603 604 } 604 605 605 - m_irq_en = readl(uport->membase + SE_GENI_M_IRQ_EN); 606 - writel(m_irq_en, uport->membase + SE_GENI_M_IRQ_EN); 607 606 geni_se_cancel_m_cmd(&port->se); 608 607 609 - done = qcom_geni_serial_poll_bit(uport, SE_GENI_S_IRQ_STATUS, 610 - S_CMD_CANCEL_EN, true); 608 + done = qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS, 609 + M_CMD_CANCEL_EN, true); 611 610 if (!done) { 612 611 geni_se_abort_m_cmd(&port->se); 613 612 done = qcom_geni_serial_poll_bit(uport, SE_GENI_M_IRQ_STATUS, ··· 1242 1245 goto out_restart_rx; 1243 1246 } 1244 1247 1245 - dev_dbg(port->se.dev, "desired_rate-%u, clk_rate-%lu, clk_div-%u\n", 1248 + dev_dbg(port->se.dev, "desired_rate = %u, clk_rate = %lu, clk_div = %u\n", 1246 1249 baud * sampling_rate, clk_rate, clk_div); 1247 1250 1248 1251 uport->uartclk = clk_rate; 1252 + port->clk_rate = clk_rate; 1249 1253 dev_pm_opp_set_rate(uport->dev, clk_rate); 1250 1254 ser_clk_cfg = SER_CLK_EN; 1251 1255 ser_clk_cfg |= clk_div << CLK_DIV_SHFT; ··· 1511 1513 1512 1514 if (new_state == UART_PM_STATE_ON && old_state == UART_PM_STATE_OFF) { 1513 1515 geni_icc_enable(&port->se); 1516 + if (port->clk_rate) 1517 + dev_pm_opp_set_rate(uport->dev, port->clk_rate); 1514 1518 geni_se_resources_on(&port->se); 1515 1519 } else if (new_state == UART_PM_STATE_OFF && 1516 1520 old_state == UART_PM_STATE_ON) { 1517 1521 geni_se_resources_off(&port->se); 1522 + dev_pm_opp_set_rate(uport->dev, 0); 1518 1523 geni_icc_disable(&port->se); 1519 1524 } 1520 1525 } ··· 1751 1750 private_data = uport->private_data; 1752 1751 1753 1752 if (uart_console(uport)) { 1754 - geni_icc_set_tag(&port->se, 0x7); 1753 + geni_icc_set_tag(&port->se, QCOM_ICC_TAG_ALWAYS); 1755 1754 geni_icc_set_bw(&port->se); 1756 1755 ret = uart_resume_port(private_data->drv, uport); 1757 1756 /*
+2 -2
drivers/tty/serial/rp2.c
··· 401 401 402 402 for (; bytes != 0; bytes--) { 403 403 u32 byte = readw(up->base + RP2_DATA_BYTE) | RP2_DUMMY_READ; 404 - char ch = byte & 0xff; 404 + u8 ch = byte & 0xff; 405 405 406 406 if (likely(!(byte & RP2_DATA_BYTE_EXCEPTION_MASK))) { 407 407 if (!uart_handle_sysrq_char(&up->port, ch)) 408 408 uart_insert_char(&up->port, byte, 0, ch, 409 409 TTY_NORMAL); 410 410 } else { 411 - char flag = TTY_NORMAL; 411 + u8 flag = TTY_NORMAL; 412 412 413 413 if (byte & RP2_DATA_BYTE_BREAK_m) 414 414 flag = TTY_BREAK;
+2 -1
drivers/tty/serial/sa1100.c
··· 180 180 static void 181 181 sa1100_rx_chars(struct sa1100_port *sport) 182 182 { 183 - unsigned int status, ch, flg; 183 + unsigned int status; 184 + u8 ch, flg; 184 185 185 186 status = UTSR1_TO_SM(UART_GET_UTSR1(sport)) | 186 187 UTSR0_TO_SM(UART_GET_UTSR0(sport));
+4 -4
drivers/tty/serial/samsung_tty.c
··· 759 759 static void s3c24xx_serial_rx_drain_fifo(struct s3c24xx_uart_port *ourport) 760 760 { 761 761 struct uart_port *port = &ourport->port; 762 - unsigned int ufcon, ch, flag, ufstat, uerstat; 762 + unsigned int ufcon, ufstat, uerstat; 763 763 unsigned int fifocnt = 0; 764 764 int max_count = port->fifosize; 765 + u8 ch, flag; 765 766 766 767 while (max_count-- > 0) { 767 768 /* ··· 2274 2273 } 2275 2274 2276 2275 static const struct dev_pm_ops s3c24xx_serial_pm_ops = { 2277 - .suspend = s3c24xx_serial_suspend, 2278 - .resume = s3c24xx_serial_resume, 2279 - .resume_noirq = s3c24xx_serial_resume_noirq, 2276 + SET_SYSTEM_SLEEP_PM_OPS(s3c24xx_serial_suspend, s3c24xx_serial_resume) 2277 + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(NULL, s3c24xx_serial_resume_noirq) 2280 2278 }; 2281 2279 #define SERIAL_SAMSUNG_PM_OPS (&s3c24xx_serial_pm_ops) 2282 2280
+2 -1
drivers/tty/serial/sb1250-duart.c
··· 331 331 { 332 332 struct uart_port *uport = &sport->port; 333 333 struct uart_icount *icount; 334 - unsigned int status, ch, flag; 334 + unsigned int status; 335 335 int count; 336 + u8 ch, flag; 336 337 337 338 for (count = 16; count; count--) { 338 339 status = read_sbdchn(sport, R_DUART_STATUS);
+131 -39
drivers/tty/serial/sc16is7xx.c
··· 236 236 237 237 /* IOControl register bits (Only 750/760) */ 238 238 #define SC16IS7XX_IOCONTROL_LATCH_BIT (1 << 0) /* Enable input latching */ 239 - #define SC16IS7XX_IOCONTROL_MODEM_BIT (1 << 1) /* Enable GPIO[7:4] as modem pins */ 239 + #define SC16IS7XX_IOCONTROL_MODEM_A_BIT (1 << 1) /* Enable GPIO[7:4] as modem A pins */ 240 + #define SC16IS7XX_IOCONTROL_MODEM_B_BIT (1 << 2) /* Enable GPIO[3:0] as modem B pins */ 240 241 #define SC16IS7XX_IOCONTROL_SRESET_BIT (1 << 3) /* Software Reset */ 241 242 242 243 /* EFCR register bits */ ··· 302 301 /* Misc definitions */ 303 302 #define SC16IS7XX_FIFO_SIZE (64) 304 303 #define SC16IS7XX_REG_SHIFT 2 304 + #define SC16IS7XX_GPIOS_PER_BANK 4 305 305 306 306 struct sc16is7xx_devtype { 307 307 char name[10]; 308 308 int nr_gpio; 309 309 int nr_uart; 310 - int has_mctrl; 311 310 }; 312 311 313 312 #define SC16IS7XX_RECONF_MD (1 << 0) ··· 337 336 struct clk *clk; 338 337 #ifdef CONFIG_GPIOLIB 339 338 struct gpio_chip gpio; 339 + unsigned long gpio_valid_mask; 340 340 #endif 341 + u8 mctrl_mask; 341 342 unsigned char buf[SC16IS7XX_FIFO_SIZE]; 342 343 struct kthread_worker kworker; 343 344 struct task_struct *kworker_task; ··· 450 447 .name = "SC16IS74X", 451 448 .nr_gpio = 0, 452 449 .nr_uart = 1, 453 - .has_mctrl = 0, 454 450 }; 455 451 456 452 static const struct sc16is7xx_devtype sc16is750_devtype = { 457 453 .name = "SC16IS750", 458 - .nr_gpio = 4, 454 + .nr_gpio = 8, 459 455 .nr_uart = 1, 460 - .has_mctrl = 1, 461 456 }; 462 457 463 458 static const struct sc16is7xx_devtype sc16is752_devtype = { 464 459 .name = "SC16IS752", 465 - .nr_gpio = 0, 460 + .nr_gpio = 8, 466 461 .nr_uart = 2, 467 - .has_mctrl = 1, 468 462 }; 469 463 470 464 static const struct sc16is7xx_devtype sc16is760_devtype = { 471 465 .name = "SC16IS760", 472 - .nr_gpio = 4, 466 + .nr_gpio = 8, 473 467 .nr_uart = 1, 474 - .has_mctrl = 1, 475 468 }; 476 469 477 470 static const struct sc16is7xx_devtype sc16is762_devtype = { 478 471 .name = "SC16IS762", 479 - .nr_gpio = 0, 472 + .nr_gpio = 8, 480 473 .nr_uart = 2, 481 - .has_mctrl = 1, 482 474 }; 483 475 484 476 static bool sc16is7xx_regmap_volatile(struct device *dev, unsigned int reg) ··· 486 488 case SC16IS7XX_TXLVL_REG: 487 489 case SC16IS7XX_RXLVL_REG: 488 490 case SC16IS7XX_IOSTATE_REG: 491 + case SC16IS7XX_IOCONTROL_REG: 489 492 return true; 490 493 default: 491 494 break; ··· 577 578 unsigned int iir) 578 579 { 579 580 struct sc16is7xx_port *s = dev_get_drvdata(port->dev); 580 - unsigned int lsr = 0, ch, flag, bytes_read, i; 581 + unsigned int lsr = 0, bytes_read, i; 581 582 bool read_lsr = (iir == SC16IS7XX_IIR_RLSE_SRC) ? true : false; 583 + u8 ch, flag; 582 584 583 585 if (unlikely(rxlen >= sizeof(s->buf))) { 584 586 dev_warn_ratelimited(port->dev, ··· 1342 1342 state |= BIT(offset); 1343 1343 else 1344 1344 state &= ~BIT(offset); 1345 - sc16is7xx_port_write(port, SC16IS7XX_IOSTATE_REG, state); 1345 + 1346 + /* 1347 + * If we write IOSTATE first, and then IODIR, the output value is not 1348 + * transferred to the corresponding I/O pin. 1349 + * The datasheet states that each register bit will be transferred to 1350 + * the corresponding I/O pin programmed as output when writing to 1351 + * IOSTATE. Therefore, configure direction first with IODIR, and then 1352 + * set value after with IOSTATE. 1353 + */ 1346 1354 sc16is7xx_port_update(port, SC16IS7XX_IODIR_REG, BIT(offset), 1347 1355 BIT(offset)); 1356 + sc16is7xx_port_write(port, SC16IS7XX_IOSTATE_REG, state); 1348 1357 1349 1358 return 0; 1350 1359 } 1360 + 1361 + static int sc16is7xx_gpio_init_valid_mask(struct gpio_chip *chip, 1362 + unsigned long *valid_mask, 1363 + unsigned int ngpios) 1364 + { 1365 + struct sc16is7xx_port *s = gpiochip_get_data(chip); 1366 + 1367 + *valid_mask = s->gpio_valid_mask; 1368 + 1369 + return 0; 1370 + } 1371 + 1372 + static int sc16is7xx_setup_gpio_chip(struct sc16is7xx_port *s) 1373 + { 1374 + struct device *dev = s->p[0].port.dev; 1375 + 1376 + if (!s->devtype->nr_gpio) 1377 + return 0; 1378 + 1379 + switch (s->mctrl_mask) { 1380 + case 0: 1381 + s->gpio_valid_mask = GENMASK(7, 0); 1382 + break; 1383 + case SC16IS7XX_IOCONTROL_MODEM_A_BIT: 1384 + s->gpio_valid_mask = GENMASK(3, 0); 1385 + break; 1386 + case SC16IS7XX_IOCONTROL_MODEM_B_BIT: 1387 + s->gpio_valid_mask = GENMASK(7, 4); 1388 + break; 1389 + default: 1390 + break; 1391 + } 1392 + 1393 + if (s->gpio_valid_mask == 0) 1394 + return 0; 1395 + 1396 + s->gpio.owner = THIS_MODULE; 1397 + s->gpio.parent = dev; 1398 + s->gpio.label = dev_name(dev); 1399 + s->gpio.init_valid_mask = sc16is7xx_gpio_init_valid_mask; 1400 + s->gpio.direction_input = sc16is7xx_gpio_direction_input; 1401 + s->gpio.get = sc16is7xx_gpio_get; 1402 + s->gpio.direction_output = sc16is7xx_gpio_direction_output; 1403 + s->gpio.set = sc16is7xx_gpio_set; 1404 + s->gpio.base = -1; 1405 + s->gpio.ngpio = s->devtype->nr_gpio; 1406 + s->gpio.can_sleep = 1; 1407 + 1408 + return gpiochip_add_data(&s->gpio, s); 1409 + } 1351 1410 #endif 1411 + 1412 + /* 1413 + * Configure ports designated to operate as modem control lines. 1414 + */ 1415 + static int sc16is7xx_setup_mctrl_ports(struct sc16is7xx_port *s) 1416 + { 1417 + int i; 1418 + int ret; 1419 + int count; 1420 + u32 mctrl_port[2]; 1421 + struct device *dev = s->p[0].port.dev; 1422 + 1423 + count = device_property_count_u32(dev, "nxp,modem-control-line-ports"); 1424 + if (count < 0 || count > ARRAY_SIZE(mctrl_port)) 1425 + return 0; 1426 + 1427 + ret = device_property_read_u32_array(dev, "nxp,modem-control-line-ports", 1428 + mctrl_port, count); 1429 + if (ret) 1430 + return ret; 1431 + 1432 + s->mctrl_mask = 0; 1433 + 1434 + for (i = 0; i < count; i++) { 1435 + /* Use GPIO lines as modem control lines */ 1436 + if (mctrl_port[i] == 0) 1437 + s->mctrl_mask |= SC16IS7XX_IOCONTROL_MODEM_A_BIT; 1438 + else if (mctrl_port[i] == 1) 1439 + s->mctrl_mask |= SC16IS7XX_IOCONTROL_MODEM_B_BIT; 1440 + } 1441 + 1442 + if (s->mctrl_mask) 1443 + regmap_update_bits( 1444 + s->regmap, 1445 + SC16IS7XX_IOCONTROL_REG << SC16IS7XX_REG_SHIFT, 1446 + SC16IS7XX_IOCONTROL_MODEM_A_BIT | 1447 + SC16IS7XX_IOCONTROL_MODEM_B_BIT, s->mctrl_mask); 1448 + 1449 + return 0; 1450 + } 1352 1451 1353 1452 static const struct serial_rs485 sc16is7xx_rs485_supported = { 1354 1453 .flags = SER_RS485_ENABLED | SER_RS485_RTS_AFTER_SEND, ··· 1535 1436 s->p[i].port.fifosize = SC16IS7XX_FIFO_SIZE; 1536 1437 s->p[i].port.flags = UPF_FIXED_TYPE | UPF_LOW_LATENCY; 1537 1438 s->p[i].port.iobase = i; 1439 + /* 1440 + * Use all ones as membase to make sure uart_configure_port() in 1441 + * serial_core.c does not abort for SPI/I2C devices where the 1442 + * membase address is not applicable. 1443 + */ 1444 + s->p[i].port.membase = (void __iomem *)~0; 1538 1445 s->p[i].port.iotype = UPIO_PORT; 1539 1446 s->p[i].port.uartclk = freq; 1540 1447 s->p[i].port.rs485_config = sc16is7xx_config_rs485; ··· 1554 1449 goto out_ports; 1555 1450 } 1556 1451 1452 + ret = uart_get_rs485_mode(&s->p[i].port); 1453 + if (ret) 1454 + goto out_ports; 1455 + 1557 1456 /* Disable all interrupts */ 1558 1457 sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_IER_REG, 0); 1559 1458 /* Disable TX/RX */ 1560 1459 sc16is7xx_port_write(&s->p[i].port, SC16IS7XX_EFCR_REG, 1561 1460 SC16IS7XX_EFCR_RXDISABLE_BIT | 1562 1461 SC16IS7XX_EFCR_TXDISABLE_BIT); 1563 - 1564 - /* Use GPIO lines as modem status registers */ 1565 - if (devtype->has_mctrl) 1566 - sc16is7xx_port_write(&s->p[i].port, 1567 - SC16IS7XX_IOCONTROL_REG, 1568 - SC16IS7XX_IOCONTROL_MODEM_BIT); 1569 1462 1570 1463 /* Initialize kthread work structs */ 1571 1464 kthread_init_work(&s->p[i].tx_work, sc16is7xx_tx_proc); ··· 1602 1499 s->p[u].irda_mode = true; 1603 1500 } 1604 1501 1502 + ret = sc16is7xx_setup_mctrl_ports(s); 1503 + if (ret) 1504 + goto out_ports; 1505 + 1605 1506 #ifdef CONFIG_GPIOLIB 1606 - if (devtype->nr_gpio) { 1607 - /* Setup GPIO cotroller */ 1608 - s->gpio.owner = THIS_MODULE; 1609 - s->gpio.parent = dev; 1610 - s->gpio.label = dev_name(dev); 1611 - s->gpio.direction_input = sc16is7xx_gpio_direction_input; 1612 - s->gpio.get = sc16is7xx_gpio_get; 1613 - s->gpio.direction_output = sc16is7xx_gpio_direction_output; 1614 - s->gpio.set = sc16is7xx_gpio_set; 1615 - s->gpio.base = -1; 1616 - s->gpio.ngpio = devtype->nr_gpio; 1617 - s->gpio.can_sleep = 1; 1618 - ret = gpiochip_add_data(&s->gpio, s); 1619 - if (ret) 1620 - goto out_thread; 1621 - } 1507 + ret = sc16is7xx_setup_gpio_chip(s); 1508 + if (ret) 1509 + goto out_ports; 1622 1510 #endif 1623 1511 1624 1512 /* ··· 1632 1538 return 0; 1633 1539 1634 1540 #ifdef CONFIG_GPIOLIB 1635 - if (devtype->nr_gpio) 1541 + if (s->gpio_valid_mask) 1636 1542 gpiochip_remove(&s->gpio); 1637 - 1638 - out_thread: 1639 1543 #endif 1640 1544 1641 1545 out_ports: ··· 1656 1564 int i; 1657 1565 1658 1566 #ifdef CONFIG_GPIOLIB 1659 - if (s->devtype->nr_gpio) 1567 + if (s->gpio_valid_mask) 1660 1568 gpiochip_remove(&s->gpio); 1661 1569 #endif 1662 1570
+3 -4
drivers/tty/serial/sccnxp.c
··· 383 383 384 384 static void sccnxp_handle_rx(struct uart_port *port) 385 385 { 386 - u8 sr; 387 - unsigned int ch, flag; 386 + u8 sr, ch, flag; 388 387 389 388 for (;;) { 390 389 sr = sccnxp_port_read(port, SCCNXP_SR_REG); ··· 879 880 880 881 static int sccnxp_probe(struct platform_device *pdev) 881 882 { 882 - struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 883 883 struct sccnxp_pdata *pdata = dev_get_platdata(&pdev->dev); 884 + struct resource *res; 884 885 int i, ret, uartclk; 885 886 struct sccnxp_port *s; 886 887 void __iomem *membase; 887 888 struct clk *clk; 888 889 889 - membase = devm_ioremap_resource(&pdev->dev, res); 890 + membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 890 891 if (IS_ERR(membase)) 891 892 return PTR_ERR(membase); 892 893
+12 -17
drivers/tty/serial/serial-tegra.c
··· 20 20 #include <linux/irq.h> 21 21 #include <linux/module.h> 22 22 #include <linux/of.h> 23 - #include <linux/of_device.h> 24 23 #include <linux/pagemap.h> 25 24 #include <linux/platform_device.h> 26 25 #include <linux/reset.h> ··· 433 434 return 0; 434 435 } 435 436 436 - static char tegra_uart_decode_rx_error(struct tegra_uart_port *tup, 437 + static u8 tegra_uart_decode_rx_error(struct tegra_uart_port *tup, 437 438 unsigned long lsr) 438 439 { 439 - char flag = TTY_NORMAL; 440 + u8 flag = TTY_NORMAL; 440 441 441 442 if (unlikely(lsr & TEGRA_UART_LSR_ANY)) { 442 443 if (lsr & UART_LSR_OE) { ··· 641 642 struct tty_port *port) 642 643 { 643 644 do { 644 - char flag = TTY_NORMAL; 645 645 unsigned long lsr = 0; 646 - unsigned char ch; 646 + u8 ch, flag = TTY_NORMAL; 647 647 648 648 lsr = tegra_uart_read(tup, UART_LSR); 649 649 if (!(lsr & UART_LSR_DR)) ··· 996 998 tup->ier_shadow = 0; 997 999 tup->current_baud = 0; 998 1000 999 - clk_prepare_enable(tup->uart_clk); 1001 + ret = clk_prepare_enable(tup->uart_clk); 1002 + if (ret) { 1003 + dev_err(tup->uport.dev, "could not enable clk\n"); 1004 + return ret; 1005 + } 1000 1006 1001 1007 /* Reset the UART controller to clear all previous status.*/ 1002 1008 reset_control_assert(tup->rst); ··· 1581 1579 tup->cdata = cdata; 1582 1580 1583 1581 platform_set_drvdata(pdev, tup); 1584 - resource = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1585 - if (!resource) { 1586 - dev_err(&pdev->dev, "No IO memory resource\n"); 1587 - return -ENODEV; 1588 - } 1589 1582 1590 - u->mapbase = resource->start; 1591 - u->membase = devm_ioremap_resource(&pdev->dev, resource); 1583 + u->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &resource); 1592 1584 if (IS_ERR(u->membase)) 1593 1585 return PTR_ERR(u->membase); 1586 + u->mapbase = resource->start; 1594 1587 1595 1588 tup->uart_clk = devm_clk_get(&pdev->dev, NULL); 1596 - if (IS_ERR(tup->uart_clk)) { 1597 - dev_err(&pdev->dev, "Couldn't get the clock\n"); 1598 - return PTR_ERR(tup->uart_clk); 1599 - } 1589 + if (IS_ERR(tup->uart_clk)) 1590 + return dev_err_probe(&pdev->dev, PTR_ERR(tup->uart_clk), "Couldn't get the clock"); 1600 1591 1601 1592 tup->rst = devm_reset_control_get_exclusive(&pdev->dev, "serial"); 1602 1593 if (IS_ERR(tup->rst)) {
+11 -17
drivers/tty/serial/serial_core.c
··· 133 133 uart_port_unlock(port, flags); 134 134 } 135 135 136 - static void __uart_start(struct tty_struct *tty) 136 + static void __uart_start(struct uart_state *state) 137 137 { 138 - struct uart_state *state = tty->driver_data; 139 138 struct uart_port *port = state->uart_port; 140 139 struct serial_port_device *port_dev; 141 140 int err; ··· 169 170 unsigned long flags; 170 171 171 172 port = uart_port_lock(state, flags); 172 - __uart_start(tty); 173 + __uart_start(state); 173 174 uart_port_unlock(port, flags); 174 175 } 175 176 ··· 238 239 if (!old_hw_stopped) 239 240 uport->ops->stop_tx(uport); 240 241 else 241 - __uart_start(tty); 242 + __uart_start(state); 242 243 } 243 244 spin_unlock_irq(&uport->lock); 244 245 } ··· 551 552 } 552 553 EXPORT_SYMBOL(uart_get_divisor); 553 554 554 - static int uart_put_char(struct tty_struct *tty, unsigned char c) 555 + static int uart_put_char(struct tty_struct *tty, u8 c) 555 556 { 556 557 struct uart_state *state = tty->driver_data; 557 558 struct uart_port *port; ··· 580 581 uart_start(tty); 581 582 } 582 583 583 - static int uart_write(struct tty_struct *tty, 584 - const unsigned char *buf, int count) 584 + static ssize_t uart_write(struct tty_struct *tty, const u8 *buf, size_t count) 585 585 { 586 586 struct uart_state *state = tty->driver_data; 587 587 struct uart_port *port; ··· 592 594 * This means you called this function _after_ the port was 593 595 * closed. No cookie for you. 594 596 */ 595 - if (!state) { 596 - WARN_ON(1); 597 + if (WARN_ON(!state)) 597 598 return -EL3HLT; 598 - } 599 599 600 600 port = uart_port_lock(state, flags); 601 601 circ = &state->xmit; ··· 615 619 ret += c; 616 620 } 617 621 618 - __uart_start(tty); 622 + __uart_start(state); 619 623 uart_port_unlock(port, flags); 620 624 return ret; 621 625 } ··· 656 660 * This means you called this function _after_ the port was 657 661 * closed. No cookie for you. 658 662 */ 659 - if (!state) { 660 - WARN_ON(1); 663 + if (WARN_ON(!state)) 661 664 return; 662 - } 663 665 664 666 pr_debug("uart_flush_buffer(%d) called\n", tty->index); 665 667 ··· 3480 3486 * @flag: flag for the character (see TTY_NORMAL and friends) 3481 3487 */ 3482 3488 void uart_insert_char(struct uart_port *port, unsigned int status, 3483 - unsigned int overrun, unsigned int ch, unsigned int flag) 3489 + unsigned int overrun, u8 ch, u8 flag) 3484 3490 { 3485 3491 struct tty_port *tport = &port->state->port; 3486 3492 ··· 3499 3505 EXPORT_SYMBOL_GPL(uart_insert_char); 3500 3506 3501 3507 #ifdef CONFIG_MAGIC_SYSRQ_SERIAL 3502 - static const char sysrq_toggle_seq[] = CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE; 3508 + static const u8 sysrq_toggle_seq[] = CONFIG_MAGIC_SYSRQ_SERIAL_SEQUENCE; 3503 3509 3504 3510 static void uart_sysrq_on(struct work_struct *w) 3505 3511 { ··· 3522 3528 * Returns: %false if @ch is out of enabling sequence and should be 3523 3529 * handled some other way, %true if @ch was consumed. 3524 3530 */ 3525 - bool uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch) 3531 + bool uart_try_toggle_sysrq(struct uart_port *port, u8 ch) 3526 3532 { 3527 3533 int sysrq_toggle_seq_len = strlen(sysrq_toggle_seq); 3528 3534
+1 -2
drivers/tty/serial/serial_txx9.c
··· 246 246 static inline void 247 247 receive_chars(struct uart_port *up, unsigned int *status) 248 248 { 249 - unsigned char ch; 250 249 unsigned int disr = *status; 251 250 int max_count = 256; 252 - char flag; 253 251 unsigned int next_ignore_status_mask; 252 + u8 ch, flag; 254 253 255 254 do { 256 255 ch = sio_in(up, TXX9_SIRFIFO);
-1
drivers/tty/serial/sh-sci.c
··· 35 35 #include <linux/module.h> 36 36 #include <linux/mm.h> 37 37 #include <linux/of.h> 38 - #include <linux/of_device.h> 39 38 #include <linux/platform_device.h> 40 39 #include <linux/pm_runtime.h> 41 40 #include <linux/reset.h>
+22 -7
drivers/tty/serial/sifive.c
··· 402 402 */ 403 403 static void __ssp_receive_chars(struct sifive_serial_port *ssp) 404 404 { 405 - unsigned char ch; 406 405 char is_empty; 407 406 int c; 407 + u8 ch; 408 408 409 409 for (c = SIFIVE_RX_FIFO_DEPTH; c > 0; --c) { 410 410 ch = __ssp_receive_char(ssp, &is_empty); ··· 917 917 if (irq < 0) 918 918 return -EPROBE_DEFER; 919 919 920 - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 921 - base = devm_ioremap_resource(&pdev->dev, mem); 922 - if (IS_ERR(base)) { 923 - dev_err(&pdev->dev, "could not acquire device memory\n"); 920 + base = devm_platform_get_and_ioremap_resource(pdev, 0, &mem); 921 + if (IS_ERR(base)) 924 922 return PTR_ERR(base); 925 - } 926 923 927 924 clk = devm_clk_get_enabled(&pdev->dev, NULL); 928 925 if (IS_ERR(clk)) { ··· 1019 1022 return 0; 1020 1023 } 1021 1024 1025 + static int sifive_serial_suspend(struct device *dev) 1026 + { 1027 + struct sifive_serial_port *ssp = dev_get_drvdata(dev); 1028 + 1029 + return uart_suspend_port(&sifive_serial_uart_driver, &ssp->port); 1030 + } 1031 + 1032 + static int sifive_serial_resume(struct device *dev) 1033 + { 1034 + struct sifive_serial_port *ssp = dev_get_drvdata(dev); 1035 + 1036 + return uart_resume_port(&sifive_serial_uart_driver, &ssp->port); 1037 + } 1038 + 1039 + DEFINE_SIMPLE_DEV_PM_OPS(sifive_uart_pm_ops, sifive_serial_suspend, 1040 + sifive_serial_resume); 1041 + 1022 1042 static const struct of_device_id sifive_serial_of_match[] = { 1023 1043 { .compatible = "sifive,fu540-c000-uart0" }, 1024 1044 { .compatible = "sifive,uart0" }, ··· 1048 1034 .remove = sifive_serial_remove, 1049 1035 .driver = { 1050 1036 .name = SIFIVE_SERIAL_NAME, 1051 - .of_match_table = of_match_ptr(sifive_serial_of_match), 1037 + .pm = pm_sleep_ptr(&sifive_uart_pm_ops), 1038 + .of_match_table = sifive_serial_of_match, 1052 1039 }, 1053 1040 }; 1054 1041
+24 -14
drivers/tty/serial/sprd_serial.c
··· 364 364 if (sp->rx_dma.virt) 365 365 dma_free_coherent(sp->port.dev, SPRD_UART_RX_SIZE, 366 366 sp->rx_dma.virt, sp->rx_dma.phys_addr); 367 - 367 + sp->rx_dma.virt = NULL; 368 368 } 369 369 370 370 static int sprd_rx_dma_config(struct uart_port *port, u32 burst) ··· 558 558 } 559 559 560 560 static int handle_lsr_errors(struct uart_port *port, 561 - unsigned int *flag, 561 + u8 *flag, 562 562 unsigned int *lsr) 563 563 { 564 564 int ret = 0; ··· 594 594 struct sprd_uart_port *sp = container_of(port, struct sprd_uart_port, 595 595 port); 596 596 struct tty_port *tty = &port->state->port; 597 - unsigned int ch, flag, lsr, max_count = SPRD_TIMEOUT; 597 + unsigned int lsr, max_count = SPRD_TIMEOUT; 598 + u8 ch, flag; 598 599 599 600 if (sp->rx_dma.enable) { 600 601 sprd_uart_dma_irq(port); ··· 1107 1106 static int sprd_clk_init(struct uart_port *uport) 1108 1107 { 1109 1108 struct clk *clk_uart, *clk_parent; 1110 - struct sprd_uart_port *u = sprd_port[uport->line]; 1109 + struct sprd_uart_port *u = container_of(uport, struct sprd_uart_port, port); 1111 1110 1112 1111 clk_uart = devm_clk_get(uport->dev, "uart"); 1113 1112 if (IS_ERR(clk_uart)) { ··· 1150 1149 { 1151 1150 struct resource *res; 1152 1151 struct uart_port *up; 1152 + struct sprd_uart_port *sport; 1153 1153 int irq; 1154 1154 int index; 1155 1155 int ret; 1156 1156 1157 1157 index = of_alias_get_id(pdev->dev.of_node, "serial"); 1158 - if (index < 0 || index >= ARRAY_SIZE(sprd_port)) { 1158 + if (index < 0 || index >= UART_NR_MAX) { 1159 1159 dev_err(&pdev->dev, "got a wrong serial alias id %d\n", index); 1160 1160 return -EINVAL; 1161 1161 } 1162 1162 1163 - sprd_port[index] = devm_kzalloc(&pdev->dev, sizeof(*sprd_port[index]), 1164 - GFP_KERNEL); 1165 - if (!sprd_port[index]) 1163 + sport = devm_kzalloc(&pdev->dev, sizeof(*sport), GFP_KERNEL); 1164 + if (!sport) 1166 1165 return -ENOMEM; 1167 1166 1168 - up = &sprd_port[index]->port; 1167 + up = &sport->port; 1169 1168 up->dev = &pdev->dev; 1170 1169 up->line = index; 1171 1170 up->type = PORT_SPRD; ··· 1180 1179 if (ret) 1181 1180 return ret; 1182 1181 1183 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1184 - up->membase = devm_ioremap_resource(&pdev->dev, res); 1182 + up->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 1185 1183 if (IS_ERR(up->membase)) 1186 1184 return PTR_ERR(up->membase); 1187 1185 ··· 1195 1195 * Allocate one dma buffer to prepare for receive transfer, in case 1196 1196 * memory allocation failure at runtime. 1197 1197 */ 1198 - ret = sprd_rx_alloc_buf(sprd_port[index]); 1198 + ret = sprd_rx_alloc_buf(sport); 1199 1199 if (ret) 1200 1200 return ret; 1201 1201 ··· 1203 1203 ret = uart_register_driver(&sprd_uart_driver); 1204 1204 if (ret < 0) { 1205 1205 pr_err("Failed to register SPRD-UART driver\n"); 1206 - return ret; 1206 + goto free_rx_buf; 1207 1207 } 1208 1208 } 1209 + 1209 1210 sprd_ports_num++; 1211 + sprd_port[index] = sport; 1210 1212 1211 1213 ret = uart_add_one_port(&sprd_uart_driver, up); 1212 1214 if (ret) 1213 - sprd_remove(pdev); 1215 + goto clean_port; 1214 1216 1215 1217 platform_set_drvdata(pdev, up); 1216 1218 1219 + return 0; 1220 + 1221 + clean_port: 1222 + sprd_port[index] = NULL; 1223 + if (--sprd_ports_num == 0) 1224 + uart_unregister_driver(&sprd_uart_driver); 1225 + free_rx_buf: 1226 + sprd_rx_free_buf(sport); 1217 1227 return ret; 1218 1228 } 1219 1229
+5 -4
drivers/tty/serial/st-asc.c
··· 250 250 struct tty_port *tport = &port->state->port; 251 251 unsigned long status, mode; 252 252 unsigned long c = 0; 253 - char flag; 253 + u8 flag; 254 254 bool ignore_pe = false; 255 255 256 256 /* ··· 691 691 port->irq = platform_get_irq(pdev, 0); 692 692 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_ST_ASC_CONSOLE); 693 693 694 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 695 - port->membase = devm_ioremap_resource(&pdev->dev, res); 694 + port->membase = devm_platform_get_and_ioremap_resource(pdev, 0, &res); 696 695 if (IS_ERR(port->membase)) 697 696 return PTR_ERR(port->membase); 698 697 port->mapbase = res->start; ··· 703 704 if (WARN_ON(IS_ERR(ascport->clk))) 704 705 return -EINVAL; 705 706 /* ensure that clk rate is correct by enabling the clk */ 706 - clk_prepare_enable(ascport->clk); 707 + ret = clk_prepare_enable(ascport->clk); 708 + if (ret) 709 + return ret; 707 710 ascport->port.uartclk = clk_get_rate(ascport->clk); 708 711 WARN_ON(ascport->port.uartclk == 0); 709 712 clk_disable_unprepare(ascport->clk);
+186 -126
drivers/tty/serial/stm32-usart.c
··· 289 289 return uart_get_rs485_mode(port); 290 290 } 291 291 292 - static bool stm32_usart_rx_dma_enabled(struct uart_port *port) 292 + static bool stm32_usart_rx_dma_started(struct stm32_port *stm32_port) 293 293 { 294 - struct stm32_port *stm32_port = to_stm32_port(port); 295 - const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 294 + return stm32_port->rx_ch ? stm32_port->rx_dma_busy : false; 295 + } 296 296 297 - if (!stm32_port->rx_ch) 298 - return false; 297 + static void stm32_usart_rx_dma_terminate(struct stm32_port *stm32_port) 298 + { 299 + dmaengine_terminate_async(stm32_port->rx_ch); 300 + stm32_port->rx_dma_busy = false; 301 + } 299 302 300 - return !!(readl_relaxed(port->membase + ofs->cr3) & USART_CR3_DMAR); 303 + static int stm32_usart_dma_pause_resume(struct stm32_port *stm32_port, 304 + struct dma_chan *chan, 305 + enum dma_status expected_status, 306 + int dmaengine_pause_or_resume(struct dma_chan *), 307 + bool stm32_usart_xx_dma_started(struct stm32_port *), 308 + void stm32_usart_xx_dma_terminate(struct stm32_port *)) 309 + { 310 + struct uart_port *port = &stm32_port->port; 311 + enum dma_status dma_status; 312 + int ret; 313 + 314 + if (!stm32_usart_xx_dma_started(stm32_port)) 315 + return -EPERM; 316 + 317 + dma_status = dmaengine_tx_status(chan, chan->cookie, NULL); 318 + if (dma_status != expected_status) 319 + return -EAGAIN; 320 + 321 + ret = dmaengine_pause_or_resume(chan); 322 + if (ret) { 323 + dev_err(port->dev, "DMA failed with error code: %d\n", ret); 324 + stm32_usart_xx_dma_terminate(stm32_port); 325 + } 326 + return ret; 327 + } 328 + 329 + static int stm32_usart_rx_dma_pause(struct stm32_port *stm32_port) 330 + { 331 + return stm32_usart_dma_pause_resume(stm32_port, stm32_port->rx_ch, 332 + DMA_IN_PROGRESS, dmaengine_pause, 333 + stm32_usart_rx_dma_started, 334 + stm32_usart_rx_dma_terminate); 335 + } 336 + 337 + static int stm32_usart_rx_dma_resume(struct stm32_port *stm32_port) 338 + { 339 + return stm32_usart_dma_pause_resume(stm32_port, stm32_port->rx_ch, 340 + DMA_PAUSED, dmaengine_resume, 341 + stm32_usart_rx_dma_started, 342 + stm32_usart_rx_dma_terminate); 301 343 } 302 344 303 345 /* Return true when data is pending (in pio mode), and false when no data is pending. */ ··· 352 310 /* Get pending characters in RDR or FIFO */ 353 311 if (*sr & USART_SR_RXNE) { 354 312 /* Get all pending characters from the RDR or the FIFO when using interrupts */ 355 - if (!stm32_usart_rx_dma_enabled(port)) 313 + if (!stm32_usart_rx_dma_started(stm32_port)) 356 314 return true; 357 315 358 316 /* Handle only RX data errors when using DMA */ ··· 363 321 return false; 364 322 } 365 323 366 - static unsigned long stm32_usart_get_char_pio(struct uart_port *port) 324 + static u8 stm32_usart_get_char_pio(struct uart_port *port) 367 325 { 368 326 struct stm32_port *stm32_port = to_stm32_port(port); 369 327 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; ··· 380 338 { 381 339 struct stm32_port *stm32_port = to_stm32_port(port); 382 340 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 383 - unsigned long c; 384 341 unsigned int size = 0; 385 342 u32 sr; 386 - char flag; 343 + u8 c, flag; 387 344 388 345 while (stm32_usart_pending_rx_pio(port, &sr)) { 389 346 sr |= USART_SR_DUMMY_RX; ··· 497 456 u32 sr; 498 457 unsigned int size = 0; 499 458 500 - if (stm32_usart_rx_dma_enabled(port) || force_dma_flush) { 459 + if (stm32_usart_rx_dma_started(stm32_port) || force_dma_flush) { 501 460 rx_dma_status = dmaengine_tx_status(stm32_port->rx_ch, 502 461 stm32_port->rx_ch->cookie, 503 462 &stm32_port->rx_dma_state); 504 - if (rx_dma_status == DMA_IN_PROGRESS) { 463 + if (rx_dma_status == DMA_IN_PROGRESS || 464 + rx_dma_status == DMA_PAUSED) { 505 465 /* Empty DMA buffer */ 506 466 size = stm32_usart_receive_chars_dma(port); 507 467 sr = readl_relaxed(port->membase + ofs->isr); ··· 518 476 } 519 477 } else { 520 478 /* Disable RX DMA */ 521 - dmaengine_terminate_async(stm32_port->rx_ch); 522 - stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAR); 479 + stm32_usart_rx_dma_terminate(stm32_port); 523 480 /* Fall back to interrupt mode */ 524 481 dev_dbg(port->dev, "DMA error, fallback to irq mode\n"); 525 482 size = stm32_usart_receive_chars_pio(port); ··· 528 487 } 529 488 530 489 return size; 490 + } 491 + 492 + static void stm32_usart_rx_dma_complete(void *arg) 493 + { 494 + struct uart_port *port = arg; 495 + struct tty_port *tport = &port->state->port; 496 + unsigned int size; 497 + unsigned long flags; 498 + 499 + spin_lock_irqsave(&port->lock, flags); 500 + size = stm32_usart_receive_chars(port, false); 501 + uart_unlock_and_check_sysrq_irqrestore(port, flags); 502 + if (size) 503 + tty_flip_buffer_push(tport); 504 + } 505 + 506 + static int stm32_usart_rx_dma_start_or_resume(struct uart_port *port) 507 + { 508 + struct stm32_port *stm32_port = to_stm32_port(port); 509 + struct dma_async_tx_descriptor *desc; 510 + enum dma_status rx_dma_status; 511 + int ret; 512 + 513 + if (stm32_port->throttled) 514 + return 0; 515 + 516 + if (stm32_port->rx_dma_busy) { 517 + rx_dma_status = dmaengine_tx_status(stm32_port->rx_ch, 518 + stm32_port->rx_ch->cookie, 519 + NULL); 520 + if (rx_dma_status == DMA_IN_PROGRESS) 521 + return 0; 522 + 523 + if (rx_dma_status == DMA_PAUSED && !stm32_usart_rx_dma_resume(stm32_port)) 524 + return 0; 525 + 526 + dev_err(port->dev, "DMA failed : status error.\n"); 527 + stm32_usart_rx_dma_terminate(stm32_port); 528 + } 529 + 530 + stm32_port->rx_dma_busy = true; 531 + 532 + stm32_port->last_res = RX_BUF_L; 533 + /* Prepare a DMA cyclic transaction */ 534 + desc = dmaengine_prep_dma_cyclic(stm32_port->rx_ch, 535 + stm32_port->rx_dma_buf, 536 + RX_BUF_L, RX_BUF_P, 537 + DMA_DEV_TO_MEM, 538 + DMA_PREP_INTERRUPT); 539 + if (!desc) { 540 + dev_err(port->dev, "rx dma prep cyclic failed\n"); 541 + stm32_port->rx_dma_busy = false; 542 + return -ENODEV; 543 + } 544 + 545 + desc->callback = stm32_usart_rx_dma_complete; 546 + desc->callback_param = port; 547 + 548 + /* Push current DMA transaction in the pending queue */ 549 + ret = dma_submit_error(dmaengine_submit(desc)); 550 + if (ret) { 551 + dmaengine_terminate_sync(stm32_port->rx_ch); 552 + stm32_port->rx_dma_busy = false; 553 + return ret; 554 + } 555 + 556 + /* Issue pending DMA requests */ 557 + dma_async_issue_pending(stm32_port->rx_ch); 558 + 559 + return 0; 531 560 } 532 561 533 562 static void stm32_usart_tx_dma_terminate(struct stm32_port *stm32_port) ··· 618 507 return stm32_port->tx_dma_busy; 619 508 } 620 509 621 - static bool stm32_usart_tx_dma_enabled(struct stm32_port *stm32_port) 510 + static int stm32_usart_tx_dma_pause(struct stm32_port *stm32_port) 622 511 { 623 - const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 512 + return stm32_usart_dma_pause_resume(stm32_port, stm32_port->tx_ch, 513 + DMA_IN_PROGRESS, dmaengine_pause, 514 + stm32_usart_tx_dma_started, 515 + stm32_usart_tx_dma_terminate); 516 + } 624 517 625 - return !!(readl_relaxed(stm32_port->port.membase + ofs->cr3) & USART_CR3_DMAT); 518 + static int stm32_usart_tx_dma_resume(struct stm32_port *stm32_port) 519 + { 520 + return stm32_usart_dma_pause_resume(stm32_port, stm32_port->tx_ch, 521 + DMA_PAUSED, dmaengine_resume, 522 + stm32_usart_tx_dma_started, 523 + stm32_usart_tx_dma_terminate); 626 524 } 627 525 628 526 static void stm32_usart_tx_dma_complete(void *arg) 629 527 { 630 528 struct uart_port *port = arg; 631 529 struct stm32_port *stm32port = to_stm32_port(port); 632 - const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; 633 530 unsigned long flags; 634 531 635 - stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT); 636 532 stm32_usart_tx_dma_terminate(stm32port); 637 533 638 534 /* Let's see if we have pending data to send */ ··· 671 553 stm32_usart_set_bits(port, ofs->cr1, USART_CR1_TCIE); 672 554 } 673 555 674 - static void stm32_usart_rx_dma_complete(void *arg) 675 - { 676 - struct uart_port *port = arg; 677 - struct tty_port *tport = &port->state->port; 678 - unsigned int size; 679 - unsigned long flags; 680 - 681 - spin_lock_irqsave(&port->lock, flags); 682 - size = stm32_usart_receive_chars(port, false); 683 - uart_unlock_and_check_sysrq_irqrestore(port, flags); 684 - if (size) 685 - tty_flip_buffer_push(tport); 686 - } 687 - 688 556 static void stm32_usart_tx_interrupt_disable(struct uart_port *port) 689 557 { 690 558 struct stm32_port *stm32_port = to_stm32_port(port); ··· 696 592 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 697 593 struct circ_buf *xmit = &port->state->xmit; 698 594 699 - if (stm32_usart_tx_dma_enabled(stm32_port)) 700 - stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT); 701 - 702 595 while (!uart_circ_empty(xmit)) { 703 596 /* Check that TDR is empty before filling FIFO */ 704 597 if (!(readl_relaxed(port->membase + ofs->isr) & USART_SR_TXE)) ··· 714 613 static void stm32_usart_transmit_chars_dma(struct uart_port *port) 715 614 { 716 615 struct stm32_port *stm32port = to_stm32_port(port); 717 - const struct stm32_usart_offsets *ofs = &stm32port->info->ofs; 718 616 struct circ_buf *xmit = &port->state->xmit; 719 617 struct dma_async_tx_descriptor *desc = NULL; 720 618 unsigned int count; 619 + int ret; 721 620 722 621 if (stm32_usart_tx_dma_started(stm32port)) { 723 - if (!stm32_usart_tx_dma_enabled(stm32port)) 724 - stm32_usart_set_bits(port, ofs->cr3, USART_CR3_DMAT); 622 + ret = stm32_usart_tx_dma_resume(stm32port); 623 + if (ret < 0 && ret != -EAGAIN) 624 + goto fallback_err; 725 625 return; 726 626 } 727 627 ··· 767 665 desc->callback_param = port; 768 666 769 667 /* Push current DMA TX transaction in the pending queue */ 770 - if (dma_submit_error(dmaengine_submit(desc))) { 771 - /* dma no yet started, safe to free resources */ 668 + /* DMA no yet started, safe to free resources */ 669 + ret = dma_submit_error(dmaengine_submit(desc)); 670 + if (ret) { 671 + dev_err(port->dev, "DMA failed with error code: %d\n", ret); 772 672 stm32_usart_tx_dma_terminate(stm32port); 773 673 goto fallback_err; 774 674 } 775 675 776 676 /* Issue pending DMA TX requests */ 777 677 dma_async_issue_pending(stm32port->tx_ch); 778 - 779 - stm32_usart_set_bits(port, ofs->cr3, USART_CR3_DMAT); 780 678 781 679 uart_xmit_advance(port, count); 782 680 ··· 803 701 } 804 702 805 703 if (port->x_char) { 806 - if (stm32_usart_tx_dma_started(stm32_port) && 807 - stm32_usart_tx_dma_enabled(stm32_port)) 808 - stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT); 704 + /* dma terminate may have been called in case of dma pause failure */ 705 + stm32_usart_tx_dma_pause(stm32_port); 809 706 810 707 /* Check that TDR is empty before filling FIFO */ 811 708 ret = ··· 818 717 writel_relaxed(port->x_char, port->membase + ofs->tdr); 819 718 port->x_char = 0; 820 719 port->icount.tx++; 821 - if (stm32_usart_tx_dma_started(stm32_port)) 822 - stm32_usart_set_bits(port, ofs->cr3, USART_CR3_DMAT); 720 + 721 + /* dma terminate may have been called in case of dma resume failure */ 722 + stm32_usart_tx_dma_resume(stm32_port); 823 723 return; 824 724 } 825 725 ··· 887 785 * line has been masked by HW and rx data are stacking in FIFO. 888 786 */ 889 787 if (!stm32_port->throttled) { 890 - if (((sr & USART_SR_RXNE) && !stm32_usart_rx_dma_enabled(port)) || 891 - ((sr & USART_SR_ERR_MASK) && stm32_usart_rx_dma_enabled(port))) { 788 + if (((sr & USART_SR_RXNE) && !stm32_usart_rx_dma_started(stm32_port)) || 789 + ((sr & USART_SR_ERR_MASK) && stm32_usart_rx_dma_started(stm32_port))) { 892 790 spin_lock(&port->lock); 893 791 size = stm32_usart_receive_chars(port, false); 894 792 uart_unlock_and_check_sysrq(port); ··· 904 802 } 905 803 906 804 /* Receiver timeout irq for DMA RX */ 907 - if (stm32_usart_rx_dma_enabled(port) && !stm32_port->throttled) { 805 + if (stm32_usart_rx_dma_started(stm32_port) && !stm32_port->throttled) { 908 806 spin_lock(&port->lock); 909 807 size = stm32_usart_receive_chars(port, false); 910 808 uart_unlock_and_check_sysrq(port); ··· 953 851 static void stm32_usart_stop_tx(struct uart_port *port) 954 852 { 955 853 struct stm32_port *stm32_port = to_stm32_port(port); 956 - const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 957 854 958 855 stm32_usart_tx_interrupt_disable(port); 959 - if (stm32_usart_tx_dma_started(stm32_port) && stm32_usart_tx_dma_enabled(stm32_port)) 960 - stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT); 856 + 857 + /* dma terminate may have been called in case of dma pause failure */ 858 + stm32_usart_tx_dma_pause(stm32_port); 961 859 962 860 stm32_usart_rs485_rts_disable(port); 963 861 } ··· 981 879 static void stm32_usart_flush_buffer(struct uart_port *port) 982 880 { 983 881 struct stm32_port *stm32_port = to_stm32_port(port); 984 - const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 985 882 986 - if (stm32_port->tx_ch) { 883 + if (stm32_port->tx_ch) 987 884 stm32_usart_tx_dma_terminate(stm32_port); 988 - stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT); 989 - } 990 885 } 991 886 992 887 /* Throttle the remote when input buffer is about to overflow. */ ··· 996 897 spin_lock_irqsave(&port->lock, flags); 997 898 998 899 /* 999 - * Disable DMA request line if enabled, so the RX data gets queued into the FIFO. 900 + * Pause DMA transfer, so the RX data gets queued into the FIFO. 1000 901 * Hardware flow control is triggered when RX FIFO is full. 1001 902 */ 1002 - if (stm32_usart_rx_dma_enabled(port)) 1003 - stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAR); 903 + stm32_usart_rx_dma_pause(stm32_port); 1004 904 1005 905 stm32_usart_clr_bits(port, ofs->cr1, stm32_port->cr1_irq); 1006 906 if (stm32_port->cr3_irq) ··· 1021 923 if (stm32_port->cr3_irq) 1022 924 stm32_usart_set_bits(port, ofs->cr3, stm32_port->cr3_irq); 1023 925 926 + stm32_port->throttled = false; 927 + 1024 928 /* 1025 - * Switch back to DMA mode (re-enable DMA request line). 929 + * Switch back to DMA mode (resume DMA). 1026 930 * Hardware flow control is stopped when FIFO is not full any more. 1027 931 */ 1028 932 if (stm32_port->rx_ch) 1029 - stm32_usart_set_bits(port, ofs->cr3, USART_CR3_DMAR); 933 + stm32_usart_rx_dma_start_or_resume(port); 1030 934 1031 - stm32_port->throttled = false; 1032 935 spin_unlock_irqrestore(&port->lock, flags); 1033 936 } 1034 937 ··· 1040 941 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 1041 942 1042 943 /* Disable DMA request line. */ 1043 - if (stm32_port->rx_ch) 1044 - stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAR); 944 + stm32_usart_rx_dma_pause(stm32_port); 1045 945 1046 946 stm32_usart_clr_bits(port, ofs->cr1, stm32_port->cr1_irq); 1047 947 if (stm32_port->cr3_irq) ··· 1050 952 /* Handle breaks - ignored by us */ 1051 953 static void stm32_usart_break_ctl(struct uart_port *port, int break_state) 1052 954 { 1053 - } 1054 - 1055 - static int stm32_usart_start_rx_dma_cyclic(struct uart_port *port) 1056 - { 1057 - struct stm32_port *stm32_port = to_stm32_port(port); 1058 - const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 1059 - struct dma_async_tx_descriptor *desc; 1060 - int ret; 1061 - 1062 - stm32_port->last_res = RX_BUF_L; 1063 - /* Prepare a DMA cyclic transaction */ 1064 - desc = dmaengine_prep_dma_cyclic(stm32_port->rx_ch, 1065 - stm32_port->rx_dma_buf, 1066 - RX_BUF_L, RX_BUF_P, 1067 - DMA_DEV_TO_MEM, 1068 - DMA_PREP_INTERRUPT); 1069 - if (!desc) { 1070 - dev_err(port->dev, "rx dma prep cyclic failed\n"); 1071 - return -ENODEV; 1072 - } 1073 - 1074 - desc->callback = stm32_usart_rx_dma_complete; 1075 - desc->callback_param = port; 1076 - 1077 - /* Push current DMA transaction in the pending queue */ 1078 - ret = dma_submit_error(dmaengine_submit(desc)); 1079 - if (ret) { 1080 - dmaengine_terminate_sync(stm32_port->rx_ch); 1081 - return ret; 1082 - } 1083 - 1084 - /* Issue pending DMA requests */ 1085 - dma_async_issue_pending(stm32_port->rx_ch); 1086 - 1087 - /* 1088 - * DMA request line not re-enabled at resume when port is throttled. 1089 - * It will be re-enabled by unthrottle ops. 1090 - */ 1091 - if (!stm32_port->throttled) 1092 - stm32_usart_set_bits(port, ofs->cr3, USART_CR3_DMAR); 1093 - 1094 - return 0; 1095 955 } 1096 956 1097 957 static int stm32_usart_startup(struct uart_port *port) ··· 1077 1021 writel_relaxed(USART_RQR_RXFRQ, port->membase + ofs->rqr); 1078 1022 1079 1023 if (stm32_port->rx_ch) { 1080 - ret = stm32_usart_start_rx_dma_cyclic(port); 1024 + ret = stm32_usart_rx_dma_start_or_resume(port); 1081 1025 if (ret) { 1082 1026 free_irq(port->irq, port); 1083 1027 return ret; ··· 1099 1043 u32 val, isr; 1100 1044 int ret; 1101 1045 1102 - if (stm32_usart_tx_dma_enabled(stm32_port)) 1103 - stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT); 1104 - 1105 1046 if (stm32_usart_tx_dma_started(stm32_port)) 1106 1047 stm32_usart_tx_dma_terminate(stm32_port); 1048 + 1049 + if (stm32_port->tx_ch) 1050 + stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT); 1107 1051 1108 1052 /* Disable modem control interrupts */ 1109 1053 stm32_usart_disable_ms(port); ··· 1123 1067 dev_err(port->dev, "Transmission is not complete\n"); 1124 1068 1125 1069 /* Disable RX DMA. */ 1126 - if (stm32_port->rx_ch) 1127 - dmaengine_terminate_async(stm32_port->rx_ch); 1070 + if (stm32_port->rx_ch) { 1071 + stm32_usart_rx_dma_terminate(stm32_port); 1072 + dmaengine_synchronize(stm32_port->rx_ch); 1073 + } 1128 1074 1129 1075 /* flush RX & TX FIFO */ 1130 1076 if (ofs->rqr != UNDEF_REG) ··· 1316 1258 cr3 |= USART_CR3_DMAR; 1317 1259 cr3 |= USART_CR3_DDRE; 1318 1260 } 1261 + 1262 + if (stm32_port->tx_ch) 1263 + cr3 |= USART_CR3_DMAT; 1319 1264 1320 1265 if (rs485conf->flags & SER_RS485_ENABLED) { 1321 1266 stm32_usart_config_reg_rs485(&cr1, &cr3, ··· 1826 1765 pm_runtime_put_noidle(&pdev->dev); 1827 1766 1828 1767 stm32_usart_clr_bits(port, ofs->cr1, USART_CR1_PEIE); 1829 - cr3 = readl_relaxed(port->membase + ofs->cr3); 1830 - cr3 &= ~USART_CR3_EIE; 1831 - cr3 &= ~USART_CR3_DMAR; 1832 - cr3 &= ~USART_CR3_DDRE; 1833 - writel_relaxed(cr3, port->membase + ofs->cr3); 1834 1768 1835 1769 if (stm32_port->tx_ch) { 1836 1770 stm32_usart_of_dma_tx_remove(stm32_port, pdev); ··· 1837 1781 dma_release_channel(stm32_port->rx_ch); 1838 1782 } 1839 1783 1840 - stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAT); 1784 + cr3 = readl_relaxed(port->membase + ofs->cr3); 1785 + cr3 &= ~USART_CR3_EIE; 1786 + cr3 &= ~USART_CR3_DMAR; 1787 + cr3 &= ~USART_CR3_DMAT; 1788 + cr3 &= ~USART_CR3_DDRE; 1789 + writel_relaxed(cr3, port->membase + ofs->cr3); 1841 1790 1842 1791 if (stm32_port->wakeup_src) { 1843 1792 dev_pm_clear_wake_irq(&pdev->dev); ··· 2014 1953 const struct stm32_usart_offsets *ofs = &stm32_port->info->ofs; 2015 1954 struct tty_port *tport = &port->state->port; 2016 1955 int ret; 2017 - unsigned int size; 1956 + unsigned int size = 0; 2018 1957 unsigned long flags; 2019 1958 2020 1959 if (!stm32_port->wakeup_src || !tty_port_initialized(tport)) ··· 2036 1975 */ 2037 1976 if (stm32_port->rx_ch) { 2038 1977 spin_lock_irqsave(&port->lock, flags); 2039 - /* Avoid race with RX IRQ when DMAR is cleared */ 2040 - stm32_usart_clr_bits(port, ofs->cr3, USART_CR3_DMAR); 2041 1978 /* Poll data from DMA RX buffer if any */ 2042 - size = stm32_usart_receive_chars(port, true); 2043 - dmaengine_terminate_async(stm32_port->rx_ch); 1979 + if (!stm32_usart_rx_dma_pause(stm32_port)) 1980 + size += stm32_usart_receive_chars(port, true); 1981 + stm32_usart_rx_dma_terminate(stm32_port); 2044 1982 uart_unlock_and_check_sysrq_irqrestore(port, flags); 2045 1983 if (size) 2046 1984 tty_flip_buffer_push(tport); ··· 2049 1989 stm32_usart_receive_chars(port, false); 2050 1990 } else { 2051 1991 if (stm32_port->rx_ch) { 2052 - ret = stm32_usart_start_rx_dma_cyclic(port); 1992 + ret = stm32_usart_rx_dma_start_or_resume(port); 2053 1993 if (ret) 2054 1994 return ret; 2055 1995 }
+1
drivers/tty/serial/stm32-usart.h
··· 199 199 u32 cr3_irq; /* USART_CR3_RXFTIE */ 200 200 int last_res; 201 201 bool tx_dma_busy; /* dma tx transaction in progress */ 202 + bool rx_dma_busy; /* dma rx transaction in progress */ 202 203 bool throttled; /* port throttled */ 203 204 bool hw_flow_control; 204 205 bool swap; /* swap RX & TX pins */
+2 -2
drivers/tty/serial/sunhv.c
··· 17 17 #include <linux/slab.h> 18 18 #include <linux/delay.h> 19 19 #include <linux/init.h> 20 - #include <linux/of_device.h> 20 + #include <linux/of.h> 21 + #include <linux/platform_device.h> 21 22 22 23 #include <asm/hypervisor.h> 23 24 #include <asm/spitfire.h> 24 - #include <asm/prom.h> 25 25 #include <asm/irq.h> 26 26 #include <asm/setup.h> 27 27
+1 -1
drivers/tty/serial/sunplus-uart.c
··· 231 231 static void receive_chars(struct uart_port *port) 232 232 { 233 233 unsigned int lsr = readl(port->membase + SUP_UART_LSR); 234 - unsigned int ch, flag; 234 + u8 ch, flag; 235 235 236 236 do { 237 237 ch = readl(port->membase + SUP_UART_DATA);
+2 -1
drivers/tty/serial/sunsab.c
··· 33 33 #include <linux/slab.h> 34 34 #include <linux/delay.h> 35 35 #include <linux/init.h> 36 - #include <linux/of_device.h> 36 + #include <linux/of.h> 37 + #include <linux/platform_device.h> 37 38 38 39 #include <linux/io.h> 39 40 #include <asm/irq.h>
+2 -2
drivers/tty/serial/sunsu.c
··· 37 37 #include <linux/serial_reg.h> 38 38 #include <linux/init.h> 39 39 #include <linux/delay.h> 40 - #include <linux/of_device.h> 40 + #include <linux/of.h> 41 + #include <linux/platform_device.h> 41 42 42 43 #include <linux/io.h> 43 44 #include <asm/irq.h> 44 - #include <asm/prom.h> 45 45 #include <asm/setup.h> 46 46 47 47 #include <linux/serial_core.h>
+2 -2
drivers/tty/serial/sunzilog.c
··· 33 33 #include <linux/serio.h> 34 34 #endif 35 35 #include <linux/init.h> 36 - #include <linux/of_device.h> 36 + #include <linux/of.h> 37 + #include <linux/platform_device.h> 37 38 38 39 #include <linux/io.h> 39 40 #include <asm/irq.h> 40 - #include <asm/prom.h> 41 41 #include <asm/setup.h> 42 42 43 43 #include <linux/serial_core.h>
-1
drivers/tty/serial/tegra-tcu.c
··· 7 7 #include <linux/mailbox_client.h> 8 8 #include <linux/module.h> 9 9 #include <linux/of.h> 10 - #include <linux/of_device.h> 11 10 #include <linux/platform_device.h> 12 11 #include <linux/serial.h> 13 12 #include <linux/serial_core.h>
-3
drivers/tty/serial/uartlite.c
··· 20 20 #include <linux/io.h> 21 21 #include <linux/iopoll.h> 22 22 #include <linux/of.h> 23 - #include <linux/of_address.h> 24 - #include <linux/of_device.h> 25 - #include <linux/of_platform.h> 26 23 #include <linux/clk.h> 27 24 #include <linux/pm_runtime.h> 28 25
+2 -2
drivers/tty/serial/ucc_uart.c
··· 17 17 */ 18 18 19 19 #include <linux/module.h> 20 + #include <linux/platform_device.h> 20 21 #include <linux/serial.h> 21 22 #include <linux/serial_core.h> 22 23 #include <linux/slab.h> 23 24 #include <linux/tty.h> 24 25 #include <linux/tty_flip.h> 25 26 #include <linux/io.h> 27 + #include <linux/of.h> 26 28 #include <linux/of_address.h> 27 29 #include <linux/of_irq.h> 28 - #include <linux/of_platform.h> 29 30 #include <linux/dma-mapping.h> 30 31 31 - #include <linux/fs_uart_pd.h> 32 32 #include <soc/fsl/qe/ucc_slow.h> 33 33 34 34 #include <linux/firmware.h>
+2 -6
drivers/tty/serial/vt8500_serial.c
··· 14 14 #include <linux/irq.h> 15 15 #include <linux/init.h> 16 16 #include <linux/console.h> 17 + #include <linux/platform_device.h> 17 18 #include <linux/tty.h> 18 19 #include <linux/tty_flip.h> 19 20 #include <linux/serial_core.h> ··· 22 21 #include <linux/slab.h> 23 22 #include <linux/clk.h> 24 23 #include <linux/of.h> 25 - #include <linux/of_device.h> 26 24 #include <linux/err.h> 27 25 28 26 /* ··· 611 611 if (!flags) 612 612 return -EINVAL; 613 613 614 - mmres = platform_get_resource(pdev, IORESOURCE_MEM, 0); 615 - if (!mmres) 616 - return -ENODEV; 617 - 618 614 irq = platform_get_irq(pdev, 0); 619 615 if (irq < 0) 620 616 return irq; ··· 643 647 if (!vt8500_port) 644 648 return -ENOMEM; 645 649 646 - vt8500_port->uart.membase = devm_ioremap_resource(&pdev->dev, mmres); 650 + vt8500_port->uart.membase = devm_platform_get_and_ioremap_resource(pdev, 0, &mmres); 647 651 if (IS_ERR(vt8500_port->uart.membase)) 648 652 return PTR_ERR(vt8500_port->uart.membase); 649 653
+2 -2
drivers/tty/serial/xilinx_uartps.c
··· 1562 1562 } 1563 1563 1564 1564 irq = platform_get_irq(pdev, 0); 1565 - if (irq <= 0) { 1566 - rc = -ENXIO; 1565 + if (irq < 0) { 1566 + rc = irq; 1567 1567 goto err_out_clk_disable; 1568 1568 } 1569 1569
+2 -1
drivers/tty/serial/zs.c
··· 539 539 struct uart_port *uport = &zport->port; 540 540 struct zs_scc *scc = zport->scc; 541 541 struct uart_icount *icount; 542 - unsigned int avail, status, ch, flag; 542 + unsigned int avail, status; 543 543 int count; 544 + u8 ch, flag; 544 545 545 546 for (count = 16; count; count--) { 546 547 spin_lock(&scc->zlock);
+41 -43
drivers/tty/sysrq.c
··· 98 98 __setup("sysrq_always_enabled", sysrq_always_enabled_setup); 99 99 100 100 101 - static void sysrq_handle_loglevel(int key) 101 + static void sysrq_handle_loglevel(u8 key) 102 102 { 103 - int i; 103 + u8 loglevel = key - '0'; 104 104 105 - i = key - '0'; 106 105 console_loglevel = CONSOLE_LOGLEVEL_DEFAULT; 107 - pr_info("Loglevel set to %d\n", i); 108 - console_loglevel = i; 106 + pr_info("Loglevel set to %u\n", loglevel); 107 + console_loglevel = loglevel; 109 108 } 110 109 static const struct sysrq_key_op sysrq_loglevel_op = { 111 110 .handler = sysrq_handle_loglevel, ··· 114 115 }; 115 116 116 117 #ifdef CONFIG_VT 117 - static void sysrq_handle_SAK(int key) 118 + static void sysrq_handle_SAK(u8 key) 118 119 { 119 120 struct work_struct *SAK_work = &vc_cons[fg_console].SAK_work; 120 121 ··· 131 132 #endif 132 133 133 134 #ifdef CONFIG_VT 134 - static void sysrq_handle_unraw(int key) 135 + static void sysrq_handle_unraw(u8 key) 135 136 { 136 137 vt_reset_unicode(fg_console); 137 138 } ··· 146 147 #define sysrq_unraw_op (*(const struct sysrq_key_op *)NULL) 147 148 #endif /* CONFIG_VT */ 148 149 149 - static void sysrq_handle_crash(int key) 150 + static void sysrq_handle_crash(u8 key) 150 151 { 151 152 /* release the RCU read lock before crashing */ 152 153 rcu_read_unlock(); ··· 160 161 .enable_mask = SYSRQ_ENABLE_DUMP, 161 162 }; 162 163 163 - static void sysrq_handle_reboot(int key) 164 + static void sysrq_handle_reboot(u8 key) 164 165 { 165 166 lockdep_off(); 166 167 local_irq_enable(); ··· 175 176 176 177 const struct sysrq_key_op *__sysrq_reboot_op = &sysrq_reboot_op; 177 178 178 - static void sysrq_handle_sync(int key) 179 + static void sysrq_handle_sync(u8 key) 179 180 { 180 181 emergency_sync(); 181 182 } ··· 186 187 .enable_mask = SYSRQ_ENABLE_SYNC, 187 188 }; 188 189 189 - static void sysrq_handle_show_timers(int key) 190 + static void sysrq_handle_show_timers(u8 key) 190 191 { 191 192 sysrq_timer_list_show(); 192 193 } ··· 197 198 .action_msg = "Show clockevent devices & pending hrtimers (no others)", 198 199 }; 199 200 200 - static void sysrq_handle_mountro(int key) 201 + static void sysrq_handle_mountro(u8 key) 201 202 { 202 203 emergency_remount(); 203 204 } ··· 209 210 }; 210 211 211 212 #ifdef CONFIG_LOCKDEP 212 - static void sysrq_handle_showlocks(int key) 213 + static void sysrq_handle_showlocks(u8 key) 213 214 { 214 215 debug_show_all_locks(); 215 216 } ··· 249 250 250 251 static DECLARE_WORK(sysrq_showallcpus, sysrq_showregs_othercpus); 251 252 252 - static void sysrq_handle_showallcpus(int key) 253 + static void sysrq_handle_showallcpus(u8 key) 253 254 { 254 255 /* 255 256 * Fall back to the workqueue based printing if the ··· 282 283 #define sysrq_showallcpus_op (*(const struct sysrq_key_op *)NULL) 283 284 #endif 284 285 285 - static void sysrq_handle_showregs(int key) 286 + static void sysrq_handle_showregs(u8 key) 286 287 { 287 288 struct pt_regs *regs = NULL; 288 289 ··· 299 300 .enable_mask = SYSRQ_ENABLE_DUMP, 300 301 }; 301 302 302 - static void sysrq_handle_showstate(int key) 303 + static void sysrq_handle_showstate(u8 key) 303 304 { 304 305 show_state(); 305 306 show_all_workqueues(); ··· 311 312 .enable_mask = SYSRQ_ENABLE_DUMP, 312 313 }; 313 314 314 - static void sysrq_handle_showstate_blocked(int key) 315 + static void sysrq_handle_showstate_blocked(u8 key) 315 316 { 316 317 show_state_filter(TASK_UNINTERRUPTIBLE); 317 318 } ··· 325 326 #ifdef CONFIG_TRACING 326 327 #include <linux/ftrace.h> 327 328 328 - static void sysrq_ftrace_dump(int key) 329 + static void sysrq_ftrace_dump(u8 key) 329 330 { 330 331 ftrace_dump(DUMP_ALL); 331 332 } ··· 339 340 #define sysrq_ftrace_dump_op (*(const struct sysrq_key_op *)NULL) 340 341 #endif 341 342 342 - static void sysrq_handle_showmem(int key) 343 + static void sysrq_handle_showmem(u8 key) 343 344 { 344 345 show_mem(); 345 346 } ··· 369 370 read_unlock(&tasklist_lock); 370 371 } 371 372 372 - static void sysrq_handle_term(int key) 373 + static void sysrq_handle_term(u8 key) 373 374 { 374 375 send_sig_all(SIGTERM); 375 376 console_loglevel = CONSOLE_LOGLEVEL_DEBUG; ··· 400 401 401 402 static DECLARE_WORK(moom_work, moom_callback); 402 403 403 - static void sysrq_handle_moom(int key) 404 + static void sysrq_handle_moom(u8 key) 404 405 { 405 406 schedule_work(&moom_work); 406 407 } ··· 412 413 }; 413 414 414 415 #ifdef CONFIG_BLOCK 415 - static void sysrq_handle_thaw(int key) 416 + static void sysrq_handle_thaw(u8 key) 416 417 { 417 418 emergency_thaw_all(); 418 419 } ··· 426 427 #define sysrq_thaw_op (*(const struct sysrq_key_op *)NULL) 427 428 #endif 428 429 429 - static void sysrq_handle_kill(int key) 430 + static void sysrq_handle_kill(u8 key) 430 431 { 431 432 send_sig_all(SIGKILL); 432 433 console_loglevel = CONSOLE_LOGLEVEL_DEBUG; ··· 438 439 .enable_mask = SYSRQ_ENABLE_SIGNAL, 439 440 }; 440 441 441 - static void sysrq_handle_unrt(int key) 442 + static void sysrq_handle_unrt(u8 key) 442 443 { 443 444 normalize_rt_tasks(); 444 445 } ··· 530 531 }; 531 532 532 533 /* key2index calculation, -1 on invalid index */ 533 - static int sysrq_key_table_key2index(int key) 534 + static int sysrq_key_table_key2index(u8 key) 534 535 { 535 - int retval; 536 - 537 - if ((key >= '0') && (key <= '9')) 538 - retval = key - '0'; 539 - else if ((key >= 'a') && (key <= 'z')) 540 - retval = key + 10 - 'a'; 541 - else if ((key >= 'A') && (key <= 'Z')) 542 - retval = key + 36 - 'A'; 543 - else 544 - retval = -1; 545 - return retval; 536 + switch (key) { 537 + case '0' ... '9': 538 + return key - '0'; 539 + case 'a' ... 'z': 540 + return key - 'a' + 10; 541 + case 'A' ... 'Z': 542 + return key - 'A' + 10 + 26; 543 + default: 544 + return -1; 545 + } 546 546 } 547 547 548 548 /* 549 549 * get and put functions for the table, exposed to modules. 550 550 */ 551 - static const struct sysrq_key_op *__sysrq_get_key_op(int key) 551 + static const struct sysrq_key_op *__sysrq_get_key_op(u8 key) 552 552 { 553 553 const struct sysrq_key_op *op_p = NULL; 554 554 int i; ··· 559 561 return op_p; 560 562 } 561 563 562 - static void __sysrq_put_key_op(int key, const struct sysrq_key_op *op_p) 564 + static void __sysrq_put_key_op(u8 key, const struct sysrq_key_op *op_p) 563 565 { 564 566 int i = sysrq_key_table_key2index(key); 565 567 ··· 567 569 sysrq_key_table[i] = op_p; 568 570 } 569 571 570 - void __handle_sysrq(int key, bool check_mask) 572 + void __handle_sysrq(u8 key, bool check_mask) 571 573 { 572 574 const struct sysrq_key_op *op_p; 573 575 int orig_log_level; ··· 626 628 suppress_printk = orig_suppress_printk; 627 629 } 628 630 629 - void handle_sysrq(int key) 631 + void handle_sysrq(u8 key) 630 632 { 631 633 if (sysrq_on()) 632 634 __handle_sysrq(key, true); ··· 1110 1112 } 1111 1113 EXPORT_SYMBOL_GPL(sysrq_toggle_support); 1112 1114 1113 - static int __sysrq_swap_key_ops(int key, const struct sysrq_key_op *insert_op_p, 1115 + static int __sysrq_swap_key_ops(u8 key, const struct sysrq_key_op *insert_op_p, 1114 1116 const struct sysrq_key_op *remove_op_p) 1115 1117 { 1116 1118 int retval; ··· 1134 1136 return retval; 1135 1137 } 1136 1138 1137 - int register_sysrq_key(int key, const struct sysrq_key_op *op_p) 1139 + int register_sysrq_key(u8 key, const struct sysrq_key_op *op_p) 1138 1140 { 1139 1141 return __sysrq_swap_key_ops(key, op_p, NULL); 1140 1142 } 1141 1143 EXPORT_SYMBOL(register_sysrq_key); 1142 1144 1143 - int unregister_sysrq_key(int key, const struct sysrq_key_op *op_p) 1145 + int unregister_sysrq_key(u8 key, const struct sysrq_key_op *op_p) 1144 1146 { 1145 1147 return __sysrq_swap_key_ops(key, NULL, op_p); 1146 1148 }
+4 -4
drivers/tty/tty.h
··· 63 63 void __stop_tty(struct tty_struct *tty); 64 64 void __start_tty(struct tty_struct *tty); 65 65 void tty_write_unlock(struct tty_struct *tty); 66 - int tty_write_lock(struct tty_struct *tty, int ndelay); 66 + int tty_write_lock(struct tty_struct *tty, bool ndelay); 67 67 void tty_vhangup_session(struct tty_struct *tty); 68 68 void tty_open_proc_set_tty(struct file *filp, struct tty_struct *tty); 69 69 int tty_signal_session_leader(struct tty_struct *tty, int exit_session); ··· 101 101 #ifdef CONFIG_AUDIT 102 102 void tty_audit_add_data(const struct tty_struct *tty, const void *data, 103 103 size_t size); 104 - void tty_audit_tiocsti(const struct tty_struct *tty, char ch); 104 + void tty_audit_tiocsti(const struct tty_struct *tty, u8 ch); 105 105 #else 106 106 static inline void tty_audit_add_data(const struct tty_struct *tty, 107 107 const void *data, size_t size) 108 108 { 109 109 } 110 - static inline void tty_audit_tiocsti(const struct tty_struct *tty, char ch) 110 + static inline void tty_audit_tiocsti(const struct tty_struct *tty, u8 ch) 111 111 { 112 112 } 113 113 #endif ··· 115 115 ssize_t redirected_tty_write(struct kiocb *, struct iov_iter *); 116 116 117 117 int tty_insert_flip_string_and_push_buffer(struct tty_port *port, 118 - const unsigned char *chars, size_t cnt); 118 + const u8 *chars, size_t cnt); 119 119 120 120 #endif
+3 -3
drivers/tty/tty_audit.c
··· 17 17 dev_t dev; /* The TTY which the data is from */ 18 18 bool icanon; 19 19 size_t valid; 20 - unsigned char *data; /* Allocated size N_TTY_BUF_SIZE */ 20 + u8 *data; /* Allocated size N_TTY_BUF_SIZE */ 21 21 }; 22 22 23 23 static struct tty_audit_buf *tty_audit_buf_ref(void) ··· 59 59 } 60 60 61 61 static void tty_audit_log(const char *description, dev_t dev, 62 - const unsigned char *data, size_t size) 62 + const u8 *data, size_t size) 63 63 { 64 64 struct audit_buffer *ab; 65 65 pid_t pid = task_pid_nr(current); ··· 134 134 /* 135 135 * tty_audit_tiocsti - Log TIOCSTI 136 136 */ 137 - void tty_audit_tiocsti(const struct tty_struct *tty, char ch) 137 + void tty_audit_tiocsti(const struct tty_struct *tty, u8 ch) 138 138 { 139 139 dev_t dev; 140 140
+61 -131
drivers/tty/tty_buffer.c
··· 177 177 */ 178 178 if (atomic_read(&port->buf.mem_used) > port->buf.mem_limit) 179 179 return NULL; 180 - p = kmalloc(sizeof(struct tty_buffer) + 2 * size, 181 - GFP_ATOMIC | __GFP_NOWARN); 180 + p = kmalloc(struct_size(p, data, 2 * size), GFP_ATOMIC | __GFP_NOWARN); 182 181 if (p == NULL) 183 182 return NULL; 184 183 ··· 262 263 bool flags) 263 264 { 264 265 struct tty_bufhead *buf = &port->buf; 265 - struct tty_buffer *b, *n; 266 - int left, change; 266 + struct tty_buffer *n, *b = buf->tail; 267 + size_t left = (b->flags ? 1 : 2) * b->size - b->used; 268 + bool change = !b->flags && flags; 267 269 268 - b = buf->tail; 269 - if (!b->flags) 270 - left = 2 * b->size - b->used; 271 - else 272 - left = b->size - b->used; 270 + if (!change && left >= size) 271 + return size; 273 272 274 - change = !b->flags && flags; 275 - if (change || left < size) { 276 - /* This is the slow path - looking for new buffers to use */ 277 - n = tty_buffer_alloc(port, size); 278 - if (n != NULL) { 279 - n->flags = flags; 280 - buf->tail = n; 281 - /* 282 - * Paired w/ acquire in flush_to_ldisc() and lookahead_bufs() 283 - * ensures they see all buffer data. 284 - */ 285 - smp_store_release(&b->commit, b->used); 286 - /* 287 - * Paired w/ acquire in flush_to_ldisc() and lookahead_bufs() 288 - * ensures the latest commit value can be read before the head 289 - * is advanced to the next buffer. 290 - */ 291 - smp_store_release(&b->next, n); 292 - } else if (change) 293 - size = 0; 294 - else 295 - size = left; 296 - } 273 + /* This is the slow path - looking for new buffers to use */ 274 + n = tty_buffer_alloc(port, size); 275 + if (n == NULL) 276 + return change ? 0 : left; 277 + 278 + n->flags = flags; 279 + buf->tail = n; 280 + /* 281 + * Paired w/ acquire in flush_to_ldisc() and lookahead_bufs() 282 + * ensures they see all buffer data. 283 + */ 284 + smp_store_release(&b->commit, b->used); 285 + /* 286 + * Paired w/ acquire in flush_to_ldisc() and lookahead_bufs() 287 + * ensures the latest commit value can be read before the head 288 + * is advanced to the next buffer. 289 + */ 290 + smp_store_release(&b->next, n); 291 + 297 292 return size; 298 293 } 299 294 ··· 297 304 } 298 305 EXPORT_SYMBOL_GPL(tty_buffer_request_room); 299 306 300 - /** 301 - * tty_insert_flip_string_fixed_flag - add characters to the tty buffer 302 - * @port: tty port 303 - * @chars: characters 304 - * @flag: flag value for each character 305 - * @size: size 306 - * 307 - * Queue a series of bytes to the tty buffering. All the characters passed are 308 - * marked with the supplied flag. 309 - * 310 - * Returns: the number added. 311 - */ 312 - int tty_insert_flip_string_fixed_flag(struct tty_port *port, 313 - const unsigned char *chars, char flag, size_t size) 307 + size_t __tty_insert_flip_string_flags(struct tty_port *port, const u8 *chars, 308 + const u8 *flags, bool mutable_flags, 309 + size_t size) 314 310 { 315 - int copied = 0; 316 - bool flags = flag != TTY_NORMAL; 311 + bool need_flags = mutable_flags || flags[0] != TTY_NORMAL; 312 + size_t copied = 0; 317 313 318 314 do { 319 - int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); 320 - int space = __tty_buffer_request_room(port, goal, flags); 315 + size_t goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); 316 + size_t space = __tty_buffer_request_room(port, goal, need_flags); 321 317 struct tty_buffer *tb = port->buf.tail; 322 318 323 319 if (unlikely(space == 0)) 324 320 break; 321 + 325 322 memcpy(char_buf_ptr(tb, tb->used), chars, space); 326 - if (tb->flags) 327 - memset(flag_buf_ptr(tb, tb->used), flag, space); 323 + 324 + if (mutable_flags) { 325 + memcpy(flag_buf_ptr(tb, tb->used), flags, space); 326 + flags += space; 327 + } else if (tb->flags) { 328 + memset(flag_buf_ptr(tb, tb->used), flags[0], space); 329 + } else { 330 + /* tb->flags should be available once requested */ 331 + WARN_ON_ONCE(need_flags); 332 + } 333 + 328 334 tb->used += space; 329 335 copied += space; 330 336 chars += space; 337 + 331 338 /* There is a small chance that we need to split the data over 332 339 * several buffers. If this is the case we must loop. 333 340 */ 334 341 } while (unlikely(size > copied)); 342 + 335 343 return copied; 336 344 } 337 - EXPORT_SYMBOL(tty_insert_flip_string_fixed_flag); 338 - 339 - /** 340 - * tty_insert_flip_string_flags - add characters to the tty buffer 341 - * @port: tty port 342 - * @chars: characters 343 - * @flags: flag bytes 344 - * @size: size 345 - * 346 - * Queue a series of bytes to the tty buffering. For each character the flags 347 - * array indicates the status of the character. 348 - * 349 - * Returns: the number added. 350 - */ 351 - int tty_insert_flip_string_flags(struct tty_port *port, 352 - const unsigned char *chars, const char *flags, size_t size) 353 - { 354 - int copied = 0; 355 - 356 - do { 357 - int goal = min_t(size_t, size - copied, TTY_BUFFER_PAGE); 358 - int space = tty_buffer_request_room(port, goal); 359 - struct tty_buffer *tb = port->buf.tail; 360 - 361 - if (unlikely(space == 0)) 362 - break; 363 - memcpy(char_buf_ptr(tb, tb->used), chars, space); 364 - memcpy(flag_buf_ptr(tb, tb->used), flags, space); 365 - tb->used += space; 366 - copied += space; 367 - chars += space; 368 - flags += space; 369 - /* There is a small chance that we need to split the data over 370 - * several buffers. If this is the case we must loop. 371 - */ 372 - } while (unlikely(size > copied)); 373 - return copied; 374 - } 375 - EXPORT_SYMBOL(tty_insert_flip_string_flags); 376 - 377 - /** 378 - * __tty_insert_flip_char - add one character to the tty buffer 379 - * @port: tty port 380 - * @ch: character 381 - * @flag: flag byte 382 - * 383 - * Queue a single byte @ch to the tty buffering, with an optional flag. This is 384 - * the slow path of tty_insert_flip_char(). 385 - */ 386 - int __tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag) 387 - { 388 - struct tty_buffer *tb; 389 - bool flags = flag != TTY_NORMAL; 390 - 391 - if (!__tty_buffer_request_room(port, 1, flags)) 392 - return 0; 393 - 394 - tb = port->buf.tail; 395 - if (tb->flags) 396 - *flag_buf_ptr(tb, tb->used) = flag; 397 - *char_buf_ptr(tb, tb->used++) = ch; 398 - 399 - return 1; 400 - } 401 - EXPORT_SYMBOL(__tty_insert_flip_char); 345 + EXPORT_SYMBOL(__tty_insert_flip_string_flags); 402 346 403 347 /** 404 348 * tty_prepare_flip_string - make room for characters ··· 351 421 * Returns: the length available and buffer pointer (@chars) to the space which 352 422 * is now allocated and accounted for as ready for normal characters. 353 423 */ 354 - int tty_prepare_flip_string(struct tty_port *port, unsigned char **chars, 355 - size_t size) 424 + size_t tty_prepare_flip_string(struct tty_port *port, u8 **chars, size_t size) 356 425 { 357 - int space = __tty_buffer_request_room(port, size, false); 426 + size_t space = __tty_buffer_request_room(port, size, false); 358 427 359 428 if (likely(space)) { 360 429 struct tty_buffer *tb = port->buf.tail; ··· 363 434 memset(flag_buf_ptr(tb, tb->used), TTY_NORMAL, space); 364 435 tb->used += space; 365 436 } 437 + 366 438 return space; 367 439 } 368 440 EXPORT_SYMBOL_GPL(tty_prepare_flip_string); ··· 380 450 * 381 451 * Returns: the number of bytes processed. 382 452 */ 383 - int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, 384 - const char *f, int count) 453 + size_t tty_ldisc_receive_buf(struct tty_ldisc *ld, const u8 *p, const u8 *f, 454 + size_t count) 385 455 { 386 456 if (ld->ops->receive_buf2) 387 457 count = ld->ops->receive_buf2(ld->tty, p, f, count); 388 458 else { 389 - count = min_t(int, count, ld->tty->receive_room); 459 + count = min_t(size_t, count, ld->tty->receive_room); 390 460 if (count && ld->ops->receive_buf) 391 461 ld->ops->receive_buf(ld->tty, p, f, count); 392 462 } ··· 419 489 } 420 490 421 491 if (port->client_ops->lookahead_buf) { 422 - unsigned char *p, *f = NULL; 492 + u8 *p, *f = NULL; 423 493 424 494 p = char_buf_ptr(head, head->lookahead); 425 495 if (head->flags) ··· 432 502 } 433 503 } 434 504 435 - static int 436 - receive_buf(struct tty_port *port, struct tty_buffer *head, int count) 505 + static size_t 506 + receive_buf(struct tty_port *port, struct tty_buffer *head, size_t count) 437 507 { 438 - unsigned char *p = char_buf_ptr(head, head->read); 439 - const char *f = NULL; 440 - int n; 508 + u8 *p = char_buf_ptr(head, head->read); 509 + const u8 *f = NULL; 510 + size_t n; 441 511 442 512 if (head->flags) 443 513 f = flag_buf_ptr(head, head->read); ··· 469 539 while (1) { 470 540 struct tty_buffer *head = buf->head; 471 541 struct tty_buffer *next; 472 - int count, rcvd; 542 + size_t count, rcvd; 473 543 474 544 /* Ldisc or user is trying to gain exclusive access */ 475 545 if (atomic_read(&buf->priority)) ··· 550 620 * Returns: the number added. 551 621 */ 552 622 int tty_insert_flip_string_and_push_buffer(struct tty_port *port, 553 - const unsigned char *chars, size_t size) 623 + const u8 *chars, size_t size) 554 624 { 555 625 struct tty_bufhead *buf = &port->buf; 556 626 unsigned long flags;
+20 -30
drivers/tty/tty_io.c
··· 270 270 } 271 271 272 272 /* Caller must hold tty_lock */ 273 - static int check_tty_count(struct tty_struct *tty, const char *routine) 273 + static void check_tty_count(struct tty_struct *tty, const char *routine) 274 274 { 275 275 #ifdef CHECK_TTY_COUNT 276 276 struct list_head *p; ··· 290 290 if (tty->count != (count + kopen_count)) { 291 291 tty_warn(tty, "%s: tty->count(%d) != (#fd's(%d) + #kopen's(%d))\n", 292 292 routine, tty->count, count, kopen_count); 293 - return (count + kopen_count); 294 293 } 295 294 #endif 296 - return 0; 297 295 } 298 296 299 297 /** ··· 843 845 * data or clears the cookie. The cookie may be something that the 844 846 * ldisc maintains state for and needs to free. 845 847 */ 846 - static int iterate_tty_read(struct tty_ldisc *ld, struct tty_struct *tty, 847 - struct file *file, struct iov_iter *to) 848 + static ssize_t iterate_tty_read(struct tty_ldisc *ld, struct tty_struct *tty, 849 + struct file *file, struct iov_iter *to) 848 850 { 849 - int retval = 0; 850 851 void *cookie = NULL; 851 852 unsigned long offset = 0; 852 853 char kernel_buf[64]; 853 - size_t count = iov_iter_count(to); 854 + ssize_t retval = 0; 855 + size_t copied, count = iov_iter_count(to); 854 856 855 857 do { 856 - int size, copied; 858 + ssize_t size = min(count, sizeof(kernel_buf)); 857 859 858 - size = count > sizeof(kernel_buf) ? sizeof(kernel_buf) : count; 859 860 size = ld->ops->read(tty, file, kernel_buf, size, &cookie, offset); 860 861 if (!size) 861 862 break; ··· 911 914 */ 912 915 static ssize_t tty_read(struct kiocb *iocb, struct iov_iter *to) 913 916 { 914 - int i; 915 917 struct file *file = iocb->ki_filp; 916 918 struct inode *inode = file_inode(file); 917 919 struct tty_struct *tty = file_tty(file); 918 920 struct tty_ldisc *ld; 921 + ssize_t ret; 919 922 920 923 if (tty_paranoia_check(tty, inode, "tty_read")) 921 924 return -EIO; ··· 928 931 ld = tty_ldisc_ref_wait(tty); 929 932 if (!ld) 930 933 return hung_up_tty_read(iocb, to); 931 - i = -EIO; 934 + ret = -EIO; 932 935 if (ld->ops->read) 933 - i = iterate_tty_read(ld, tty, file, to); 936 + ret = iterate_tty_read(ld, tty, file, to); 934 937 tty_ldisc_deref(ld); 935 938 936 - if (i > 0) 939 + if (ret > 0) 937 940 tty_update_time(tty, false); 938 941 939 - return i; 942 + return ret; 940 943 } 941 944 942 945 void tty_write_unlock(struct tty_struct *tty) ··· 945 948 wake_up_interruptible_poll(&tty->write_wait, EPOLLOUT); 946 949 } 947 950 948 - int tty_write_lock(struct tty_struct *tty, int ndelay) 951 + int tty_write_lock(struct tty_struct *tty, bool ndelay) 949 952 { 950 953 if (!mutex_trylock(&tty->atomic_write_lock)) { 951 954 if (ndelay) ··· 960 963 * Split writes up in sane blocksizes to avoid 961 964 * denial-of-service type attacks 962 965 */ 963 - static inline ssize_t do_tty_write( 964 - ssize_t (*write)(struct tty_struct *, struct file *, const unsigned char *, size_t), 965 - struct tty_struct *tty, 966 - struct file *file, 967 - struct iov_iter *from) 966 + static ssize_t iterate_tty_write(struct tty_ldisc *ld, struct tty_struct *tty, 967 + struct file *file, struct iov_iter *from) 968 968 { 969 - size_t count = iov_iter_count(from); 969 + size_t chunk, count = iov_iter_count(from); 970 970 ssize_t ret, written = 0; 971 - unsigned int chunk; 972 971 973 972 ret = tty_write_lock(tty, file->f_flags & O_NDELAY); 974 973 if (ret < 0) ··· 1008 1015 1009 1016 /* Do the write .. */ 1010 1017 for (;;) { 1011 - size_t size = count; 1012 - 1013 - if (size > chunk) 1014 - size = chunk; 1018 + size_t size = min(chunk, count); 1015 1019 1016 1020 ret = -EFAULT; 1017 1021 if (copy_from_iter(tty->write_buf, size, from) != size) 1018 1022 break; 1019 1023 1020 - ret = write(tty, file, tty->write_buf, size); 1024 + ret = ld->ops->write(tty, file, tty->write_buf, size); 1021 1025 if (ret <= 0) 1022 1026 break; 1023 1027 ··· 1085 1095 if (!ld->ops->write) 1086 1096 ret = -EIO; 1087 1097 else 1088 - ret = do_tty_write(ld->ops->write, tty, file, from); 1098 + ret = iterate_tty_write(ld, tty, file, from); 1089 1099 tty_ldisc_deref(ld); 1090 1100 return ret; 1091 1101 } ··· 1152 1162 return 0; 1153 1163 } 1154 1164 1155 - if (tty_write_lock(tty, 0) < 0) 1165 + if (tty_write_lock(tty, false) < 0) 1156 1166 return -ERESTARTSYS; 1157 1167 1158 1168 down_read(&tty->termios_rwsem); ··· 2478 2488 retval = tty->ops->break_ctl(tty, duration); 2479 2489 else { 2480 2490 /* Do the work ourselves */ 2481 - if (tty_write_lock(tty, 0) < 0) 2491 + if (tty_write_lock(tty, false) < 0) 2482 2492 return -EINTR; 2483 2493 retval = tty->ops->break_ctl(tty, -1); 2484 2494 if (retval)
+4 -14
drivers/tty/tty_ioctl.c
··· 28 28 #include <asm/io.h> 29 29 #include <linux/uaccess.h> 30 30 31 - #undef TTY_DEBUG_WAIT_UNTIL_SENT 32 - 33 - #ifdef TTY_DEBUG_WAIT_UNTIL_SENT 34 - # define tty_debug_wait_until_sent(tty, f, args...) tty_debug(tty, f, ##args) 35 - #else 36 - # define tty_debug_wait_until_sent(tty, f, args...) do {} while (0) 37 - #endif 38 - 39 31 #undef DEBUG 40 32 41 33 /* ··· 190 198 191 199 void tty_wait_until_sent(struct tty_struct *tty, long timeout) 192 200 { 193 - tty_debug_wait_until_sent(tty, "wait until sent, timeout=%ld\n", timeout); 194 - 195 201 if (!timeout) 196 202 timeout = MAX_SCHEDULE_TIMEOUT; 197 203 ··· 497 507 if (retval < 0) 498 508 return retval; 499 509 500 - if (tty_write_lock(tty, 0) < 0) 510 + if (tty_write_lock(tty, false) < 0) 501 511 goto retry_write_wait; 502 512 503 513 /* Racing writer? */ ··· 737 747 /** 738 748 * tty_change_softcar - carrier change ioctl helper 739 749 * @tty: tty to update 740 - * @arg: enable/disable CLOCAL 750 + * @enable: enable/disable CLOCAL 741 751 * 742 752 * Perform a change to the CLOCAL state and call into the driver 743 753 * layer to make it visible. All done with the termios rwsem 744 754 */ 745 755 746 - static int tty_change_softcar(struct tty_struct *tty, int arg) 756 + static int tty_change_softcar(struct tty_struct *tty, bool enable) 747 757 { 748 758 int ret = 0; 749 - int bit = arg ? CLOCAL : 0; 750 759 struct ktermios old; 760 + tcflag_t bit = enable ? CLOCAL : 0; 751 761 752 762 down_write(&tty->termios_rwsem); 753 763 old = tty->termios;
+16 -18
drivers/tty/tty_port.c
··· 20 20 #include <linux/serdev.h> 21 21 #include "tty.h" 22 22 23 - static int tty_port_default_receive_buf(struct tty_port *port, 24 - const unsigned char *p, 25 - const unsigned char *f, size_t count) 23 + static size_t tty_port_default_receive_buf(struct tty_port *port, const u8 *p, 24 + const u8 *f, size_t count) 26 25 { 27 - int ret; 28 26 struct tty_struct *tty; 29 - struct tty_ldisc *disc; 27 + struct tty_ldisc *ld; 30 28 31 29 tty = READ_ONCE(port->itty); 32 30 if (!tty) 33 31 return 0; 34 32 35 - disc = tty_ldisc_ref(tty); 36 - if (!disc) 33 + ld = tty_ldisc_ref(tty); 34 + if (!ld) 37 35 return 0; 38 36 39 - ret = tty_ldisc_receive_buf(disc, p, (char *)f, count); 37 + count = tty_ldisc_receive_buf(ld, p, f, count); 40 38 41 - tty_ldisc_deref(disc); 39 + tty_ldisc_deref(ld); 42 40 43 - return ret; 41 + return count; 44 42 } 45 43 46 - static void tty_port_default_lookahead_buf(struct tty_port *port, const unsigned char *p, 47 - const unsigned char *f, unsigned int count) 44 + static void tty_port_default_lookahead_buf(struct tty_port *port, const u8 *p, 45 + const u8 *f, size_t count) 48 46 { 49 47 struct tty_struct *tty; 50 - struct tty_ldisc *disc; 48 + struct tty_ldisc *ld; 51 49 52 50 tty = READ_ONCE(port->itty); 53 51 if (!tty) 54 52 return; 55 53 56 - disc = tty_ldisc_ref(tty); 57 - if (!disc) 54 + ld = tty_ldisc_ref(tty); 55 + if (!ld) 58 56 return; 59 57 60 - if (disc->ops->lookahead_buf) 61 - disc->ops->lookahead_buf(disc->tty, p, f, count); 58 + if (ld->ops->lookahead_buf) 59 + ld->ops->lookahead_buf(ld->tty, p, f, count); 62 60 63 - tty_ldisc_deref(disc); 61 + tty_ldisc_deref(ld); 64 62 } 65 63 66 64 static void tty_port_default_wakeup(struct tty_port *port)
+2 -2
drivers/tty/ttynull.c
··· 29 29 tty_port_hangup(&ttynull_port); 30 30 } 31 31 32 - static int ttynull_write(struct tty_struct *tty, const unsigned char *buf, 33 - int count) 32 + static ssize_t ttynull_write(struct tty_struct *tty, const u8 *buf, 33 + size_t count) 34 34 { 35 35 return count; 36 36 }
+9 -9
drivers/tty/vcc.c
··· 36 36 * and guarantee that any characters that the driver accepts will 37 37 * be eventually sent, either immediately or later. 38 38 */ 39 - int chars_in_buffer; 39 + size_t chars_in_buffer; 40 40 struct vio_vcc buffer; 41 41 42 42 struct timer_list rx_timer; ··· 385 385 struct vcc_port *port = from_timer(port, t, tx_timer); 386 386 struct vio_vcc *pkt; 387 387 unsigned long flags; 388 - int tosend = 0; 388 + size_t tosend = 0; 389 389 int rv; 390 390 391 391 spin_lock_irqsave(&port->lock, flags); ··· 804 804 tty_port_hangup(tty->port); 805 805 } 806 806 807 - static int vcc_write(struct tty_struct *tty, const unsigned char *buf, 808 - int count) 807 + static ssize_t vcc_write(struct tty_struct *tty, const u8 *buf, size_t count) 809 808 { 810 809 struct vcc_port *port; 811 810 struct vio_vcc *pkt; 812 811 unsigned long flags; 813 - int total_sent = 0; 814 - int tosend = 0; 812 + size_t total_sent = 0; 813 + size_t tosend = 0; 815 814 int rv = -EINVAL; 816 815 817 816 port = vcc_get_ne(tty->index); ··· 826 827 827 828 while (count > 0) { 828 829 /* Minimum of data to write and space available */ 829 - tosend = min(count, (VCC_BUFF_LEN - port->chars_in_buffer)); 830 + tosend = min_t(size_t, count, 831 + (VCC_BUFF_LEN - port->chars_in_buffer)); 830 832 831 833 if (!tosend) 832 834 break; ··· 847 847 * hypervisor actually took it because we have it buffered. 848 848 */ 849 849 rv = ldc_write(port->vio.lp, pkt, (VIO_TAG_SIZE + tosend)); 850 - vccdbg("VCC: write: ldc_write(%d)=%d\n", 850 + vccdbg("VCC: write: ldc_write(%zu)=%d\n", 851 851 (VIO_TAG_SIZE + tosend), rv); 852 852 853 853 total_sent += tosend; ··· 864 864 865 865 vcc_put(port, false); 866 866 867 - vccdbg("VCC: write: total=%d rv=%d", total_sent, rv); 867 + vccdbg("VCC: write: total=%zu rv=%d", total_sent, rv); 868 868 869 869 return total_sent ? total_sent : rv; 870 870 }
+1 -1
drivers/tty/vt/selection.c
··· 376 376 { 377 377 struct vc_data *vc = tty->driver_data; 378 378 int pasted = 0; 379 - unsigned int count; 379 + size_t count; 380 380 struct tty_ldisc *ld; 381 381 DECLARE_WAITQUEUE(wait, current); 382 382 int ret = 0;
+7 -15
drivers/tty/vt/vt.c
··· 140 140 static const struct consw *con_driver_map[MAX_NR_CONSOLES]; 141 141 142 142 static int con_open(struct tty_struct *, struct file *); 143 - static void vc_init(struct vc_data *vc, unsigned int rows, 144 - unsigned int cols, int do_clear); 143 + static void vc_init(struct vc_data *vc, int do_clear); 145 144 static void gotoxy(struct vc_data *vc, int new_x, int new_y); 146 145 static void save_cur(struct vc_data *vc); 147 146 static void reset_terminal(struct vc_data *vc, int do_clear); ··· 1102 1103 if (global_cursor_default == -1) 1103 1104 global_cursor_default = 1; 1104 1105 1105 - vc_init(vc, vc->vc_rows, vc->vc_cols, 1); 1106 + vc_init(vc, 1); 1106 1107 vcs_make_sysfs(currcons); 1107 1108 atomic_notifier_call_chain(&vt_notifier_list, VT_ALLOCATE, &param); 1108 1109 ··· 2845 2846 } 2846 2847 2847 2848 /* acquires console_lock */ 2848 - static int do_con_write(struct tty_struct *tty, const unsigned char *buf, int count) 2849 + static int do_con_write(struct tty_struct *tty, const u8 *buf, int count) 2849 2850 { 2850 2851 struct vc_draw_region draw = { 2851 2852 .x = -1, ··· 3238 3239 * /dev/ttyN handling 3239 3240 */ 3240 3241 3241 - static int con_write(struct tty_struct *tty, const unsigned char *buf, int count) 3242 + static ssize_t con_write(struct tty_struct *tty, const u8 *buf, size_t count) 3242 3243 { 3243 3244 int retval; 3244 3245 ··· 3248 3249 return retval; 3249 3250 } 3250 3251 3251 - static int con_put_char(struct tty_struct *tty, unsigned char ch) 3252 + static int con_put_char(struct tty_struct *tty, u8 ch) 3252 3253 { 3253 3254 return do_con_write(tty, &ch, 1); 3254 3255 } ··· 3397 3398 module_param_named(italic, default_italic_color, int, S_IRUGO | S_IWUSR); 3398 3399 module_param_named(underline, default_underline_color, int, S_IRUGO | S_IWUSR); 3399 3400 3400 - static void vc_init(struct vc_data *vc, unsigned int rows, 3401 - unsigned int cols, int do_clear) 3401 + static void vc_init(struct vc_data *vc, int do_clear) 3402 3402 { 3403 3403 int j, k ; 3404 - 3405 - vc->vc_cols = cols; 3406 - vc->vc_rows = rows; 3407 - vc->vc_size_row = cols << 1; 3408 - vc->vc_screenbuf_size = vc->vc_rows * vc->vc_size_row; 3409 3404 3410 3405 set_origin(vc); 3411 3406 vc->vc_pos = vc->vc_origin; ··· 3468 3475 visual_init(vc, currcons, 1); 3469 3476 /* Assuming vc->vc_{cols,rows,screenbuf_size} are sane here. */ 3470 3477 vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_NOWAIT); 3471 - vc_init(vc, vc->vc_rows, vc->vc_cols, 3472 - currcons || !vc->vc_sw->con_save_screen); 3478 + vc_init(vc, currcons || !vc->vc_sw->con_save_screen); 3473 3479 } 3474 3480 currcons = fg_console = 0; 3475 3481 master_display_fg = vc = vc_cons[currcons].d;
+4 -4
drivers/usb/class/cdc-acm.c
··· 800 800 tty_port_close(&acm->port, tty, filp); 801 801 } 802 802 803 - static int acm_tty_write(struct tty_struct *tty, 804 - const unsigned char *buf, int count) 803 + static ssize_t acm_tty_write(struct tty_struct *tty, const u8 *buf, 804 + size_t count) 805 805 { 806 806 struct acm *acm = tty->driver_data; 807 807 int stat; ··· 812 812 if (!count) 813 813 return 0; 814 814 815 - dev_vdbg(&acm->data->dev, "%d bytes from tty layer\n", count); 815 + dev_vdbg(&acm->data->dev, "%zu bytes from tty layer\n", count); 816 816 817 817 spin_lock_irqsave(&acm->write_lock, flags); 818 818 wbn = acm_wb_alloc(acm); ··· 829 829 } 830 830 831 831 count = (count > acm->writesize) ? acm->writesize : count; 832 - dev_vdbg(&acm->data->dev, "writing %d bytes\n", count); 832 + dev_vdbg(&acm->data->dev, "writing %zu bytes\n", count); 833 833 memcpy(wb->buf, buf, count); 834 834 wb->len = count; 835 835
+3 -3
drivers/usb/gadget/function/u_serial.c
··· 734 734 spin_unlock_irq(&port->port_lock); 735 735 } 736 736 737 - static int gs_write(struct tty_struct *tty, const unsigned char *buf, int count) 737 + static ssize_t gs_write(struct tty_struct *tty, const u8 *buf, size_t count) 738 738 { 739 739 struct gs_port *port = tty->driver_data; 740 740 unsigned long flags; 741 741 742 - pr_vdebug("gs_write: ttyGS%d (%p) writing %d bytes\n", 742 + pr_vdebug("gs_write: ttyGS%d (%p) writing %zu bytes\n", 743 743 port->port_num, tty, count); 744 744 745 745 spin_lock_irqsave(&port->port_lock, flags); ··· 753 753 return count; 754 754 } 755 755 756 - static int gs_put_char(struct tty_struct *tty, unsigned char ch) 756 + static int gs_put_char(struct tty_struct *tty, u8 ch) 757 757 { 758 758 struct gs_port *port = tty->driver_data; 759 759 unsigned long flags;
+3 -4
drivers/usb/host/xhci-dbgtty.c
··· 208 208 tty_port_close(&port->port, tty, file); 209 209 } 210 210 211 - static int dbc_tty_write(struct tty_struct *tty, 212 - const unsigned char *buf, 213 - int count) 211 + static ssize_t dbc_tty_write(struct tty_struct *tty, const u8 *buf, 212 + size_t count) 214 213 { 215 214 struct dbc_port *port = tty->driver_data; 216 215 unsigned long flags; ··· 223 224 return count; 224 225 } 225 226 226 - static int dbc_tty_put_char(struct tty_struct *tty, unsigned char ch) 227 + static int dbc_tty_put_char(struct tty_struct *tty, u8 ch) 227 228 { 228 229 struct dbc_port *port = tty->driver_data; 229 230 unsigned long flags;
+2 -3
drivers/usb/serial/usb-serial.c
··· 361 361 module_put(owner); 362 362 } 363 363 364 - static int serial_write(struct tty_struct *tty, const unsigned char *buf, 365 - int count) 364 + static ssize_t serial_write(struct tty_struct *tty, const u8 *buf, size_t count) 366 365 { 367 366 struct usb_serial_port *port = tty->driver_data; 368 367 int retval = -ENODEV; ··· 369 370 if (port->serial->dev->state == USB_STATE_NOTATTACHED) 370 371 goto exit; 371 372 372 - dev_dbg(&port->dev, "%s - %d byte(s)\n", __func__, count); 373 + dev_dbg(&port->dev, "%s - %zu byte(s)\n", __func__, count); 373 374 374 375 retval = port->serial->type->write(tty, port, buf, count); 375 376 if (retval < 0)
-71
include/linux/fs_uart_pd.h
··· 1 - /* 2 - * Platform information definitions for the CPM Uart driver. 3 - * 4 - * 2006 (c) MontaVista Software, Inc. 5 - * Vitaly Bordug <vbordug@ru.mvista.com> 6 - * 7 - * This file is licensed under the terms of the GNU General Public License 8 - * version 2. This program is licensed "as is" without any warranty of any 9 - * kind, whether express or implied. 10 - */ 11 - 12 - #ifndef FS_UART_PD_H 13 - #define FS_UART_PD_H 14 - 15 - #include <asm/types.h> 16 - 17 - enum fs_uart_id { 18 - fsid_smc1_uart, 19 - fsid_smc2_uart, 20 - fsid_scc1_uart, 21 - fsid_scc2_uart, 22 - fsid_scc3_uart, 23 - fsid_scc4_uart, 24 - fs_uart_nr, 25 - }; 26 - 27 - static inline int fs_uart_id_scc2fsid(int id) 28 - { 29 - return fsid_scc1_uart + id - 1; 30 - } 31 - 32 - static inline int fs_uart_id_fsid2scc(int id) 33 - { 34 - return id - fsid_scc1_uart + 1; 35 - } 36 - 37 - static inline int fs_uart_id_smc2fsid(int id) 38 - { 39 - return fsid_smc1_uart + id - 1; 40 - } 41 - 42 - static inline int fs_uart_id_fsid2smc(int id) 43 - { 44 - return id - fsid_smc1_uart + 1; 45 - } 46 - 47 - struct fs_uart_platform_info { 48 - void(*init_ioports)(struct fs_uart_platform_info *); 49 - /* device specific information */ 50 - int fs_no; /* controller index */ 51 - char fs_type[4]; /* controller type */ 52 - u32 uart_clk; 53 - u8 tx_num_fifo; 54 - u8 tx_buf_size; 55 - u8 rx_num_fifo; 56 - u8 rx_buf_size; 57 - u8 brg; 58 - u8 clk_rx; 59 - u8 clk_tx; 60 - }; 61 - 62 - static inline int fs_uart_get_id(struct fs_uart_platform_info *fpi) 63 - { 64 - if(strstr(fpi->fs_type, "SMC")) 65 - return fs_uart_id_smc2fsid(fpi->fs_no); 66 - if(strstr(fpi->fs_type, "SCC")) 67 - return fs_uart_id_scc2fsid(fpi->fs_no); 68 - return fpi->fs_no; 69 - } 70 - 71 - #endif
+4
include/linux/pci_ids.h
··· 1762 1762 #define PCI_SUBDEVICE_ID_AT_2700FX 0x2701 1763 1763 #define PCI_SUBDEVICE_ID_AT_2701FX 0x2703 1764 1764 1765 + #define PCI_VENDOR_ID_ASIX 0x125b 1766 + #define PCI_DEVICE_ID_ASIX_AX99100 0x9100 1767 + #define PCI_DEVICE_ID_ASIX_AX99100_LB 0x9110 1768 + 1765 1769 #define PCI_VENDOR_ID_ESS 0x125d 1766 1770 #define PCI_DEVICE_ID_ESS_ESS1968 0x1968 1767 1771 #define PCI_DEVICE_ID_ESS_ESS1978 0x1978
+9 -9
include/linux/serial_core.h
··· 570 570 struct serial_port_device *port_dev; /* serial core port device */ 571 571 572 572 unsigned long sysrq; /* sysrq timeout */ 573 - unsigned int sysrq_ch; /* char for sysrq */ 573 + u8 sysrq_ch; /* char for sysrq */ 574 574 unsigned char has_sysrq; 575 575 unsigned char sysrq_seq; /* index in sysrq_toggle_seq */ 576 576 ··· 904 904 void uart_handle_cts_change(struct uart_port *uport, bool active); 905 905 906 906 void uart_insert_char(struct uart_port *port, unsigned int status, 907 - unsigned int overrun, unsigned int ch, unsigned int flag); 907 + unsigned int overrun, u8 ch, u8 flag); 908 908 909 909 void uart_xchar_out(struct uart_port *uport, int offset); 910 910 911 911 #ifdef CONFIG_MAGIC_SYSRQ_SERIAL 912 912 #define SYSRQ_TIMEOUT (HZ * 5) 913 913 914 - bool uart_try_toggle_sysrq(struct uart_port *port, unsigned int ch); 914 + bool uart_try_toggle_sysrq(struct uart_port *port, u8 ch); 915 915 916 - static inline int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch) 916 + static inline int uart_handle_sysrq_char(struct uart_port *port, u8 ch) 917 917 { 918 918 if (!port->sysrq) 919 919 return 0; ··· 932 932 return 0; 933 933 } 934 934 935 - static inline int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch) 935 + static inline int uart_prepare_sysrq_char(struct uart_port *port, u8 ch) 936 936 { 937 937 if (!port->sysrq) 938 938 return 0; ··· 953 953 954 954 static inline void uart_unlock_and_check_sysrq(struct uart_port *port) 955 955 { 956 - int sysrq_ch; 956 + u8 sysrq_ch; 957 957 958 958 if (!port->has_sysrq) { 959 959 spin_unlock(&port->lock); ··· 972 972 static inline void uart_unlock_and_check_sysrq_irqrestore(struct uart_port *port, 973 973 unsigned long flags) 974 974 { 975 - int sysrq_ch; 975 + u8 sysrq_ch; 976 976 977 977 if (!port->has_sysrq) { 978 978 spin_unlock_irqrestore(&port->lock, flags); ··· 988 988 handle_sysrq(sysrq_ch); 989 989 } 990 990 #else /* CONFIG_MAGIC_SYSRQ_SERIAL */ 991 - static inline int uart_handle_sysrq_char(struct uart_port *port, unsigned int ch) 991 + static inline int uart_handle_sysrq_char(struct uart_port *port, u8 ch) 992 992 { 993 993 return 0; 994 994 } 995 - static inline int uart_prepare_sysrq_char(struct uart_port *port, unsigned int ch) 995 + static inline int uart_prepare_sysrq_char(struct uart_port *port, u8 ch) 996 996 { 997 997 return 0; 998 998 }
+9 -9
include/linux/sysrq.h
··· 30 30 #define SYSRQ_ENABLE_RTNICE 0x0100 31 31 32 32 struct sysrq_key_op { 33 - void (* const handler)(int); 33 + void (* const handler)(u8); 34 34 const char * const help_msg; 35 35 const char * const action_msg; 36 36 const int enable_mask; ··· 43 43 * are available -- else NULL's). 44 44 */ 45 45 46 - void handle_sysrq(int key); 47 - void __handle_sysrq(int key, bool check_mask); 48 - int register_sysrq_key(int key, const struct sysrq_key_op *op); 49 - int unregister_sysrq_key(int key, const struct sysrq_key_op *op); 46 + void handle_sysrq(u8 key); 47 + void __handle_sysrq(u8 key, bool check_mask); 48 + int register_sysrq_key(u8 key, const struct sysrq_key_op *op); 49 + int unregister_sysrq_key(u8 key, const struct sysrq_key_op *op); 50 50 extern const struct sysrq_key_op *__sysrq_reboot_op; 51 51 52 52 int sysrq_toggle_support(int enable_mask); ··· 54 54 55 55 #else 56 56 57 - static inline void handle_sysrq(int key) 57 + static inline void handle_sysrq(u8 key) 58 58 { 59 59 } 60 60 61 - static inline void __handle_sysrq(int key, bool check_mask) 61 + static inline void __handle_sysrq(u8 key, bool check_mask) 62 62 { 63 63 } 64 64 65 - static inline int register_sysrq_key(int key, const struct sysrq_key_op *op) 65 + static inline int register_sysrq_key(u8 key, const struct sysrq_key_op *op) 66 66 { 67 67 return -EINVAL; 68 68 } 69 69 70 - static inline int unregister_sysrq_key(int key, const struct sysrq_key_op *op) 70 + static inline int unregister_sysrq_key(u8 key, const struct sysrq_key_op *op) 71 71 { 72 72 return -EINVAL; 73 73 }
+9 -9
include/linux/tty.h
··· 192 192 */ 193 193 struct tty_struct { 194 194 struct kref kref; 195 + int index; 195 196 struct device *dev; 196 197 struct tty_driver *driver; 198 + struct tty_port *port; 197 199 const struct tty_operations *ops; 198 - int index; 199 200 200 - struct ld_semaphore ldisc_sem; 201 201 struct tty_ldisc *ldisc; 202 + struct ld_semaphore ldisc_sem; 202 203 203 204 struct mutex atomic_write_lock; 204 205 struct mutex legacy_mutex; ··· 210 209 char name[64]; 211 210 unsigned long flags; 212 211 int count; 212 + unsigned int receive_room; 213 213 struct winsize winsize; 214 214 215 215 struct { ··· 221 219 } __aligned(sizeof(unsigned long)) flow; 222 220 223 221 struct { 224 - spinlock_t lock; 225 222 struct pid *pgrp; 226 223 struct pid *session; 224 + spinlock_t lock; 227 225 unsigned char pktstatus; 228 226 bool packet; 229 227 unsigned long unused[0]; 230 228 } __aligned(sizeof(unsigned long)) ctrl; 231 229 232 230 bool hw_stopped; 233 - unsigned int receive_room; 231 + bool closing; 234 232 int flow_change; 235 233 236 234 struct tty_struct *link; ··· 241 239 void *disc_data; 242 240 void *driver_data; 243 241 spinlock_t files_lock; 242 + int write_cnt; 243 + unsigned char *write_buf; 244 + 244 245 struct list_head tty_files; 245 246 246 247 #define N_TTY_BUF_SIZE 4096 247 - 248 - int closing; 249 - unsigned char *write_buf; 250 - int write_cnt; 251 248 struct work_struct SAK_work; 252 - struct tty_port *port; 253 249 } __randomize_layout; 254 250 255 251 /* Each of a tty's open files has private_data pointing to tty_file_private */
+10 -10
include/linux/tty_buffer.h
··· 12 12 struct tty_buffer *next; 13 13 struct llist_node free; 14 14 }; 15 - int used; 16 - int size; 17 - int commit; 18 - int lookahead; /* Lazy update on recv, can become less than "read" */ 19 - int read; 15 + unsigned int used; 16 + unsigned int size; 17 + unsigned int commit; 18 + unsigned int lookahead; /* Lazy update on recv, can become less than "read" */ 19 + unsigned int read; 20 20 bool flags; 21 21 /* Data points here */ 22 - unsigned long data[]; 22 + u8 data[] __aligned(sizeof(unsigned long)); 23 23 }; 24 24 25 - static inline unsigned char *char_buf_ptr(struct tty_buffer *b, int ofs) 25 + static inline u8 *char_buf_ptr(struct tty_buffer *b, unsigned int ofs) 26 26 { 27 - return ((unsigned char *)b->data) + ofs; 27 + return b->data + ofs; 28 28 } 29 29 30 - static inline char *flag_buf_ptr(struct tty_buffer *b, int ofs) 30 + static inline u8 *flag_buf_ptr(struct tty_buffer *b, unsigned int ofs) 31 31 { 32 - return (char *)char_buf_ptr(b, ofs) + b->size; 32 + return char_buf_ptr(b, ofs) + b->size; 33 33 } 34 34 35 35 struct tty_bufhead {
+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: ``int ()(struct tty_struct *tty, const unsigned char *buf, 76 - * int count)`` 75 + * @write: ``ssize_t ()(struct tty_struct *tty, const unsigned char *buf, 76 + * size_t count)`` 77 77 * 78 78 * This routine is called by the kernel to write a series (@count) of 79 79 * characters (@buf) to the @tty device. The characters may come from ··· 356 356 void (*close)(struct tty_struct * tty, struct file * filp); 357 357 void (*shutdown)(struct tty_struct *tty); 358 358 void (*cleanup)(struct tty_struct *tty); 359 - int (*write)(struct tty_struct * tty, 360 - const unsigned char *buf, int count); 361 - int (*put_char)(struct tty_struct *tty, unsigned char ch); 359 + ssize_t (*write)(struct tty_struct *tty, const u8 *buf, size_t count); 360 + int (*put_char)(struct tty_struct *tty, u8 ch); 362 361 void (*flush_chars)(struct tty_struct *tty); 363 362 unsigned int (*write_room)(struct tty_struct *tty); 364 363 unsigned int (*chars_in_buffer)(struct tty_struct *tty);
+56 -14
include/linux/tty_flip.h
··· 10 10 int tty_buffer_set_limit(struct tty_port *port, int limit); 11 11 unsigned int tty_buffer_space_avail(struct tty_port *port); 12 12 int tty_buffer_request_room(struct tty_port *port, size_t size); 13 - int tty_insert_flip_string_flags(struct tty_port *port, 14 - const unsigned char *chars, const char *flags, size_t size); 15 - int tty_insert_flip_string_fixed_flag(struct tty_port *port, 16 - const unsigned char *chars, char flag, size_t size); 17 - int tty_prepare_flip_string(struct tty_port *port, unsigned char **chars, 18 - size_t size); 13 + size_t __tty_insert_flip_string_flags(struct tty_port *port, const u8 *chars, 14 + const u8 *flags, bool mutable_flags, 15 + size_t size); 16 + size_t tty_prepare_flip_string(struct tty_port *port, u8 **chars, size_t size); 19 17 void tty_flip_buffer_push(struct tty_port *port); 20 - int __tty_insert_flip_char(struct tty_port *port, unsigned char ch, char flag); 21 18 22 - static inline int tty_insert_flip_char(struct tty_port *port, 23 - unsigned char ch, char flag) 19 + /** 20 + * tty_insert_flip_string_fixed_flag - add characters to the tty buffer 21 + * @port: tty port 22 + * @chars: characters 23 + * @flag: flag value for each character 24 + * @size: size 25 + * 26 + * Queue a series of bytes to the tty buffering. All the characters passed are 27 + * marked with the supplied flag. 28 + * 29 + * Returns: the number added. 30 + */ 31 + static inline size_t tty_insert_flip_string_fixed_flag(struct tty_port *port, 32 + const u8 *chars, u8 flag, 33 + size_t size) 34 + { 35 + return __tty_insert_flip_string_flags(port, chars, &flag, false, size); 36 + } 37 + 38 + /** 39 + * tty_insert_flip_string_flags - add characters to the tty buffer 40 + * @port: tty port 41 + * @chars: characters 42 + * @flags: flag bytes 43 + * @size: size 44 + * 45 + * Queue a series of bytes to the tty buffering. For each character the flags 46 + * array indicates the status of the character. 47 + * 48 + * Returns: the number added. 49 + */ 50 + static inline size_t tty_insert_flip_string_flags(struct tty_port *port, 51 + const u8 *chars, 52 + const u8 *flags, size_t size) 53 + { 54 + return __tty_insert_flip_string_flags(port, chars, flags, true, size); 55 + } 56 + 57 + /** 58 + * tty_insert_flip_char - add one character to the tty buffer 59 + * @port: tty port 60 + * @ch: character 61 + * @flag: flag byte 62 + * 63 + * Queue a single byte @ch to the tty buffering, with an optional flag. 64 + */ 65 + static inline size_t tty_insert_flip_char(struct tty_port *port, u8 ch, u8 flag) 24 66 { 25 67 struct tty_buffer *tb = port->buf.tail; 26 68 int change; ··· 74 32 *char_buf_ptr(tb, tb->used++) = ch; 75 33 return 1; 76 34 } 77 - return __tty_insert_flip_char(port, ch, flag); 35 + return __tty_insert_flip_string_flags(port, &ch, &flag, false, 1); 78 36 } 79 37 80 - static inline int tty_insert_flip_string(struct tty_port *port, 81 - const unsigned char *chars, size_t size) 38 + static inline size_t tty_insert_flip_string(struct tty_port *port, 39 + const u8 *chars, size_t size) 82 40 { 83 41 return tty_insert_flip_string_fixed_flag(port, chars, TTY_NORMAL, size); 84 42 } 85 43 86 - int tty_ldisc_receive_buf(struct tty_ldisc *ld, const unsigned char *p, 87 - const char *f, int count); 44 + size_t tty_ldisc_receive_buf(struct tty_ldisc *ld, const u8 *p, const u8 *f, 45 + size_t count); 88 46 89 47 void tty_buffer_lock_exclusive(struct tty_port *port); 90 48 void tty_buffer_unlock_exclusive(struct tty_port *port);
+43 -24
include/linux/tty_ldisc.h
··· 71 71 * call to @receive_buf(). Returning an error will prevent the ldisc from 72 72 * being attached. 73 73 * 74 - * Can sleep. 74 + * Optional. Can sleep. 75 75 * 76 76 * @close: [TTY] ``void ()(struct tty_struct *tty)`` 77 77 * ··· 80 80 * changed to use a new line discipline. At the point of execution no 81 81 * further users will enter the ldisc code for this tty. 82 82 * 83 - * Can sleep. 83 + * Optional. Can sleep. 84 84 * 85 85 * @flush_buffer: [TTY] ``void ()(struct tty_struct *tty)`` 86 86 * ··· 88 88 * input characters it may have queued to be delivered to the user mode 89 89 * process. It may be called at any point between open and close. 90 90 * 91 - * @read: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file, 92 - * unsigned char *buf, size_t nr)`` 91 + * Optional. 92 + * 93 + * @read: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file, u8 *buf, 94 + * size_t nr)`` 93 95 * 94 96 * This function is called when the user requests to read from the @tty. 95 97 * The line discipline will return whatever characters it has buffered up ··· 99 97 * an %EIO error. Multiple read calls may occur in parallel and the ldisc 100 98 * must deal with serialization issues. 101 99 * 102 - * Can sleep. 100 + * Optional: %EIO unless provided. Can sleep. 103 101 * 104 102 * @write: [TTY] ``ssize_t ()(struct tty_struct *tty, struct file *file, 105 - * const unsigned char *buf, size_t nr)`` 103 + * const u8 *buf, size_t nr)`` 106 104 * 107 105 * This function is called when the user requests to write to the @tty. 108 106 * The line discipline will deliver the characters to the low-level tty ··· 110 108 * characters first. If this function is not defined, the user will 111 109 * receive an %EIO error. 112 110 * 113 - * Can sleep. 111 + * Optional: %EIO unless provided. Can sleep. 114 112 * 115 113 * @ioctl: [TTY] ``int ()(struct tty_struct *tty, unsigned int cmd, 116 114 * unsigned long arg)`` ··· 122 120 * discpline. So a low-level driver can "grab" an ioctl request before 123 121 * the line discpline has a chance to see it. 124 122 * 123 + * Optional. 124 + * 125 125 * @compat_ioctl: [TTY] ``int ()(struct tty_struct *tty, unsigned int cmd, 126 126 * unsigned long arg)`` 127 127 * ··· 134 130 * a pointer to wordsize-sensitive structure belongs here, but most of 135 131 * ldiscs will happily leave it %NULL. 136 132 * 133 + * Optional. 134 + * 137 135 * @set_termios: [TTY] ``void ()(struct tty_struct *tty, const struct ktermios *old)`` 138 136 * 139 137 * This function notifies the line discpline that a change has been made 140 138 * to the termios structure. 139 + * 140 + * Optional. 141 141 * 142 142 * @poll: [TTY] ``int ()(struct tty_struct *tty, struct file *file, 143 143 * struct poll_table_struct *wait)`` ··· 150 142 * device. It is solely the responsibility of the line discipline to 151 143 * handle poll requests. 152 144 * 145 + * Optional. 146 + * 153 147 * @hangup: [TTY] ``void ()(struct tty_struct *tty)`` 154 148 * 155 149 * Called on a hangup. Tells the discipline that it should cease I/O to ··· 159 149 * but should wait until any pending driver I/O is completed. No further 160 150 * calls into the ldisc code will occur. 161 151 * 162 - * Can sleep. 152 + * Optional. Can sleep. 163 153 * 164 - * @receive_buf: [DRV] ``void ()(struct tty_struct *tty, 165 - * const unsigned char *cp, const char *fp, int count)`` 154 + * @receive_buf: [DRV] ``void ()(struct tty_struct *tty, const u8 *cp, 155 + * const u8 *fp, size_t count)`` 166 156 * 167 157 * This function is called by the low-level tty driver to send characters 168 158 * received by the hardware to the line discpline for processing. @cp is ··· 170 160 * is a pointer to an array of flag bytes which indicate whether a 171 161 * character was received with a parity error, etc. @fp may be %NULL to 172 162 * indicate all data received is %TTY_NORMAL. 163 + * 164 + * Optional. 173 165 * 174 166 * @write_wakeup: [DRV] ``void ()(struct tty_struct *tty)`` 175 167 * ··· 182 170 * send, please arise a tasklet or workqueue to do the real data transfer. 183 171 * Do not send data in this hook, it may lead to a deadlock. 184 172 * 173 + * Optional. 174 + * 185 175 * @dcd_change: [DRV] ``void ()(struct tty_struct *tty, bool active)`` 186 176 * 187 177 * Tells the discipline that the DCD pin has changed its status. Used 188 178 * exclusively by the %N_PPS (Pulse-Per-Second) line discipline. 189 179 * 190 - * @receive_buf2: [DRV] ``int ()(struct tty_struct *tty, 191 - * const unsigned char *cp, const char *fp, int count)`` 180 + * Optional. 181 + * 182 + * @receive_buf2: [DRV] ``ssize_t ()(struct tty_struct *tty, const u8 *cp, 183 + * const u8 *fp, size_t count)`` 192 184 * 193 185 * This function is called by the low-level tty driver to send characters 194 186 * received by the hardware to the line discpline for processing. @cp is a ··· 202 186 * indicate all data received is %TTY_NORMAL. If assigned, prefer this 203 187 * function for automatic flow control. 204 188 * 205 - * @lookahead_buf: [DRV] ``void ()(struct tty_struct *tty, 206 - * const unsigned char *cp, const char *fp, int count)`` 189 + * Optional. 190 + * 191 + * @lookahead_buf: [DRV] ``void ()(struct tty_struct *tty, const u8 *cp, 192 + * const u8 *fp, size_t count)`` 207 193 * 208 194 * This function is called by the low-level tty driver for characters 209 195 * not eaten by ->receive_buf() or ->receive_buf2(). It is useful for ··· 215 197 * handle later a ->receive_buf() or ->receive_buf2() call for the 216 198 * same characters (e.g. by skipping the actions for high-priority 217 199 * characters already handled by ->lookahead_buf()). 200 + * 201 + * Optional. 218 202 * 219 203 * @owner: module containting this ldisc (for reference counting) 220 204 * ··· 238 218 int (*open)(struct tty_struct *tty); 239 219 void (*close)(struct tty_struct *tty); 240 220 void (*flush_buffer)(struct tty_struct *tty); 241 - ssize_t (*read)(struct tty_struct *tty, struct file *file, 242 - unsigned char *buf, size_t nr, 243 - void **cookie, unsigned long offset); 221 + ssize_t (*read)(struct tty_struct *tty, struct file *file, u8 *buf, 222 + size_t nr, void **cookie, unsigned long offset); 244 223 ssize_t (*write)(struct tty_struct *tty, struct file *file, 245 - const unsigned char *buf, size_t nr); 224 + const u8 *buf, size_t nr); 246 225 int (*ioctl)(struct tty_struct *tty, unsigned int cmd, 247 226 unsigned long arg); 248 227 int (*compat_ioctl)(struct tty_struct *tty, unsigned int cmd, ··· 254 235 /* 255 236 * The following routines are called from below. 256 237 */ 257 - void (*receive_buf)(struct tty_struct *tty, const unsigned char *cp, 258 - const char *fp, int count); 238 + void (*receive_buf)(struct tty_struct *tty, const u8 *cp, 239 + const u8 *fp, size_t count); 259 240 void (*write_wakeup)(struct tty_struct *tty); 260 241 void (*dcd_change)(struct tty_struct *tty, bool active); 261 - int (*receive_buf2)(struct tty_struct *tty, const unsigned char *cp, 262 - const char *fp, int count); 263 - void (*lookahead_buf)(struct tty_struct *tty, const unsigned char *cp, 264 - const unsigned char *fp, unsigned int count); 242 + size_t (*receive_buf2)(struct tty_struct *tty, const u8 *cp, 243 + const u8 *fp, size_t count); 244 + void (*lookahead_buf)(struct tty_struct *tty, const u8 *cp, 245 + const u8 *fp, size_t count); 265 246 266 247 struct module *owner; 267 248 };
+4 -3
include/linux/tty_port.h
··· 39 39 }; 40 40 41 41 struct tty_port_client_operations { 42 - int (*receive_buf)(struct tty_port *port, const unsigned char *, const unsigned char *, size_t); 43 - void (*lookahead_buf)(struct tty_port *port, const unsigned char *cp, 44 - const unsigned char *fp, unsigned int count); 42 + size_t (*receive_buf)(struct tty_port *port, const u8 *cp, const u8 *fp, 43 + size_t count); 44 + void (*lookahead_buf)(struct tty_port *port, const u8 *cp, 45 + const u8 *fp, size_t count); 45 46 void (*write_wakeup)(struct tty_port *port); 46 47 }; 47 48
+99 -19
include/uapi/linux/gsmmux.h
··· 2 2 #ifndef _LINUX_GSMMUX_H 3 3 #define _LINUX_GSMMUX_H 4 4 5 + #include <linux/const.h> 5 6 #include <linux/if.h> 6 7 #include <linux/ioctl.h> 7 8 #include <linux/types.h> 8 9 10 + /* 11 + * flags definition for n_gsm 12 + * 13 + * Used by: 14 + * struct gsm_config_ext.flags 15 + * struct gsm_dlci_config.flags 16 + */ 17 + /* Forces a DLCI reset if set. Otherwise, a DLCI reset is only done if 18 + * incompatible settings were provided. Always cleared on retrieval. 19 + */ 20 + #define GSM_FL_RESTART _BITUL(0) 21 + 22 + /** 23 + * struct gsm_config - n_gsm basic configuration parameters 24 + * 25 + * This structure is used in combination with GSMIOC_GETCONF and GSMIOC_SETCONF 26 + * to retrieve and set the basic parameters of an n_gsm ldisc. 27 + * struct gsm_config_ext can be used to configure extended ldisc parameters. 28 + * 29 + * All timers are in units of 1/100th of a second. 30 + * 31 + * @adaption: Convergence layer type 32 + * @encapsulation: Framing (0 = basic option, 1 = advanced option) 33 + * @initiator: Initiator or responder 34 + * @t1: Acknowledgment timer 35 + * @t2: Response timer for multiplexer control channel 36 + * @t3: Response timer for wake-up procedure 37 + * @n2: Maximum number of retransmissions 38 + * @mru: Maximum incoming frame payload size 39 + * @mtu: Maximum outgoing frame payload size 40 + * @k: Window size 41 + * @i: Frame type (1 = UIH, 2 = UI) 42 + * @unused: Can not be used 43 + */ 9 44 struct gsm_config 10 45 { 11 46 unsigned int adaption; ··· 54 19 unsigned int mtu; 55 20 unsigned int k; 56 21 unsigned int i; 57 - unsigned int unused[8]; /* Can not be used */ 22 + unsigned int unused[8]; 58 23 }; 59 24 60 25 #define GSMIOC_GETCONF _IOR('G', 0, struct gsm_config) 61 26 #define GSMIOC_SETCONF _IOW('G', 1, struct gsm_config) 62 27 28 + /** 29 + * struct gsm_netconfig - n_gsm network configuration parameters 30 + * 31 + * This structure is used in combination with GSMIOC_ENABLE_NET and 32 + * GSMIOC_DISABLE_NET to enable or disable a network data connection 33 + * over a mux virtual tty channel. This is for modems that support 34 + * data connections with raw IP frames instead of PPP. 35 + * 36 + * @adaption: Adaption to use in network mode. 37 + * @protocol: Protocol to use - only ETH_P_IP supported. 38 + * @unused2: Can not be used. 39 + * @if_name: Interface name format string. 40 + * @unused: Can not be used. 41 + */ 63 42 struct gsm_netconfig { 64 - unsigned int adaption; /* Adaption to use in network mode */ 65 - unsigned short protocol;/* Protocol to use - only ETH_P_IP supported */ 66 - unsigned short unused2; /* Can not be used */ 67 - char if_name[IFNAMSIZ]; /* interface name format string */ 68 - __u8 unused[28]; /* Can not be used */ 43 + unsigned int adaption; 44 + unsigned short protocol; 45 + unsigned short unused2; 46 + char if_name[IFNAMSIZ]; 47 + __u8 unused[28]; 69 48 }; 70 49 71 50 #define GSMIOC_ENABLE_NET _IOW('G', 2, struct gsm_netconfig) ··· 88 39 /* get the base tty number for a configured gsmmux tty */ 89 40 #define GSMIOC_GETFIRST _IOR('G', 4, __u32) 90 41 42 + /** 43 + * struct gsm_config_ext - n_gsm extended configuration parameters 44 + * 45 + * This structure is used in combination with GSMIOC_GETCONF_EXT and 46 + * GSMIOC_SETCONF_EXT to retrieve and set the extended parameters of an 47 + * n_gsm ldisc. 48 + * 49 + * All timers are in units of 1/100th of a second. 50 + * 51 + * @keep_alive: Control channel keep-alive in 1/100th of a second (0 to disable). 52 + * @wait_config: Wait for DLCI config before opening virtual link? 53 + * @flags: Mux specific flags. 54 + * @reserved: For future use, must be initialized to zero. 55 + */ 91 56 struct gsm_config_ext { 92 - __u32 keep_alive; /* Control channel keep-alive in 1/100th of a 93 - * second (0 to disable) 94 - */ 95 - __u32 wait_config; /* Wait for DLCI config before opening virtual link? */ 96 - __u32 reserved[6]; /* For future use, must be initialized to zero */ 57 + __u32 keep_alive; 58 + __u32 wait_config; 59 + __u32 flags; 60 + __u32 reserved[5]; 97 61 }; 98 62 99 63 #define GSMIOC_GETCONF_EXT _IOR('G', 5, struct gsm_config_ext) 100 64 #define GSMIOC_SETCONF_EXT _IOW('G', 6, struct gsm_config_ext) 101 65 102 - /* Set channel accordingly before calling GSMIOC_GETCONF_DLCI. */ 66 + /** 67 + * struct gsm_dlci_config - n_gsm channel configuration parameters 68 + * 69 + * This structure is used in combination with GSMIOC_GETCONF_DLCI and 70 + * GSMIOC_SETCONF_DLCI to retrieve and set the channel specific parameters 71 + * of an n_gsm ldisc. 72 + * 73 + * Set the channel accordingly before calling GSMIOC_GETCONF_DLCI. 74 + * 75 + * @channel: DLCI (0 for the associated DLCI). 76 + * @adaption: Convergence layer type. 77 + * @mtu: Maximum transfer unit. 78 + * @priority: Priority (0 for default value). 79 + * @i: Frame type (1 = UIH, 2 = UI). 80 + * @k: Window size (0 for default value). 81 + * @flags: DLCI specific flags. 82 + * @reserved: For future use, must be initialized to zero. 83 + */ 103 84 struct gsm_dlci_config { 104 - __u32 channel; /* DLCI (0 for the associated DLCI) */ 105 - __u32 adaption; /* Convergence layer type */ 106 - __u32 mtu; /* Maximum transfer unit */ 107 - __u32 priority; /* Priority (0 for default value) */ 108 - __u32 i; /* Frame type (1 = UIH, 2 = UI) */ 109 - __u32 k; /* Window size (0 for default value) */ 110 - __u32 reserved[8]; /* For future use, must be initialized to zero */ 85 + __u32 channel; 86 + __u32 adaption; 87 + __u32 mtu; 88 + __u32 priority; 89 + __u32 i; 90 + __u32 k; 91 + __u32 flags; 92 + __u32 reserved[7]; 111 93 }; 112 94 113 95 #define GSMIOC_GETCONF_DLCI _IOWR('G', 7, struct gsm_dlci_config)
+5 -39
include/uapi/linux/serial_core.h
··· 25 25 26 26 /* 27 27 * The type definitions. These are from Ted Ts'o's serial.h 28 + * By historical reasons the values from 0 to 13 are defined 29 + * in the include/uapi/linux/serial.h, do not define them here. 28 30 */ 29 31 #define PORT_NS16550A 14 30 32 #define PORT_XSCALE 15 ··· 96 94 #define PORT_SCIF 53 97 95 #define PORT_IRDA 54 98 96 99 - /* Samsung S3C2410 SoC and derivatives thereof */ 100 - #define PORT_S3C2410 55 101 - 102 97 /* SGI IP22 aka Indy / Challenge S / Indigo 2 */ 103 98 #define PORT_IP22ZILOG 56 104 - 105 - /* Sharp LH7a40x -- an ARM9 SoC series */ 106 - #define PORT_LH7A40X 57 107 99 108 100 /* PPC CPM type number */ 109 101 #define PORT_CPM 58 ··· 108 112 /* IBM icom */ 109 113 #define PORT_ICOM 60 110 114 111 - /* Samsung S3C2440 SoC */ 112 - #define PORT_S3C2440 61 113 - 114 115 /* Motorola i.MX SoC */ 115 116 #define PORT_IMX 62 116 117 117 - /* Marvell MPSC (obsolete unused) */ 118 - #define PORT_MPSC 63 119 - 120 118 /* TXX9 type number */ 121 119 #define PORT_TXX9 64 122 - 123 - /* Samsung S3C2400 SoC */ 124 - #define PORT_S3C2400 67 125 - 126 - /* M32R SIO */ 127 - #define PORT_M32R_SIO 68 128 120 129 121 /*Digi jsm */ 130 122 #define PORT_JSM 69 ··· 120 136 /* SUN4V Hypervisor Console */ 121 137 #define PORT_SUNHV 72 122 138 123 - #define PORT_S3C2412 73 124 - 125 139 /* Xilinx uartlite */ 126 140 #define PORT_UARTLITE 74 127 141 128 - /* Blackfin bf5xx */ 129 - #define PORT_BFIN 75 142 + /* Broadcom BCM7271 UART */ 143 + #define PORT_BCM7271 76 130 144 131 145 /* Broadcom SB1250, etc. SOC */ 132 146 #define PORT_SB1250_DUART 77 ··· 132 150 /* Freescale ColdFire */ 133 151 #define PORT_MCF 78 134 152 135 - /* Blackfin SPORT */ 136 - #define PORT_BFIN_SPORT 79 137 - 138 - /* MN10300 on-chip UART numbers */ 139 - #define PORT_MN10300 80 140 - #define PORT_MN10300_CTS 81 141 - 142 153 #define PORT_SC26XX 82 143 154 144 155 /* SH-SCI */ 145 156 #define PORT_SCIFA 83 146 157 147 158 #define PORT_S3C6400 84 148 - 149 - /* NWPSERIAL, now removed */ 150 - #define PORT_NWPSERIAL 85 151 159 152 160 /* MAX3100 */ 153 161 #define PORT_MAX3100 86 ··· 197 225 /* ST ASC type numbers */ 198 226 #define PORT_ASC 105 199 227 200 - /* Tilera TILE-Gx UART */ 201 - #define PORT_TILEGX 106 202 - 203 228 /* MEN 16z135 UART */ 204 229 #define PORT_MEN_Z135 107 205 230 206 - /* SC16IS74xx */ 231 + /* SC16IS7xx */ 207 232 #define PORT_SC16IS7XX 108 208 233 209 234 /* MESON */ ··· 211 242 212 243 /* SPRD SERIAL */ 213 244 #define PORT_SPRD 111 214 - 215 - /* Cris v10 / v32 SoC */ 216 - #define PORT_CRIS 112 217 245 218 246 /* STM32 USART */ 219 247 #define PORT_STM32 113
+1 -1
kernel/debug/debug_core.c
··· 968 968 early_param("kgdbcon", opt_kgdb_con); 969 969 970 970 #ifdef CONFIG_MAGIC_SYSRQ 971 - static void sysrq_handle_dbg(int key) 971 + static void sysrq_handle_dbg(u8 key) 972 972 { 973 973 if (!dbg_io_ops) { 974 974 pr_crit("ERROR: No KGDB I/O module available\n");
+1 -1
kernel/power/poweroff.c
··· 23 23 24 24 static DECLARE_WORK(poweroff_work, do_poweroff); 25 25 26 - static void handle_poweroff(int key) 26 + static void handle_poweroff(u8 key) 27 27 { 28 28 /* run sysrq poweroff on boot cpu */ 29 29 schedule_work_on(cpumask_first(cpu_online_mask), &poweroff_work);
+1 -1
kernel/rcu/tree_stall.h
··· 1035 1035 module_param(sysrq_rcu, bool, 0444); 1036 1036 1037 1037 /* Dump grace-period-request information due to commandeered sysrq. */ 1038 - static void sysrq_show_rcu(int key) 1038 + static void sysrq_show_rcu(u8 key) 1039 1039 { 1040 1040 show_rcu_gp_kthreads(); 1041 1041 }
+16 -15
net/bluetooth/rfcomm/tty.c
··· 771 771 772 772 static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp) 773 773 { 774 - struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; 774 + struct rfcomm_dev *dev = tty->driver_data; 775 775 776 776 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc, 777 777 dev->port.count); ··· 779 779 tty_port_close(&dev->port, tty, filp); 780 780 } 781 781 782 - static int rfcomm_tty_write(struct tty_struct *tty, const unsigned char *buf, int count) 782 + static ssize_t rfcomm_tty_write(struct tty_struct *tty, const u8 *buf, 783 + size_t count) 783 784 { 784 - struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; 785 + struct rfcomm_dev *dev = tty->driver_data; 785 786 struct rfcomm_dlc *dlc = dev->dlc; 786 787 struct sk_buff *skb; 787 - int sent = 0, size; 788 + size_t sent = 0, size; 788 789 789 - BT_DBG("tty %p count %d", tty, count); 790 + BT_DBG("tty %p count %zu", tty, count); 790 791 791 792 while (count) { 792 - size = min_t(uint, count, dlc->mtu); 793 + size = min_t(size_t, count, dlc->mtu); 793 794 794 795 skb = rfcomm_wmalloc(dev, size + RFCOMM_SKB_RESERVE, GFP_ATOMIC); 795 796 if (!skb) ··· 811 810 812 811 static unsigned int rfcomm_tty_write_room(struct tty_struct *tty) 813 812 { 814 - struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; 813 + struct rfcomm_dev *dev = tty->driver_data; 815 814 int room = 0; 816 815 817 816 if (dev && dev->dlc) ··· 865 864 u8 baud, data_bits, stop_bits, parity, x_on, x_off; 866 865 u16 changes = 0; 867 866 868 - struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; 867 + struct rfcomm_dev *dev = tty->driver_data; 869 868 870 869 BT_DBG("tty %p termios %p", tty, old); 871 870 ··· 997 996 998 997 static void rfcomm_tty_throttle(struct tty_struct *tty) 999 998 { 1000 - struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; 999 + struct rfcomm_dev *dev = tty->driver_data; 1001 1000 1002 1001 BT_DBG("tty %p dev %p", tty, dev); 1003 1002 ··· 1006 1005 1007 1006 static void rfcomm_tty_unthrottle(struct tty_struct *tty) 1008 1007 { 1009 - struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; 1008 + struct rfcomm_dev *dev = tty->driver_data; 1010 1009 1011 1010 BT_DBG("tty %p dev %p", tty, dev); 1012 1011 ··· 1015 1014 1016 1015 static unsigned int rfcomm_tty_chars_in_buffer(struct tty_struct *tty) 1017 1016 { 1018 - struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; 1017 + struct rfcomm_dev *dev = tty->driver_data; 1019 1018 1020 1019 BT_DBG("tty %p dev %p", tty, dev); 1021 1020 ··· 1030 1029 1031 1030 static void rfcomm_tty_flush_buffer(struct tty_struct *tty) 1032 1031 { 1033 - struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; 1032 + struct rfcomm_dev *dev = tty->driver_data; 1034 1033 1035 1034 BT_DBG("tty %p dev %p", tty, dev); 1036 1035 ··· 1053 1052 1054 1053 static void rfcomm_tty_hangup(struct tty_struct *tty) 1055 1054 { 1056 - struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; 1055 + struct rfcomm_dev *dev = tty->driver_data; 1057 1056 1058 1057 BT_DBG("tty %p dev %p", tty, dev); 1059 1058 ··· 1062 1061 1063 1062 static int rfcomm_tty_tiocmget(struct tty_struct *tty) 1064 1063 { 1065 - struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; 1064 + struct rfcomm_dev *dev = tty->driver_data; 1066 1065 1067 1066 BT_DBG("tty %p dev %p", tty, dev); 1068 1067 ··· 1071 1070 1072 1071 static int rfcomm_tty_tiocmset(struct tty_struct *tty, unsigned int set, unsigned int clear) 1073 1072 { 1074 - struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data; 1073 + struct rfcomm_dev *dev = tty->driver_data; 1075 1074 struct rfcomm_dlc *dlc = dev->dlc; 1076 1075 u8 v24_sig; 1077 1076
+8 -15
net/nfc/nci/uart.c
··· 172 172 */ 173 173 static void nci_uart_tty_close(struct tty_struct *tty) 174 174 { 175 - struct nci_uart *nu = (void *)tty->disc_data; 175 + struct nci_uart *nu = tty->disc_data; 176 176 177 177 /* Detach from the tty */ 178 178 tty->disc_data = NULL; ··· 204 204 */ 205 205 static void nci_uart_tty_wakeup(struct tty_struct *tty) 206 206 { 207 - struct nci_uart *nu = (void *)tty->disc_data; 207 + struct nci_uart *nu = tty->disc_data; 208 208 209 209 if (!nu) 210 210 return; ··· 296 296 * Return Value: None 297 297 */ 298 298 static void nci_uart_tty_receive(struct tty_struct *tty, const u8 *data, 299 - const char *flags, int count) 299 + const u8 *flags, size_t count) 300 300 { 301 - struct nci_uart *nu = (void *)tty->disc_data; 301 + struct nci_uart *nu = tty->disc_data; 302 302 303 303 if (!nu || tty != nu->tty) 304 304 return; ··· 325 325 static int nci_uart_tty_ioctl(struct tty_struct *tty, unsigned int cmd, 326 326 unsigned long arg) 327 327 { 328 - struct nci_uart *nu = (void *)tty->disc_data; 328 + struct nci_uart *nu = tty->disc_data; 329 329 int err = 0; 330 330 331 331 switch (cmd) { ··· 345 345 346 346 /* We don't provide read/write/poll interface for user space. */ 347 347 static ssize_t nci_uart_tty_read(struct tty_struct *tty, struct file *file, 348 - unsigned char *buf, size_t nr, 349 - void **cookie, unsigned long offset) 348 + u8 *buf, size_t nr, void **cookie, 349 + unsigned long offset) 350 350 { 351 351 return 0; 352 352 } 353 353 354 354 static ssize_t nci_uart_tty_write(struct tty_struct *tty, struct file *file, 355 - const unsigned char *data, size_t count) 356 - { 357 - return 0; 358 - } 359 - 360 - static __poll_t nci_uart_tty_poll(struct tty_struct *tty, 361 - struct file *filp, poll_table *wait) 355 + const u8 *data, size_t count) 362 356 { 363 357 return 0; 364 358 } ··· 429 435 .close = nci_uart_tty_close, 430 436 .read = nci_uart_tty_read, 431 437 .write = nci_uart_tty_write, 432 - .poll = nci_uart_tty_poll, 433 438 .receive_buf = nci_uart_tty_receive, 434 439 .write_wakeup = nci_uart_tty_wakeup, 435 440 .ioctl = nci_uart_tty_ioctl,
+2 -2
sound/soc/codecs/cx20442.c
··· 258 258 } 259 259 260 260 /* Line discipline .receive_buf() */ 261 - static void v253_receive(struct tty_struct *tty, const unsigned char *cp, 262 - const char *fp, int count) 261 + static void v253_receive(struct tty_struct *tty, const u8 *cp, const u8 *fp, 262 + size_t count) 263 263 { 264 264 struct snd_soc_component *component = tty->disc_data; 265 265 struct cx20442_priv *cx20442;
+1 -1
sound/soc/ti/ams-delta.c
··· 336 336 } 337 337 338 338 /* Line discipline .receive_buf() */ 339 - static void cx81801_receive(struct tty_struct *tty, const unsigned char *cp, 339 + static void cx81801_receive(struct tty_struct *tty, const u8 *cp, 340 340 const char *fp, int count) 341 341 { 342 342 struct snd_soc_component *component = tty->disc_data;