From owner-svn-src-stable@freebsd.org Sat Oct 31 17:07:44 2020 Return-Path: Delivered-To: svn-src-stable@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 558FE451B3B; Sat, 31 Oct 2020 17:07:44 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4CNlww1G4jz3TG3; Sat, 31 Oct 2020 17:07:44 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 09FB7AB2D; Sat, 31 Oct 2020 17:07:44 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 09VH7h4B062072; Sat, 31 Oct 2020 17:07:43 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 09VH7hqt062071; Sat, 31 Oct 2020 17:07:43 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <202010311707.09VH7hqt062071@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Sat, 31 Oct 2020 17:07:43 +0000 (UTC) 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 X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/dev/fdt X-SVN-Commit-Revision: 367223 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 31 Oct 2020 17:07:44 -0000 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 */