staging: iio: Replace a bit shift by a use of BIT.
Subsystems (5)
This patch replaces bit shifting on 1 with the BIT(x) macro. This was done with coccinelle:
@@
constant c;
@@
-1 << c
+BIT(c)
--- drivers/staging/iio/adc/ad7816.c | 2 +- drivers/staging/iio/cdc/ad7150.c | 2 +- drivers/staging/iio/cdc/ad7746.c | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-)
drivers/staging/iio/adc/ad7816.c +1 -1
@@ -222,7 +222,7 @@ static ssize_t ad7816_show_value(struct device *dev, value = (s8)((data >>AD7816_TEMP_FLOAT_OFFSET ) -103 ); data &=AD7816_TEMP_FLOAT_MASK ;if (value <0 ) - data = (1 <<AD7816_TEMP_FLOAT_OFFSET ) - data; + data = (BIT (AD7816_TEMP_FLOAT_OFFSET )) - data;return sprintf (buf,"%d.%.2d\n" , value, data *25 ); }return sprintf (buf,"%u\n" , data);
drivers/staging/iio/cdc/ad7150.c +1 -1
@@ -232,7 +232,7 @@ static int ad7150_write_event_config(struct iio_dev *indio_dev,if (ret <0 ) goto error_ret; - cfg = ret & ~((0x03 <<5 ) | (0x1 <<7 )); + cfg = ret & ~((0x03 <<5 ) | (BIT (7 )));switch (type) {case IIO_EV_TYPE_MAG_ADAPTIVE :
drivers/staging/iio/cdc/ad7746.c +11 -11
@@ -45,20 +45,20 @@#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) +#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 (1 << 4) -#define AD7746_VTSETUP_VTSHORT (1 << 1) -#define AD7746_VTSETUP_VTCHOP (1 << 0) +#define AD7746_VTSETUP_EXTREF (BIT(4)) +#define AD7746_VTSETUP_VTSHORT (BIT(1)) +#define AD7746_VTSETUP_VTCHOP (BIT(0))/* Excitation Setup Register Bit Designations (AD7746_REG_EXC_SETUP) */ #define AD7746_EXCSETUP_CLKCTRL BIT(7)
@@ -75,14 +75,14 @@#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)#define AD7746_CONF_MODE_GAIN_CAL (6 << 0)/* CAPDAC Register Bit Designations (AD7746_REG_CAPDACx) */ -#define AD7746_CAPDAC_DACEN (1 << 7) +#define AD7746_CAPDAC_DACEN (BIT(7))#define AD7746_CAPDAC_DACP (x) ((x) & 0x7F)/*
Signature · 1 line
2.11.0
Greg Kroah-Hartman
maintainerQuoted 9 lines · Arushi Singhal
This patch replaces bit shifting on 1 with the BIT(x) macro. This was done with coccinelle:
@@
constant c;
@@-1 << c
+BIT(c)
Quoted 6 lines
Signed-off-by Arushi Singhal <[email protected]>--- drivers/staging/iio/adc/ad7816.c | 2 +- drivers/staging/iio/cdc/ad7150.c | 2 +- drivers/staging/iio/cdc/ad7746.c | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-)
Please be careful about your cc: list, you missed the correct list, and added one not needed at all. And you forgot the [PATCH] prefix :(
thanks,
greg k-h
drivers/staging/iio/cdc/ad7150.c static int ad7150_write_event_config(struct iio_dev *indio_dev, · line 238
Quoted 9 lines · Arushi Singhal
drivers/staging/iio/cdc/ad7150.c +1
-1@@ -232,7 +232,7 @@ static int ad7150_write_event_config(struct iio_dev *indio_dev,if (ret <0 ) goto error_ret; - cfg = ret & ~((0x03 <<5 ) | (0x1 <<7 )); + cfg = ret & ~((0x03 <<5 ) | (BIT (7 )));switch (type) {case IIO_EV_TYPE_MAG_ADAPTIVE :
While the change in the #defines is not unusual, this particular change here makes it harder to read, so I'd recommend leaving it alone, or changing it to use symbolic names instead of the bit masks.
drivers/staging/iio/cdc/ad7746.c line 56
Quoted 6 lines
/* Voltage/Temperature Setup Register Bit Designations (
AD7746_REG_VT_SETUP) */drivers/staging/iio/cdc/ad7746.c +2
-2-#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))
Why did you leave one of them unchanged?
Arnd
Quoted 21 lines · Arushi Singhal
This patch replaces bit shifting on 1 with the BIT(x) macro. This was done with coccinelle:
@@
constant c;
@@-1 << c
+BIT(c)Signed-off-by Arushi Singhal <[email protected]>--- drivers/staging/iio/adc/ad7816.c | 2 +- drivers/staging/iio/cdc/ad7150.c | 2 +- drivers/staging/iio/cdc/ad7746.c | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-)drivers/staging/iio/adc/ad7816.c +0
-0
drivers/staging/iio/adc/ad7816.c static ssize_t ad7816_show_value(struct device *dev, · line 225
Quoted 5 lines
drivers/staging/iio/adc/ad7816.c +1
-1@@ -222,7 +222,7 @@ static ssize_t ad7816_show_value(struct device *dev, value = (s8)((data >>AD7816_TEMP_FLOAT_OFFSET ) -103 ); data &=AD7816_TEMP_FLOAT_MASK ;if (value <0 ) - data = (1 <<AD7816_TEMP_FLOAT_OFFSET ) - data; + data = (BIT (AD7816_TEMP_FLOAT_OFFSET )) - data;
Remove the extra parentheses from all of these:
data = BIT(AD7816_TEMP_FLOAT_OFFSET) - data;
regards,
dan carpenter