staging: wilc1000: use kernel define byte order macros
authorGlen Lee <glen.lee@atmel.com>
Mon, 21 Dec 2015 05:18:08 +0000 (14:18 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Dec 2015 21:20:04 +0000 (13:20 -0800)
This patch removes define BIG_ENDIAN and use kernel define byte order macros
instead of swap itself. Remove unused BYTE_SWAP macro and __CHECK_ENDIAN__
in Makefile also.

Signed-off-by: Glen Lee <glen.lee@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/Makefile
drivers/staging/wilc1000/wilc_sdio.c
drivers/staging/wilc1000/wilc_spi.c
drivers/staging/wilc1000/wilc_wlan.c
drivers/staging/wilc1000/wilc_wlan.h
drivers/staging/wilc1000/wilc_wlan_cfg.c

index cd71be9ebc8c91f5abf87c7b020614938a84241f..207674376553e91badb5ea51246ee2ee902ce3a5 100644 (file)
@@ -4,7 +4,7 @@ ccflags-y += -DSTA_FIRMWARE=\"atmel/wilc1000_fw.bin\" \
                -DAP_FIRMWARE=\"atmel/wilc1000_ap_fw.bin\" \
                -DP2P_CONCURRENCY_FIRMWARE=\"atmel/wilc1000_p2p_fw.bin\"
 
-ccflags-y += -I$(src)/ -D__CHECK_ENDIAN__ -DWILC_ASIC_A0 -DWILC_DEBUGFS
+ccflags-y += -I$(src)/ -DWILC_ASIC_A0 -DWILC_DEBUGFS
 #ccflags-y += -DTCP_ACK_FILTER
 
 wilc1000-objs := wilc_wfi_cfgoperations.o linux_wlan.o linux_mon.o \
index ff7990a0b5ec9b80f40ab8ee0beb73491841b3dc..a9ad49f70d395ca607c42dcfe162e3b573c23cf3 100644 (file)
@@ -163,9 +163,7 @@ static int sdio_clear_int(struct wilc *wilc)
  ********************************************/
 static int sdio_write_reg(struct wilc *wilc, u32 addr, u32 data)
 {
-#ifdef BIG_ENDIAN
-       data = BYTE_SWAP(data);
-#endif
+       data = cpu_to_le32(data);
 
        if ((addr >= 0xf0) && (addr <= 0xff)) {
                sdio_cmd52_t cmd;
@@ -330,9 +328,7 @@ static int sdio_read_reg(struct wilc *wilc, u32 addr, u32 *data)
                }
        }
 
-#ifdef BIG_ENDIAN
-       *data = BYTE_SWAP(*data);
-#endif
+       *data = cpu_to_le32(*data);
 
        return 1;
 
index d6f412117fd87bd59c02bd3f632251c19007f6c5..c94d86f6cbeaa4735140abfa8481ab3d964d4109 100644 (file)
@@ -529,9 +529,7 @@ static int spi_internal_write(struct wilc *wilc, u32 adr, u32 dat)
 {
        int result;
 
-#ifdef BIG_ENDIAN
-       dat = BYTE_SWAP(dat);
-#endif
+       dat = cpu_to_le32(dat);
        result = spi_cmd_complete(wilc, CMD_INTERNAL_WRITE, adr, (u8 *)&dat, 4,
                                  0);
        if (result != N_OK) {
@@ -552,9 +550,7 @@ static int spi_internal_read(struct wilc *wilc, u32 adr, u32 *data)
                return 0;
        }
 
-#ifdef BIG_ENDIAN
-       *data = BYTE_SWAP(*data);
-#endif
+       *data = cpu_to_le32(*data);
 
        return 1;
 }
@@ -571,9 +567,7 @@ static int wilc_spi_write_reg(struct wilc *wilc, u32 addr, u32 data)
        u8 cmd = CMD_SINGLE_WRITE;
        u8 clockless = 0;
 
-#ifdef BIG_ENDIAN
-       data = BYTE_SWAP(data);
-#endif
+       data = cpu_to_le32(data);
        if (addr < 0x30) {
                /* Clockless register*/
                cmd = CMD_INTERNAL_WRITE;
@@ -635,9 +629,7 @@ static int wilc_spi_read_reg(struct wilc *wilc, u32 addr, u32 *data)
                return 0;
        }
 
-#ifdef BIG_ENDIAN
-       *data = BYTE_SWAP(*data);
-#endif
+       *data = cpu_to_le32(*data);
 
        return 1;
 }
index 27a44ee576cb30e5d27a553bc34ad31bcc39ebc6..a74a95e3830e427fc46a62fbd2ca5d0a2c6b6d85 100644 (file)
@@ -759,9 +759,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
                                        vmm_table[i] |= BIT(10);
                                        PRINT_D(TX_DBG, "VMMTable entry changed for CFG packet = %d\n", vmm_table[i]);
                                }
