Skip to contentSkip to conversation

Staging: iio: cdc: Use BIT and GENMASK macro

PATCH In review Shraddha Barke 3 participants 6 messages Oct 1, 2015

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 Staging: iio: cdc: Use BIT and GENMASK macro

Use BIT()/GENMASK() macros for all register definitions instead of hand-writing bit masks.

---
Changes in v2-
Used GENMASK macro; covered more cases of BIT macro and updated commit message

 drivers/staging/iio/cdc/ad7746.c | 52 ++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 26 deletions(-)
drivers/staging/iio/cdc/ad7746.c +26 -26
index 10fa372..a8049ef 100644
@@ -52,42 +52,42 @@
 #define AD7746_STATUS_RDYCAP		BIT(0)
 
 /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
-#define AD7746_CAPSETUP_CAPEN		(1 << 7)
-#define AD7746_CAPSETUP_CIN2		(1 << 6) /* AD7746 only */
-#define AD7746_CAPSETUP_CAPDIFF		(1 << 5)
-#define AD7746_CAPSETUP_CACHOP		(1 << 0)
+#define AD7746_CAPSETUP_CAPEN		BIT(7)
+#define AD7746_CAPSETUP_CIN2		BIT(6) /* AD7746 only */
+#define AD7746_CAPSETUP_CAPDIFF		BIT(5)
+#define AD7746_CAPSETUP_CACHOP		BIT(0)
 
 /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
-#define AD7746_VTSETUP_VTEN		(1 << 7)
-#define AD7746_VTSETUP_VTMD_INT_TEMP	(0 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_TEMP	(1 << 5)
-#define AD7746_VTSETUP_VTMD_VDD_MON	(2 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_VIN	(3 << 5)
-#define AD7746_VTSETUP_EXTREF		(1 << 4)
-#define AD7746_VTSETUP_VTSHORT		(1 << 1)
-#define AD7746_VTSETUP_VTCHOP		(1 << 0)
+#define AD7746_VTSETUP_VTEN		BIT(7)
+#define AD7746_VTSETUP_VTMD_INT_TEMP	0
+#define AD7746_VTSETUP_VTMD_EXT_TEMP	BIT(5)
+#define AD7746_VTSETUP_VTMD_VDD_MON	GENMASK(6, 0)
+#define AD7746_VTSETUP_VTMD_EXT_VIN	GENMASK(6, 5)
+#define AD7746_VTSETUP_EXTREF		BIT(4)
+#define AD7746_VTSETUP_VTSHORT		BIT(1)
+#define AD7746_VTSETUP_VTCHOP		BIT(0)
 
 /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
-#define AD7746_EXCSETUP_CLKCTRL		(1 << 7)
-#define AD7746_EXCSETUP_EXCON		(1 << 6)
-#define AD7746_EXCSETUP_EXCB		(1 << 5)
-#define AD7746_EXCSETUP_NEXCB		(1 << 4)
-#define AD7746_EXCSETUP_EXCA		(1 << 3)
-#define AD7746_EXCSETUP_NEXCA		(1 << 2)
-#define AD7746_EXCSETUP_EXCLVL(x)	(((x) & 0x3) << 0)
+#define AD7746_EXCSETUP_CLKCTRL		BIT(7)
+#define AD7746_EXCSETUP_EXCON		BIT(6)
+#define AD7746_EXCSETUP_EXCB		BIT(5)
+#define AD7746_EXCSETUP_NEXCB		BIT(4)
+#define AD7746_EXCSETUP_EXCA		BIT(3)
+#define AD7746_EXCSETUP_NEXCA		BIT(2)
+#define AD7746_EXCSETUP_EXCLVL(x)	GENMASK(((x) & 0x3), 0)
 
 /* Config Register Bit Designations (AD7746_REG_CFG) */
 #define AD7746_CONF_VTFS(x)		((x) << 6)
 #define AD7746_CONF_CAPFS(x)		((x) << 3)
