Module Name: src Committed By: tsutsui Date: Sun Jul 4 15:38:27 UTC 2010
Modified Files: src/sys/dev/usb: if_zyd.c Log Message: Make zyd(4) use config_mountroot(9) to complete device initialization (which requires firmload(9)) right after mountroot. Now it's attached on boot as following: --- uhub4 at usb4: vendor 0x1033 EHCI root hub, class 9/0, rev 2.00/1.00, addr 1 uhub4: 5 ports with 5 removable, self powered : zyd0 at uhub4 port 4 zyd0: PCI PCI GW-US54GXS, rev 2.00/48.10, addr 3 : boot device: wd0 root on wd0a dumps on wd0b root file system type: ffs zyd0: HMAC ZD1211B, FW 47.25, RF AL2230, PA 0, address 00:22:cf:xx:xx:xx zyd0: 11b rates: 1Mbps 2Mbps 5.5Mbps 11Mbps zyd0: 11g rates: 1Mbps 2Mbps 5.5Mbps 11Mbps 6Mbps 9Mbps 12Mbps 18Mbps 24Mbps 36Mbps 48Mbps 54Mbps : --- Should close PR kern/43125, no particular objections in that PR. To generate a diff of this commit: cvs rdiff -u -r1.25 -r1.26 src/sys/dev/usb/if_zyd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/usb/if_zyd.c diff -u src/sys/dev/usb/if_zyd.c:1.25 src/sys/dev/usb/if_zyd.c:1.26 --- src/sys/dev/usb/if_zyd.c:1.25 Mon Apr 5 07:21:49 2010 +++ src/sys/dev/usb/if_zyd.c Sun Jul 4 15:38:27 2010 @@ -1,5 +1,5 @@ /* $OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $ */ -/* $NetBSD: if_zyd.c,v 1.25 2010/04/05 07:21:49 joerg Exp $ */ +/* $NetBSD: if_zyd.c,v 1.26 2010/07/04 15:38:27 tsutsui Exp $ */ /*- * Copyright (c) 2006 by Damien Bergamini <damien.bergam...@free.fr> @@ -22,7 +22,7 @@ * ZyDAS ZD1211/ZD1211B USB WLAN driver. */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.25 2010/04/05 07:21:49 joerg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.26 2010/07/04 15:38:27 tsutsui Exp $"); #include <sys/param.h> @@ -156,7 +156,7 @@ CFATTACH_DECL_NEW(zyd, sizeof(struct zyd_softc), zyd_match, zyd_attach, zyd_detach, zyd_activate); -Static int zyd_attachhook(void *); +Static void zyd_attachhook(device_t); Static int zyd_complete_attach(struct zyd_softc *); Static int zyd_open_pipes(struct zyd_softc *); Static void zyd_close_pipes(struct zyd_softc *); @@ -245,10 +245,10 @@ UMATCH_VENDOR_PRODUCT : UMATCH_NONE; } -Static int -zyd_attachhook(void *xsc) +Static void +zyd_attachhook(device_t self) { - struct zyd_softc *sc = xsc; + struct zyd_softc *sc = device_private(self); firmware_handle_t fwh; const char *fwname; u_char *fw; @@ -259,7 +259,7 @@ if ((error = firmware_open("zyd", fwname, &fwh)) != 0) { aprint_error_dev(sc->sc_dev, "failed to open firmware %s (error=%d)\n", fwname, error); - return error; + return; } size = firmware_get_size(fwh); fw = firmware_malloc(size); @@ -267,7 +267,7 @@ aprint_error_dev(sc->sc_dev, "failed to allocate firmware memory\n"); firmware_close(fwh); - return ENOMEM; + return; } error = firmware_read(fwh, 0, fw, size); firmware_close(fwh); @@ -275,7 +275,7 @@ aprint_error_dev(sc->sc_dev, "failed to read firmware (error %d)\n", error); firmware_free(fw, 0); - return error; + return; } error = zyd_loadfirmware(sc, fw, size); @@ -283,7 +283,7 @@ aprint_error_dev(sc->sc_dev, "could not load firmware (error=%d)\n", error); firmware_free(fw, 0); - return ENXIO; + return; } firmware_free(fw, 0); @@ -292,7 +292,7 @@ /* complete the attach process */ if ((error = zyd_complete_attach(sc)) == 0) sc->attached = 1; - return error; + return; } void @@ -334,13 +334,10 @@ IFQ_SET_READY(&ifp->if_snd); memcpy(ifp->if_xname, device_xname(sc->sc_dev), IFNAMSIZ); - if_attach(ifp); - /* XXXX: alloc temporarily until the layer2 can be configured. */ - if_alloc_sadl(ifp); - SIMPLEQ_INIT(&sc->sc_rqh); - return; + /* defer configrations after file system is ready to load firmware */ + config_mountroot(self, zyd_attachhook); } Static int @@ -424,7 +421,7 @@ IEEE80211_CHAN_DYN | IEEE80211_CHAN_2GHZ; } - if_free_sadl(ifp); + if_attach(ifp); ieee80211_ifattach(ic); ic->ic_node_alloc = zyd_node_alloc; ic->ic_newassoc = zyd_newassoc; @@ -461,11 +458,8 @@ struct ifnet *ifp = &sc->sc_if; int s; - if (!sc->attached) { - if_free_sadl(ifp); - if_detach(ifp); + if (!sc->attached) return 0; - } s = splusb(); @@ -2450,10 +2444,6 @@ struct ieee80211com *ic = &sc->sc_ic; int i, error; - if ((sc->sc_flags & ZD1211_FWLOADED) == 0) - if ((error = zyd_attachhook(sc)) != 0) - return error; - zyd_stop(ifp, 0); IEEE80211_ADDR_COPY(ic->ic_myaddr, CLLADDR(ifp->if_sadl));