diff options
author | Andrew Turner <andrew@FreeBSD.org> | 2020-08-03 16:26:10 +0000 |
---|---|---|
committer | Andrew Turner <andrew@FreeBSD.org> | 2020-08-03 16:26:10 +0000 |
commit | bc9b178cd01a5ce7642ade237975e44b096413a8 (patch) | |
tree | c327be33abe4953411439182d2bf3c4ad610d7fd | |
parent | 8c72577900e317393dc43be3df159e0dd4036ddc (diff) |
Allow child classes of simplebus to call attach directly
Reduce code duplication when a bus is subclassed from simplebus by allowing
them to call simplebus_attach directly. This is useful when the child bus
will just implement the same calls.
As not all children will expect to have a ranges property, e.g. the
Raspberry Pi firmware, allow this property to be missing.
Reviewed by: manu
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D25925
Notes
Notes:
svn path=/head/; revision=363799
-rw-r--r-- | sys/dev/fdt/simplebus.c | 6 | ||||
-rw-r--r-- | sys/dev/fdt/simplebus.h | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/sys/dev/fdt/simplebus.c b/sys/dev/fdt/simplebus.c index 2f4fa8608626..60387a9e7a81 100644 --- a/sys/dev/fdt/simplebus.c +++ b/sys/dev/fdt/simplebus.c @@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$"); * Bus interface. */ static int simplebus_probe(device_t dev); -static int simplebus_attach(device_t dev); static struct resource *simplebus_alloc_resource(device_t, device_t, int, int *, rman_res_t, rman_res_t, rman_res_t, u_int); static void simplebus_probe_nomatch(device_t bus, device_t child); @@ -134,7 +133,7 @@ simplebus_probe(device_t dev) return (BUS_PROBE_GENERIC); } -static int +int simplebus_attach(device_t dev) { struct simplebus_softc *sc; @@ -142,7 +141,8 @@ simplebus_attach(device_t dev) sc = device_get_softc(dev); simplebus_init(dev, 0); - if (simplebus_fill_ranges(sc->node, sc) < 0) { + if ((sc->flags & SB_FLAG_NO_RANGES) == 0 && + simplebus_fill_ranges(sc->node, sc) < 0) { device_printf(dev, "could not get ranges\n"); return (ENXIO); } diff --git a/sys/dev/fdt/simplebus.h b/sys/dev/fdt/simplebus.h index bc695578e874..b416f1b94cfb 100644 --- a/sys/dev/fdt/simplebus.h +++ b/sys/dev/fdt/simplebus.h @@ -47,6 +47,8 @@ struct simplebus_softc { struct simplebus_range *ranges; int nranges; +#define SB_FLAG_NO_RANGES (1 << 0) /* Bus doesn't have ranges property */ + int flags; pcell_t acells, scells; }; @@ -63,4 +65,7 @@ struct simplebus_devinfo *simplebus_setup_dinfo(device_t dev, phandle_t node, struct simplebus_devinfo *di); int simplebus_fill_ranges(phandle_t node, struct simplebus_softc *sc); + +int simplebus_attach(device_t dev); + #endif /* _FDT_SIMPLEBUS_H */ |