-#define AD7746_CONF_MODE_IDLE		(0 << 0)
-#define AD7746_CONF_MODE_CONT_CONV	(1 << 0)
-#define AD7746_CONF_MODE_SINGLE_CONV	(2 << 0)
-#define AD7746_CONF_MODE_PWRDN		(3 << 0)
-#define AD7746_CONF_MODE_OFFS_CAL	(5 << 0)
-#define AD7746_CONF_MODE_GAIN_CAL	(6 << 0)
+#define AD7746_CONF_MODE_IDLE		0
+#define AD7746_CONF_MODE_CONT_CONV	GENMASK(1, 0)
+#define AD7746_CONF_MODE_SINGLE_CONV	GENMASK(2, 0)
+#define AD7746_CONF_MODE_PWRDN		GENMASK(3, 0)
+#define AD7746_CONF_MODE_OFFS_CAL	GENMASK(5, 0)
+#define AD7746_CONF_MODE_GAIN_CAL	GENMASK(6, 0)
 
 /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
-#define AD7746_CAPDAC_DACEN		(1 << 7)
+#define AD7746_CAPDAC_DACEN		BIT(7)
 #define AD7746_CAPDAC_DACP(x)		((x) & 0x7F)
 
 /*
Signature · 1 line
2.1.4
#1 lore raw
Quoted 2 lines · Shraddha Barke

Use BIT()/GENMASK() macros for all register definitions instead of hand-writing bit masks.

Hi Shraddha,

I think this should come as a patch series as you are replacing things with two different macros. You can go for one patch to replace all cases with BIT macro and another one to handle cases where you can use GENMASK macro.

Thanks

Quoted 91 lines

---
Changes in v2-
Used GENMASK macro; covered more cases of BIT macro and updated commit message

 drivers/staging/iio/cdc/ad7746.c | 52 ++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 26 deletions(-)
drivers/staging/iio/cdc/ad7746.c +26 -27
index 10fa372..a8049ef 100644
@@ -52,42 +52,42 @@
 #define AD7746_STATUS_RDYCAP           BIT(0)
 
 /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
-#define AD7746_CAPSETUP_CAPEN          (1 << 7)
-#define AD7746_CAPSETUP_CIN2           (1 << 6) /* AD7746 only */
-#define AD7746_CAPSETUP_CAPDIFF                (1 << 5)
-#define AD7746_CAPSETUP_CACHOP         (1 << 0)
+#define AD7746_CAPSETUP_CAPEN          BIT(7)
+#define AD7746_CAPSETUP_CIN2           BIT(6) /* AD7746 only */
+#define AD7746_CAPSETUP_CAPDIFF                BIT(5)
+#define AD7746_CAPSETUP_CACHOP         BIT(0)
 
 /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
-#define AD7746_VTSETUP_VTEN            (1 << 7)
-#define AD7746_VTSETUP_VTMD_INT_TEMP   (0 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_TEMP   (1 << 5)
-#define AD7746_VTSETUP_VTMD_VDD_MON    (2 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_VIN    (3 << 5)
-#define AD7746_VTSETUP_EXTREF          (1 << 4)
-#define AD7746_VTSETUP_VTSHORT         (1 << 1)
-#define AD7746_VTSETUP_VTCHOP          (1 << 0)
+#define AD7746_VTSETUP_VTEN            BIT(7)
+#define AD7746_VTSETUP_VTMD_INT_TEMP   0
+#define AD7746_VTSETUP_VTMD_EXT_TEMP   BIT(5)
+#define AD7746_VTSETUP_VTMD_VDD_MON    GENMASK(6, 0)
+#define AD7746_VTSETUP_VTMD_EXT_VIN    GENMASK(6, 5)
+#define AD7746_VTSETUP_EXTREF          BIT(4)
+#define AD7746_VTSETUP_VTSHORT         BIT(1)
+#define AD7746_VTSETUP_VTCHOP          BIT(0)
 
 /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
