linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4/6] Staging: iio: cdc: Prefer using the BIT macro
@ 2015-09-10 16:32 Shraddha Barke
  2015-09-10 16:32 ` [PATCH 5/6] Staging: lustre: ptlrpc: " Shraddha Barke
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-09-10 16:32 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Julia Lawall, Hartmut Knaack, Andreas Dilger
  Cc: Ian Abbott, linux-iio, linux-kernel, Shraddha Barke

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(-)

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)
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 5/6] Staging: lustre: ptlrpc: Prefer using the BIT macro
  2015-09-10 16:32 [PATCH 4/6] Staging: iio: cdc: Prefer using the BIT macro Shraddha Barke
@ 2015-09-10 16:32 ` Shraddha Barke
  2015-09-10 16:32 ` [PATCH 6/6] Staging: comedi: " Shraddha Barke
  2015-09-12  9:47 ` [PATCH 4/6] Staging: iio: cdc: " Jonathan Cameron
  2 siblings, 0 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-09-10 16:32 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Julia Lawall, Hartmut Knaack, Andreas Dilger
  Cc: Ian Abbott, linux-iio, linux-kernel, Shraddha Barke

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/lustre/lustre/ptlrpc/layout.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/lustre/lustre/ptlrpc/layout.c b/drivers/staging/lustre/lustre/ptlrpc/layout.c
index d14c200..5d19cfc 100644
--- a/drivers/staging/lustre/lustre/ptlrpc/layout.c
+++ b/drivers/staging/lustre/lustre/ptlrpc/layout.c
@@ -789,17 +789,17 @@ enum rmf_flags {
 	/**
 	 * The field is a string, must be NUL-terminated.
 	 */
-	RMF_F_STRING = 1 << 0,
+	RMF_F_STRING = BIT(0),
 	/**
 	 * The field's buffer size need not match the declared \a rmf_size.
 	 */
-	RMF_F_NO_SIZE_CHECK = 1 << 1,
+	RMF_F_NO_SIZE_CHECK = BIT(1),
 	/**
 	 * The field's buffer size must be a whole multiple of the declared \a
 	 * rmf_size and the \a rmf_swabber function must work on the declared \a
 	 * rmf_size worth of bytes.
 	 */
-	RMF_F_STRUCT_ARRAY = 1 << 2
+	RMF_F_STRUCT_ARRAY = BIT(2)
 };
 
 struct req_capsule;
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 6/6] Staging: comedi: Prefer using the BIT macro
  2015-09-10 16:32 [PATCH 4/6] Staging: iio: cdc: Prefer using the BIT macro Shraddha Barke
  2015-09-10 16:32 ` [PATCH 5/6] Staging: lustre: ptlrpc: " Shraddha Barke
@ 2015-09-10 16:32 ` Shraddha Barke
  2015-09-12  9:47 ` [PATCH 4/6] Staging: iio: cdc: " Jonathan Cameron
  2 siblings, 0 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-09-10 16:32 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Julia Lawall, Hartmut Knaack, Andreas Dilger
  Cc: Ian Abbott, linux-iio, linux-kernel, Shraddha Barke

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/comedi/drivers/mpc624.c | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/comedi/drivers/mpc624.c b/drivers/staging/comedi/drivers/mpc624.c
index 0207b8e..8e92041 100644
--- a/drivers/staging/comedi/drivers/mpc624.c
+++ b/drivers/staging/comedi/drivers/mpc624.c
@@ -66,24 +66,24 @@ Configuration Options:
 #define MPC624_IRQ_MASK         6 /* IRQ masking enable/disable */
 
 /* Register bits' names */
-#define MPC624_ADBUSY           (1<<5)
-#define MPC624_ADSDO            (1<<4)
-#define MPC624_ADFO             (1<<3)
-#define MPC624_ADCS             (1<<2)
-#define MPC624_ADSCK            (1<<1)
-#define MPC624_ADSDI            (1<<0)
+#define MPC624_ADBUSY           BIT(5)
+#define MPC624_ADSDO            BIT(4)
+#define MPC624_ADFO             BIT(3)
+#define MPC624_ADCS             BIT(2)
+#define MPC624_ADSCK            BIT(1)
+#define MPC624_ADSDI            BIT(0)
 
 /* SDI Speed/Resolution Programming bits */
-#define MPC624_OSR4             (1<<31)
-#define MPC624_OSR3             (1<<30)
-#define MPC624_OSR2             (1<<29)
-#define MPC624_OSR1             (1<<28)
-#define MPC624_OSR0             (1<<27)
+#define MPC624_OSR4             BIT(31)
+#define MPC624_OSR3             BIT(30)
+#define MPC624_OSR2             BIT(29)
+#define MPC624_OSR1             BIT(28)
+#define MPC624_OSR0             BIT(27)
 
 /* 32-bit output value bits' names */
-#define MPC624_EOC_BIT          (1<<31)
-#define MPC624_DMY_BIT          (1<<30)
-#define MPC624_SGN_BIT          (1<<29)
+#define MPC624_EOC_BIT          BIT(31)
+#define MPC624_DMY_BIT          BIT(30)
+#define MPC624_SGN_BIT          BIT(29)
 
 /* Conversion speeds */
 /* OSR4 OSR3 OSR2 OSR1 OSR0  Conversion rate  RMS noise  ENOB^
@@ -189,7 +189,7 @@ static int mpc624_ai_rinsn(struct comedi_device *dev,
 			outb(0, dev->iobase + MPC624_ADC);
 			udelay(1);
 
-			if (data_out & (1 << 31)) { /*  the next bit is a 1 */
+			if (data_out & BIT(31)) { /*  the next bit is a 1 */
 				/*  Set the ADSDI line (send to MPC624) */
 				outb(MPC624_ADSDI, dev->iobase + MPC624_ADC);
 				udelay(1);
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 4/6] Staging: iio: cdc: Prefer using the BIT macro
  2015-09-10 16:32 [PATCH 4/6] Staging: iio: cdc: Prefer using the BIT macro Shraddha Barke
  2015-09-10 16:32 ` [PATCH 5/6] Staging: lustre: ptlrpc: " Shraddha Barke
  2015-09-10 16:32 ` [PATCH 6/6] Staging: comedi: " Shraddha Barke
@ 2015-09-12  9:47 ` Jonathan Cameron
  2015-09-12 11:17   ` Shraddha Barke
  2 siblings, 1 reply; 6+ messages in thread
From: Jonathan Cameron @ 2015-09-12  9:47 UTC (permalink / raw)
  To: Shraddha Barke, Greg Kroah-Hartman, Julia Lawall, Hartmut Knaack,
	Andreas Dilger
  Cc: Ian Abbott, linux-iio, linux-kernel

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 4/6] Staging: iio: cdc: Prefer using the BIT macro
  2015-09-12  9:47 ` [PATCH 4/6] Staging: iio: cdc: " Jonathan Cameron
