| .. | .. |
|---|
| 56 | 56 | const char *name) |
|---|
| 57 | 57 | { |
|---|
| 58 | 58 | struct console *earlycon = device->con; |
|---|
| 59 | | - struct uart_port *port = &device->port; |
|---|
| 60 | 59 | const char *s; |
|---|
| 61 | 60 | size_t len; |
|---|
| 62 | 61 | |
|---|
| .. | .. |
|---|
| 70 | 69 | len = s - name; |
|---|
| 71 | 70 | strlcpy(earlycon->name, name, min(len + 1, sizeof(earlycon->name))); |
|---|
| 72 | 71 | 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; |
|---|
| 73 | 78 | |
|---|
| 74 | 79 | if (port->iotype == UPIO_MEM || port->iotype == UPIO_MEM16 || |
|---|
| 75 | 80 | port->iotype == UPIO_MEM32 || port->iotype == UPIO_MEM32BE) |
|---|
| .. | .. |
|---|
| 140 | 145 | |
|---|
| 141 | 146 | earlycon_init(&early_console_dev, match->name); |
|---|
| 142 | 147 | err = match->setup(&early_console_dev, buf); |
|---|
| 148 | + earlycon_print_info(&early_console_dev); |
|---|
| 143 | 149 | if (err < 0) |
|---|
| 144 | 150 | return err; |
|---|
| 145 | 151 | if (!early_console_dev.con->write) |
|---|
| .. | .. |
|---|
| 170 | 176 | int __init setup_earlycon(char *buf) |
|---|
| 171 | 177 | { |
|---|
| 172 | 178 | const struct earlycon_id **p_match; |
|---|
| 179 | + bool empty_compatible = true; |
|---|
| 173 | 180 | |
|---|
| 174 | 181 | if (!buf || !buf[0]) |
|---|
| 175 | 182 | return -EINVAL; |
|---|
| .. | .. |
|---|
| 177 | 184 | if (early_con.flags & CON_ENABLED) |
|---|
| 178 | 185 | return -EALREADY; |
|---|
| 179 | 186 | |
|---|
| 187 | +again: |
|---|
| 180 | 188 | for (p_match = __earlycon_table; p_match < __earlycon_table_end; |
|---|
| 181 | 189 | p_match++) { |
|---|
| 182 | 190 | const struct earlycon_id *match = *p_match; |
|---|
| 183 | 191 | size_t len = strlen(match->name); |
|---|
| 184 | 192 | |
|---|
| 185 | 193 | if (strncmp(buf, match->name, len)) |
|---|
| 194 | + continue; |
|---|
| 195 | + |
|---|
| 196 | + /* prefer entries with empty compatible */ |
|---|
| 197 | + if (empty_compatible && *match->compatible) |
|---|
| 186 | 198 | continue; |
|---|
| 187 | 199 | |
|---|
| 188 | 200 | if (buf[len]) { |
|---|
| .. | .. |
|---|
| 193 | 205 | buf = NULL; |
|---|
| 194 | 206 | |
|---|
| 195 | 207 | return register_earlycon(buf, match); |
|---|
| 208 | + } |
|---|
| 209 | + |
|---|
| 210 | + if (empty_compatible) { |
|---|
| 211 | + empty_compatible = false; |
|---|
| 212 | + goto again; |
|---|
| 196 | 213 | } |
|---|
| 197 | 214 | |
|---|
| 198 | 215 | return -ENOENT; |
|---|
| .. | .. |
|---|
| 291 | 308 | } |
|---|
| 292 | 309 | earlycon_init(&early_console_dev, match->name); |
|---|
| 293 | 310 | err = match->setup(&early_console_dev, options); |
|---|
| 311 | + earlycon_print_info(&early_console_dev); |
|---|
| 294 | 312 | if (err < 0) |
|---|
| 295 | 313 | return err; |
|---|
| 296 | 314 | if (!early_console_dev.con->write) |
|---|