Index: dev/mainbus.c =================================================================== RCS file: /cvs/src/sys/arch/arm64/dev/mainbus.c,v diff -u -p -r1.32 mainbus.c --- dev/mainbus.c 18 Nov 2024 05:32:39 -0000 1.32 +++ dev/mainbus.c 13 Jul 2025 07:21:55 -0000 @@ -38,7 +38,8 @@ int mainbus_match_primary(struct device int mainbus_match_secondary(struct device *, void *, void *); void mainbus_attach_psci(struct device *); void mainbus_attach_efi(struct device *); -void mainbus_attach_apm(struct device *); +void mainbus_attach_subsystem(struct device *, const char *); +void mainbus_attach_late(struct device *); void mainbus_attach_framebuffer(struct device *); void mainbus_attach_firmware(struct device *); void mainbus_attach_resvmem(struct device *); @@ -147,7 +148,7 @@ mainbus_attach(struct device *parent, st sc->sc_rangeslen); } - mainbus_attach_apm(self); + mainbus_attach_subsystem(self, "apm"); /* Scan the whole tree. */ for (sc->sc_early = 2; sc->sc_early >= 0; sc->sc_early--) { @@ -156,13 +157,19 @@ mainbus_attach(struct device *parent, st } sc->sc_early = 0; + config_mountroot(self, mainbus_attach_late); + + thermal_init(); +} + +void +mainbus_attach_late(struct device *self) +{ /* * Delay attaching the framebuffer to give other drivers a * chance to claim it. */ - config_mountroot(self, mainbus_attach_framebuffer); - - thermal_init(); + mainbus_attach_framebuffer(self); } int @@ -399,15 +406,27 @@ mainbus_attach_efi(struct device *self) config_found(self, &fa, NULL); } -void -mainbus_attach_apm(struct device *self) +static int +mainbus_match_subsystem(struct device *parent, void *match, void *aux) { - struct fdt_attach_args fa; + struct cfdata *cf = match; + struct fdt_attach_args *fa = aux; - memset(&fa, 0, sizeof(fa)); - fa.fa_name = "apm"; + if (strcmp(cf->cf_driver->cd_name, fa->fa_name) == 0) + return cf->cf_attach->ca_match(parent, match, aux); - config_found(self, &fa, NULL); + return (0); +} + +void +mainbus_attach_subsystem(struct device *self, const char *name) +{ + struct fdt_attach_args fa = { .fa_name = name }; + void *match; + + match = config_search(mainbus_match_subsystem, self, &fa); + if (match != NULL) + config_attach(self, match, &fa, mainbus_print); } void