hc
2024-01-03 2f7c68cb55ecb7331f2381deb497c27155f32faf
kernel/drivers/tty/serial/8250/8250_early.c
....@@ -109,6 +109,28 @@
109109 uart_console_write(port, s, count, serial_putc);
110110 }
111111
112
+#ifdef CONFIG_CONSOLE_POLL
113
+static int early_serial8250_read(struct console *console,
114
+ char *s, unsigned int count)
115
+{
116
+ struct earlycon_device *device = console->data;
117
+ struct uart_port *port = &device->port;
118
+ unsigned int status;
119
+ int num_read = 0;
120
+
121
+ while (num_read < count) {
122
+ status = serial8250_early_in(port, UART_LSR);
123
+ if (!(status & UART_LSR_DR))
124
+ break;
125
+ s[num_read++] = serial8250_early_in(port, UART_RX);
126
+ }
127
+
128
+ return num_read;
129
+}
130
+#else
131
+#define early_serial8250_read NULL
132
+#endif
133
+
112134 static void __init init_port(struct earlycon_device *device)
113135 {
114136 struct uart_port *port = &device->port;
....@@ -149,6 +171,7 @@
149171 init_port(device);
150172
151173 device->con->write = early_serial8250_write;
174
+ device->con->read = early_serial8250_read;
152175 return 0;
153176 }
154177 EARLYCON_DECLARE(uart8250, early_serial8250_setup);