@ 2015-09-12 11:17   ` Shraddha Barke
  2015-09-12 15:49     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Shraddha Barke @ 2015-09-12 11:17 UTC (permalink / raw)
  To: Jonathan Cameron
  Cc: Greg Kroah-Hartman, Julia Lawall, Hartmut Knaack, Andreas Dilger,
	Ian Abbott, linux-iio, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 2027 bytes --]

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 ? :(


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

[-- Attachment #2: Type: text/html, Size: 2878 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 4/6] Staging: iio: cdc: Prefer using the BIT macro
  2015-09-12 11:17   ` Shraddha Barke
@ 2015-09-12 15:49     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2015-09-12 15:49 UTC (permalink / raw)
  To: Shraddha Barke
  Cc: Jonathan Cameron, Julia Lawall, Hartmut Knaack, Andreas Dilger,
	Ian Abbott, linux-iio, linux-kernel

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 :)

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-09-12 15:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-10 16:32 [PATCH 4/6] Staging: iio: cdc: Prefer using the BIT macro Shraddha Barke
2015-09-10 16:32 ` [PATCH 5/6] Staging: lustre: ptlrpc: " Shraddha Barke
2015-09-10 16:32 ` [PATCH 6/6] Staging: comedi: " Shraddha Barke
2015-09-12  9:47 ` [PATCH 4/6] Staging: iio: cdc: " Jonathan Cameron
2015-09-12 11:17   ` Shraddha Barke
2015-09-12 15:49     ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).