public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Joshua Abraham <j.abraham1776@gmail.com>
To: gregkh@linuxfoundation.org
Cc: marcin.s.ciupak@gmail.com, linux@Wolf-Entwicklungen.de,
	colin.king@canonical.com, robsonde@gmail.com,
	dudebrobro179@gmail.com, devel@driverdev.osuosl.org,
	linux-kernel@vger.kernel.org, j.abraham1776@gmail.com
Subject: [PATCH] staging: pi433: #define shift constants in rf69.c
Date: Wed, 8 Nov 2017 06:25:06 -0500	[thread overview]
Message-ID: <20171108112506.GA1654@josharch> (raw)

This patch completes TODO improvements in rf69.c to change shift
constants to a define.

Signed-off-by: Joshua Abraham <j.abraham1776@gmail.com>
---
 drivers/staging/pi433/rf69.c           | 4 ++--
 drivers/staging/pi433/rf69_registers.h | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/pi433/rf69.c b/drivers/staging/pi433/rf69.c
index e69a2153c999..cfcace195be9 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 = READ_REG(REG_DATAMODUL);
 
-	switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> 3) { // TODO improvement: change 3 to define
+	switch (currentValue & MASK_DATAMODUL_MODULATION_TYPE >> SHIFT_DATAMODUL_MODE) {
 	case DATAMODUL_MODULATION_TYPE_OOK: return OOK;
 	case DATAMODUL_MODULATION_TYPE_FSK: return FSK;
 	default:			    return undefined;
@@ -409,7 +409,7 @@ enum lnaGain rf69_get_lna_gain(struct spi_device *spi)
 
 	currentValue = READ_REG(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 6335d42142fe..119df543e80e 100644
--- a/drivers/staging/pi433/rf69_registers.h
+++ b/drivers/staging/pi433/rf69_registers.h
@@ -121,6 +121,8 @@
 #define  OPMODE_MODE_RECEIVE			0x10
 
 /* RegDataModul */
+#define  SHIFT_DATAMODUL_MODE				0x03
+
 #define  MASK_DATAMODUL_MODE			0x06
 #define  MASK_DATAMODUL_MODULATION_TYPE		0x18
 #define  MASK_DATAMODUL_MODULATION_SHAPE	0x03
@@ -234,6 +236,8 @@
  */
 
 /* RegLna (0x18) */
+#define  SHIFT_LNA_CURRENT_GAIN			0x03
+
 #define  MASK_LNA_ZIN				0x80
 #define  MASK_LNA_CURRENT_GAIN			0x38
 #define  MASK_LNA_GAIN				0x07
-- 
2.15.0

             reply	other threads:[~2017-11-08 11:25 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08 11:25 Joshua Abraham [this message]
2017-11-08 11:52 ` [PATCH] staging: pi433: #define shift constants in rf69.c Dan Carpenter
2017-11-08 14:21   ` Marcus Wolf
2017-11-08 14:46   ` Josh Abraham

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=20171108112506.GA1654@josharch \
    --to=j.abraham1776@gmail.com \
    --cc=colin.king@canonical.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=dudebrobro179@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@Wolf-Entwicklungen.de \
    --cc=marcin.s.ciupak@gmail.com \
    --cc=robsonde@gmail.com \
    /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