staging: wilc1000: Merge memcpy + le32_to_cpus to get_unaligned_le32
authorChuhong Yuan <hslester96@gmail.com>
Thu, 25 Jul 2019 02:52:03 +0000 (10:52 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jul 2019 07:48:14 +0000 (09:48 +0200)
Merge the combo use of memcpy and le32_to_cpus.
Use get_unaligned_le32 instead.
This simplifies the code.

Signed-off-by: Chuhong Yuan <hslester96@gmail.com>
Link: https://lore.kernel.org/r/20190725025203.8772-1-hslester96@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/wilc_mon.c
drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
drivers/staging/wilc1000/wilc_wlan.c

index 7d7933d40924f379b8c28f5c62b7cb995c5926ee..d6f14f69ad64e10660db67d55d5758a6a164747a 100644 (file)
@@ -35,8 +35,7 @@ void wilc_wfi_monitor_rx(struct net_device *mon_dev, u8 *buff, u32 size)
                return;
 
        /* Get WILC header */
-       memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
-       le32_to_cpus(&header);
+       header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
        /*
         * The packet offset field contain info about what type of management
         * the frame we are dealing with and ack status
index d72fdd333050cd45042237942f794a41f9d7ffa9..12fb4add05eca8b12cd59886e9a4bc56ad008967 100644 (file)
@@ -1038,8 +1038,7 @@ void wilc_wfi_p2p_rx(struct wilc_vif *vif, u8 *buff, u32 size)
        s32 freq;
        __le16 fc;
 
-       memcpy(&header, (buff - HOST_HDR_OFFSET), HOST_HDR_OFFSET);
-       le32_to_cpus(&header);
+       header = get_unaligned_le32(buff - HOST_HDR_OFFSET);
        pkt_offset = GET_PKT_OFFSET(header);
 
        if (pkt_offset & IS_MANAGMEMENT_CALLBACK) {
index 2cbdbf0090e42b4da9d845488466ecdd56a0c473..8ca0a7a4fa3fe7c6c2c9658cb3183a871bec5a78 100644 (file)
@@ -703,8 +703,7 @@ static void wilc_wlan_handle_rx_buff(struct wilc *wilc, u8 *buffer, int size)
 
        do {
                buff_ptr = buffer + offset;
-               memcpy(&header, buff_ptr, 4);
-               le32_to_cpus(&header);
+               header = get_unaligned_le32(buff_ptr);
 
                is_cfg_packet = (header >> 31) & 0x1;
                pkt_offset = (header >> 22) & 0x1ff;
@@ -874,10 +873,8 @@ int wilc_wlan_firmware_download(struct wilc *wilc, const u8 *buffer,
 
        offset = 0;
        do {
-               memcpy(&addr, &buffer[offset], 4);
-               memcpy(&size, &buffer[offset + 4], 4);
-               le32_to_cpus(&addr);
-               le32_to_cpus(&size);
+               addr = get_unaligned_le32(&buffer[offset]);
+               size = get_unaligned_le32(&buffer[offset + 4]);
                acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
                offset += 8;
                while (((int)size) && (offset < buffer_size)) {