>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:
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-bugs
To unsubscribe, send any mail to "[email protected]"

Reply via email to