libertas: endianness fixes
authorHolger Schurig <hs4233@mail.mn-solutions.de>
Fri, 7 Dec 2007 15:30:44 +0000 (15:30 +0000)
committerDavid S. Miller <davem@davemloft.net>
Mon, 28 Jan 2008 23:06:13 +0000 (15:06 -0800)
Recently I found that that sparse by default doesn't endianness
checks. So I changed my compilation habit to be

make modules C=1 SUBDIRS=drivers/net/wireless/libertas
CHECKFLAGS="-D__CHECK_ENDIAN__"

so that I get the little-endian checks from sparse as well. That
showed up a good bunch of problems.

Signed-off-by: Holger Schurig <hs4233@mail.mn-solutions.de>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/libertas/11d.c
drivers/net/wireless/libertas/cmd.c
drivers/net/wireless/libertas/cmdresp.c
drivers/net/wireless/libertas/hostcmd.h
drivers/net/wireless/libertas/if_sdio.c
drivers/net/wireless/libertas/if_usb.c

index 377dcb5b8f0ca6be329d833f7709efe8c3992351..013965d4051920e2fbf3bec7dfbcf68add03f7d1 100644 (file)
@@ -518,7 +518,7 @@ int lbs_cmd_802_11d_domain_info(struct lbs_private *priv,
                cmd->size =
                    cpu_to_le16(sizeof(pdomaininfo->action) + S_DS_GEN);
                lbs_deb_hex(LBS_DEB_11D, "802_11D_DOMAIN_INFO", (u8 *) cmd,
-                       (int)(cmd->size));
+                       le16_to_cpu(cmd->size));
                goto done;
        }
 
index ebfcb7bac68166bec077fa5d4bcdcd30a9893695..cf1ab8a345fe96cd60bdccf6f9cce47e8ea04aa9 100644 (file)
@@ -431,7 +431,7 @@ static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv,
                u8 mode = (u8) (size_t) pdata_buf;
                pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
                pSNMPMIB->oid = cpu_to_le16((u16) DESIRED_BSSTYPE_I);
