linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] staging: wlan-ng: make use of GENMASK macro
@ 2016-11-10 18:16 Sergio Paracuellos
  2016-11-10 18:16 ` [PATCH 1/4] staging: wlan-ng: use GENMASK macro in different defines of hfa384x.h Sergio Paracuellos
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Sergio Paracuellos @ 2016-11-10 18:16 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel

This patchset replaces mask stuff manipulation which is being used
using BIT macro with or operators with the use of GENMASK macro.

Sergio Paracuellos (4):
  staging: wlan-ng: use GENMASK macro in different defines of hfa384x.h
  staging: wlan-ng: use GENMASK macro in different defines of
    p80211hdr.h
  staging: wlan-ng: use GENMASK macro in define of p80211netdev.h
  staging: wlan-ng: use GENMASK macro in two bitwise operations in
    prism2sta.c

 drivers/staging/wlan-ng/hfa384x.h      | 29 ++++++++---------------------
 drivers/staging/wlan-ng/p80211hdr.h    |  5 ++---
 drivers/staging/wlan-ng/p80211netdev.h |  2 +-
 drivers/staging/wlan-ng/prism2sta.c    |  4 ++--
 4 files changed, 13 insertions(+), 27 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] staging: wlan-ng: use GENMASK macro in different defines of hfa384x.h
  2016-11-10 18:16 [PATCH 0/4] staging: wlan-ng: make use of GENMASK macro Sergio Paracuellos
@ 2016-11-10 18:16 ` Sergio Paracuellos
  2016-11-15 12:21   ` Dan Carpenter
  2016-11-10 18:16 ` [PATCH 2/4] staging: wlan-ng: use GENMASK macro in different defines of p80211hdr.h Sergio Paracuellos
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Sergio Paracuellos @ 2016-11-10 18:16 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel

This patch replace actual mask stuff using BIT macros with 
or operators to make use of GENMASK macro which simplifies 
code clearity and readibility.

It applies for defines included in hfa384x.h header file.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/wlan-ng/hfa384x.h | 29 ++++++++---------------------
 1 file changed, 8 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h
index 01945a9..60caf9c3 100644
--- a/drivers/staging/wlan-ng/hfa384x.h
+++ b/drivers/staging/wlan-ng/hfa384x.h
@@ -137,21 +137,11 @@
 #define		HFA384x_DLSTATE_FLASHENABLED		2
 
 /*--- Register Field Masks --------------------------*/
-#define		HFA384x_CMD_AINFO		((u16)(BIT(14) | BIT(13) \
-							| BIT(12) | BIT(11) \
-							| BIT(10) | BIT(9) \
-							| BIT(8)))
-#define		HFA384x_CMD_MACPORT		((u16)(BIT(10) | BIT(9) | \
-							BIT(8)))
-#define		HFA384x_CMD_PROGMODE		((u16)(BIT(9) | BIT(8)))
-#define		HFA384x_CMD_CMDCODE		((u16)(BIT(5) | BIT(4) | \
-							BIT(3) | BIT(2) | \
-							BIT(1) | BIT(0)))
-
-#define		HFA384x_STATUS_RESULT		((u16)(BIT(14) | BIT(13) \
-							| BIT(12) | BIT(11) \
-							| BIT(10) | BIT(9) \
-							| BIT(8)))
+#define		HFA384x_CMD_AINFO		((u16)GENMASK(14, 8))
+#define		HFA384x_CMD_MACPORT		((u16)GENMASK(10, 8))
+#define		HFA384x_CMD_PROGMODE		((u16)GENMASK(9, 8))
+#define		HFA384x_CMD_CMDCODE		((u16)GENMASK(5, 0))
+#define		HFA384x_STATUS_RESULT		((u16)GENMASK(14, 8))
 
 /*--- Command Code Constants --------------------------*/
 /*--- Controller Commands --------------------------*/
