Date: Sat, 31 Oct 2020 17:07:43 +0000 (UTC) From: Michal Meloun <mmel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367223 - stable/12/sys/dev/fdt Message-ID: <202010311707.09VH7hqt062071@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: mmel Date: Sat Oct 31 17:07:43 2020 New Revision: 367223 URL: https://svnweb.freebsd.org/changeset/base/367223 Log: MFC r342008,r363799,r366146: r342008: fdt: Add support for simple-mfd bus r363799: Allow child classes of simplebus to call attach directly r366146: Make simplebus friendlier for subclassing. Modified: stable/12/sys/dev/fdt/simplebus.c stable/12/sys/dev/fdt/simplebus.h Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/dev/fdt/simplebus.c ============================================================================== --- stable/12/sys/dev/fdt/simplebus.c Sat Oct 31 16:51:19 2020 (r367222) +++ stable/12/sys/dev/fdt/simplebus.c Sat Oct 31 17:07:43 2020 (r367223) @@ -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); @@ -68,7 +67,7 @@ static device_method_t simplebus_methods[] = { /* Device interface */ DEVMETHOD(device_probe, simplebus_probe), DEVMETHOD(device_attach, simplebus_attach), - DEVMETHOD(device_detach, bus_generic_detach), + DEVMETHOD(device_detach, simplebus_detach), DEVMETHOD(device_shutdown, bus_generic_shutdown), DEVMETHOD(device_suspend, bus_generic_suspend), DEVMETHOD(device_resume, bus_generic_resume), @@ -134,15 +133,16 @@ simplebus_probe(device_t dev) return (BUS_PROBE_GENERIC); } -static int -simplebus_attach(device_t dev) +int +simplebus_attach_impl(device_t dev) { struct simplebus_softc *sc; phandle_t node; 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); } @@ -154,7 +154,32 @@ simplebus_attach(device_t dev) for (node = OF_child(sc->node); node > 0; node = OF_peer(node)) simplebus_add_device(dev, node, 0, NULL, -1, NULL); + + return (0); +} + +int +simplebus_attach(device_t dev) +{ + int rv; + + rv = simplebus_attach_impl(dev); + if (rv != 0) + return (rv); + return (bus_generic_attach(dev)); +} + +int +simplebus_detach(device_t dev) +{ + struct simplebus_softc *sc; + + sc = device_get_softc(dev); + if (sc->ranges != NULL) + free(sc->ranges, M_DEVBUF); + + return (bus_generic_detach(dev)); } void Modified: stable/12/sys/dev/fdt/simplebus.h ============================================================================== --- stable/12/sys/dev/fdt/simplebus.h Sat Oct 31 16:51:19 2020 (r367222) +++ stable/12/sys/dev/fdt/simplebus.h Sat Oct 31 17:07:43 2020 (r367223) @@ -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,9 @@ struct simplebus_devinfo *simplebus_setup_dinfo(device struct simplebus_devinfo *di); int simplebus_fill_ranges(phandle_t node, struct simplebus_softc *sc); + +int simplebus_attach(device_t dev); +int simplebus_attach_impl(device_t dev); +int simplebus_detach(device_t dev); + #endif /* _FDT_SIMPLEBUS_H */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202010311707.09VH7hqt062071>