Date: Thu, 28 Jan 2010 22:46:04 +0000 (UTC) From: Andrew Thompson <thompsa@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r203137 - head/sys/dev/usb/wlan Message-ID: <201001282246.o0SMk4oZ075502@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: thompsa Date: Thu Jan 28 22:46:04 2010 New Revision: 203137 URL: http://svn.freebsd.org/changeset/base/203137 Log: Release the firmware after loading to the device. Modified: head/sys/dev/usb/wlan/if_run.c head/sys/dev/usb/wlan/if_runvar.h Modified: head/sys/dev/usb/wlan/if_run.c ============================================================================== --- head/sys/dev/usb/wlan/if_run.c Thu Jan 28 22:28:59 2010 (r203136) +++ head/sys/dev/usb/wlan/if_run.c Thu Jan 28 22:46:04 2010 (r203137) @@ -803,22 +803,25 @@ int run_load_microcode(struct run_softc *sc) { usb_device_request_t req; + const struct firmware *fw; const u_char *base; uint32_t tmp; int ntries, error; const uint64_t *temp; uint64_t bytes; - if((sc->fwp = firmware_get("runfw")) == NULL){ + fw = firmware_get("runfw"); + if(fw == NULL){ printf("%s: failed loadfirmware of file %s (error %d)\n", device_get_nameunit(sc->sc_dev), "runfw", ENOENT); return ENOENT; } - if (sc->fwp->datasize != 8192) { + if (fw->datasize != 8192) { printf("%s: invalid firmware size (should be 8KB)\n", device_get_nameunit(sc->sc_dev)); - return EINVAL; + error = EINVAL; + goto fail; } /* @@ -827,7 +830,7 @@ run_load_microcode(struct run_softc *sc) * first half (4KB) is for rt2870, * last half is for rt3071. */ - base = sc->fwp->data; + base = fw->data; if ((sc->mac_rev >> 16) != 0x2860 && (sc->mac_rev >> 16) != 0x2872 && (sc->mac_rev >> 16) != 0x3070 && @@ -840,10 +843,14 @@ run_load_microcode(struct run_softc *sc) device_get_nameunit(sc->sc_dev)); /* cheap sanity check */ - temp = sc->fwp->data; + temp = fw->data; bytes = *temp; - if(bytes != be64toh(0xffffff0210280210)) - return EINVAL; + if(bytes != be64toh(0xffffff0210280210)) { + printf("%s: firmware checksum failed\n", + device_get_nameunit(sc->sc_dev)); + error = EINVAL; + goto fail; + } run_read(sc, RT2860_ASIC_VER_ID, &tmp); /* write microcode image */ @@ -856,19 +863,23 @@ run_load_microcode(struct run_softc *sc) USETW(req.wValue, 8); USETW(req.wIndex, 0); USETW(req.wLength, 0); - if ((error = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL)) != 0) - return error; + if ((error = usbd_do_request(sc->sc_udev, &sc->sc_mtx, &req, NULL)) != 0) { + printf("%s: firmware reset failed\n", + device_get_nameunit(sc->sc_dev)); + goto fail; + } run_delay(sc, 10); run_write(sc, RT2860_H2M_MAILBOX, 0); if ((error = run_mcu_cmd(sc, RT2860_MCU_CMD_BOOT, 0)) != 0) - return error; + goto fail; /* wait until microcontroller is ready */ for (ntries = 0; ntries < 1000; ntries++) { - if ((error = run_read(sc, RT2860_SYS_CTRL, &tmp)) != 0) - return error; + if ((error = run_read(sc, RT2860_SYS_CTRL, &tmp)) != 0) { + goto fail; + } if (tmp & RT2860_MCU_READY) break; run_delay(sc, 10); @@ -876,11 +887,14 @@ run_load_microcode(struct run_softc *sc) if (ntries == 1000) { printf("%s: timeout waiting for MCU to initialize\n", device_get_nameunit(sc->sc_dev)); - return ETIMEDOUT; + error = ETIMEDOUT; + goto fail; } DPRINTF("microcode successfully loaded after %d tries\n", ntries); - return 0; +fail: + firmware_put(fw, FIRMWARE_UNLOAD); + return (error); } int Modified: head/sys/dev/usb/wlan/if_runvar.h ============================================================================== --- head/sys/dev/usb/wlan/if_runvar.h Thu Jan 28 22:28:59 2010 (r203136) +++ head/sys/dev/usb/wlan/if_runvar.h Thu Jan 28 22:46:04 2010 (r203137) @@ -154,8 +154,6 @@ struct run_softc { int (*sc_srom_read)(struct run_softc *, uint16_t, uint16_t *); - const struct firmware *fwp; - uint32_t mac_rev; uint8_t rf_rev; uint8_t freq;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201001282246.o0SMk4oZ075502>