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

Configure Feed

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

serial: 8250: extract serial8250_set_fcr()

serial8250_do_set_termios() consists of many registers and up flags
settings. Extract all these into separate functions. This time, setting
of FCR.

serial8250_do_set_termios() looks sane at this point.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20250611100319.186924-25-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
cdc4a3e0 c5d43d65

+26 -15
+26 -15
drivers/tty/serial/8250/8250_port.c
··· 2792 2792 serial_port_out(port, efr_reg, efr); 2793 2793 } 2794 2794 2795 + static void serial8250_set_fcr(struct uart_port *port, struct ktermios *termios) 2796 + { 2797 + struct uart_8250_port *up = up_to_u8250p(port); 2798 + bool is_16750 = port->type == PORT_16750; 2799 + 2800 + if (is_16750) 2801 + serial_port_out(port, UART_FCR, up->fcr); 2802 + 2803 + /* 2804 + * LCR DLAB must be reset to enable 64-byte FIFO mode. If the FCR is written without DLAB 2805 + * set, this mode will be disabled. 2806 + */ 2807 + serial_port_out(port, UART_LCR, up->lcr); 2808 + 2809 + if (is_16750) 2810 + return; 2811 + 2812 + /* emulated UARTs (Lucent Venus 167x) need two steps */ 2813 + if (up->fcr & UART_FCR_ENABLE_FIFO) 2814 + serial_port_out(port, UART_FCR, UART_FCR_ENABLE_FIFO); 2815 + 2816 + serial_port_out(port, UART_FCR, up->fcr); 2817 + } 2818 + 2795 2819 void 2796 2820 serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, 2797 2821 const struct ktermios *old) ··· 2847 2823 serial8250_set_ier(port, termios); 2848 2824 serial8250_set_efr(port, termios); 2849 2825 serial8250_set_divisor(port, baud, quot, frac); 2850 - 2851 - /* 2852 - * LCR DLAB must be set to enable 64-byte FIFO mode. If the FCR 2853 - * is written without DLAB set, this mode will be disabled. 2854 - */ 2855 - if (port->type == PORT_16750) 2856 - serial_port_out(port, UART_FCR, up->fcr); 2857 - 2858 - serial_port_out(port, UART_LCR, up->lcr); /* reset DLAB */ 2859 - if (port->type != PORT_16750) { 2860 - /* emulated UARTs (Lucent Venus 167x) need two steps */ 2861 - if (up->fcr & UART_FCR_ENABLE_FIFO) 2862 - serial_port_out(port, UART_FCR, UART_FCR_ENABLE_FIFO); 2863 - serial_port_out(port, UART_FCR, up->fcr); /* set fcr */ 2864 - } 2826 + serial8250_set_fcr(port, termios); 2865 2827 serial8250_set_mctrl(port, port->mctrl); 2828 + 2866 2829 uart_port_unlock_irqrestore(port, flags); 2867 2830 serial8250_rpm_put(up); 2868 2831