Staging: iio: addac: Prefer using the BIT macro
Subsystems (4)
PATCH 1/6 Staging: iio: addac: Prefer using the BIT macro
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@ int g; @@
-(1 << g)
+BIT(g)
--- drivers/staging/iio/addac/adt7316.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/staging/iio/addac/adt7316.c +7 -7
@@ -1756,43 +1756,43 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) stat1 &=0x1F ; time =iio_get_time_ns (); -if (stat1 & (1 <<0 )) +if (stat1 &BIT (0 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_TEMP ,0 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_RISING ), time); -if (stat1 & (1 <<1 )) +if (stat1 &BIT (1 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_TEMP ,0 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_FALLING ), time); -if (stat1 & (1 <<2 )) +if (stat1 &BIT (2 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_TEMP ,1 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_RISING ), time); -if (stat1 & (1 <<3 )) +if (stat1 &BIT (3 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_TEMP ,1 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_FALLING ), time); -if (stat1 & (1 <<5 )) +if (stat1 &BIT (5 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_VOLTAGE ,1 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_EITHER ), time); -if (stat1 & (1 <<6 )) +if (stat1 &BIT (6 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_VOLTAGE ,2 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_EITHER ), time); -if (stat1 & (1 <<7 )) +if (stat1 &BIT (7 )) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 3, IIO_EV_TYPE_THRESH,
Signature · 1 line
2.1.4
PATCH 2/6 Staging: iio: meter: Prefer using the BIT macro
This patch replaces bit shifting on 1 with the BIT(x) macro
This was done with coccinelle:
@@ int g; @@
-(1 << g)
+BIT(g)
--- drivers/staging/iio/meter/ade7753.c | 8 ++++---- drivers/staging/iio/meter/ade7754.c | 6 +++--- drivers/staging/iio/meter/ade7758_core.c | 6 +++--- drivers/staging/iio/meter/ade7759.c | 8 ++++---- drivers/staging/iio/meter/ade7854.c | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-)
drivers/staging/iio/meter/ade7753.c +4 -4
@@ -219,7 +219,7 @@ static int ade7753_reset(struct device *dev)u16 val;ade7753_spi_read_reg_16 (dev,ADE7753_MODE , &val); - val |=1 <<6 ;/* Software Chip Reset */ + val |=BIT (6 );/* Software Chip Reset */ return ade7753_spi_write_reg_16 (dev,ADE7753_MODE , val); }
@@ -328,10 +328,10 @@ static int ade7753_set_irq(struct device *dev, bool enable) goto error_ret;if (enable) - irqen |=1 <<3 ;/* Enables an interrupt when a data is + irqen |=BIT (3 );/* Enables an interrupt when a data is present in the waveform register */ else - irqen &= ~(1 <<3 ); + irqen &= ~BIT (3 ); ret =ade7753_spi_write_reg_8 (dev,ADE7753_IRQEN , irqen);
@@ -345,7 +345,7 @@ static int ade7753_stop_device(struct device *dev)u16 val;ade7753_spi_read_reg_16 (dev,ADE7753_MODE , &val); - val |=1 <<4 ;/* AD converters can be turned off */ + val |=BIT (4 );/* AD converters can be turned off */ return ade7753_spi_write_reg_16 (dev,ADE7753_MODE , val); }
drivers/staging/iio/meter/ade7754.c +3 -3
@@ -223,7 +223,7 @@ static int ade7754_reset(struct device *dev)if (ret <0 )return ret; - val |=1 <<6 ;/* Software Chip Reset */ + val |=BIT (6 );/* Software Chip Reset */ return ade7754_spi_write_reg_8 (dev,ADE7754_OPMODE , val); }
@@ -350,10 +350,10 @@ static int ade7754_set_irq(struct device *dev, bool enable) goto error_ret;if (enable) - irqen |=1 <<14 ;/* Enables an interrupt when a data is + irqen |=BIT (14 );/* Enables an interrupt when a data is present in the waveform register */ else - irqen &= ~(1 <<14 ); + irqen &= ~BIT (14 ); ret =ade7754_spi_write_reg_16 (dev,ADE7754_IRQEN , irqen);if (ret)
drivers/staging/iio/meter/ade7758_core.c +3 -3
@@ -308,7 +308,7 @@ static int ade7758_reset(struct device *dev)dev_err (dev,"Failed to read opmode reg\n" );return ret; } - val |=1 <<6 ;/* Software Chip Reset */ + val |=BIT (6 );/* Software Chip Reset */ ret =ade7758_spi_write_reg_8 (dev,ADE7758_OPMODE , val);if (ret <0 )dev_err (dev,"Failed to write opmode reg\n" );
@@ -426,10 +426,10 @@ int ade7758_set_irq(struct device *dev, bool enable) goto error_ret;if (enable) - irqen |=1 <<16 ;/* Enables an interrupt when a data is + irqen |=BIT (16 );/* Enables an interrupt when a data is present in the waveform register */ else - irqen &= ~(1 <<16 ); + irqen &= ~BIT (16 ); ret =ade7758_spi_write_reg_24 (dev,ADE7758_MASK , irqen);if (ret)
drivers/staging/iio/meter/ade7759.c +4 -4
@@ -224,7 +224,7 @@ static int ade7759_reset(struct device *dev)if (ret <0 )return ret; - val |=1 <<6 ;/* Software Chip Reset */ + val |=BIT (6 );/* Software Chip Reset */ return ade7759_spi_write_reg_16 (dev,ADE7759_MODE , val);
@@ -288,10 +288,10 @@ static int ade7759_set_irq(struct device *dev, bool enable) goto error_ret;if (enable) - irqen |=1 <<3 ;/* Enables an interrupt when a data is + irqen |=BIT (3 );/* Enables an interrupt when a data is present in the waveform register */ else - irqen &= ~(1 <<3 ); + irqen &= ~BIT (3 ); ret =ade7759_spi_write_reg_8 (dev,ADE7759_IRQEN , irqen);
@@ -314,7 +314,7 @@ static int ade7759_stop_device(struct device *dev)return ret; } - val |=1 <<4 ;/* AD converters can be turned off */ + val |=BIT (4 );/* AD converters can be turned off */ return ade7759_spi_write_reg_16 (dev,ADE7759_MODE , val); }
drivers/staging/iio/meter/ade7854.c +3 -3
@@ -181,7 +181,7 @@ static int ade7854_reset(struct device *dev)u16 val; st->read_reg_16 (dev,ADE7854_CONFIG , &val); - val |=1 <<7 ;/* Software Chip Reset */ + val |=BIT (7 );/* Software Chip Reset */ return st->write_reg_16 (dev,ADE7854_CONFIG , val); }
@@ -420,10 +420,10 @@ static int ade7854_set_irq(struct device *dev, bool enable) goto error_ret;if (enable) - irqen |=1 <<17 ;/* 1: interrupt enabled when all periodical + irqen |=BIT (17 );/* 1: interrupt enabled when all periodical (at 8 kHz rate) DSP computations finish. */ else - irqen &= ~(1 <<17 ); + irqen &= ~BIT (17 ); ret = st->write_reg_32 (dev,ADE7854_MASK0 , irqen);if (ret)
Signature · 1 line
2.1.4
Re: [PATCH 2/6] Staging: iio: meter: Prefer using the BIT macro
Quoted 9 lines · Shraddha Barke
This patch replaces bit shifting on 1 with the BIT(x) macro
This was done with coccinelle:
@@ int g; @@(quoted diff) +1
-1-(1 << g) +BIT(g)Signed-off-by Shraddha Barke <[email protected]>
There are a number of places in these drivers where the use of GENMASK and a related shift macro would also improve the code, but the changes here seem sensible.
I'll pick this one up.
Applied to the togreg branch of iio.git.
Thanks,
Jonathan
Quoted 157 lines
--- drivers/staging/iio/meter/ade7753.c | 8 ++++---- drivers/staging/iio/meter/ade7754.c | 6 +++--- drivers/staging/iio/meter/ade7758_core.c | 6 +++--- drivers/staging/iio/meter/ade7759.c | 8 ++++---- drivers/staging/iio/meter/ade7854.c | 6 +++--- 5 files changed, 17 insertions(+), 17 deletions(-)drivers/staging/iio/meter/ade7753.c +4
-4@@ -219,7 +219,7 @@ static int ade7753_reset(struct device *dev)u16 val;ade7753_spi_read_reg_16 (dev,ADE7753_MODE , &val); - val |=1 <<6 ;/* Software Chip Reset */ + val |=BIT (6 );/* Software Chip Reset */ return ade7753_spi_write_reg_16 (dev,ADE7753_MODE , val); }@@ -328,10 +328,10 @@ static int ade7753_set_irq(struct device *dev, bool enable) goto error_ret;if (enable) - irqen |=1 <<3 ;/* Enables an interrupt when a data is + irqen |=BIT (3 );/* Enables an interrupt when a data is present in the waveform register */ else - irqen &= ~(1 <<3 ); + irqen &= ~BIT (3 ); ret =ade7753_spi_write_reg_8 (dev,ADE7753_IRQEN , irqen);@@ -345,7 +345,7 @@ static int ade7753_stop_device(struct device *dev)u16 val;ade7753_spi_read_reg_16 (dev,ADE7753_MODE , &val); - val |=1 <<4 ;/* AD converters can be turned off */ + val |=BIT (4 );/* AD converters can be turned off */ return ade7753_spi_write_reg_16 (dev,ADE7753_MODE , val); }drivers/staging/iio/meter/ade7754.c +3
-3@@ -223,7 +223,7 @@ static int ade7754_reset(struct device *dev)if (ret <0 )return ret; - val |=1 <<6 ;/* Software Chip Reset */ + val |=BIT (6 );/* Software Chip Reset */ return ade7754_spi_write_reg_8 (dev,ADE7754_OPMODE , val); }@@ -350,10 +350,10 @@ static int ade7754_set_irq(struct device *dev, bool enable) goto error_ret;if (enable) - irqen |=1 <<14 ;/* Enables an interrupt when a data is + irqen |=BIT (14 );/* Enables an interrupt when a data is present in the waveform register */ else - irqen &= ~(1 <<14 ); + irqen &= ~BIT (14 ); ret =ade7754_spi_write_reg_16 (dev,ADE7754_IRQEN , irqen);if (ret)drivers/staging/iio/meter/ade7758_core.c +3
-3@@ -308,7 +308,7 @@ static int ade7758_reset(struct device *dev)dev_err (dev,"Failed to read opmode reg\n" );return ret; } - val |=1 <<6 ;/* Software Chip Reset */ + val |=BIT (6 );/* Software Chip Reset */ ret =ade7758_spi_write_reg_8 (dev,ADE7758_OPMODE , val);if (ret <0 )dev_err (dev,"Failed to write opmode reg\n" );@@ -426,10 +426,10 @@ int ade7758_set_irq(struct device *dev, bool enable) goto error_ret;if (enable) - irqen |=1 <<16 ;/* Enables an interrupt when a data is + irqen |=BIT (16 );/* Enables an interrupt when a data is present in the waveform register */ else - irqen &= ~(1 <<16 ); + irqen &= ~BIT (16 ); ret =ade7758_spi_write_reg_24 (dev,ADE7758_MASK , irqen);if (ret)drivers/staging/iio/meter/ade7759.c +4
-4@@ -224,7 +224,7 @@ static int ade7759_reset(struct device *dev)if (ret <0 )return ret; - val |=1 <<6 ;/* Software Chip Reset */ + val |=BIT (6 );/* Software Chip Reset */ return ade7759_spi_write_reg_16 (dev,ADE7759_MODE , val);@@ -288,10 +288,10 @@ static int ade7759_set_irq(struct device *dev, bool enable) goto error_ret;if (enable) - irqen |=1 <<3 ;/* Enables an interrupt when a data is + irqen |=BIT (3 );/* Enables an interrupt when a data is present in the waveform register */ else - irqen &= ~(1 <<3 ); + irqen &= ~BIT (3 ); ret =ade7759_spi_write_reg_8 (dev,ADE7759_IRQEN , irqen);@@ -314,7 +314,7 @@ static int ade7759_stop_device(struct device *dev)return ret; } - val |=1 <<4 ;/* AD converters can be turned off */ + val |=BIT (4 );/* AD converters can be turned off */ return ade7759_spi_write_reg_16 (dev,ADE7759_MODE , val); }drivers/staging/iio/meter/ade7854.c +3
-3@@ -181,7 +181,7 @@ static int ade7854_reset(struct device *dev)u16 val; st->read_reg_16 (dev,ADE7854_CONFIG , &val); - val |=1 <<7 ;/* Software Chip Reset */ + val |=BIT (7 );/* Software Chip Reset */ return st->write_reg_16 (dev,ADE7854_CONFIG , val); }@@ -420,10 +420,10 @@ static int ade7854_set_irq(struct device *dev, bool enable) goto error_ret;if (enable) - irqen |=1 <<17 ;/* 1: interrupt enabled when all periodical + irqen |=BIT (17 );/* 1: interrupt enabled when all periodical (at 8 kHz rate) DSP computations finish. */ else - irqen &= ~(1 <<17 ); + irqen &= ~BIT (17 ); ret = st->write_reg_32 (dev,ADE7854_MASK0 , irqen);if (ret)
PATCH 3/6 Staging: lustre: libcfs: Prefer using the BIT macro
In reply to Shraddha BarkeThis patch replaces bit shifting on 1 with the BIT(x) macro
This was done with coccinelle:
@@ int g; @@
-(1 << g)
+BIT(g)
--- drivers/staging/lustre/lustre/libcfs/hash.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/staging/lustre/lustre/libcfs/hash.c +4 -4
@@ -588,13 +588,13 @@ EXPORT_SYMBOL(cfs_hash_bd_move_locked);enum {/** always set, for sanity (avoid ZERO intent) */ -CFS_HS_LOOKUP_MASK_FIND =1 <<0 , +CFS_HS_LOOKUP_MASK_FIND =BIT (0 ),/** return entry with a ref */ -CFS_HS_LOOKUP_MASK_REF =1 <<1 , +CFS_HS_LOOKUP_MASK_REF =BIT (1 ),/** add entry if not existing */ -CFS_HS_LOOKUP_MASK_ADD =1 <<2 , +CFS_HS_LOOKUP_MASK_ADD =BIT (2 ),/** delete entry, ignore other masks */ -CFS_HS_LOOKUP_MASK_DEL =1 <<3 , +CFS_HS_LOOKUP_MASK_DEL =BIT (3 ), }; typedef enum cfs_hash_lookup_intent {
Signature · 1 line
2.1.4
Jonathan Cameron
maintainerQuoted 10 lines · Shraddha Barke
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@ int g; @@
(quoted diff) +1
-1-(1 << g) +BIT(g)Signed-off-by Shraddha Barke <[email protected]>
Good straight forward cases. Applied to the togreg branch of iio.git. Will be initially pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 60 lines
--- drivers/staging/iio/addac/adt7316.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/staging/iio/addac/adt7316.c +7
-7@@ -1756,43 +1756,43 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) stat1 &=0x1F ; time =iio_get_time_ns (); -if (stat1 & (1 <<0 )) +if (stat1 &BIT (0 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_TEMP ,0 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_RISING ), time); -if (stat1 & (1 <<1 )) +if (stat1 &BIT (1 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_TEMP ,0 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_FALLING ), time); -if (stat1 & (1 <<2 )) +if (stat1 &BIT (2 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_TEMP ,1 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_RISING ), time); -if (stat1 & (1 <<3 )) +if (stat1 &BIT (3 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_TEMP ,1 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_FALLING ), time); -if (stat1 & (1 <<5 )) +if (stat1 &BIT (5 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_VOLTAGE ,1 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_EITHER ), time); -if (stat1 & (1 <<6 )) +if (stat1 &BIT (6 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_VOLTAGE ,2 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_EITHER ), time); -if (stat1 & (1 <<7 )) +if (stat1 &BIT (7 )) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 3, IIO_EV_TYPE_THRESH,
Jonathan Cameron
maintainerQuoted 10 lines · Shraddha Barke
This patch replaces bit shifting on 1 with the BIT(x) macro.
This was done with coccinelle:
@@ int g; @@
(quoted diff) +1
-1-(1 << g) +BIT(g)Signed-off-by Shraddha Barke <[email protected]>
A small process related point. These are reworked versions of your earlier series. Please make that obvious with a V2 in the patch name. A cover letter explaining what the changes were is also a useful addition.
I suspect a lot of reviewers do what I do and work backwards through their email and hence need the indication that there is an earlier thread they should be cross referring to.
Thanks,
Jonathan
Quoted 60 lines
--- drivers/staging/iio/addac/adt7316.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)drivers/staging/iio/addac/adt7316.c +7
-7@@ -1756,43 +1756,43 @@ static irqreturn_t adt7316_event_handler(int irq, void *private) stat1 &=0x1F ; time =iio_get_time_ns (); -if (stat1 & (1 <<0 )) +if (stat1 &BIT (0 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_TEMP ,0 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_RISING ), time); -if (stat1 & (1 <<1 )) +if (stat1 &BIT (1 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_TEMP ,0 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_FALLING ), time); -if (stat1 & (1 <<2 )) +if (stat1 &BIT (2 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_TEMP ,1 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_RISING ), time); -if (stat1 & (1 <<3 )) +if (stat1 &BIT (3 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_TEMP ,1 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_FALLING ), time); -if (stat1 & (1 <<5 )) +if (stat1 &BIT (5 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_VOLTAGE ,1 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_EITHER ), time); -if (stat1 & (1 <<6 )) +if (stat1 &BIT (6 ))iio_push_event (indio_dev,IIO_UNMOD_EVENT_CODE (IIO_VOLTAGE ,2 ,IIO_EV_TYPE_THRESH ,IIO_EV_DIR_EITHER ), time); -if (stat1 & (1 <<7 )) +if (stat1 &BIT (7 )) iio_push_event(indio_dev, IIO_UNMOD_EVENT_CODE(IIO_VOLTAGE, 3, IIO_EV_TYPE_THRESH,