Commit 28da734d authored by Christophe Leroy's avatar Christophe Leroy Committed by Michael Ellerman
Browse files

powerpc/machdep: Define 'compatibles' property in ppc_md and use it



Most probe functions that do not use the 'compatible' string do
nothing else than checking whether the machine is compatible with
one of the strings in a NULL terminated table of strings.

Define that table of strings in ppc_md structure and check it directly
from probe_machine() instead of using ppc_md.probe() for that.

Keep checking in ppc_md.probe() only for more complex probing.

All .compatible could be replaced with a single element NULL
terminated list but that's not worth the churn. Can be do incrementaly
in follow-up patches.

Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: default avatarRob Herring <robh@kernel.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231214103152.12269-4-mpe@ellerman.id.au
parent 1ac8205f
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ struct pci_host_bridge;
struct machdep_calls {
	const char	*name;
	const char	*compatible;
	const char * const *compatibles;
#ifdef CONFIG_PPC64
#ifdef CONFIG_PM
	void		(*iommu_restore)(void);
+2 −0
Original line number Diff line number Diff line
@@ -640,6 +640,8 @@ static __init void probe_machine(void)
		DBG("  %s ...\n", machine_id->name);
		if (machine_id->compatible && !of_machine_is_compatible(machine_id->compatible))
			continue;
		if (machine_id->compatibles && !of_machine_compatible_match(machine_id->compatibles))
			continue;
		memcpy(&ppc_md, machine_id, sizeof(struct machdep_calls));
		if (ppc_md.probe && !ppc_md.probe())
			continue;
+3 −6
Original line number Diff line number Diff line
@@ -59,16 +59,13 @@ static const char * const board[] __initconst = {

static int __init ppc40x_probe(void)
{
	if (of_device_compatible_match(of_root, board)) {
	pci_set_flags(PCI_REASSIGN_ALL_RSRC);
	return 1;
}

	return 0;
}

define_machine(ppc40x_simple) {
	.name = "PowerPC 40x Platform",
	.compatibles = board,
	.probe = ppc40x_probe,
	.progress = udbg_progress,
	.init_IRQ = uic_init_tree,
+1 −3
Original line number Diff line number Diff line
@@ -32,9 +32,6 @@ static const char * const board[] __initconst = {
 */
static int __init mpc512x_generic_probe(void)
{
	if (!of_device_compatible_match(of_root, board))
		return 0;

	mpc512x_init_early();

	return 1;
@@ -42,6 +39,7 @@ static int __init mpc512x_generic_probe(void)

define_machine(mpc512x_generic) {
	.name			= "MPC512x generic",
	.compatibles		= board,
	.probe			= mpc512x_generic_probe,
	.init			= mpc512x_init,
	.setup_arch		= mpc512x_setup_arch,
+1 −9
Original line number Diff line number Diff line
@@ -172,17 +172,9 @@ static const char * const board[] __initconst = {
	NULL,
};

/*
 * Called very early, MMU is off, device-tree isn't unflattened
 */
static int __init lite5200_probe(void)
{
	return of_device_compatible_match(of_root, board);
}

define_machine(lite5200) {
	.name 		= "lite5200",
	.probe 		= lite5200_probe,
	.compatibles	= board,
	.setup_arch 	= lite5200_setup_arch,
	.discover_phbs	= mpc52xx_setup_pci,
	.init		= mpc52xx_declare_of_platform_devices,
Loading