@@ -511,9 +501,8 @@ struct hfa384x_tx_frame {
 #define		HFA384x_TXSTATUS_AGEDERR		((u16)BIT(1))
 #define		HFA384x_TXSTATUS_RETRYERR		((u16)BIT(0))
 /*-- Transmit Control Field --*/
-#define		HFA384x_TX_MACPORT			((u16)(BIT(10) | \
-							  BIT(9) | BIT(8)))
-#define		HFA384x_TX_STRUCTYPE			((u16)(BIT(4) | BIT(3)))
+#define		HFA384x_TX_MACPORT			((u16)GENMASK(10, 8))
+#define		HFA384x_TX_STRUCTYPE			((u16)GENMASK(4, 3))
 #define		HFA384x_TX_TXEX				((u16)BIT(2))
 #define		HFA384x_TX_TXOK				((u16)BIT(1))
 /*--------------------------------------------------------------------
@@ -571,9 +560,7 @@ struct hfa384x_rx_frame {
  */
 
 /*-- Status Fields --*/
-#define		HFA384x_RXSTATUS_MACPORT		((u16)(BIT(10) | \
-								BIT(9) | \
-								BIT(8)))
+#define		HFA384x_RXSTATUS_MACPORT		((u16)GENMASK(10, 8))
 #define		HFA384x_RXSTATUS_FCSERR			((u16)BIT(0))
 /*--------------------------------------------------------------------
  * Communication Frames: Test/Get/Set Field Values for Receive Frames
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] staging: wlan-ng: use GENMASK macro in different defines of p80211hdr.h
  2016-11-10 18:16 [PATCH 0/4] staging: wlan-ng: make use of GENMASK macro Sergio Paracuellos
  2016-11-10 18:16 ` [PATCH 1/4] staging: wlan-ng: use GENMASK macro in different defines of hfa384x.h Sergio Paracuellos
@ 2016-11-10 18:16 ` Sergio Paracuellos
  2016-11-15 12:25   ` Dan Carpenter
  2016-11-10 18:16 ` [PATCH 3/4] staging: wlan-ng: use GENMASK macro in define of p80211netdev.h Sergio Paracuellos
  2016-11-10 18:16 ` [PATCH 4/4] staging: wlan-ng: use GENMASK macro in two bitwise operations in prism2sta.c Sergio Paracuellos
  3 siblings, 1 reply; 8+ messages in thread
From: Sergio Paracuellos @ 2016-11-10 18:16 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel

This patch replace actual mask stuff using BIT macros with 
or operators to make use of GENMASK macro which simplifies 
code clearity and readibility.

It applies for defines included in p80211hdr.h header file.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/wlan-ng/p80211hdr.h | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/wlan-ng/p80211hdr.h b/drivers/staging/wlan-ng/p80211hdr.h
index c8f78d9..2c44c61 100644
--- a/drivers/staging/wlan-ng/p80211hdr.h
+++ b/drivers/staging/wlan-ng/p80211hdr.h
@@ -131,9 +131,8 @@
 /*                        SET_FC_FSTYPE(WLAN_FSTYPE_RTS) );   */
 /*------------------------------------------------------------*/
 
-#define WLAN_GET_FC_FTYPE(n)	((((u16)(n)) & (BIT(2) | BIT(3))) >> 2)
-#define WLAN_GET_FC_FSTYPE(n)	((((u16)(n)) & \
-				(BIT(4) | BIT(5) | BIT(6) | BIT(7))) >> 4)
+#define WLAN_GET_FC_FTYPE(n)	((((u16)(n)) & GENMASK(3, 2)) >> 2)
+#define WLAN_GET_FC_FSTYPE(n)	((((u16)(n)) & GENMASK(7, 4)) >> 4)
 #define WLAN_GET_FC_TODS(n)	((((u16)(n)) & (BIT(8))) >> 8)
 #define WLAN_GET_FC_FROMDS(n)	((((u16)(n)) & (BIT(9))) >> 9)
 #define WLAN_GET_FC_ISWEP(n)	((((u16)(n)) & (BIT(14))) >> 14)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] staging: wlan-ng: use GENMASK macro in define of p80211netdev.h
  2016-11-10 18:16 [PATCH 0/4] staging: wlan-ng: make use of GENMASK macro Sergio Paracuellos
  2016-11-10 18:16 ` [PATCH 1/4] staging: wlan-ng: use GENMASK macro in different defines of hfa384x.h Sergio Paracuellos
  2016-11-10 18:16 ` [PATCH 2/4] staging: wlan-ng: use GENMASK macro in different defines of p80211hdr.h Sergio Paracuellos
