diff options
author | Marcus Glocker <mglocker@cvs.openbsd.org> | 2007-01-05 10:17:33 +0000 |
---|---|---|
committer | Marcus Glocker <mglocker@cvs.openbsd.org> | 2007-01-05 10:17:33 +0000 |
commit | 779c7c89790ef336f10f3322b892269848134f1e (patch) | |
tree | ab80a1e8494b92ab57223d6a5cd005f12e6fe848 /sys | |
parent | 06d101cc84dc35c14cfb445fb999268e6e9be9ce (diff) |
Make the upload of initialization values work again, after implementing
the single firmware file.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/ic/bcw.c | 58 |
1 files changed, 32 insertions, 26 deletions
diff --git a/sys/dev/ic/bcw.c b/sys/dev/ic/bcw.c index 22750160a24..0ba6a917475 100644 --- a/sys/dev/ic/bcw.c +++ b/sys/dev/ic/bcw.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bcw.c,v 1.26 2007/01/05 07:09:15 mglocker Exp $ */ +/* $OpenBSD: bcw.c,v 1.27 2007/01/05 10:17:32 mglocker Exp $ */ /* * Copyright (c) 2006 Jon Simola <jsimola@gmail.com> @@ -1150,8 +1150,6 @@ bcw_init(struct ifnet *ifp) return (1); } - return (0); - /* load init values */ if ((error = bcw_load_initvals(sc))) return (error); @@ -2387,11 +2385,20 @@ bcw_load_initvals(struct bcw_softc *sc) int rev = sc->sc_core[sc->sc_currentcore].rev; int error, nr; uint32_t val; - uint8_t *initval0, *initval1; - size_t size_initval0, size_initval1; - char name[32]; + uint8_t *ucode; + size_t size_ucode, size_ival0, size_ival1, off_ival0, off_ival1; + char *name = "bcw-bcm43xx"; + char filename[64]; + + /* load firmware */ + if ((error = loadfirmware(name, &ucode, &size_ucode)) != 0) { + printf("%s: error %d, could not read initval0 %s!\n", + sc->sc_dev.dv_xname, error, name); + return (EIO); + } + DPRINTF(("%s: successfully read %s\n", sc->sc_dev.dv_xname, name)); - /* read initval0 file */ + /* get initval0 file offset */ if (rev == 2 || rev == 4) { switch (sc->sc_phy_type) { case BCW_PHY_TYPEA: @@ -2419,16 +2426,15 @@ bcw_load_initvals(struct bcw_softc *sc) } else goto bad_noinitval; - snprintf(name, sizeof(name), "bcm43xx_initval%02d.fw", nr); + snprintf(filename, sizeof(filename), "bcm43xx_initval%02d.fw", nr); - if ((error = loadfirmware(name, &initval0, &size_initval0)) != 0) { - printf("%s: error %d, could not read initval0 %s!\n", - sc->sc_dev.dv_xname, error, name); + if (bcw_get_firmware(filename, ucode, &size_ival0, &off_ival0) != 0) { + printf("%s: getting initval0 file %s failed\n", + sc->sc_dev.dv_xname, filename); return (EIO); } - DPRINTF(("%s: successfully read %s\n", sc->sc_dev.dv_xname, name)); - /* read initval1 file */ + /* get initval1 file offset */ if (rev >= 5) { switch (sc->sc_phy_type) { case BCW_PHY_TYPEA: @@ -2446,34 +2452,34 @@ bcw_load_initvals(struct bcw_softc *sc) goto bad_noinitval; } - snprintf(name, sizeof(name), "bcm43xx_initval%02d.fw", nr); + snprintf(filename, sizeof(filename), "bcm43xx_initval%02d.fw", + nr); - if ((error = loadfirmware(name, &initval1, &size_initval1)) + if (bcw_get_firmware(filename, ucode, &size_ival1, &off_ival1) != 0) { - printf("%s: error %d, could not read initval1 %s\n", - sc->sc_dev.dv_xname, error, name); + printf("%s: getting initval1 file %s failed\n", + sc->sc_dev.dv_xname, filename); return (EIO); } - DPRINTF(("%s: successfully read %s\n", sc->sc_dev.dv_xname, - name)); } /* upload initval0 */ - if (bcw_write_initvals(sc, (struct bcw_initval *)initval0, - size_initval0 / sizeof(struct bcw_initval))) + if (bcw_write_initvals(sc, (struct bcw_initval *)(ucode + off_ival0), + size_ival0 / sizeof(struct bcw_initval))) return (EIO); DPRINTF(("%s: uploaded initval0\n", sc->sc_dev.dv_xname)); - free(initval0, M_DEVBUF); /* upload initval1 */ - if (initval1 != NULL) { - if (bcw_write_initvals(sc, (struct bcw_initval *)initval1, - size_initval1 / sizeof(struct bcw_initval))) + if (off_ival1 != 0) { + if (bcw_write_initvals(sc, + (struct bcw_initval *)(ucode + off_ival1), + size_ival1 / sizeof(struct bcw_initval))) return (EIO); DPRINTF(("%s: uploaded initval1\n", sc->sc_dev.dv_xname)); - free(initval1, M_DEVBUF); } + free(ucode, M_DEVBUF); + return (0); bad_noinitval: |