[4/6] Staging: iio: cdc: Prefer using the BIT macro
diff mbox series

Message ID 1441902761-11190-1-git-send-email-shraddha.6596@gmail.com
State New, archived
Headers show
Series
  • [1/6] Staging: iio: addac: Prefer using the BIT macro
Related show

Commit Message

Shraddha Barke Sept. 10, 2015, 4:32 p.m. UTC
This patch replaces bit shifting on 1 with the BIT(x) macro

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

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

Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
---
 drivers/staging/iio/cdc/ad7746.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Jonathan Cameron Sept. 12, 2015, 9:47 a.m. UTC | #1
On 10/09/15 17:32, Shraddha Barke wrote:
> This patch replaces bit shifting on 1 with the BIT(x) macro
> 
> This was done with coccinelle:
> @@ int g; @@
> 
> -(1 << g)
> +BIT(g)
> 
> Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
Something odd happened here as this is only a small proportion of the cases
that should be updated in this file.  There's one at the bottom of the
patch for starters!

This driver also uses  a lot of cases of 0 shifted to represent
the opposite state for a given bit in the register.  The effective
documentation provided by that is lost if we convert the bit set ones
over like this.  Might seem odd, but perhaps we need a ZERO(X) macro
as well (which is of course always 0) to cover that approach.

Jonathan
> ---
>  drivers/staging/iio/cdc/ad7746.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
> index e6e9eaa..10fa372 100644
> --- a/drivers/staging/iio/cdc/ad7746.c
> +++ b/drivers/staging/iio/cdc/ad7746.c
> @@ -46,10 +46,10 @@
>  #define AD7746_REG_VOLT_GAINL		18
>  
>  /* Status Register Bit Designations (AD7746_REG_STATUS) */
> -#define AD7746_STATUS_EXCERR		(1 << 3)
> -#define AD7746_STATUS_RDY		(1 << 2)
> -#define AD7746_STATUS_RDYVT		(1 << 1)
> -#define AD7746_STATUS_RDYCAP		(1 << 0)
> +#define AD7746_STATUS_EXCERR		BIT(3)
> +#define AD7746_STATUS_RDY		BIT(2)
> +#define AD7746_STATUS_RDYVT		BIT(1)
> +#define AD7746_STATUS_RDYCAP		BIT(0)
>  
>  /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
>  #define AD7746_CAPSETUP_CAPEN		(1 << 7)
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Greg Kroah-Hartman Sept. 12, 2015, 3:49 p.m. UTC | #2
On Sat, Sep 12, 2015 at 04:47:23PM +0530, Shraddha Barke wrote:
> 
> 
> On Sat, Sep 12, 2015 at 3:17 PM, Jonathan Cameron <jic23@kernel.org> wrote:
> 
>     On 10/09/15 17:32, Shraddha Barke wrote:
>     > This patch replaces bit shifting on 1 with the BIT(x) macro
>     >
>     > This was done with coccinelle:
>     > @@ int g; @@
>     >
>     > -(1 << g)
>     > +BIT(g)
>     >
>     > Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
>     Something odd happened here as this is only a small proportion of the cases
>     that should be updated in this file.  There's one at the bottom of the
>     patch for starters!
> 
> 
> I didn't apply BIT(x) for mixed cases.I think I should drop this patch
> altogether but
> Greg has added it. Will it cause problems ? :(

Greg can always drop it :)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Patch
diff mbox series

diff --git a/drivers/staging/iio/cdc/ad7746.c b/drivers/staging/iio/cdc/ad7746.c
index e6e9eaa..10fa372 100644
--- a/drivers/staging/iio/cdc/ad7746.c
+++ b/drivers/staging/iio/cdc/ad7746.c
@@ -46,10 +46,10 @@ 
 #define AD7746_REG_VOLT_GAINL		18
 
 /* Status Register Bit Designations (AD7746_REG_STATUS) */
-#define AD7746_STATUS_EXCERR		(1 << 3)
-#define AD7746_STATUS_RDY		(1 << 2)
-#define AD7746_STATUS_RDYVT		(1 << 1)
-#define AD7746_STATUS_RDYCAP		(1 << 0)
+#define AD7746_STATUS_EXCERR		BIT(3)
+#define AD7746_STATUS_RDY		BIT(2)
+#define AD7746_STATUS_RDYVT		BIT(1)
+#define AD7746_STATUS_RDYCAP		BIT(0)
 
 /* Capacitive Channel Setup Register Bit Designations (AD7746_REG_CAP_SETUP) */
 #define AD7746_CAPSETUP_CAPEN		(1 << 7)