svn commit: r204657 - in head/sys/dev: bwn siba

Weongyo Jeong weongyo at FreeBSD.org
Wed Mar 3 20:06:10 UTC 2010


Author: weongyo
Date: Wed Mar  3 20:06:09 2010
New Revision: 204657
URL: http://svn.freebsd.org/changeset/base/204657

Log:
  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:
  head/sys/dev/bwn/if_bwn.c
  head/sys/dev/siba/siba_bwn.c
  head/sys/dev/siba/siba_core.c

Modified: head/sys/dev/bwn/if_bwn.c
==============================================================================
--- head/sys/dev/bwn/if_bwn.c	Wed Mar  3 20:01:31 2010	(r204656)
+++ head/sys/dev/bwn/if_bwn.c	Wed Mar  3 20:06:09 2010	(r204657)
@@ -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: head/sys/dev/siba/siba_bwn.c
==============================================================================
--- head/sys/dev/siba/siba_bwn.c	Wed Mar  3 20:01:31 2010	(r204656)
+++ head/sys/dev/siba/siba_bwn.c	Wed Mar  3 20:06:09 2010	(r204657)
@@ -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: head/sys/dev/siba/siba_core.c
==============================================================================
--- head/sys/dev/siba/siba_core.c	Wed Mar  3 20:01:31 2010	(r204656)
+++ head/sys/dev/siba/siba_core.c	Wed Mar  3 20:06:09 2010	(r204657)
@@ -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)
 {


More information about the svn-src-head mailing list