-#define AD7746_EXCSETUP_CLKCTRL                (1 << 7)
-#define AD7746_EXCSETUP_EXCON          (1 << 6)
-#define AD7746_EXCSETUP_EXCB           (1 << 5)
-#define AD7746_EXCSETUP_NEXCB          (1 << 4)
-#define AD7746_EXCSETUP_EXCA           (1 << 3)
-#define AD7746_EXCSETUP_NEXCA          (1 << 2)
-#define AD7746_EXCSETUP_EXCLVL(x)      (((x) & 0x3) << 0)
+#define AD7746_EXCSETUP_CLKCTRL                BIT(7)
+#define AD7746_EXCSETUP_EXCON          BIT(6)
+#define AD7746_EXCSETUP_EXCB           BIT(5)
+#define AD7746_EXCSETUP_NEXCB          BIT(4)
+#define AD7746_EXCSETUP_EXCA           BIT(3)
+#define AD7746_EXCSETUP_NEXCA          BIT(2)
+#define AD7746_EXCSETUP_EXCLVL(x)      GENMASK(((x) & 0x3), 0)
 
 /* Config Register Bit Designations (AD7746_REG_CFG) */
 #define AD7746_CONF_VTFS(x)            ((x) << 6)
 #define AD7746_CONF_CAPFS(x)           ((x) << 3)
-#define AD7746_CONF_MODE_IDLE          (0 << 0)
-#define AD7746_CONF_MODE_CONT_CONV     (1 << 0)
-#define AD7746_CONF_MODE_SINGLE_CONV   (2 << 0)
-#define AD7746_CONF_MODE_PWRDN         (3 << 0)
-#define AD7746_CONF_MODE_OFFS_CAL      (5 << 0)
-#define AD7746_CONF_MODE_GAIN_CAL      (6 << 0)
+#define AD7746_CONF_MODE_IDLE          0
+#define AD7746_CONF_MODE_CONT_CONV     GENMASK(1, 0)
+#define AD7746_CONF_MODE_SINGLE_CONV   GENMASK(2, 0)
+#define AD7746_CONF_MODE_PWRDN         GENMASK(3, 0)
+#define AD7746_CONF_MODE_OFFS_CAL      GENMASK(5, 0)
+#define AD7746_CONF_MODE_GAIN_CAL      GENMASK(6, 0)
 
 /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
-#define AD7746_CAPDAC_DACEN            (1 << 7)
+#define AD7746_CAPDAC_DACEN            BIT(7)
 #define AD7746_CAPDAC_DACP(x)          ((x) & 0x7F)
 
 /*
--

2.1.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1443666230-8999-1-git-send-email-shraddha.6596%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Signature · 1 line
Vaishali
#2 lore raw
Quoted 9 lines · Vaishali Thakkar
Quoted 2 lines · Shraddha Barke

Use BIT()/GENMASK() macros for all register definitions instead of hand-writing bit masks.

Hi Shraddha,

I think this should come as a patch series as you are replacing things with two different macros. You can go for one patch to replace all cases with BIT macro and another one to handle cases where you can use

Thanks Vaishali .Can I handle cases of BIT macro in multiple files in a single patch?

Shraddha

Quoted 101 lines

GENMASK macro.

Thanks

Quoted 91 lines

---
Changes in v2-
Used GENMASK macro; covered more cases of BIT macro and updated commit message

 drivers/staging/iio/cdc/ad7746.c | 52 ++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 26 deletions(-)
drivers/staging/iio/cdc/ad7746.c +26 -27
index 10fa372..a8049ef 100644
@@ -52,42 +52,42 @@
 #define AD7746_STATUS_RDYCAP           BIT(0)
 
 /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
-#define AD7746_CAPSETUP_CAPEN          (1 << 7)
-#define AD7746_CAPSETUP_CIN2           (1 << 6) /* AD7746 only */
-#define AD7746_CAPSETUP_CAPDIFF                (1 << 5)
-#define AD7746_CAPSETUP_CACHOP         (1 << 0)
+#define AD7746_CAPSETUP_CAPEN          BIT(7)
+#define AD7746_CAPSETUP_CIN2           BIT(6) /* AD7746 only */
+#define AD7746_CAPSETUP_CAPDIFF                BIT(5)
+#define AD7746_CAPSETUP_CACHOP         BIT(0)
 
 /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