@ 2016-11-10 18:16 ` Sergio Paracuellos
  2016-11-10 18:16 ` [PATCH 4/4] staging: wlan-ng: use GENMASK macro in two bitwise operations in prism2sta.c Sergio Paracuellos
  3 siblings, 0 replies; 8+ messages in thread
From: Sergio Paracuellos @ 2016-11-10 18:16 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel

This patch replace actual mask stuff using BIT macros with 
or operators to make use of GENMASK macro which simplifies 
code clearity and readibility.

It applies for defines included in p80211netdev.h header file.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/wlan-ng/p80211netdev.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/wlan-ng/p80211netdev.h b/drivers/staging/wlan-ng/p80211netdev.h
index 8066ac4..8e0d082 100644
--- a/drivers/staging/wlan-ng/p80211netdev.h
+++ b/drivers/staging/wlan-ng/p80211netdev.h
@@ -143,7 +143,7 @@ struct p80211_frmrx {
 #define NUM_WEPKEYS 4
 #define MAX_KEYLEN 32
 
-#define HOSTWEP_DEFAULTKEY_MASK (BIT(1) | BIT(0))
+#define HOSTWEP_DEFAULTKEY_MASK GENMASK(1, 0)
 #define HOSTWEP_SHAREDKEY BIT(3)
 #define HOSTWEP_DECRYPT  BIT(4)
 #define HOSTWEP_ENCRYPT  BIT(5)
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] staging: wlan-ng: use GENMASK macro in two bitwise operations in prism2sta.c
  2016-11-10 18:16 [PATCH 0/4] staging: wlan-ng: make use of GENMASK macro Sergio Paracuellos
                   ` (2 preceding siblings ...)
  2016-11-10 18:16 ` [PATCH 3/4] staging: wlan-ng: use GENMASK macro in define of p80211netdev.h Sergio Paracuellos
@ 2016-11-10 18:16 ` Sergio Paracuellos
  2016-11-15 12:34   ` Dan Carpenter
  3 siblings, 1 reply; 8+ messages in thread
From: Sergio Paracuellos @ 2016-11-10 18:16 UTC (permalink / raw)
  To: gregkh; +Cc: devel, linux-kernel

This patch replace actual mask stuff using BIT macros with 
or operators to make use of GENMASK macro which simplifies 
code clearity and readibility.

It applies for two bitwise operations included in prism2sta.c source file.

Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
---
 drivers/staging/wlan-ng/prism2sta.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c
index 351f08d..984804b 100644
--- a/drivers/staging/wlan-ng/prism2sta.c
+++ b/drivers/staging/wlan-ng/prism2sta.c
@@ -654,8 +654,8 @@ static int prism2sta_getcardinfo(struct wlandevice *wlandev)
 	hw->ident_sta_fw.minor = le16_to_cpu(hw->ident_sta_fw.minor);
 
 	/* strip out the 'special' variant bits */
