Date: Wed, 21 Apr 2010 00:13:44 +0000 (UTC) From: Weongyo Jeong <weongyo@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r206967 - in stable/8/sys/dev: bwn siba Message-ID: <201004210013.o3L0DiE0087711@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: weongyo Date: Wed Apr 21 00:13:44 2010 New Revision: 206967 URL: http://svn.freebsd.org/changeset/base/206967 Log: MFC r204657: fixes an attached-at-boot issue that bwn(4) using device_identify interface didn't be attached automatically at boot time so changes a approach to attach children based on leveraging some newbus niceties. Submitted by: nwhitehorn Modified: stable/8/sys/dev/bwn/if_bwn.c stable/8/sys/dev/siba/siba_bwn.c stable/8/sys/dev/siba/siba_core.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/dev/uath/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/siba/siba_cc.c (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) stable/8/sys/geom/sched/ (props changed) Modified: stable/8/sys/dev/bwn/if_bwn.c ============================================================================== --- stable/8/sys/dev/bwn/if_bwn.c Wed Apr 21 00:10:30 2010 (r206966) +++ stable/8/sys/dev/bwn/if_bwn.c Wed Apr 21 00:13:44 2010 (r206967) @@ -14312,16 +14312,8 @@ bwn_sysctl_node(struct bwn_softc *sc) #endif } -static void -bwn_identify(driver_t *driver, device_t parent) -{ - - BUS_ADD_CHILD(parent, 0, "bwn", -1); -} - static device_method_t bwn_methods[] = { /* Device interface */ - DEVMETHOD(device_identify, bwn_identify), DEVMETHOD(device_probe, bwn_probe), DEVMETHOD(device_attach, bwn_attach), DEVMETHOD(device_detach, bwn_detach), Modified: stable/8/sys/dev/siba/siba_bwn.c ============================================================================== --- stable/8/sys/dev/siba/siba_bwn.c Wed Apr 21 00:10:30 2010 (r206966) +++ stable/8/sys/dev/siba/siba_bwn.c Wed Apr 21 00:13:44 2010 (r206967) @@ -97,8 +97,6 @@ static const struct siba_dev { { PCI_VENDOR_BROADCOM, 0x432b, "Unknown" } }; -device_t siba_add_child(device_t, struct siba_softc *, int, const char *, - int); int siba_core_attach(struct siba_softc *); int siba_core_detach(struct siba_softc *); int siba_core_suspend(struct siba_softc *); @@ -238,15 +236,6 @@ siba_bwn_resume(device_t dev) return (0); } -static device_t -siba_bwn_add_child(device_t dev, int order, const char *name, int unit) -{ - struct siba_bwn_softc *ssc = device_get_softc(dev); - struct siba_softc *siba = &ssc->ssc_siba; - - return (siba_add_child(dev, siba, order, name, unit)); -} - /* proxying to the parent */ static struct resource * siba_bwn_alloc_resource(device_t dev, device_t child, int type, int *rid, @@ -342,7 +331,6 @@ static device_method_t siba_bwn_methods[ DEVMETHOD(device_resume, siba_bwn_resume), /* Bus interface */ - DEVMETHOD(bus_add_child, siba_bwn_add_child), DEVMETHOD(bus_alloc_resource, siba_bwn_alloc_resource), DEVMETHOD(bus_release_resource, siba_bwn_release_resource), DEVMETHOD(bus_setup_intr, siba_bwn_setup_intr), Modified: stable/8/sys/dev/siba/siba_core.c ============================================================================== --- stable/8/sys/dev/siba/siba_core.c Wed Apr 21 00:10:30 2010 (r206966) +++ stable/8/sys/dev/siba/siba_core.c Wed Apr 21 00:13:44 2010 (r206967) @@ -133,8 +133,6 @@ static void siba_pci_write_multi_4(struc size_t, uint16_t); static const char *siba_core_name(uint16_t); static void siba_pcicore_init(struct siba_pci *); -device_t siba_add_child(device_t, struct siba_softc *, int, const char *, - int); int siba_core_attach(struct siba_softc *); int siba_core_detach(struct siba_softc *); int siba_core_suspend(struct siba_softc *); @@ -206,8 +204,10 @@ siba_core_attach(struct siba_softc *siba return (error); } + siba_pcicore_init(&siba->siba_pci); siba_powerdown(siba); - return (0); + + return (bus_generic_attach(siba->siba_dev)); } int @@ -277,6 +277,7 @@ siba_scan(struct siba_softc *siba) { struct siba_dev_softc *sd; uint32_t idhi, tmp; + device_t child; int base, dev_i = 0, error, i, is_pcie, n_80211 = 0, n_cc = 0, n_pci = 0; @@ -387,6 +388,14 @@ siba_scan(struct siba_softc *siba) break; } dev_i++; + + child = device_add_child(siba->siba_dev, NULL, -1); + if (child == NULL) { + device_printf(siba->siba_dev, "child attach failed\n"); + continue; + } + + device_set_ivars(child, sd); } siba->siba_ndevs = dev_i; } @@ -1964,52 +1973,6 @@ siba_barrier(struct siba_dev_softc *sd, SIBA_BARRIER(siba, flags); } -/* - * Attach it as child. - */ -device_t -siba_add_child(device_t dev, struct siba_softc *siba, int order, - const char *name, int unit) -{ - struct siba_dev_softc *sd; - device_t child; - int idx = 0, i; - - child = device_add_child(dev, name, unit); - if (child == NULL) - return (NULL); - - siba_powerup(siba, 0); - siba_pcicore_init(&siba->siba_pci); - siba_powerdown(siba); - - for (i = 0; i < siba->siba_ndevs; i++) { - sd = &(siba->siba_devs[i]); - - if (sd->sd_id.sd_device != SIBA_DEVID_80211) { - DPRINTF(siba, SIBA_DEBUG_CORE, - "skip to register coreid %#x (%s)\n", - sd->sd_id.sd_device, - siba_core_name(sd->sd_id.sd_device)); - continue; - } - - DPRINTF(siba, SIBA_DEBUG_CORE, - "siba: attaching coreid %#x (%s) idx %d\n", - sd->sd_id.sd_device, - siba_core_name(sd->sd_id.sd_device), idx); - - KASSERT(sd->sd_id.sd_device == SIBA_DEVID_80211, - ("%s:%d: SIBA_DEVID_80211 is only supportted currently.", - __func__, __LINE__)); - - device_set_ivars(child, sd); - device_probe_and_attach(child); - idx++; - } - return (child); -} - static void siba_cc_suspend(struct siba_cc *scc) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004210013.o3L0DiE0087711>