Skip to contentSkip to conversation

Staging: iio: cdc: Prefer using the BIT macro

PATCH In review Shraddha Barke 3 participants 7 messages Sep 30, 2015

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

PATCH 1/1 Staging: iio: cdc: Prefer using the BIT macro

Replace bit shifting on 1 with the BIT(x) macro

This was done with coccinelle:
@@ int g; @@

-(1 << g)
+BIT(g)

---
 drivers/staging/iio/cdc/ad7746.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/cdc/ad7746.c +4 -4
index 10fa372..aa97437 100644
@@ -52,10 +52,10 @@
 #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)
Signature · 1 line
2.1.4
#1 lore raw
Quoted 22 lines · Shraddha Barke

Replace bit shifting on 1 with the BIT(x) macro

This was done with coccinelle:
@@ int g; @@

(quoted diff) +1 -1
-(1 << g)
+BIT(g)
---
 drivers/staging/iio/cdc/ad7746.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/cdc/ad7746.c +0 -1
index 10fa372..aa97437 100644
@@ -52,10 +52,10 @@
 #define AD7746_STATUS_RDYCAP           BIT(0)
 
 /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
-#define AD7746_CAPSETUP_CAPEN          (1 << 7)

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

Quoted 10 lines
drivers/staging/iio/cdc/ad7746.c +4 -3
-#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)

What about this? It's preferred to fix all issues of the same type in a single patch.

thanks,
Daniel.

#2 lore raw
Quoted 31 lines · Daniel Baluta
Quoted 30 lines · Shraddha Barke

Replace bit shifting on 1 with the BIT(x) macro

This was done with coccinelle:
@@ int g; @@

(quoted diff) +1 -1
-(1 << g)
+BIT(g)
---
 drivers/staging/iio/cdc/ad7746.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/cdc/ad7746.c +4 -4
index 10fa372..aa97437 100644
@@ -52,10 +52,10 @@
 #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)
 
Quoted 5 lines

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

Quoted 2 lines
drivers/staging/iio/cdc/ad7746.c +0 -0
 /* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */
 #define AD7746_VTSETUP_VTEN            (1 << 7)

What about this? It's preferred to fix all issues of the same type in a single patch.

These are instances of mixed cases of BIT macro. Wouldn't it be better to leave them as is ?
Should I change them ?

Shraddha

Quoted 4 lines

thanks,
Daniel.

#3 lore raw
Quoted 48 lines · Shraddha Barke
Quoted 35 lines · Daniel Baluta
Quoted 33 lines · Shraddha Barke

Replace bit shifting on 1 with the BIT(x) macro

This was done with coccinelle:
@@ int g; @@

(quoted diff) +1 -1
-(1 << g)
+BIT(g)
---
 drivers/staging/iio/cdc/ad7746.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/cdc/ad7746.c +0 -0
index 10fa372..aa97437 100644
@@ -52,10 +52,10 @@
 #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)
Quoted 7 lines
Quoted 3 lines

/* Voltage/Temperature Setup Register Bit Designations
(AD7746_REG_VT_SETUP) */
#define AD7746_VTSETUP_VTEN (1 << 7)

What about this? It's preferred to fix all issues of the same type in a single patch.

Quoted 3 lines

These are instances of mixed cases of BIT macro. Wouldn't it be better to leave them as is ?
Should I change them ?

Hmm, isn't

#define AD7746_VTSETUP_VTEN (1 << 7)

the same as the macros you've fixed?

#4 lore raw
Quoted 53 lines · Daniel Baluta
Quoted 48 lines · Shraddha Barke
Quoted 35 lines · Daniel Baluta
Quoted 33 lines · Shraddha Barke

Replace bit shifting on 1 with the BIT(x) macro

This was done with coccinelle:
@@ int g; @@

(quoted diff) +1 -1
-(1 << g)
+BIT(g)
---
 drivers/staging/iio/cdc/ad7746.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/cdc/ad7746.c +0 -0
index 10fa372..aa97437 100644
@@ -52,10 +52,10 @@
 #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)
Quoted 7 lines
Quoted 3 lines

/* Voltage/Temperature Setup Register Bit Designations
(AD7746_REG_VT_SETUP) */
#define AD7746_VTSETUP_VTEN (1 << 7)

What about this? It's preferred to fix all issues of the same type in a single patch.

Quoted 3 lines

These are instances of mixed cases of BIT macro. Wouldn't it be better to leave them as is ?
Should I change them ?

Quoted 6 lines

Hmm, isn't

#define AD7746_VTSETUP_VTEN (1 << 7)

the same as the macros you've fixed?

Yes it is. What I meant was it is a part of this bunch-

/* 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)

so I won't be able to replace all of them by BIT(x).

Shraddha

#5 lore raw
Quoted 74 lines · Shraddha Barke
Quoted 60 lines · Daniel Baluta
Quoted 53 lines · Shraddha Barke
Quoted 37 lines · Daniel Baluta
Quoted 34 lines · Shraddha Barke

Replace bit shifting on 1 with the BIT(x) macro

This was done with coccinelle:
@@ int g; @@

(quoted diff) +1 -1
-(1 << g)
+BIT(g)
---
 drivers/staging/iio/cdc/ad7746.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/cdc/ad7746.c +0 -0
index 10fa372..aa97437 100644
@@ -52,10 +52,10 @@
 #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)
Quoted 8 lines
Quoted 3 lines

/* Voltage/Temperature Setup Register Bit Designations
(AD7746_REG_VT_SETUP) */
#define AD7746_VTSETUP_VTEN (1 << 7)

What about this? It's preferred to fix all issues of the same type in a single patch.

Quoted 3 lines

These are instances of mixed cases of BIT macro. Wouldn't it be better to leave them as is ?
Should I change them ?

Quoted 6 lines

Hmm, isn't

#define AD7746_VTSETUP_VTEN (1 << 7)

the same as the macros you've fixed?

Yes it is. What I meant was it is a part of this bunch-

/* Voltage/Temperature Setup Register Bit Designations (AD7746_REG_VT_SETUP) */

Quoted 8 lines
#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)

Have a look at GENMASK :).

thanks,
Daniel.

#6 lore raw
In reply to Shraddha Barke
Quoted 18 lines · Shraddha Barke

Replace bit shifting on 1 with the BIT(x) macro

This was done with coccinelle:
@@ int g; @@

(quoted diff) +1 -1
-(1 << g)
+BIT(g)
---
 drivers/staging/iio/cdc/ad7746.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/iio/cdc/ad7746.c +0 -0
index 10fa372..aa97437 100644

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

Quoted 9 lines
drivers/staging/iio/cdc/ad7746.c +2 -4
@@ -52,10 +52,10 @@
 #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 */

It looks like you could improve the indentation here, since BIT is a little shorter than the original code.

julia

Quoted 15 lines
drivers/staging/iio/cdc/ad7746.c +2 -1
+#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)
--

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/1443621463-8343-1-git-send-email-shraddha.6596%40gmail.com.
For more options, visit https://groups.google.com/d/optout.