-#ifdef BIG_ENDIAN
-                               vmm_table[i] = BYTE_SWAP(vmm_table[i]);
-#endif
+                               vmm_table[i] = cpu_to_le32(vmm_table[i]);
 
                                i++;
                                sum += vmm_sz;
@@ -886,9 +884,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
                        if (tqe && (vmm_table[i] != 0)) {
                                u32 header, buffer_offset;
 
-#ifdef BIG_ENDIAN
-                               vmm_table[i] = BYTE_SWAP(vmm_table[i]);
-#endif
+                               vmm_table[i] = cpu_to_le32(vmm_table[i]);
                                vmm_sz = (vmm_table[i] & 0x3ff);
                                vmm_sz *= 4;
                                header = (tqe->type << 31) |
@@ -899,9 +895,7 @@ int wilc_wlan_handle_txq(struct net_device *dev, u32 *txq_count)
                                else
                                        header &= ~BIT(30);
 
-#ifdef BIG_ENDIAN
-                               header = BYTE_SWAP(header);
-#endif
+                               header = cpu_to_le32(header);
                                memcpy(&txb[offset], &header, 4);
                                if (tqe->type == WILC_CFG_PKT) {
                                        buffer_offset = ETH_CONFIG_PKT_HDR_OFFSET;
@@ -993,9 +987,7 @@ static void wilc_wlan_handle_rxq(struct wilc *wilc)
 
                        PRINT_D(RX_DBG, "In the 2nd do-while\n");
                        memcpy(&header, &buffer[offset], 4);
-#ifdef BIG_ENDIAN
-                       header = BYTE_SWAP(header);
-#endif
+                       header = cpu_to_le32(header);
                        PRINT_D(RX_DBG, "Header = %04x - Offset = %d\n",
                                header, offset);
 
@@ -1194,10 +1186,8 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer, u32 buffer_
        do {
                memcpy(&addr, &buffer[offset], 4);
                memcpy(&size, &buffer[offset + 4], 4);
-#ifdef BIG_ENDIAN
-               addr = BYTE_SWAP(addr);
-               size = BYTE_SWAP(size);
-#endif
+               addr = cpu_to_le32(addr);
+               size = cpu_to_le32(size);
                acquire_bus(wilc, ACQUIRE_ONLY);
                offset += 8;
                while (((int)size) && (offset < buffer_size)) {
index 27c7bbb17b33cc39e94c83e7acbec26652656bae..366645318ad27b437354550824b9d2349e92e572 100644 (file)
 #define ETH_CONFIG_PKT_HDR_OFFSET      (ETH_ETHERNET_HDR_OFFSET + \
                                         ETH_CONFIG_PKT_HDR_LEN)
 
-/********************************************
- *
- *      Endian Conversion
- *
- ********************************************/
-
-#define BYTE_SWAP(val)                 (((val & 0x000000FF) << 24) + \
-                                        ((val & 0x0000FF00) << 8) + \
-                                        ((val & 0x00FF0000) >> 8) + \
-                                        ((val & 0xFF000000) >> 24))
-
 /********************************************
  *
  *      Register Defines
index 274052f36400cfb0b7cb66a3cc87ade8a9806dc6..f62c0e696a0183212b878e80637e71f5cfd41a3d 100644 (file)
@@ -275,9 +275,7 @@ static void wilc_wlan_parse_response_frame(u8 *info, int size)
        while (size > 0) {
                i = 0;
                wid = info[0] | (info[1] << 8);
-#ifdef BIG_ENDIAN
-               wid = BYTE_SWAP(wid);
-#endif
+               wid = cpu_to_le32(wid);
                PRINT_INFO(GENERIC_DBG, "Processing response for %d seq %d\n", wid, seq++);
                switch ((wid >> 12) & 0x7) {
                case WID_CHAR:
@@ -300,11 +298,7 @@ static void wilc_wlan_parse_response_frame(u8 *info, int size)
                                        break;
 
                                if (g_cfg_hword[i].id == wid) {
-#ifdef BIG_ENDIAN
-                                       g_cfg_hword[i].val = (info[3] << 8) | (info[4]);
-#else
-                                       g_cfg_hword[i].val = info[3] | (info[4] << 8);
-#endif
+                                       g_cfg_hword[i].val = cpu_to_le16(info[3] | (info[4] << 8));
                                        break;
                                }
                                i++;
@@ -318,11 +312,7 @@ static void wilc_wlan_parse_response_frame(u8 *info, int size)
                                        break;
 
                                if (g_cfg_word[i].id == wid) {
-#ifdef BIG_ENDIAN
-                                       g_cfg_word[i].val = (info[3] << 24) | (info[4] << 16) | (info[5] << 8) | (info[6]);
-#else
-                                       g_cfg_word[i].val = info[3] | (info[4] << 8) | (info[5] << 16) | (info[6] << 24);
-#endif
+                                       g_cfg_word[i].val = cpu_to_le32(info[3] | (info[4] << 8) | (info[5] << 16) | (info[6] << 24));
                                        break;
                                }
                                i++;