Skip to content

Commit bd8cad8

Browse files
andy-shevgregkh
authored andcommitted
serial: 8250_dw: Comment possible corner cases in serial_out() implementation
8250 DesignWare driver uses a few custom implementations of the serial_out(). These implementations are carefully made to avoid infinite loops. But this is not obvious from looking at the code. Comment the possible corner cases in the respective functions. Signed-off-by: Andy Shevchenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 067e958 commit bd8cad8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

drivers/tty/serial/8250/8250_dw.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,23 @@ static inline int dw8250_modify_msr(struct uart_port *p, int offset, int value)
107107
return value;
108108
}
109109

110+
/*
111+
* This function is being called as part of the uart_port::serial_out()
112+
* routine. Hence, it must not call serial_port_out() or serial_out()
113+
* against the modified registers here, i.e. LCR.
114+
*/
110115
static void dw8250_force_idle(struct uart_port *p)
111116
{
112117
struct uart_8250_port *up = up_to_u8250p(p);
113118
unsigned int lsr;
114119

120+
/*
121+
* The following call currently performs serial_out()
122+
* against the FCR register. Because it differs to LCR
123+
* there will be no infinite loop, but if it ever gets
124+
* modified, we might need a new custom version of it
125+
* that avoids infinite recursion.
126+
*/
115127
serial8250_clear_and_reinit_fifos(up);
116128

117129
/*
@@ -128,6 +140,11 @@ static void dw8250_force_idle(struct uart_port *p)
128140
serial_port_in(p, UART_RX);
129141
}
130142

143+
/*
144+
* This function is being called as part of the uart_port::serial_out()
145+
* routine. Hence, it must not call serial_port_out() or serial_out()
146+
* against the modified registers here, i.e. LCR.
147+
*/
131148
static void dw8250_check_lcr(struct uart_port *p, int offset, int value)
132149
{
133150
struct dw8250_data *d = to_dw8250_data(p->private_data);

0 commit comments

Comments
 (0)