-               pSNMPMIB->bufsize = sizeof(u8);
+               pSNMPMIB->bufsize = cpu_to_le16(sizeof(u8));
                if (mode == IW_MODE_ADHOC) {
                        ucTemp = SNMP_MIB_VALUE_ADHOC;
                } else {
@@ -451,8 +451,8 @@ static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv,
                        pSNMPMIB->oid = cpu_to_le16((u16) DOT11D_I);
 
                        if (cmd_action == CMD_ACT_SET) {
-                               pSNMPMIB->querytype = CMD_ACT_SET;
-                               pSNMPMIB->bufsize = sizeof(u16);
+                               pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_SET);
+                               pSNMPMIB->bufsize = cpu_to_le16(sizeof(u16));
                                ulTemp = *(u32 *)pdata_buf;
                                *((__le16 *)(pSNMPMIB->value)) =
                                    cpu_to_le16((u16) ulTemp);
@@ -484,7 +484,7 @@ static int lbs_cmd_802_11_snmp_mib(struct lbs_private *priv,
                {
 
                        u32 ulTemp;
-                       pSNMPMIB->oid = le16_to_cpu((u16) RTSTHRESH_I);
+                       pSNMPMIB->oid = cpu_to_le16(RTSTHRESH_I);
 
                        if (cmd_action == CMD_ACT_GET) {
                                pSNMPMIB->querytype = cpu_to_le16(CMD_ACT_GET);
@@ -759,7 +759,7 @@ static int lbs_cmd_reg_access(struct lbs_private *priv,
 
        offval = (struct lbs_offset_value *)pdata_buf;
 
-       switch (cmdptr->command) {
+       switch (le16_to_cpu(cmdptr->command)) {
        case CMD_MAC_REG_ACCESS:
                {
                        struct cmd_ds_mac_reg_access *macreg;
@@ -999,7 +999,7 @@ void lbs_queue_cmd(struct lbs_adapter *adapter,
        }
 
        /* Exit_PS command needs to be queued in the header always. */
-       if (cmdptr->command == CMD_802_11_PS_MODE) {
+       if (le16_to_cpu(cmdptr->command) == CMD_802_11_PS_MODE) {
                struct cmd_ds_802_11_ps_mode *psm = &cmdptr->params.psmode;
                if (psm->action == cpu_to_le16(CMD_SUBCMD_EXIT_PS)) {
                        if (adapter->psstate != PS_STATE_FULL_POWER)
@@ -1062,15 +1062,14 @@ static int DownloadcommandToStation(struct lbs_private *priv,
        adapter->cur_cmd_retcode = 0;
        spin_unlock_irqrestore(&adapter->driver_lock, flags);
 
-       cmdsize = cmdptr->size;
-       command = cpu_to_le16(cmdptr->command);
+       cmdsize = le16_to_cpu(cmdptr->size);
+       command = le16_to_cpu(cmdptr->command);
 
        lbs_deb_host("DNLD_CMD: command 0x%04x, size %d, jiffies %lu\n",
-                   command, le16_to_cpu(cmdptr->size), jiffies);
+                   command, cmdsize, jiffies);
        lbs_deb_hex(LBS_DEB_HOST, "DNLD_CMD", cmdnode->bufvirtualaddr, cmdsize);
 
        cmdnode->cmdwaitqwoken = 0;
-       cmdsize = cpu_to_le16(cmdsize);
 
        ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmdptr, cmdsize);
 
@@ -1426,9 +1425,10 @@ int lbs_prepare_and_send_command(struct lbs_private *priv,
 
 #define ACTION_NUMLED_TLVTYPE_LEN_FIELDS_LEN 8
                        cmdptr->size =
-                           cpu_to_le16(gpio->header.len + S_DS_GEN +
-                                            ACTION_NUMLED_TLVTYPE_LEN_FIELDS_LEN);
-                       gpio->header.len = cpu_to_le16(gpio->header.len);
+                           cpu_to_le16(le16_to_cpu(gpio->header.len)
+                               + S_DS_GEN
+                               + ACTION_NUMLED_TLVTYPE_LEN_FIELDS_LEN);
+                       gpio->header.len = gpio->header.len;
 
                        ret = 0;
                        break;
@@ -2019,7 +2019,7 @@ static int lbs_cmd_callback(uint16_t respcmd, struct cmd_ds_command *resp, struc
 { 
        struct cmd_ds_gen *r = (struct cmd_ds_gen *)resp;
        struct lbs_adapter *adapter = priv->adapter;
-       u16 sz = cpu_to_le16(resp->size) - S_DS_GEN;
+       u16 sz = le16_to_cpu(resp->size) - S_DS_GEN;
 
        if (sz > *adapter->cur_cmd->pdata_size) {
                lbs_pr_err("response 0x%04x doesn't fit into buffer (%d > %d)\n",
index 20ca38c7f87076cd93d04a973ffc599ca3e00c0c..f6c1016b2bb6f8ec5be42716527c3df5f56d39cb 100644 (file)
@@ -561,7 +561,7 @@ static int lbs_ret_802_11_subscribe_event(struct lbs_private *priv,
        lbs_deb_enter(LBS_DEB_CMD);
 
        if (dst_event->action == cpu_to_le16(CMD_ACT_GET)) {
-               dst_event->events = le16_to_cpu(cmd_event->events);
+               dst_event->events = cmd_event->events;
                memcpy(dst_event->tlv, cmd_event->tlv, sizeof(dst_event->tlv));
        }
 
index 5ef65ae0de5ad5f3b11e9ea98b8f7ad7e50806f3..efdb720d9fe77b4c6f1da302fd82ee86e217dafc 100644 (file)
@@ -419,13 +419,13 @@ struct cmd_ds_802_11_rf_antenna {
 };
 
 struct cmd_ds_802_11_monitor_mode {
-       u16 action;
-       u16 mode;
+       __le16 action;
+       __le16 mode;
 };
 
 struct cmd_ds_set_boot2_ver {
-       u16 action;
-       u16 version;
+       __le16 action;
+       __le16 version;
 };
 
 struct cmd_ds_802_11_ps_mode {
index cccca311f75bb77ef0a5ea721d1041da8a1d99a8..181ebf0fc0df3a7a27fc4dee7993d2747861879a 100644 (file)
@@ -454,7 +454,7 @@ static int if_sdio_prog_helper(struct if_sdio_card *card)
 
                chunk_size = min(size, (size_t)60);
 
-               *((u32*)chunk_buffer) = cpu_to_le32(chunk_size);
+               *((__le32*)chunk_buffer) = cpu_to_le32(chunk_size);
                memcpy(chunk_buffer + 4, firmware, chunk_size);
 /*
                lbs_deb_sdio("sending %d bytes chunk\n", chunk_size);
index e9190a6a1dcf254846a44e51e7ec7b0827de4adf..a17371fe2fe400d5a15ec7493b94b45540b6123e 100644 (file)
@@ -107,7 +107,7 @@ static void if_usb_set_boot2_ver(struct lbs_private *priv)
        int rsp_len = sizeof(b2_cmd);
 
        b2_cmd.action = 0;
-       b2_cmd.version = cpu_to_le16(priv->boot2_version);
+       b2_cmd.version = priv->boot2_version;
 
        if (lbs_cmd(priv, CMD_SET_BOOT2_VER, &b2_cmd, sizeof(b2_cmd),
                    &b2_cmd, &rsp_len)) {
@@ -227,7 +227,7 @@ static int if_usb_probe(struct usb_interface *intf,
        priv->hw_host_to_card = if_usb_host_to_card;
        priv->hw_get_int_status = if_usb_get_int_status;
        priv->hw_read_event_cause = if_usb_read_event_cause;
-       priv->boot2_version = le16_to_cpu(udev->descriptor.bcdDevice);
+       priv->boot2_version = udev->descriptor.bcdDevice;
 
        /* Delay 200 ms to waiting for the FW ready */
        if_usb_submit_rx_urb(cardp);