Date: Thu, 26 Jan 2012 02:05:12 GMT From: Justin Hibbits <jrh29@alumni.cwru.edu> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/164499: if_wi needs fix for big endian architectures. Message-ID: <201201260205.q0Q25CU4047488@red.freebsd.org> Resent-Message-ID: <201201260210.q0Q2A1cZ092948@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 164499 >Category: kern >Synopsis: if_wi needs fix for big endian architectures. >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Jan 26 02:10:01 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Justin Hibbits >Release: CURRENT >Organization: >Environment: >Description: if_wi(4) byte-swaps twice on big endian when reading from the device. The attached patch fixes this by calling the streaming read. Patch discussed with adrian@. >How-To-Repeat: >Fix: Patch attached with submission follows: Index: sys/dev/wi/if_wi.c =================================================================== --- sys/dev/wi/if_wi.c (revision 230483) +++ sys/dev/wi/if_wi.c (working copy) @@ -1898,8 +1898,7 @@ static int wi_read_bap(struct wi_softc *sc, int id, int off, void *buf, int buflen) { - u_int16_t *ptr; - int i, error, cnt; + int error, cnt; if (buflen == 0) return 0; @@ -1908,9 +1907,7 @@ return error; } cnt = (buflen + 1) / 2; - ptr = (u_int16_t *)buf; - for (i = 0; i < cnt; i++) - *ptr++ = CSR_READ_2(sc, WI_DATA0); + CSR_READ_MULTI_STREAM_2(sc, WI_DATA0, (u_int16_t *)buf, cnt); sc->sc_bap_off += cnt * 2; return 0; } @@ -1918,8 +1915,7 @@ static int wi_write_bap(struct wi_softc *sc, int id, int off, void *buf, int buflen) { - u_int16_t *ptr; - int i, error, cnt; + int error, cnt; if (buflen == 0) return 0; @@ -1929,9 +1925,7 @@ return error; } cnt = (buflen + 1) / 2; - ptr = (u_int16_t *)buf; - for (i = 0; i < cnt; i++) - CSR_WRITE_2(sc, WI_DATA0, ptr[i]); + CSR_WRITE_MULTI_STREAM_2(sc, WI_DATA0, (u_int16_t *)buf, cnt); sc->sc_bap_off += cnt * 2; return 0; >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201260205.q0Q25CU4047488>