-	hw->mm_mods = hw->ident_sta_fw.variant & (BIT(14) | BIT(15));
-	hw->ident_sta_fw.variant &= ~((u16)(BIT(14) | BIT(15)));
+	hw->mm_mods = hw->ident_sta_fw.variant & GENMASK(15, 14);
+	hw->ident_sta_fw.variant &= ~((u16)GENMASK(15, 14));
 
 	if (hw->ident_sta_fw.id == 0x1f) {
 		netdev_info(wlandev->netdev,
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/4] staging: wlan-ng: use GENMASK macro in different defines of hfa384x.h
  2016-11-10 18:16 ` [PATCH 1/4] staging: wlan-ng: use GENMASK macro in different defines of hfa384x.h Sergio Paracuellos
@ 2016-11-15 12:21   ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2016-11-15 12:21 UTC (permalink / raw)
  To: Sergio Paracuellos; +Cc: gregkh, devel, linux-kernel

On Thu, Nov 10, 2016 at 07:16:39PM +0100, Sergio Paracuellos wrote:
> +#define		HFA384x_CMD_AINFO		((u16)GENMASK(14, 8))

The casts to u16 are pointless because of type promotion and half of
these defines aren't used anyway (both that I looked at).

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/4] staging: wlan-ng: use GENMASK macro in different defines of p80211hdr.h
  2016-11-10 18:16 ` [PATCH 2/4] staging: wlan-ng: use GENMASK macro in different defines of p80211hdr.h Sergio Paracuellos
@ 2016-11-15 12:25   ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2016-11-15 12:25 UTC (permalink / raw)
  To: Sergio Paracuellos; +Cc: gregkh, devel, linux-kernel

On Thu, Nov 10, 2016 at 07:16:40PM +0100, Sergio Paracuellos wrote:
> -#define WLAN_GET_FC_FTYPE(n)	((((u16)(n)) & (BIT(2) | BIT(3))) >> 2)
> -#define WLAN_GET_FC_FSTYPE(n)	((((u16)(n)) & \
> -				(BIT(4) | BIT(5) | BIT(6) | BIT(7))) >> 4)
> +#define WLAN_GET_FC_FTYPE(n)	((((u16)(n)) & GENMASK(3, 2)) >> 2)
> +#define WLAN_GET_FC_FSTYPE(n)	((((u16)(n)) & GENMASK(7, 4)) >> 4)

The casts to u16 are not needed.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 4/4] staging: wlan-ng: use GENMASK macro in two bitwise operations in prism2sta.c
  2016-11-10 18:16 ` [PATCH 4/4] staging: wlan-ng: use GENMASK macro in two bitwise operations in prism2sta.c Sergio Paracuellos
@ 2016-11-15 12:34   ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2016-11-15 12:34 UTC (permalink / raw)
  To: Sergio Paracuellos; +Cc: gregkh, devel, linux-kernel

On Thu, Nov 10, 2016 at 07:16:42PM +0100, Sergio Paracuellos wrote:
> This patch replace actual mask stuff using BIT macros with 
> or operators to make use of GENMASK macro which simplifies 
> code clearity and readibility.
> 
> It applies for two bitwise operations included in prism2sta.c source file.
> 
> Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
> ---
>  drivers/staging/wlan-ng/prism2sta.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c
> index 351f08d..984804b 100644
> --- a/drivers/staging/wlan-ng/prism2sta.c
> +++ b/drivers/staging/wlan-ng/prism2sta.c
> @@ -654,8 +654,8 @@ static int prism2sta_getcardinfo(struct wlandevice *wlandev)
>  	hw->ident_sta_fw.minor = le16_to_cpu(hw->ident_sta_fw.minor);
>  
>  	/* strip out the 'special' variant bits */
> -	hw->mm_mods = hw->ident_sta_fw.variant & (BIT(14) | BIT(15));
> -	hw->ident_sta_fw.variant &= ~((u16)(BIT(14) | BIT(15)));
> +	hw->mm_mods = hw->ident_sta_fw.variant & GENMASK(15, 14);
> +	hw->ident_sta_fw.variant &= ~((u16)GENMASK(15, 14));

The cast is a no-op because of type promotion.  It gets cast to u16 then
immediately recast to int before the bitwise negate op.

regards,
dan carpenter

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-11-15 12:35 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-10 18:16 [PATCH 0/4] staging: wlan-ng: make use of GENMASK macro Sergio Paracuellos
2016-11-10 18:16 ` [PATCH 1/4] staging: wlan-ng: use GENMASK macro in different defines of hfa384x.h Sergio Paracuellos
2016-11-15 12:21   ` Dan Carpenter
2016-11-10 18:16 ` [PATCH 2/4] staging: wlan-ng: use GENMASK macro in different defines of p80211hdr.h Sergio Paracuellos
2016-11-15 12:25   ` Dan Carpenter
2016-11-10 18:16 ` [PATCH 3/4] staging: wlan-ng: use GENMASK macro in define of p80211netdev.h Sergio Paracuellos
2016-11-10 18:16 ` [PATCH 4/4] staging: wlan-ng: use GENMASK macro in two bitwise operations in prism2sta.c Sergio Paracuellos
2016-11-15 12:34   ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).