Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2eaa7909 authored by Peter Hurley's avatar Peter Hurley Committed by Greg Kroah-Hartman
Browse files

earlycon: Use common framework for earlycon declarations



Use a single common table of struct earlycon_id for both command line
and devicetree. Re-define OF_EARLYCON_DECLARE() macro to instance a
unique earlycon declaration (the declaration is only guaranteed to be
unique within a compilation unit; separate compilation units must still
use unique earlycon names).

The semantics of OF_EARLYCON_DECLARE() is different; it declares an
earlycon which can matched either on the command line or by devicetree.
EARLYCON_DECLARE() is semantically unchanged; it declares an earlycon
which is matched by command line only. Remove redundant instances of
EARLYCON_DECLARE().

This enables all earlycons to properly initialize struct console
with the appropriate name and index, which improves diagnostics and
enables direct earlycon-to-console handoff.

Acked-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8477614d
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -796,14 +796,13 @@ static inline void early_init_dt_check_for_initrd(unsigned long node)
#endif /* CONFIG_BLK_DEV_INITRD */

#ifdef CONFIG_SERIAL_EARLYCON
extern struct of_device_id __earlycon_of_table[];

static int __init early_init_dt_scan_chosen_serial(void)
{
	int offset;
	const char *p;
	int l;
	const struct of_device_id *match = __earlycon_of_table;
	const struct earlycon_id *match;
	const void *fdt = initial_boot_params;

	offset = fdt_path_offset(fdt, "/chosen");
@@ -826,19 +825,20 @@ static int __init early_init_dt_scan_chosen_serial(void)
	if (offset < 0)
		return -ENODEV;

	while (match->compatible[0]) {
	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
		u64 addr;

		if (fdt_node_check_compatible(fdt, offset, match->compatible)) {
			match++;
		if (!match->compatible[0])
			continue;

		if (fdt_node_check_compatible(fdt, offset, match->compatible))
			continue;
		}

		addr = fdt_translate_address(fdt, offset);
		if (addr == OF_BAD_ADDR)
			return -ENXIO;

		of_setup_earlycon(addr, match->data);
		of_setup_earlycon(addr, match->setup);
		return 0;
	}
	return -ENODEV;
+0 −1
Original line number Diff line number Diff line
@@ -2327,7 +2327,6 @@ static int __init pl011_early_console_setup(struct earlycon_device *device,
	device->con->write = pl011_early_write;
	return 0;
}
EARLYCON_DECLARE(pl011, pl011_early_console_setup);
OF_EARLYCON_DECLARE(pl011, "arm,pl011", pl011_early_console_setup);

#else
+0 −1
Original line number Diff line number Diff line
@@ -576,7 +576,6 @@ static int __init arc_early_console_setup(struct earlycon_device *dev,
	dev->con->write = arc_early_serial_write;
	return 0;
}
EARLYCON_DECLARE(arc_uart, arc_early_console_setup);
OF_EARLYCON_DECLARE(arc_uart, "snps,arc-uart", arc_early_console_setup);

#endif	/* CONFIG_SERIAL_ARC_CONSOLE */
+1 −9
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@
#include <linux/io.h>
#include <linux/serial_core.h>
#include <linux/sizes.h>
#include <linux/mod_devicetable.h>

#ifdef CONFIG_FIX_EARLYCON_MEM
#include <asm/fixmap.h>
@@ -37,13 +36,6 @@ static struct earlycon_device early_console_dev = {
	.con = &early_con,
};

extern struct earlycon_id __earlycon_table[];
static const struct earlycon_id __earlycon_table_sentinel
	__used __section(__earlycon_table_end);

static const struct of_device_id __earlycon_of_table_sentinel
	__used __section(__earlycon_of_table_end);

static void __iomem * __init earlycon_map(unsigned long paddr, size_t size)
{
	void __iomem *base;
@@ -166,7 +158,7 @@ int __init setup_earlycon(char *buf)
	if (early_con.flags & CON_ENABLED)
		return -EALREADY;

	for (match = __earlycon_table; match->name[0]; match++) {
	for (match = __earlycon_table; match < __earlycon_table_end; match++) {
		size_t len = strlen(match->name);

		if (strncmp(buf, match->name, len))
+0 −2
Original line number Diff line number Diff line
@@ -1478,7 +1478,6 @@ msm_serial_early_console_setup(struct earlycon_device *device, const char *opt)
	device->con->write = msm_serial_early_write;
	return 0;
}
EARLYCON_DECLARE(msm_serial, msm_serial_early_console_setup);
OF_EARLYCON_DECLARE(msm_serial, "qcom,msm-uart",
		    msm_serial_early_console_setup);

@@ -1500,7 +1499,6 @@ msm_serial_early_console_setup_dm(struct earlycon_device *device,
	device->con->write = msm_serial_early_write_dm;
	return 0;
}
EARLYCON_DECLARE(msm_serial_dm, msm_serial_early_console_setup_dm);
OF_EARLYCON_DECLARE(msm_serial_dm, "qcom,msm-uartdm",
		    msm_serial_early_console_setup_dm);

Loading