-#define AD7746_VTSETUP_VTEN            (1 << 7)
-#define AD7746_VTSETUP_VTMD_INT_TEMP   (0 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_TEMP   (1 << 5)
-#define AD7746_VTSETUP_VTMD_VDD_MON    (2 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_VIN    (3 << 5)
-#define AD7746_VTSETUP_EXTREF          (1 << 4)
-#define AD7746_VTSETUP_VTSHORT         (1 << 1)
-#define AD7746_VTSETUP_VTCHOP          (1 << 0)
+#define AD7746_VTSETUP_VTEN            BIT(7)
+#define AD7746_VTSETUP_VTMD_INT_TEMP   0
+#define AD7746_VTSETUP_VTMD_EXT_TEMP   BIT(5)
+#define AD7746_VTSETUP_VTMD_VDD_MON    GENMASK(6, 0)
+#define AD7746_VTSETUP_VTMD_EXT_VIN    GENMASK(6, 5)
+#define AD7746_VTSETUP_EXTREF          BIT(4)
+#define AD7746_VTSETUP_VTSHORT         BIT(1)
+#define AD7746_VTSETUP_VTCHOP          BIT(0)
 
 /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
-#define AD7746_EXCSETUP_CLKCTRL                (1 << 7)
-#define AD7746_EXCSETUP_EXCON          (1 << 6)
-#define AD7746_EXCSETUP_EXCB           (1 << 5)
-#define AD7746_EXCSETUP_NEXCB          (1 << 4)
-#define AD7746_EXCSETUP_EXCA           (1 << 3)
-#define AD7746_EXCSETUP_NEXCA          (1 << 2)
-#define AD7746_EXCSETUP_EXCLVL(x)      (((x) & 0x3) << 0)
+#define AD7746_EXCSETUP_CLKCTRL                BIT(7)
+#define AD7746_EXCSETUP_EXCON          BIT(6)
+#define AD7746_EXCSETUP_EXCB           BIT(5)
+#define AD7746_EXCSETUP_NEXCB          BIT(4)
+#define AD7746_EXCSETUP_EXCA           BIT(3)
+#define AD7746_EXCSETUP_NEXCA          BIT(2)
+#define AD7746_EXCSETUP_EXCLVL(x)      GENMASK(((x) & 0x3), 0)
 
 /* Config Register Bit Designations (AD7746_REG_CFG) */
 #define AD7746_CONF_VTFS(x)            ((x) << 6)
 #define AD7746_CONF_CAPFS(x)           ((x) << 3)
-#define AD7746_CONF_MODE_IDLE          (0 << 0)
-#define AD7746_CONF_MODE_CONT_CONV     (1 << 0)
-#define AD7746_CONF_MODE_SINGLE_CONV   (2 << 0)
-#define AD7746_CONF_MODE_PWRDN         (3 << 0)
-#define AD7746_CONF_MODE_OFFS_CAL      (5 << 0)
-#define AD7746_CONF_MODE_GAIN_CAL      (6 << 0)
+#define AD7746_CONF_MODE_IDLE          0
+#define AD7746_CONF_MODE_CONT_CONV     GENMASK(1, 0)
+#define AD7746_CONF_MODE_SINGLE_CONV   GENMASK(2, 0)
+#define AD7746_CONF_MODE_PWRDN         GENMASK(3, 0)
+#define AD7746_CONF_MODE_OFFS_CAL      GENMASK(5, 0)
+#define AD7746_CONF_MODE_GAIN_CAL      GENMASK(6, 0)
 
 /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
