Skip to content

Commit 28da734

Browse files
chleroympe
authored andcommitted
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: Christophe Leroy <christophe.leroy@csgroup.eu> Reviewed-by: Rob Herring <robh@kernel.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20231214103152.12269-4-mpe@ellerman.id.au
1 parent 1ac8205 commit 28da734

11 files changed

Lines changed: 14 additions & 64 deletions

File tree

arch/powerpc/include/asm/machdep.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct pci_host_bridge;
2222
struct machdep_calls {
2323
const char *name;
2424
const char *compatible;
25+
const char * const *compatibles;
2526
#ifdef CONFIG_PPC64
2627
#ifdef CONFIG_PM
2728
void (*iommu_restore)(void);

arch/powerpc/kernel/setup-common.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,8 @@ static __init void probe_machine(void)
640640
DBG(" %s ...\n", machine_id->name);
641641
if (machine_id->compatible && !of_machine_is_compatible(machine_id->compatible))
642642
continue;
643+
if (machine_id->compatibles && !of_machine_compatible_match(machine_id->compatibles))
644+
continue;
643645
memcpy(&ppc_md, machine_id, sizeof(struct machdep_calls));
644646
if (ppc_md.probe && !ppc_md.probe())
645647
continue;

arch/powerpc/platforms/40x/ppc40x_simple.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,16 +59,13 @@ static const char * const board[] __initconst = {
5959

6060
static int __init ppc40x_probe(void)
6161
{
62-
if (of_device_compatible_match(of_root, board)) {
63-
pci_set_flags(PCI_REASSIGN_ALL_RSRC);
64-
return 1;
65-
}
66-
67-
return 0;
62+
pci_set_flags(PCI_REASSIGN_ALL_RSRC);
63+
return 1;
6864
}
6965

7066
define_machine(ppc40x_simple) {
7167
.name = "PowerPC 40x Platform",
68+
.compatibles = board,
7269
.probe = ppc40x_probe,
7370
.progress = udbg_progress,
7471
.init_IRQ = uic_init_tree,

arch/powerpc/platforms/512x/mpc512x_generic.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,14 @@ static const char * const board[] __initconst = {
3232
*/
3333
static int __init mpc512x_generic_probe(void)
3434
{
35-
if (!of_device_compatible_match(of_root, board))
36-
return 0;
37-
3835
mpc512x_init_early();
3936

4037
return 1;
4138
}
4239

4340
define_machine(mpc512x_generic) {
4441
.name = "MPC512x generic",
42+
.compatibles = board,
4543
.probe = mpc512x_generic_probe,
4644
.init = mpc512x_init,
4745
.setup_arch = mpc512x_setup_arch,

arch/powerpc/platforms/52xx/lite5200.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,9 @@ static const char * const board[] __initconst = {
172172
NULL,
173173
};
174174

175-
/*
176-
* Called very early, MMU is off, device-tree isn't unflattened
177-
*/
178-
static int __init lite5200_probe(void)
179-
{
180-
return of_device_compatible_match(of_root, board);
181-
}
182-
183175
define_machine(lite5200) {
184176
.name = "lite5200",
185-
.probe = lite5200_probe,
177+
.compatibles = board,
186178
.setup_arch = lite5200_setup_arch,
187179
.discover_phbs = mpc52xx_setup_pci,
188180
.init = mpc52xx_declare_of_platform_devices,

arch/powerpc/platforms/52xx/mpc5200_simple.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,9 @@ static const char *board[] __initdata = {
5959
NULL
6060
};
6161

62-
/*
63-
* Called very early, MMU is off, device-tree isn't unflattened
64-
*/
65-
static int __init mpc5200_simple_probe(void)
66-
{
67-
return of_device_compatible_match(of_root, board);
68-
}
69-
7062
define_machine(mpc5200_simple_platform) {
7163
.name = "mpc5200-simple-platform",
72-
.probe = mpc5200_simple_probe,
64+
.compatibles = board,
7365
.setup_arch = mpc5200_simple_setup_arch,
7466
.discover_phbs = mpc52xx_setup_pci,
7567
.init = mpc52xx_declare_of_platform_devices,

arch/powerpc/platforms/83xx/mpc830x_rdb.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,11 @@ static const char *board[] __initdata = {
3434
NULL
3535
};
3636

37-
/*
38-
* Called very early, MMU is off, device-tree isn't unflattened
39-
*/
40-
static int __init mpc830x_rdb_probe(void)
41-
{
42-
return of_device_compatible_match(of_root, board);
43-
}
44-
4537
machine_device_initcall(mpc830x_rdb, mpc83xx_declare_of_platform_devices);
4638

4739
define_machine(mpc830x_rdb) {
4840
.name = "MPC830x RDB",
49-
.probe = mpc830x_rdb_probe,
41+
.compatibles = board,
5042
.setup_arch = mpc830x_rdb_setup_arch,
5143
.discover_phbs = mpc83xx_setup_pci,
5244
.init_IRQ = mpc83xx_ipic_init_IRQ,

arch/powerpc/platforms/83xx/mpc831x_rdb.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,11 @@ static const char *board[] __initdata = {
3434
NULL
3535
};
3636

37-
/*
38-
* Called very early, MMU is off, device-tree isn't unflattened
39-
*/
40-
static int __init mpc831x_rdb_probe(void)
41-
{
42-
return of_device_compatible_match(of_root, board);
43-
}
44-
4537
machine_device_initcall(mpc831x_rdb, mpc83xx_declare_of_platform_devices);
4638

4739
define_machine(mpc831x_rdb) {
4840
.name = "MPC831x RDB",
49-
.probe = mpc831x_rdb_probe,
41+
.compatibles = board,
5042
.setup_arch = mpc831x_rdb_setup_arch,
5143
.discover_phbs = mpc83xx_setup_pci,
5244
.init_IRQ = mpc83xx_ipic_init_IRQ,

arch/powerpc/platforms/83xx/mpc837x_rdb.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,9 @@ static const char * const board[] __initconst = {
6161
NULL
6262
};
6363

64-
/*
65-
* Called very early, MMU is off, device-tree isn't unflattened
66-
*/
67-
static int __init mpc837x_rdb_probe(void)
68-
{
69-
return of_device_compatible_match(of_root, board);
70-
}
71-
7264
define_machine(mpc837x_rdb) {
7365
.name = "MPC837x RDB/WLAN",
74-
.probe = mpc837x_rdb_probe,
66+
.compatibles = board,
7567
.setup_arch = mpc837x_rdb_setup_arch,
7668
.discover_phbs = mpc83xx_setup_pci,
7769
.init_IRQ = mpc83xx_ipic_init_IRQ,

arch/powerpc/platforms/85xx/corenet_generic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static int __init corenet_generic_probe(void)
149149
extern struct smp_ops_t smp_85xx_ops;
150150
#endif
151151

152-
if (of_device_compatible_match(of_root, boards))
152+
if (of_machine_compatible_match(boards))
153153
return 1;
154154

155155
/* Check if we're running under the Freescale hypervisor */

0 commit comments

Comments
 (0)