Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/pci Unbreak the endian issue in firmware header deco...



details:   https://anonhg.NetBSD.org/src/rev/843d59ac231a
branches:  trunk
changeset: 778261:843d59ac231a
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Wed Mar 21 00:29:39 2012 +0000

description:
Unbreak the endian issue in firmware header decoding. Comfirmed good and
running by a powerpc machine.

diffstat:

 sys/dev/pci/if_iwi.c |  25 ++++++++++++++-----------
 1 files changed, 14 insertions(+), 11 deletions(-)

diffs (62 lines):

diff -r aeaafcb6fd07 -r 843d59ac231a sys/dev/pci/if_iwi.c
--- a/sys/dev/pci/if_iwi.c      Tue Mar 20 23:57:57 2012 +0000
+++ b/sys/dev/pci/if_iwi.c      Wed Mar 21 00:29:39 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_iwi.c,v 1.89 2012/01/30 19:41:20 drochner Exp $  */
+/*     $NetBSD: if_iwi.c,v 1.90 2012/03/21 00:29:39 nisimura Exp $  */
 /*     $OpenBSD: if_iwi.c,v 1.111 2010/11/15 19:11:57 damien Exp $     */
 
 /*-
@@ -19,7 +19,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.89 2012/01/30 19:41:20 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_iwi.c,v 1.90 2012/03/21 00:29:39 nisimura Exp $");
 
 /*-
  * Intel(R) PRO/Wireless 2200BG/2225BG/2915ABG driver
@@ -2154,7 +2154,7 @@
 {
        struct iwi_firmware *kfw = &sc->fw;
        firmware_handle_t fwh;
-       const struct iwi_firmware_hdr *hdr;
+       struct iwi_firmware_hdr *hdr;
        off_t size;     
        char *fw;
        int error;
@@ -2192,8 +2192,12 @@
        if (error != 0)
                goto fail2;
 
-
-       hdr = (const struct iwi_firmware_hdr *)sc->sc_blob;
+       hdr = (struct iwi_firmware_hdr *)sc->sc_blob;
+       hdr->version = le32toh(hdr->version);
+       hdr->bsize = le32toh(hdr->bsize);
+       hdr->usize = le32toh(hdr->usize);
+       hdr->fsize = le32toh(hdr->fsize);
+
        if (size < sizeof(struct iwi_firmware_hdr) + hdr->bsize + hdr->usize + hdr->fsize) {
                aprint_error_dev(sc->sc_dev, "image '%s' too small\n",
                    sc->sc_fwname);
@@ -2201,14 +2205,13 @@
                goto fail2;
        }
 
-       hdr = (const struct iwi_firmware_hdr *)sc->sc_blob;
-       DPRINTF(("firmware version = %d\n", le32toh(hdr->version)));
-       if ((IWI_FW_GET_MAJOR(le32toh(hdr->version)) != IWI_FW_REQ_MAJOR) ||
-           (IWI_FW_GET_MINOR(le32toh(hdr->version)) != IWI_FW_REQ_MINOR)) {
+       DPRINTF(("firmware version = %d\n", hdr->version));
+       if ((IWI_FW_GET_MAJOR(hdr->version) != IWI_FW_REQ_MAJOR) ||
+           (IWI_FW_GET_MINOR(hdr->version) != IWI_FW_REQ_MINOR)) {
                aprint_error_dev(sc->sc_dev,
                    "version for '%s' %d.%d != %d.%d\n", sc->sc_fwname,
-                   IWI_FW_GET_MAJOR(le32toh(hdr->version)),
-                   IWI_FW_GET_MINOR(le32toh(hdr->version)),
+                   IWI_FW_GET_MAJOR(hdr->version),
+                   IWI_FW_GET_MINOR(hdr->version),
                    IWI_FW_REQ_MAJOR, IWI_FW_REQ_MINOR);
                error = EIO;
                goto fail2;



Home | Main Index | Thread Index | Old Index