[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20171213142156.3201-6-Valentin.Vidic@CARNet.hr>
Date: Wed, 13 Dec 2017 15:21:54 +0100
From: Valentin Vidic <Valentin.Vidic@...Net.hr>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>
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,
Valentin Vidic <Valentin.Vidic@...Net.hr>
Subject: [PATCH 6/8] staging: pi433: use defines for shifting register values
Avoid shifting by magic numbers and use defines instead:
SHIFT_DATAMODUL_MODULATION_TYPE
SHIFT_LNA_CURRENT_GAIN
Signed-off-by: Valentin Vidic <Valentin.Vidic@...Net.hr>
---
drivers/staging/pi433/rf69.c | 4 ++--
drivers/staging/pi433/rf69_registers.h | 2 ++
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index b1e243e5bcac..8c4841c9d796 100644
--- a/drivers/staging/pi433/rf69.c
+++ b/drivers/staging/pi433/rf69.c
@@ -102,7 +102,7 @@ enum modulation rf69_get_modulation(struct spi_device *spi)
currentValue = rf69_read_reg(spi, REG_DATAMODUL);
- switch ((currentValue & MASK_DATAMODUL_MODULATION_TYPE) >> 3) { // TODO improvement: change 3 to define
+ switch ((currentValue & MASK_DATAMODUL_MODULATION_TYPE) >> SHIFT_DATAMODUL_MODULATION_TYPE) {
case DATAMODUL_MODULATION_TYPE_OOK: return OOK;
case DATAMODUL_MODULATION_TYPE_FSK: return FSK;
default: return UNDEF;
@@ -340,7 +340,7 @@ 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
+ switch ((currentValue & MASK_LNA_CURRENT_GAIN) >> SHIFT_LNA_CURRENT_GAIN) {
case LNA_GAIN_AUTO: return automatic;
case LNA_GAIN_MAX: return max;
case LNA_GAIN_MAX_MINUS_6: return maxMinus6;
diff --git a/drivers/staging/pi433/rf69_registers.h b/drivers/staging/pi433/rf69_registers.h
index 981b57d7cc0b..da12642cf249 100644
--- a/drivers/staging/pi433/rf69_registers.h
+++ b/drivers/staging/pi433/rf69_registers.h
@@ -124,6 +124,7 @@
#define MASK_DATAMODUL_MODE 0x06
#define MASK_DATAMODUL_MODULATION_TYPE 0x18
#define MASK_DATAMODUL_MODULATION_SHAPE 0x03
+#define SHIFT_DATAMODUL_MODULATION_TYPE 3
#define DATAMODUL_MODE_PACKET 0x00 /* default */
#define DATAMODUL_MODE_CONTINUOUS 0x40
@@ -235,6 +236,7 @@
#define MASK_LNA_ZIN 0x80
#define MASK_LNA_CURRENT_GAIN 0x38
#define MASK_LNA_GAIN 0x07
+#define SHIFT_LNA_CURRENT_GAIN 3
#define LNA_GAIN_AUTO 0x00 /* default */
#define LNA_GAIN_MAX 0x01
--
2.15.0
Powered by blists - more mailing lists