lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aee2bf16-6ddf-411a-e81b-7ece9de53747@smarthome-wolf.de>
Date:   Wed, 13 Dec 2017 19:52:27 +0200
From:   Marcus Wolf <marcus.wolf@...rthome-wolf.de>
To:     Valentin Vidic <Valentin.Vidic@...Net.hr>
Cc:     Simon Sandström <simon@...anor.nu>,
        Marcin Ciupak <marcin.s.ciupak@...il.com>,
        Marcus Wolf <linux@...f-entwicklungen.de>,
        devel@...verdev.osuosl.org, linux-kernel@...r.kernel.org,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>
Subject: Re: [PATCH 6/8 v3] staging: pi433: use defines for shifting register
 values



Am 13.12.2017 um 19:44 schrieb Valentin Vidic:
> Avoid shifting by magic numbers and use defines instead.
> 
> Signed-off-by: Valentin Vidic <Valentin.Vidic@...Net.hr>
> ---
> v2: - drop change for SHIFT_DATAMODUL_MODULATION_TYPE
>      - move shifting to the header file
> v3: - drop auto case
>      - use CURRENT suffix
>      - precompute define values
> 
>   drivers/staging/pi433/rf69.c           | 15 +++++++--------
>   drivers/staging/pi433/rf69_registers.h |  6 ++++++
>   2 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
> index f77ecd60f43a..0889c65d5a31 100644
> --- a/drivers/staging/pi433/rf69.c
> +++ b/drivers/staging/pi433/rf69.c
> @@ -340,14 +340,13 @@ enum lnaGain rf69_get_lna_gain(struct spi_device *spi)
>   
>   	currentValue = rf69_read_reg(spi, REG_LNA);
>   
> -	switch (currentValue & MASK_LNA_CURRENT_GAIN >> 3) { // improvement: change 3 to define
> -	case LNA_GAIN_AUTO:	    return automatic;
> -	case LNA_GAIN_MAX:	    return max;
> -	case LNA_GAIN_MAX_MINUS_6:  return maxMinus6;
> -	case LNA_GAIN_MAX_MINUS_12: return maxMinus12;
> -	case LNA_GAIN_MAX_MINUS_24: return maxMinus24;
> -	case LNA_GAIN_MAX_MINUS_36: return maxMinus36;
> -	case LNA_GAIN_MAX_MINUS_48: return maxMinus48;
> +	switch (currentValue & MASK_LNA_CURRENT_GAIN) {
> +	case LNA_GAIN_MAX_CURRENT:	    return max;
> +	case LNA_GAIN_MAX_MINUS_6_CURRENT:  return maxMinus6;
> +	case LNA_GAIN_MAX_MINUS_12_CURRENT: return maxMinus12;
> +	case LNA_GAIN_MAX_MINUS_24_CURRENT: return maxMinus24;
> +	case LNA_GAIN_MAX_MINUS_36_CURRENT: return maxMinus36;
> +	case LNA_GAIN_MAX_MINUS_48_CURRENT: return maxMinus48;
>   	default:		    return undefined;
>   	}
>   }
> diff --git a/drivers/staging/pi433/rf69_registers.h b/drivers/staging/pi433/rf69_registers.h
> index d23b8b668ef5..4a189c6a4ab3 100644
> --- a/drivers/staging/pi433/rf69_registers.h
> +++ b/drivers/staging/pi433/rf69_registers.h
> @@ -246,6 +246,12 @@
>   #define  LNA_GAIN_MAX_MINUS_36			0x05
>   #define  LNA_GAIN_MAX_MINUS_48			0x06
>   
> +#define  LNA_GAIN_MAX_CURRENT			0x08
> +#define  LNA_GAIN_MAX_MINUS_6_CURRENT		0x10
> +#define  LNA_GAIN_MAX_MINUS_12_CURRENT		0x18
> +#define  LNA_GAIN_MAX_MINUS_24_CURRENT		0x20
> +#define  LNA_GAIN_MAX_MINUS_36_CURRENT		0x28
> +#define  LNA_GAIN_MAX_MINUS_48_CURRENT		0x30
>   
>   /* RegRxBw (0x19) and RegAfcBw (0x1A) */
>   #define  MASK_BW_DCC_FREQ			0xE0
> 

Hi Valetin,

perfect :-)

Thank you so much!

Marcus

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