-#define AD7746_CAPDAC_DACEN            (1 << 7)
+#define AD7746_CAPDAC_DACEN            BIT(7)
 #define AD7746_CAPDAC_DACP(x)          ((x) & 0x7F)
 
 /*
--

2.1.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1443666230-8999-1-git-send-email-shraddha.6596%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Signature · 1 line
Vaishali
#3 lore raw
Quoted 13 lines · Shraddha Barke
Quoted 9 lines · Vaishali Thakkar
Quoted 3 lines · Shraddha Barke

Use BIT()/GENMASK() macros for all register definitions instead of hand-writing bit masks.

Hi Shraddha,

Quoted 8 lines
Quoted 4 lines

I think this should come as a patch series as you are replacing things with
two different macros. You can go for one patch to replace all cases with BIT macro and another one to handle cases where you can use

Thanks Vaishali .Can I handle cases of BIT macro in multiple files in a single patch?

Yes, you can. But only when those files belongs to single directory. eg. You can handle files which comes under drivers/staging/iio/cdc/ at a single point of time. Like you did here:

https://git.kernel.org/cgit/linux/kernel/git/next/linux-next.git/commit/?id=64ffdc383b18e66c3698fff05ea693f4346cfbf9

Although for this patch, I think just sending a patch series with v3 is preferable. You can go for sending separate patches for other such cases.

Quoted 113 lines

Shraddha

Quoted 109 lines

GENMASK macro.

Thanks

Quoted 89 lines

---
Changes in v2-
Used GENMASK macro; covered more cases of BIT macro and updated commit message

 drivers/staging/iio/cdc/ad7746.c | 52
++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 26 deletions(-)
drivers/staging/iio/cdc/ad7746.c +0 -0
index 10fa372..a8049ef 100644
@@ -52,42 +52,42 @@
 #define AD7746_STATUS_RDYCAP           BIT(0)
 
 /* Capacitive Channel Setup Register Bit Designations

(AD7746_REG_CAP_SETUP) */

drivers/staging/iio/cdc/ad7746.c +4 -4
-#define AD7746_CAPSETUP_CAPEN          (1 << 7)
-#define AD7746_CAPSETUP_CIN2           (1 << 6) /* AD7746 only */
-#define AD7746_CAPSETUP_CAPDIFF                (1 << 5)
-#define AD7746_CAPSETUP_CACHOP         (1 << 0)
+#define AD7746_CAPSETUP_CAPEN          BIT(7)
+#define AD7746_CAPSETUP_CIN2           BIT(6) /* AD7746 only */
+#define AD7746_CAPSETUP_CAPDIFF                BIT(5)
+#define AD7746_CAPSETUP_CACHOP         BIT(0)
 
 /* Voltage/Temperature Setup Register Bit Designations

(AD7746_REG_VT_SETUP) */

drivers/staging/iio/cdc/ad7746.c +22 -23
-#define AD7746_VTSETUP_VTEN            (1 << 7)
-#define AD7746_VTSETUP_VTMD_INT_TEMP   (0 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_TEMP   (1 << 5)
-#define AD7746_VTSETUP_VTMD_VDD_MON    (2 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_VIN    (3 << 5)
-#define AD7746_VTSETUP_EXTREF          (1 << 4)
-#define AD7746_VTSETUP_VTSHORT         (1 << 1)
-#define AD7746_VTSETUP_VTCHOP          (1 << 0)
+#define AD7746_VTSETUP_VTEN            BIT(7)
+#define AD7746_VTSETUP_VTMD_INT_TEMP   0
+#define AD7746_VTSETUP_VTMD_EXT_TEMP   BIT(5)
+#define AD7746_VTSETUP_VTMD_VDD_MON    GENMASK(6, 0)
+#define AD7746_VTSETUP_VTMD_EXT_VIN    GENMASK(6, 5)
+#define AD7746_VTSETUP_EXTREF          BIT(4)
+#define AD7746_VTSETUP_VTSHORT         BIT(1)
+#define AD7746_VTSETUP_VTCHOP          BIT(0)
 
 /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
-#define AD7746_EXCSETUP_CLKCTRL                (1 << 7)
-#define AD7746_EXCSETUP_EXCON          (1 << 6)
-#define AD7746_EXCSETUP_EXCB           (1 << 5)
-#define AD7746_EXCSETUP_NEXCB          (1 << 4)
-#define AD7746_EXCSETUP_EXCA           (1 << 3)
-#define AD7746_EXCSETUP_NEXCA          (1 << 2)
-#define AD7746_EXCSETUP_EXCLVL(x)      (((x) & 0x3) << 0)
+#define AD7746_EXCSETUP_CLKCTRL                BIT(7)
+#define AD7746_EXCSETUP_EXCON          BIT(6)
+#define AD7746_EXCSETUP_EXCB           BIT(5)
+#define AD7746_EXCSETUP_NEXCB          BIT(4)
+#define AD7746_EXCSETUP_EXCA           BIT(3)
+#define AD7746_EXCSETUP_NEXCA          BIT(2)
+#define AD7746_EXCSETUP_EXCLVL(x)      GENMASK(((x) & 0x3), 0)
 
 /* Config Register Bit Designations (AD7746_REG_CFG) */
 #define AD7746_CONF_VTFS(x)            ((x) << 6)
 #define AD7746_CONF_CAPFS(x)           ((x) << 3)
