From: Marcus Wolf <marcus.wolf@smarthome-wolf.de>
To: Valentin Vidic <Valentin.Vidic@CARNet.hr>
Cc: "Simon Sandström" <simon@nikanor.nu>,
"Marcin Ciupak" <marcin.s.ciupak@gmail.com>,
"Marcus Wolf" <linux@wolf-entwicklungen.de>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
Subject: Re: [PATCH 6/8 v3] staging: pi433: use defines for shifting register values
Date: Wed, 13 Dec 2017 19:52:27 +0200 [thread overview]
Message-ID: <aee2bf16-6ddf-411a-e81b-7ece9de53747@smarthome-wolf.de> (raw)
In-Reply-To: <20171213174444.21088-1-Valentin.Vidic@CARNet.hr>
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@CARNet.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
next prev parent reply other threads:[~2017-12-13 17:52 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-13 14:21 [PATCH 1/8] staging: pi433: collapse else block after return statement Valentin Vidic
2017-12-13 14:21 ` [PATCH 2/8] staging: pi433: move var declaration to function level Valentin Vidic
2017-12-13 14:47 ` Dan Carpenter
2017-12-13 15:57 ` [PATCH 2/8 v2] " Valentin Vidic
2017-12-13 19:01 ` [PATCH 2/8] " Joe Perches
2017-12-13 19:46 ` [PATCH 2/8 v3] staging: pi433: cleanup local variable declaration Valentin Vidic
2017-12-13 14:21 ` [PATCH 3/8] staging: pi433: replace unsigned with unsigned int Valentin Vidic
2017-12-13 14:21 ` [PATCH 4/8] staging: pi433: add parentheses to mask and shift Valentin Vidic
2017-12-13 14:49 ` Dan Carpenter
2017-12-13 15:24 ` Marcus Wolf
2017-12-13 14:21 ` [PATCH 5/8] staging: pi433: fix DATAMODUL_MODULATION_TYPE_OOK value Valentin Vidic
2017-12-13 14:36 ` Dan Carpenter
2017-12-13 14:21 ` [PATCH 6/8] staging: pi433: use defines for shifting register values Valentin Vidic
2017-12-13 15:32 ` Marcus Wolf
2017-12-13 16:55 ` [PATCH 6/8 v2] " Valentin Vidic
2017-12-13 17:15 ` Marcus Wolf
2017-12-13 17:44 ` [PATCH 6/8 v3] " Valentin Vidic
2017-12-13 17:52 ` Marcus Wolf [this message]
2017-12-14 14:42 ` Dan Carpenter
2017-12-14 15:20 ` [PATCH 6/8 v4] staging: pi433: remove unused function Valentin Vidic
2017-12-14 16:08 ` rf69_get_lna_gain Marcus Wolf
2017-12-14 18:13 ` rf69_get_lna_gain Simon Sandström
2017-12-19 14:12 ` [PATCH 6/8 v4] staging: pi433: remove unused function Greg Kroah-Hartman
2017-12-13 16:58 ` [PATCH 6/8] staging: pi433: use defines for shifting register values Valentin Vidic
2017-12-13 14:21 ` [PATCH 7/8] staging: pi433: avoid logging ENOMEM messages Valentin Vidic
2017-12-13 14:21 ` [PATCH 8/8] staging: pi433: replace printk calls with dev_dbg Valentin Vidic
2017-12-13 14:52 ` Dan Carpenter
2017-12-13 15:23 ` Valentin Vidic
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aee2bf16-6ddf-411a-e81b-7ece9de53747@smarthome-wolf.de \
--to=marcus.wolf@smarthome-wolf.de \
--cc=Valentin.Vidic@CARNet.hr \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@wolf-entwicklungen.de \
--cc=marcin.s.ciupak@gmail.com \
--cc=simon@nikanor.nu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®