Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1522642

Re: [PATCH 4/4] staging: wlan-ng: use GENMASK macro in two bitwise operations in prism2sta.c

From Dan Carpenter <dan.carpenter@oracle.com>
Newsgroups linux.kernel
Subject Re: [PATCH 4/4] staging: wlan-ng: use GENMASK macro in two bitwise operations in prism2sta.c
Date 2016-11-15 13:40 +0100
Message-ID <sDLbQ-4VX-13@gated-at.bofh.it> (permalink)
References <sC278-1l5-1@gated-at.bofh.it> <sC278-1l5-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | Next | Find similar | Unroll thread


Thread

Re: [PATCH 4/4] staging: wlan-ng: use GENMASK macro in two bitwise  operations in prism2sta.c Dan Carpenter <dan.carpenter@oracle.com> - 2016-11-15 13:40 +0100

csiph-web