-#define AD7746_CONF_MODE_IDLE          (0 << 0)
-#define AD7746_CONF_MODE_CONT_CONV     (1 << 0)
-#define AD7746_CONF_MODE_SINGLE_CONV   (2 << 0)
-#define AD7746_CONF_MODE_PWRDN         (3 << 0)
-#define AD7746_CONF_MODE_OFFS_CAL      (5 << 0)
-#define AD7746_CONF_MODE_GAIN_CAL      (6 << 0)
+#define AD7746_CONF_MODE_IDLE          0
+#define AD7746_CONF_MODE_CONT_CONV     GENMASK(1, 0)
+#define AD7746_CONF_MODE_SINGLE_CONV   GENMASK(2, 0)
+#define AD7746_CONF_MODE_PWRDN         GENMASK(3, 0)
+#define AD7746_CONF_MODE_OFFS_CAL      GENMASK(5, 0)
+#define AD7746_CONF_MODE_GAIN_CAL      GENMASK(6, 0)
 
 /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
-#define AD7746_CAPDAC_DACEN            (1 << 7)
+#define AD7746_CAPDAC_DACEN            BIT(7)
 #define AD7746_CAPDAC_DACP(x)          ((x) & 0x7F)
 
 /*
--

2.1.4

Quoted 9 lines

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected]. To view this discussion on the web visit
https://groups.google.com/d/msgid/outreachy-kernel/1443666230-8999-1-git-send-email-shraddha.6596%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
Vaishali

Signature · 1 line
Vaishali
#4 lore raw
In reply to Shraddha Barke
Quoted 2 lines · Shraddha Barke

Use BIT()/GENMASK() macros for all register definitions instead of hand-writing bit masks.

It would be nice to fix the alignment at various palaces as well.

julia

Quoted 92 lines

---
Changes in v2-
Used GENMASK macro; covered more cases of BIT macro and updated commit message

 drivers/staging/iio/cdc/ad7746.c | 52 ++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 26 deletions(-)
drivers/staging/iio/cdc/ad7746.c +26 -27
index 10fa372..a8049ef 100644
@@ -52,42 +52,42 @@
 #define AD7746_STATUS_RDYCAP		BIT(0)
 
 /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
-#define AD7746_CAPSETUP_CAPEN		(1 << 7)
-#define AD7746_CAPSETUP_CIN2		(1 << 6) /* AD7746 only */
-#define AD7746_CAPSETUP_CAPDIFF		(1 << 5)
-#define AD7746_CAPSETUP_CACHOP		(1 << 0)
+#define AD7746_CAPSETUP_CAPEN		BIT(7)
+#define AD7746_CAPSETUP_CIN2		BIT(6) /* AD7746 only */
+#define AD7746_CAPSETUP_CAPDIFF		BIT(5)
+#define AD7746_CAPSETUP_CACHOP		BIT(0)
 
 /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
-#define AD7746_VTSETUP_VTEN		(1 << 7)
-#define AD7746_VTSETUP_VTMD_INT_TEMP	(0 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_TEMP	(1 << 5)
-#define AD7746_VTSETUP_VTMD_VDD_MON	(2 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_VIN	(3 << 5)
-#define AD7746_VTSETUP_EXTREF		(1 << 4)
-#define AD7746_VTSETUP_VTSHORT		(1 << 1)
-#define AD7746_VTSETUP_VTCHOP		(1 << 0)
+#define AD7746_VTSETUP_VTEN		BIT(7)
+#define AD7746_VTSETUP_VTMD_INT_TEMP	0
+#define AD7746_VTSETUP_VTMD_EXT_TEMP	BIT(5)
+#define AD7746_VTSETUP_VTMD_VDD_MON	GENMASK(6, 0)
+#define AD7746_VTSETUP_VTMD_EXT_VIN	GENMASK(6, 5)
+#define AD7746_VTSETUP_EXTREF		BIT(4)
+#define AD7746_VTSETUP_VTSHORT		BIT(1)
+#define AD7746_VTSETUP_VTCHOP		BIT(0)
 
 /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
