Re: [PATCH 1/1] Staging: comedi: dmm32at: fix BIT macro issue.

From: Ian Abbott
Date: Fri Jun 10 2016 - 06:38:15 EST


On 09/06/16 13:04, Ravishankar Karkala Mallikarjunayya wrote:
This Replace all occurences of (1<<x) by BIT(x) and DMM32AT_CTRL(x),
DMM32AT_AI_CFG(x) macros to get rid of checkpatch.pl
"CHECK" output "Prefer using the BIT macro"

Signed-off-by: Ravishankar Karkala Mallikarjunayya <ravishankarkm32@xxxxxxxxx>
---
drivers/staging/comedi/drivers/dmm32at.c | 98 ++++++++++++++++----------------
1 file changed, 50 insertions(+), 48 deletions(-)

diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c
index 958c0d4..0d50105 100644
--- a/drivers/staging/comedi/drivers/dmm32at.c
+++ b/drivers/staging/comedi/drivers/dmm32at.c
[snip]
-#define DMM32AT_CTRL_RESETA (1 << 5)
-#define DMM32AT_CTRL_RESETD (1 << 4)
-#define DMM32AT_CTRL_INTRST (1 << 3)
-#define DMM32AT_CTRL_PAGE_8254 (0 << 0)
-#define DMM32AT_CTRL_PAGE_8255 (1 << 0)
-#define DMM32AT_CTRL_PAGE_CALIB (3 << 0)
+#define DMM32AT_CTRL_RESETA BIT(5)
+#define DMM32AT_CTRL_RESETD BIT(4)
+#define DMM32AT_CTRL_INTRST BIT(3)
+#define DMM32AT_CTRL(x) ((x) << 0)
+#define DMM32AT_CTRL_PAGE_8254 DMM32AT_CTRL(0)
+#define DMM32AT_CTRL_PAGE_8255 DMM32AT_CTRL(1)
+#define DMM32AT_CTRL_PAGE_CALIB DMM32AT_CTRL(3)

The macro name DMM32AT_CTRL(x) is not specific enough. It should be DMM32AT_CTRL_PAGE(x) to match the names of the macros that use it (DMM32AT_CTRL_PAGE_8254 etc.).

[snip]
-#define DMM32AT_AI_CFG_SCINT_20US (0 << 4)
-#define DMM32AT_AI_CFG_SCINT_15US (1 << 4)
-#define DMM32AT_AI_CFG_SCINT_10US (2 << 4)
-#define DMM32AT_AI_CFG_SCINT_5US (3 << 4)
-#define DMM32AT_AI_CFG_RANGE (1 << 3) /* 0=5V 1=10V */
-#define DMM32AT_AI_CFG_ADBU (1 << 2) /* 0=bipolar 1=unipolar */
+#define DMM32AT_AI_CFG(x) ((x) << 4)
+#define DMM32AT_AI_CFG_SCINT_20US DMM32AT_AI_CFG(0)
+#define DMM32AT_AI_CFG_SCINT_15US DMM32AT_AI_CFG(1)
+#define DMM32AT_AI_CFG_SCINT_10US DMM32AT_AI_CFG(2)
+#define DMM32AT_AI_CFG_SCINT_5US DMM32AT_AI_CFG(3)

The same thing here. Please rename DMM32AT_AI_CFG(x) to DMM32AT_AI_CFG_SCINT(x).

(Don't forget to update the patch description to match these changes.)

--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@xxxxxxxxx> )=-
-=( Web: http://www.mev.co.uk/ )=-