]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
staging: wilc1000: use GENMASK to extract wid type
authorAjay Singh <ajay.kathat@microchip.com>
Fri, 22 Nov 2019 20:52:05 +0000 (20:52 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 10 Dec 2019 09:28:31 +0000 (10:28 +0100)
Refactor code by make use of 'GENMASK' to extract the WID type from
buffer received from firmware.

Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
Link: https://lore.kernel.org/r/20191122205153.30723-4-adham.abozaeid@microchip.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wilc1000/wlan.h
drivers/staging/wilc1000/wlan_cfg.c

index 1f6957cf2e9c1df94e88da6ad04e7becd81d6ade..44ae6ed6882c84bac64f9a8f9982abbe9eaa262d 100644 (file)
 #define IS_MANAGMEMENT_CALLBACK        0x080
 #define IS_MGMT_STATUS_SUCCES  0x040
 
+#define WILC_WID_TYPE          GENMASK(15, 12)
 /********************************************
  *
  *      Tx/Rx Queue Structure
index 6f6b286788d114c46cbe9a6ead9665cf73ecefea..2538435b82fd65539f81febe08eb90e7da3631c4 100644 (file)
@@ -4,6 +4,7 @@
  * All rights reserved.
  */
 
+#include <linux/bitfield.h>
 #include "wlan_if.h"
 #include "wlan.h"
 #include "wlan_cfg.h"
@@ -132,7 +133,6 @@ static int wilc_wlan_cfg_set_bin(u8 *frame, u32 offset, u16 id, u8 *b, u32 size)
  *
  ********************************************/
 
-#define GET_WID_TYPE(wid)              (((wid) >> 12) & 0x7)
 static void wilc_wlan_parse_response_frame(struct wilc *wl, u8 *info, int size)
 {
        u16 wid;
@@ -142,7 +142,7 @@ static void wilc_wlan_parse_response_frame(struct wilc *wl, u8 *info, int size)
                i = 0;
                wid = get_unaligned_le16(info);
 
-               switch (GET_WID_TYPE(wid)) {
+               switch (FIELD_GET(WILC_WID_TYPE, wid)) {
                case WID_CHAR:
                        do {
                                if (wl->cfg.b[i].id == WID_NIL)
@@ -244,7 +244,7 @@ static void wilc_wlan_parse_info_frame(struct wilc *wl, u8 *info)
 
 int wilc_wlan_cfg_set_wid(u8 *frame, u32 offset, u16 id, u8 *buf, int size)
 {
-       u8 type = (id >> 12) & 0xf;
+       u8 type = FIELD_GET(WILC_WID_TYPE, id);
        int ret = 0;
 
        switch (type) {
@@ -290,7 +290,7 @@ int wilc_wlan_cfg_get_wid(u8 *frame, u32 offset, u16 id)
 int wilc_wlan_cfg_get_val(struct wilc *wl, u16 wid, u8 *buffer,
                          u32 buffer_size)
 {
-       u32 type = (wid >> 12) & 0xf;
+       u8 type = FIELD_GET(WILC_WID_TYPE, wid);
        int i, ret = 0;
 
        i = 0;