-#define AD7746_EXCSETUP_CLKCTRL		(1 << 7)
-#define AD7746_EXCSETUP_EXCON		(1 << 6)
-#define AD7746_EXCSETUP_EXCB		(1 << 5)
-#define AD7746_EXCSETUP_NEXCB		(1 << 4)
-#define AD7746_EXCSETUP_EXCA		(1 << 3)
-#define AD7746_EXCSETUP_NEXCA		(1 << 2)
-#define AD7746_EXCSETUP_EXCLVL(x)	(((x) & 0x3) << 0)
+#define AD7746_EXCSETUP_CLKCTRL		BIT(7)
+#define AD7746_EXCSETUP_EXCON		BIT(6)
+#define AD7746_EXCSETUP_EXCB		BIT(5)
+#define AD7746_EXCSETUP_NEXCB		BIT(4)
+#define AD7746_EXCSETUP_EXCA		BIT(3)
+#define AD7746_EXCSETUP_NEXCA		BIT(2)
+#define AD7746_EXCSETUP_EXCLVL(x)	GENMASK(((x) & 0x3), 0)
 
 /* Config Register Bit Designations (AD7746_REG_CFG) */
 #define AD7746_CONF_VTFS(x)		((x) << 6)
 #define AD7746_CONF_CAPFS(x)		((x) << 3)
-#define AD7746_CONF_MODE_IDLE		(0 << 0)
-#define AD7746_CONF_MODE_CONT_CONV	(1 << 0)
-#define AD7746_CONF_MODE_SINGLE_CONV	(2 << 0)
-#define AD7746_CONF_MODE_PWRDN		(3 << 0)
-#define AD7746_CONF_MODE_OFFS_CAL	(5 << 0)
-#define AD7746_CONF_MODE_GAIN_CAL	(6 << 0)
+#define AD7746_CONF_MODE_IDLE		0
+#define AD7746_CONF_MODE_CONT_CONV	GENMASK(1, 0)
+#define AD7746_CONF_MODE_SINGLE_CONV	GENMASK(2, 0)
+#define AD7746_CONF_MODE_PWRDN		GENMASK(3, 0)
+#define AD7746_CONF_MODE_OFFS_CAL	GENMASK(5, 0)
+#define AD7746_CONF_MODE_GAIN_CAL	GENMASK(6, 0)
 
 /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
-#define AD7746_CAPDAC_DACEN		(1 << 7)
+#define AD7746_CAPDAC_DACEN		BIT(7)
 #define AD7746_CAPDAC_DACP(x)		((x) & 0x7F)
 
 /*
--

2.1.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1443666230-8999-1-git-send-email-shraddha.6596%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

#5 lore raw
Quoted 8 lines · Julia Lawall
Quoted 2 lines · Shraddha Barke

Use BIT()/GENMASK() macros for all register definitions instead of hand-writing bit masks.

It would be nice to fix the alignment at various palaces as well.

Hello Julia,
Yes I know it looks messy. But I'm not able to figure out how I should
fix this alignment issue. I have faced this problem while sending patches before as well. I use git-send-email for sending patches.

Shraddha.

Quoted 96 lines

julia

Quoted 92 lines

---
Changes in v2-
Used GENMASK macro; covered more cases of BIT macro and updated commit message

 drivers/staging/iio/cdc/ad7746.c | 52 ++++++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 26 deletions(-)
drivers/staging/iio/cdc/ad7746.c +26 -27
index 10fa372..a8049ef 100644
@@ -52,42 +52,42 @@
 #define AD7746_STATUS_RDYCAP		BIT(0)
 
 /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
-#define AD7746_CAPSETUP_CAPEN		(1 << 7)
-#define AD7746_CAPSETUP_CIN2		(1 << 6) /* AD7746 only */
-#define AD7746_CAPSETUP_CAPDIFF		(1 << 5)
-#define AD7746_CAPSETUP_CACHOP		(1 << 0)
+#define AD7746_CAPSETUP_CAPEN		BIT(7)
+#define AD7746_CAPSETUP_CIN2		BIT(6) /* AD7746 only */
+#define AD7746_CAPSETUP_CAPDIFF		BIT(5)
+#define AD7746_CAPSETUP_CACHOP		BIT(0)
 
 /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
