Skip to contentSkip to conversation

staging: iio: cdc: ad7746: Replace bitshift by BIT

PATCH In review Lucas Oshiro 4 participants 4 messages Apr 3, 2019 – Apr 8, 2019

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

PATCH 1/1 staging: iio: cdc: ad7746: Replace bitshift by BIT

Replace bitshifts on lines 54, 56 and 78 of ad7746.c.

---
 drivers/staging/iio/cdc/ad7746.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/cdc/ad7746.c +3 -3
index 0eb28fea876e..ea48b14cee72 100644
@@ -51,9 +51,9 @@
 #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_VTEN		BIT(7)
 #define AD7746_VTSETUP_VTMD_INT_TEMP	(0 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_TEMP	(1 << 5)
+#define AD7746_VTSETUP_VTMD_EXT_TEMP	BIT(5)
 #define AD7746_VTSETUP_VTMD_VDD_MON	(2 << 5)
 #define AD7746_VTSETUP_VTMD_EXT_VIN	(3 << 5)
 #define AD7746_VTSETUP_EXTREF		BIT(4)
@@ -75,7 +75,7 @@
 #define AD7746_CONF_VTFS_MASK		GENMASK(7, 6)
 #define AD7746_CONF_CAPFS_MASK		GENMASK(5, 3)
 #define AD7746_CONF_MODE_IDLE		(0 << 0)
-#define AD7746_CONF_MODE_CONT_CONV	(1 << 0)
+#define AD7746_CONF_MODE_CONT_CONV	BIT(0)
 #define AD7746_CONF_MODE_SINGLE_CONV	(2 << 0)
 #define AD7746_CONF_MODE_PWRDN		(3 << 0)
 #define AD7746_CONF_MODE_OFFS_CAL	(5 << 0)
Signature · 1 line
2.21.0
#1 lore raw
Quoted 3 lines · Lucas Oshiro

Replace bitshifts on lines 54, 56 and 78 of ad7746.c.

Hey,
This is only partially done.
If doing conversions to BIT(x) macro, I would say to do them for all cases.

Thanks
Alex

Quoted 33 lines
---
 drivers/staging/iio/cdc/ad7746.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/cdc/ad7746.c +3 -4
index 0eb28fea876e..ea48b14cee72 100644
@@ -51,9 +51,9 @@
 #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_VTEN            BIT(7)
 #define AD7746_VTSETUP_VTMD_INT_TEMP   (0 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_TEMP   (1 << 5)
+#define AD7746_VTSETUP_VTMD_EXT_TEMP   BIT(5)
 #define AD7746_VTSETUP_VTMD_VDD_MON    (2 << 5)
 #define AD7746_VTSETUP_VTMD_EXT_VIN    (3 << 5)
 #define AD7746_VTSETUP_EXTREF          BIT(4)
@@ -75,7 +75,7 @@
 #define AD7746_CONF_VTFS_MASK          GENMASK(7, 6)
 #define AD7746_CONF_CAPFS_MASK         GENMASK(5, 3)
 #define AD7746_CONF_MODE_IDLE          (0 << 0)
-#define AD7746_CONF_MODE_CONT_CONV     (1 << 0)
+#define AD7746_CONF_MODE_CONT_CONV     BIT(0)
 #define AD7746_CONF_MODE_SINGLE_CONV   (2 << 0)
 #define AD7746_CONF_MODE_PWRDN         (3 << 0)
 #define AD7746_CONF_MODE_OFFS_CAL      (5 << 0)
--

2.21.0

#2 lore raw
In reply to Lucas Oshiro

drivers/staging/iio/cdc/ad7746.c line 56

Quoted 3 lines · Lucas Oshiro

#define AD7746_VTSETUP_VTMD_INT_TEMP (0 << 5)

drivers/staging/iio/cdc/ad7746.c +1 -1
-#define AD7746_VTSETUP_VTMD_EXT_TEMP	(1 << 5)
+#define AD7746_VTSETUP_VTMD_EXT_TEMP	BIT(5)

No, the original is more readable. Otherwise you can't see that it's part of a set.

Just ignore checkpatch when it gives nonsense advice.

regards,
dan carpenter

#3 lore raw
In reply to Lucas Oshiro
Quoted 1 line · Lucas Oshiro

Replace bitshifts on lines 54, 56 and 78 of ad7746.c.

checkpatch is not something that should be followed blindly. Look at the shifted blocks and determine if you think it was better before your proposed change.

drivers/staging/iio/cdc/ad7746.c

Quoted 1 line
drivers/staging/iio/cdc/ad7746.c +0 -0

[]

Quoted 13 lines
drivers/staging/iio/cdc/ad7746.c +2 -2
@@ -51,9 +51,9 @@
 #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_VTEN		BIT(7)
 #define AD7746_VTSETUP_VTMD_INT_TEMP	(0 << 5)
-#define AD7746_VTSETUP_VTMD_EXT_TEMP	(1 << 5)
+#define AD7746_VTSETUP_VTMD_EXT_TEMP	BIT(5)
 #define AD7746_VTSETUP_VTMD_VDD_MON	(2 << 5)
 #define AD7746_VTSETUP_VTMD_EXT_VIN	(3 << 5)
 #define AD7746_VTSETUP_EXTREF		BIT(4)

drivers/staging/iio/cdc/ad7746.c line 81

Quoted 8 lines
drivers/staging/iio/cdc/ad7746.c +1 -1
@@ -75,7 +75,7 @@
 #define AD7746_CONF_VTFS_MASK		GENMASK(7, 6)
 #define AD7746_CONF_CAPFS_MASK		GENMASK(5, 3)
 #define AD7746_CONF_MODE_IDLE		(0 << 0)
-#define AD7746_CONF_MODE_CONT_CONV	(1 << 0)
+#define AD7746_CONF_MODE_CONT_CONV	BIT(0)
 #define AD7746_CONF_MODE_SINGLE_CONV	(2 << 0)
 #define AD7746_CONF_MODE_PWRDN		(3 << 0)
 #define AD7746_CONF_MODE_OFFS_CAL	(5 << 0)

Now the code looks unbalanced.