forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-10 cde9070d9970eef1f7ec2360586c802a16230ad8
kernel/drivers/tty/serial/earlycon.c
....@@ -56,7 +56,6 @@
5656 const char *name)
5757 {
5858 struct console *earlycon = device->con;
59
- struct uart_port *port = &device->port;
6059 const char *s;
6160 size_t len;
6261
....@@ -70,6 +69,12 @@
7069 len = s - name;
7170 strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name)));
7271 earlycon->data = &early_console_dev;
72
+}
73
+
74
+static void __init earlycon_print_info(struct earlycon_device *device)
75
+{
76
+ struct console *earlycon = device->con;
77
+ struct uart_port *port = &device->port;
7378
7479 if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 ||
7580 port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE)
....@@ -140,6 +145,7 @@
140145
141146 earlycon_init(&early_console_dev, match->name);
142147 err = match->setup(&early_console_dev, buf);
148
+ earlycon_print_info(&early_console_dev);
143149 if (err < 0)
144150 return err;
145151 if (!early_console_dev.con->write)
....@@ -170,6 +176,7 @@
170176 int __init setup_earlycon(char *buf)
171177 {
172178 const struct earlycon_id **p_match;
179
+ bool empty_compatible = true;
173180
174181 if (!buf || !buf[0])
175182 return -EINVAL;
....@@ -177,12 +184,17 @@
177184 if (early_con.flags & CON_ENABLED)
178185 return -EALREADY;
179186
187
+again:
180188 for (p_match = __earlycon_table; p_match < __earlycon_table_end;
181189 p_match++) {
182190 const struct earlycon_id *match = *p_match;
183191 size_t len = strlen(match->name);
184192
185193 if (strncmp(buf, match->name, len))
194
+ continue;
195
+
196
+ /* prefer entries with empty compatible */
197
+ if (empty_compatible && *match->compatible)
186198 continue;
187199
188200 if (buf[len]) {
....@@ -193,6 +205,11 @@
193205 buf = NULL;
194206
195207 return register_earlycon(buf, match);
208
+ }
209
+
210
+ if (empty_compatible) {
211
+ empty_compatible = false;
212
+ goto again;
196213 }
197214
198215 return -ENOENT;
....@@ -291,6 +308,7 @@
291308 }
292309 earlycon_init(&early_console_dev, match->name);
293310 err = match->setup(&early_console_dev, options);
311
+ earlycon_print_info(&early_console_dev);
294312 if (err < 0)
295313 return err;
296314 if (!early_console_dev.con->write)