-#define AD7746_VTSETUP_VTEN		(1 << 7)
-#define AD7746_VTSETUP_VTMD_INT_TEMP	(0 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_TEMP	(1 << 5)
-#define AD7746_VTSETUP_VTMD_VDD_MON	(2 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_VIN	(3 << 5)
-#define AD7746_VTSETUP_EXTREF		(1 << 4)
-#define AD7746_VTSETUP_VTSHORT		(1 << 1)
-#define AD7746_VTSETUP_VTCHOP		(1 << 0)
+#define AD7746_VTSETUP_VTEN		BIT(7)
+#define AD7746_VTSETUP_VTMD_INT_TEMP	0
+#define AD7746_VTSETUP_VTMD_EXT_TEMP	BIT(5)
+#define AD7746_VTSETUP_VTMD_VDD_MON	GENMASK(6, 0)
+#define AD7746_VTSETUP_VTMD_EXT_VIN	GENMASK(6, 5)
+#define AD7746_VTSETUP_EXTREF		BIT(4)
+#define AD7746_VTSETUP_VTSHORT		BIT(1)
+#define AD7746_VTSETUP_VTCHOP		BIT(0)
 
 /* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */
-#define AD7746_EXCSETUP_CLKCTRL		(1 << 7)
-#define AD7746_EXCSETUP_EXCON		(1 << 6)
-#define AD7746_EXCSETUP_EXCB		(1 << 5)
-#define AD7746_EXCSETUP_NEXCB		(1 << 4)
-#define AD7746_EXCSETUP_EXCA		(1 << 3)
-#define AD7746_EXCSETUP_NEXCA		(1 << 2)
-#define AD7746_EXCSETUP_EXCLVL(x)	(((x) & 0x3) << 0)
+#define AD7746_EXCSETUP_CLKCTRL		BIT(7)
+#define AD7746_EXCSETUP_EXCON		BIT(6)
+#define AD7746_EXCSETUP_EXCB		BIT(5)
+#define AD7746_EXCSETUP_NEXCB		BIT(4)
+#define AD7746_EXCSETUP_EXCA		BIT(3)
+#define AD7746_EXCSETUP_NEXCA		BIT(2)
+#define AD7746_EXCSETUP_EXCLVL(x)	GENMASK(((x) & 0x3), 0)
 
 /* Config Register Bit Designations (AD7746_REG_CFG) */
 #define AD7746_CONF_VTFS(x)		((x) << 6)
 #define AD7746_CONF_CAPFS(x)		((x) << 3)
-#define AD7746_CONF_MODE_IDLE		(0 << 0)
-#define AD7746_CONF_MODE_CONT_CONV	(1 << 0)
-#define AD7746_CONF_MODE_SINGLE_CONV	(2 << 0)
-#define AD7746_CONF_MODE_PWRDN		(3 << 0)
-#define AD7746_CONF_MODE_OFFS_CAL	(5 << 0)
-#define AD7746_CONF_MODE_GAIN_CAL	(6 << 0)
+#define AD7746_CONF_MODE_IDLE		0
+#define AD7746_CONF_MODE_CONT_CONV	GENMASK(1, 0)
+#define AD7746_CONF_MODE_SINGLE_CONV	GENMASK(2, 0)
+#define AD7746_CONF_MODE_PWRDN		GENMASK(3, 0)
+#define AD7746_CONF_MODE_OFFS_CAL	GENMASK(5, 0)
+#define AD7746_CONF_MODE_GAIN_CAL	GENMASK(6, 0)
 
 /* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */
-#define AD7746_CAPDAC_DACEN		(1 << 7)
+#define AD7746_CAPDAC_DACEN		BIT(7)
 #define AD7746_CAPDAC_DACP(x)		((x) & 0x7F)
 
 /*
--

2.1.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/1443666230-8999-1-git-send-email-shraddha.6596%40gmail.com.
For more options, visit https://groups.google.com/d/optout.