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

serial: 8250: Decouple RSA probe

Prepare for 8250 split; separate RSA probe and resource management
from base port operations. Override base port operations for the
config_port(), request_port() and release_port() methods to
implement the optional RSA probe and resource management only in
the universal/legacy 8250 driver.

Introduce 'probe' flags for 8250 ports, which allows drivers higher
up the driver stack to enable optional probes.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Peter Hurley and committed by
Greg Kroah-Hartman
40375393 3b81c26c

+78 -39
-3
drivers/tty/serial/8250/8250.h
··· 84 84 #define UART_BUG_THRE (1 << 3) /* UART has buggy THRE reassertion */ 85 85 #define UART_BUG_PARITY (1 << 4) /* UART mishandles parity if FIFO enabled */ 86 86 87 - #define PROBE_RSA (1 << 0) 88 - #define PROBE_ANY (~0) 89 - 90 87 #define HIGH_BITS_OFFSET ((sizeof(long)-sizeof(int))*8) 91 88 92 89 #ifdef CONFIG_SERIAL_8250_SHARE_IRQ
+76 -36
drivers/tty/serial/8250/8250_core.c
··· 1105 1105 * whether or not this UART is a 16550A or not, since this will 1106 1106 * determine whether or not we can use its FIFO features or not. 1107 1107 */ 1108 - static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) 1108 + static void autoconfig(struct uart_8250_port *up) 1109 1109 { 1110 1110 unsigned char status1, scratch, scratch2, scratch3; 1111 1111 unsigned char save_lcr, save_mcr; ··· 1228 1228 /* 1229 1229 * Only probe for RSA ports if we got the region. 1230 1230 */ 1231 - if (port->type == PORT_16550A && probeflags & PROBE_RSA && 1231 + if (port->type == PORT_16550A && up->probe & UART_PROBE_RSA && 1232 1232 __enable_rsa(up)) 1233 1233 port->type = PORT_RSA; 1234 1234 #endif ··· 2832 2832 struct uart_8250_port *up = up_to_u8250p(port); 2833 2833 2834 2834 serial8250_release_std_resource(up); 2835 - #ifdef CONFIG_SERIAL_8250_RSA 2836 - if (port->type == PORT_RSA) 2837 - serial8250_release_rsa_resource(up); 2838 - #endif 2839 2835 } 2840 2836 2841 2837 static int serial8250_request_port(struct uart_port *port) ··· 2843 2847 return -ENODEV; 2844 2848 2845 2849 ret = serial8250_request_std_resource(up); 2846 - #ifdef CONFIG_SERIAL_8250_RSA 2847 - if (ret == 0 && port->type == PORT_RSA) { 2848 - ret = serial8250_request_rsa_resource(up); 2849 - if (ret < 0) 2850 - serial8250_release_std_resource(up); 2851 - } 2852 - #endif 2853 2850 2854 2851 return ret; 2855 2852 } ··· 2990 3001 static void serial8250_config_port(struct uart_port *port, int flags) 2991 3002 { 2992 3003 struct uart_8250_port *up = up_to_u8250p(port); 2993 - int probeflags = 0; 2994 3004 int ret; 2995 3005 2996 3006 if (port->type == PORT_8250_CIR) ··· 3003 3015 if (ret < 0) 3004 3016 return; 3005 3017 3006 - #ifdef CONFIG_SERIAL_8250_RSA 3007 - if (port->type == PORT_RSA) { 3008 - if (serial8250_request_rsa_resource(up) == 0) 3009 - probeflags |= PROBE_RSA; 3010 - } else if (flags & UART_CONFIG_TYPE) { 3011 - int i; 3012 - 3013 - for (i = 0 ; i < probe_rsa_count; ++i) { 3014 - if (probe_rsa[i] == port->iobase) { 3015 - if (serial8250_request_rsa_resource(up) == 0) 3016 - probeflags |= PROBE_RSA; 3017 - break; 3018 - } 3019 - } 3020 - } 3021 - #endif 3022 - 3023 3018 if (port->iotype != up->cur_iotype) 3024 3019 set_io_from_upio(port); 3025 3020 3026 3021 if (flags & UART_CONFIG_TYPE) 3027 - autoconfig(up, probeflags); 3022 + autoconfig(up); 3028 3023 3029 3024 /* if access method is AU, it is a 16550 with a quirk */ 3030 3025 if (port->type == PORT_16550A && port->iotype == UPIO_AU) ··· 3020 3049 if (port->type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ) 3021 3050 autoconfig_irq(up); 3022 3051 3023 - #ifdef CONFIG_SERIAL_8250_RSA 3024 - if (port->type != PORT_RSA && probeflags & PROBE_RSA) 3025 - serial8250_release_rsa_resource(up); 3026 - #endif 3027 3052 if (port->type == PORT_UNKNOWN) 3028 3053 serial8250_release_std_resource(up); 3029 3054 ··· 3079 3112 .poll_put_char = serial8250_put_poll_char, 3080 3113 #endif 3081 3114 }; 3115 + 3116 + static const struct uart_ops *base_ops; 3117 + static struct uart_ops univ8250_port_ops; 3082 3118 3083 3119 static const struct uart_8250_ops univ8250_driver_ops = { 3084 3120 .setup_irq = univ8250_setup_irq, ··· 3154 3184 } 3155 3185 } 3156 3186 3187 + #ifdef CONFIG_SERIAL_8250_RSA 3188 + 3189 + static void univ8250_config_port(struct uart_port *port, int flags) 3190 + { 3191 + struct uart_8250_port *up = up_to_u8250p(port); 3192 + 3193 + up->probe &= ~UART_PROBE_RSA; 3194 + if (port->type == PORT_RSA) { 3195 + if (serial8250_request_rsa_resource(up) == 0) 3196 + up->probe |= UART_PROBE_RSA; 3197 + } else if (flags & UART_CONFIG_TYPE) { 3198 + int i; 3199 + 3200 + for (i = 0; i < probe_rsa_count; i++) { 3201 + if (probe_rsa[i] == up->port.iobase) { 3202 + if (serial8250_request_rsa_resource(up) == 0) 3203 + up->probe |= UART_PROBE_RSA; 3204 + break; 3205 + } 3206 + } 3207 + } 3208 + 3209 + base_ops->config_port(port, flags); 3210 + 3211 + if (port->type != PORT_RSA && up->probe & UART_PROBE_RSA) 3212 + serial8250_release_rsa_resource(up); 3213 + } 3214 + 3215 + static int univ8250_request_port(struct uart_port *port) 3216 + { 3217 + struct uart_8250_port *up = up_to_u8250p(port); 3218 + int ret; 3219 + 3220 + ret = base_ops->request_port(port); 3221 + if (ret == 0 && port->type == PORT_RSA) { 3222 + ret = serial8250_request_rsa_resource(up); 3223 + if (ret < 0) 3224 + base_ops->release_port(port); 3225 + } 3226 + 3227 + return ret; 3228 + } 3229 + 3230 + static void univ8250_release_port(struct uart_port *port) 3231 + { 3232 + struct uart_8250_port *up = up_to_u8250p(port); 3233 + 3234 + if (port->type == PORT_RSA) 3235 + serial8250_release_rsa_resource(up); 3236 + base_ops->release_port(port); 3237 + } 3238 + 3239 + static void univ8250_rsa_support(struct uart_ops *ops) 3240 + { 3241 + ops->config_port = univ8250_config_port; 3242 + ops->request_port = univ8250_request_port; 3243 + ops->release_port = univ8250_release_port; 3244 + } 3245 + 3246 + #else 3247 + #define univ8250_rsa_support(x) do { } while (0) 3248 + #endif /* CONFIG_SERIAL_8250_RSA */ 3249 + 3157 3250 static void __init serial8250_isa_init_ports(void) 3158 3251 { 3159 3252 struct uart_8250_port *up; ··· 3236 3203 3237 3204 port->line = i; 3238 3205 serial8250_init_port(up); 3206 + if (!base_ops) 3207 + base_ops = port->ops; 3208 + port->ops = &univ8250_port_ops; 3239 3209 3240 3210 init_timer(&up->timer); 3241 3211 up->timer.function = serial8250_timeout; ··· 3251 3215 up->mcr_mask = ~ALPHA_KLUDGE_MCR; 3252 3216 up->mcr_force = ALPHA_KLUDGE_MCR; 3253 3217 } 3218 + 3219 + /* chain base port ops to support Remote Supervisor Adapter */ 3220 + univ8250_port_ops = *base_ops; 3221 + univ8250_rsa_support(&univ8250_port_ops); 3254 3222 3255 3223 if (share_irqs) 3256 3224 irqflag = IRQF_SHARED;
+2
include/linux/serial_8250.h
··· 102 102 unsigned char canary; /* non-zero during system sleep 103 103 * if no_console_suspend 104 104 */ 105 + unsigned char probe; 106 + #define UART_PROBE_RSA (1 << 0) 105 107 106 108 /* 107 109 * Some bits in registers are cleared on a read, so they must