Fix byteswap errors in rtwn(4) and urtwn(4) introduced by me on June 17.
authorstsp <stsp@openbsd.org>
Tue, 26 Jul 2016 13:00:28 +0000 (13:00 +0000)
committerstsp <stsp@openbsd.org>
Tue, 26 Jul 2016 13:00:28 +0000 (13:00 +0000)
Repairs urtwn(4) on macppc. Problem reported by juanfra@.
ok millert@ deraadt@

sys/dev/ic/rtwn.c
sys/dev/pci/if_rtwn.c

index 314819a..ee4e5b3 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: rtwn.c,v 1.9 2016/06/17 10:53:55 stsp Exp $   */
+/*     $OpenBSD: rtwn.c,v 1.10 2016/07/26 13:00:28 stsp Exp $  */
 
 /*-
  * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -297,14 +297,12 @@ rtwn_write_1(struct rtwn_softc *sc, uint16_t addr, uint8_t val)
 void
 rtwn_write_2(struct rtwn_softc *sc, uint16_t addr, uint16_t val)
 {
-       val = htole16(val);
        sc->sc_ops.write_2(sc->sc_ops.cookie, addr, val);
 }
 
 void
 rtwn_write_4(struct rtwn_softc *sc, uint16_t addr, uint32_t val)
 {
-       val = htole32(val);
        sc->sc_ops.write_4(sc->sc_ops.cookie, addr, val);
 }
 
@@ -687,13 +685,11 @@ rtwn_ra_init(struct rtwn_softc *sc)
                /* Configure Automatic Rate Fallback Register. */
                if (ic->ic_curmode == IEEE80211_MODE_11B) {
                        if (rates & 0x0c)
-                               rtwn_write_4(sc, R92C_ARFR(0),
-                                   htole32(rates & 0x0d));
+                               rtwn_write_4(sc, R92C_ARFR(0), rates & 0x0d);
                        else
-                               rtwn_write_4(sc, R92C_ARFR(0),
-                                   htole32(rates & 0x0f));
+                               rtwn_write_4(sc, R92C_ARFR(0), rates & 0x0f);
                } else
-                       rtwn_write_4(sc, R92C_ARFR(0), htole32(rates & 0x0ff5));
+                       rtwn_write_4(sc, R92C_ARFR(0), rates & 0x0ff5);
        }
 
        if (sc->chip & RTWN_CHIP_88E)
index a50eec5..93d6abe 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: if_rtwn.c,v 1.23 2016/07/21 08:38:33 stsp Exp $       */
+/*     $OpenBSD: if_rtwn.c,v 1.24 2016/07/26 13:00:28 stsp Exp $       */
 
 /*-
  * Copyright (c) 2010 Damien Bergamini <damien.bergamini@free.fr>
@@ -742,16 +742,20 @@ uint16_t
 rtwn_pci_read_2(void *cookie, uint16_t addr)
 {
        struct rtwn_pci_softc *sc = cookie;
+       uint16_t val;
 
-       return bus_space_read_2(sc->sc_st, sc->sc_sh, addr);
+       val = bus_space_read_2(sc->sc_st, sc->sc_sh, addr);
+       return le16toh(val);
 }
 
 uint32_t
 rtwn_pci_read_4(void *cookie, uint16_t addr)
 {
        struct rtwn_pci_softc *sc = cookie;
+       uint32_t val;
 
-       return bus_space_read_4(sc->sc_st, sc->sc_sh, addr);
+       val = bus_space_read_4(sc->sc_st, sc->sc_sh, addr);
+       return le32toh(val);
 }
 
 void