Staging: iio: use the BIT macro in .h and adc
Subsystems (5)
cover Staging: iio: use the BIT macro in .h and adc
This patchset replace bit shifting on 0,1,2, and 3 with the BIT(x) macro. Issue addressed by checkpatch.pl with --strict flag.
This was done with the help of the following Coccinelle script:
@r1@
constant int g;
@@
(
0<<g
|
1<<g
|
2<<g
|
3<<g
)
@script:python b@
g2 <<r1.g;
y;
@@
coccinelle.y = int(g2) + 1
@c@
constant int r1.g;
identifier b.y;
@@
(
-(1 << g)
+BIT(g)
|
-(0 << g)
+ 0
|
-(2 << g)
+BIT(y)
|
-(3 << g)
+(BIT(y)| BIT(g))
)
Haneen Mohammed (2):
Staging: iio: use the BIT macro in .h files
Staging: iio: use the BIT macro in adc
drivers/staging/iio/accel/adis16201.h | 18 +++++----- drivers/staging/iio/accel/adis16203.h | 24 ++++++------- drivers/staging/iio/accel/adis16204.h | 22 ++++++------ drivers/staging/iio/accel/adis16209.h | 22 ++++++------ drivers/staging/iio/accel/adis16220.h | 40 ++++++++++----------- drivers/staging/iio/accel/adis16240.h | 30 ++++++++-------- drivers/staging/iio/adc/ad7192.c | 64 +++++++++++++++++----------------- drivers/staging/iio/adc/ad7280a.c | 58 +++++++++++++++---------------- drivers/staging/iio/adc/ad7280a.h | 8 ++--- drivers/staging/iio/adc/ad7780.c | 18 +++++----- drivers/staging/iio/adc/ad7816.c | 2 +- drivers/staging/iio/adc/mxs-lradc.c | 65 ++++++++++++++++++----------------- drivers/staging/iio/adc/spear_adc.c | 6 ++-- 13 files changed, 189 insertions(+), 188 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/2 Staging: iio: use the BIT macro in .h files
This patch replace bit shifting on 1, 2, and 3 with the BIT(x) macro. Issue addressed by checkpatch.pl with --strict flag.
This was done with the help of Coccninelle:
@r1@
constant int g;
@@
(
0<<g
|
1<<g
|
2<<g
|
3<<g
)
@script:python b@
g2 <<r1.g;
y;
@@
coccinelle.y = int(g2) + 1
@c@
constant int r1.g;
identifier b.y;
@@
(
-(1 << g)
+BIT(g)
|
-(0 << g)
+ 0
|
-(2 << g)
+BIT(y)
|
-(3 << g)
+(BIT(y)| BIT(g))
)
--- drivers/staging/iio/accel/adis16201.h | 18 ++++++++-------- drivers/staging/iio/accel/adis16203.h | 24 ++++++++++----------- drivers/staging/iio/accel/adis16204.h | 22 +++++++++---------- drivers/staging/iio/accel/adis16209.h | 22 +++++++++---------- drivers/staging/iio/accel/adis16220.h | 40 +++++++++++++++++------------------ drivers/staging/iio/accel/adis16240.h | 30 +++++++++++++------------- drivers/staging/iio/adc/ad7280a.h | 8 +++---- 7 files changed, 82 insertions(+), 82 deletions(-)
drivers/staging/iio/accel/adis16201.h +9 -9
@@ -34,24 +34,24 @@#define ADIS16201_GLOB_CMD 0x3E/* Operation, system command register */ /* MSC_CTRL */ -#define ADIS16201_MSC_CTRL_SELF_TEST_EN (1 << 8)/* Self-test enable */ -#define ADIS16201_MSC_CTRL_DATA_RDY_EN (1 << 2)/* Data-ready enable: 1 = enabled, 0 = disabled */ -#define ADIS16201_MSC_CTRL_ACTIVE_HIGH (1 << 1)/* Data-ready polarity: 1 = active high, 0 = active low */ -#define ADIS16201_MSC_CTRL_DATA_RDY_DIO1 (1 << 0)/* Data-ready line selection: 1 = DIO1, 0 = DIO0 */ +#define ADIS16201_MSC_CTRL_SELF_TEST_EN BIT(8)/* Self-test enable */ +#define ADIS16201_MSC_CTRL_DATA_RDY_EN BIT(2)/* Data-ready enable: 1 = enabled, 0 = disabled */ +#define ADIS16201_MSC_CTRL_ACTIVE_HIGH BIT(1)/* Data-ready polarity: 1 = active high, 0 = active low */ +#define ADIS16201_MSC_CTRL_DATA_RDY_DIO1 BIT(0)/* Data-ready line selection: 1 = DIO1, 0 = DIO0 */ /* DIAG_STAT */ -#define ADIS16201_DIAG_STAT_ALARM2 (1<<9)/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16201_DIAG_STAT_ALARM1 (1<<8)/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ +#define ADIS16201_DIAG_STAT_ALARM2 BIT(9)/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */ +#define ADIS16201_DIAG_STAT_ALARM1 BIT(8)/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ #define ADIS16201_DIAG_STAT_SPI_FAIL_BIT 3/* SPI communications failure */ #define ADIS16201_DIAG_STAT_FLASH_UPT_BIT 2/* Flash update failure */ #define ADIS16201_DIAG_STAT_POWER_HIGH_BIT 1/* Power supply above 3.625 V */ #define ADIS16201_DIAG_STAT_POWER_LOW_BIT 0/* Power supply below 3.15 V */ /* GLOB_CMD */ -#define ADIS16201_GLOB_CMD_SW_RESET (1<<7) -#define ADIS16201_GLOB_CMD_FACTORY_CAL (1<<1) +#define ADIS16201_GLOB_CMD_SW_RESET BIT(7) +#define ADIS16201_GLOB_CMD_FACTORY_CAL BIT(1) -#define ADIS16201_ERROR_ACTIVE (1<<14) +#define ADIS16201_ERROR_ACTIVE BIT(14)enum adis16201_scan {ADIS16201_SCAN_ACC_X ,
drivers/staging/iio/accel/adis16203.h +12 -12
@@ -25,16 +25,16 @@#define ADIS16203_GLOB_CMD 0x3E/* Operation, system command register */ /* MSC_CTRL */ -#define ADIS16203_MSC_CTRL_PWRUP_SELF_TEST (1 << 10)/* Self-test at power-on: 1 = disabled, 0 = enabled */ -#define ADIS16203_MSC_CTRL_REVERSE_ROT_EN (1 << 9)/* Reverses rotation of both inclination outputs */ -#define ADIS16203_MSC_CTRL_SELF_TEST_EN (1 << 8)/* Self-test enable */ -#define ADIS16203_MSC_CTRL_DATA_RDY_EN (1 << 2)/* Data-ready enable: 1 = enabled, 0 = disabled */ -#define ADIS16203_MSC_CTRL_ACTIVE_HIGH (1 << 1)/* Data-ready polarity: 1 = active high, 0 = active low */ -#define ADIS16203_MSC_CTRL_DATA_RDY_DIO1 (1 << 0)/* Data-ready line selection: 1 = DIO1, 0 = DIO0 */ +#define ADIS16203_MSC_CTRL_PWRUP_SELF_TEST BIT(10)/* Self-test at power-on: 1 = disabled, 0 = enabled */ +#define ADIS16203_MSC_CTRL_REVERSE_ROT_EN BIT(9)/* Reverses rotation of both inclination outputs */ +#define ADIS16203_MSC_CTRL_SELF_TEST_EN BIT(8)/* Self-test enable */ +#define ADIS16203_MSC_CTRL_DATA_RDY_EN BIT(2)/* Data-ready enable: 1 = enabled, 0 = disabled */ +#define ADIS16203_MSC_CTRL_ACTIVE_HIGH BIT(1)/* Data-ready polarity: 1 = active high, 0 = active low */ +#define ADIS16203_MSC_CTRL_DATA_RDY_DIO1 BIT(0)/* Data-ready line selection: 1 = DIO1, 0 = DIO0 */ /* DIAG_STAT */ -#define ADIS16203_DIAG_STAT_ALARM2 (1<<9)/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16203_DIAG_STAT_ALARM1 (1<<8)/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ +#define ADIS16203_DIAG_STAT_ALARM2 BIT(9)/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */ +#define ADIS16203_DIAG_STAT_ALARM1 BIT(8)/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ #define ADIS16203_DIAG_STAT_SELFTEST_FAIL_BIT 5/* Self-test diagnostic error flag */ #define ADIS16203_DIAG_STAT_SPI_FAIL_BIT 3/* SPI communications failure */ #define ADIS16203_DIAG_STAT_FLASH_UPT_BIT 2/* Flash update failure */
@@ -42,11 +42,11 @@#define ADIS16203_DIAG_STAT_POWER_LOW_BIT 0/* Power supply below 3.15 V */ /* GLOB_CMD */ -#define ADIS16203_GLOB_CMD_SW_RESET (1<<7) -#define ADIS16203_GLOB_CMD_CLEAR_STAT (1<<4) -#define ADIS16203_GLOB_CMD_FACTORY_CAL (1<<1) +#define ADIS16203_GLOB_CMD_SW_RESET BIT(7) +#define ADIS16203_GLOB_CMD_CLEAR_STAT BIT(4) +#define ADIS16203_GLOB_CMD_FACTORY_CAL BIT(1) -#define ADIS16203_ERROR_ACTIVE (1<<14) +#define ADIS16203_ERROR_ACTIVE BIT(14)enum adis16203_scan {ADIS16203_SCAN_INCLI_X ,
drivers/staging/iio/accel/adis16204.h +11 -11
@@ -33,15 +33,15 @@#define ADIS16204_GLOB_CMD 0x3E/* Operation, system command register */ /* MSC_CTRL */ -#define ADIS16204_MSC_CTRL_PWRUP_SELF_TEST (1 << 10)/* Self-test at power-on: 1 = disabled, 0 = enabled */ -#define ADIS16204_MSC_CTRL_SELF_TEST_EN (1 << 8)/* Self-test enable */ -#define ADIS16204_MSC_CTRL_DATA_RDY_EN (1 << 2)/* Data-ready enable: 1 = enabled, 0 = disabled */ -#define ADIS16204_MSC_CTRL_ACTIVE_HIGH (1 << 1)/* Data-ready polarity: 1 = active high, 0 = active low */ -#define ADIS16204_MSC_CTRL_DATA_RDY_DIO2 (1 << 0)/* Data-ready line selection: 1 = DIO2, 0 = DIO1 */ +#define ADIS16204_MSC_CTRL_PWRUP_SELF_TEST BIT(10)/* Self-test at power-on: 1 = disabled, 0 = enabled */ +#define ADIS16204_MSC_CTRL_SELF_TEST_EN BIT(8)/* Self-test enable */ +#define ADIS16204_MSC_CTRL_DATA_RDY_EN BIT(2)/* Data-ready enable: 1 = enabled, 0 = disabled */ +#define ADIS16204_MSC_CTRL_ACTIVE_HIGH BIT(1)/* Data-ready polarity: 1 = active high, 0 = active low */ +#define ADIS16204_MSC_CTRL_DATA_RDY_DIO2 BIT(0)/* Data-ready line selection: 1 = DIO2, 0 = DIO1 */ /* DIAG_STAT */ -#define ADIS16204_DIAG_STAT_ALARM2 (1<<9)/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16204_DIAG_STAT_ALARM1 (1<<8)/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ +#define ADIS16204_DIAG_STAT_ALARM2 BIT(9)/* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */ +#define ADIS16204_DIAG_STAT_ALARM1 BIT(8)/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ #define ADIS16204_DIAG_STAT_SELFTEST_FAIL_BIT 5/* Self-test diagnostic error flag: 1 = error condition, 0 = normal operation */ #define ADIS16204_DIAG_STAT_SPI_FAIL_BIT 3/* SPI communications failure */
@@ -50,11 +50,11 @@#define ADIS16204_DIAG_STAT_POWER_LOW_BIT 0/* Power supply below 2.975 V */ /* GLOB_CMD */ -#define ADIS16204_GLOB_CMD_SW_RESET (1<<7) -#define ADIS16204_GLOB_CMD_CLEAR_STAT (1<<4) -#define ADIS16204_GLOB_CMD_FACTORY_CAL (1<<1) +#define ADIS16204_GLOB_CMD_SW_RESET BIT(7) +#define ADIS16204_GLOB_CMD_CLEAR_STAT BIT(4) +#define ADIS16204_GLOB_CMD_FACTORY_CAL BIT(1) -#define ADIS16204_ERROR_ACTIVE (1<<14) +#define ADIS16204_ERROR_ACTIVE BIT(14)enum adis16204_scan {ADIS16204_SCAN_ACC_X ,
drivers/staging/iio/accel/adis16209.h +11 -11
@@ -60,21 +60,21 @@/* MSC_CTRL */ /* Self-test at power-on: 1 = disabled, 0 = enabled */ -#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST (1 << 10) +#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST BIT(10)/* Self-test enable */ -#define ADIS16209_MSC_CTRL_SELF_TEST_EN (1 << 8) +#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8)/* Data-ready enable: 1 = enabled, 0 = disabled */ -#define ADIS16209_MSC_CTRL_DATA_RDY_EN (1 << 2) +#define ADIS16209_MSC_CTRL_DATA_RDY_EN BIT(2)/* Data-ready polarity: 1 = active high, 0 = active low */ -#define ADIS16209_MSC_CTRL_ACTIVE_HIGH (1 << 1) +#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1)/* Data-ready line selection: 1 = DIO2, 0 = DIO1 */ -#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 (1 << 0) +#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0)/* DIAG_STAT */ /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16209_DIAG_STAT_ALARM2 (1<<9) +#define ADIS16209_DIAG_STAT_ALARM2 BIT(9)/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16209_DIAG_STAT_ALARM1 (1<<8) +#define ADIS16209_DIAG_STAT_ALARM1 BIT(8)/* Self-test diagnostic error flag: 1 = error condition, 0 = normal operation */ #define ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT 5/* SPI communications failure */
@@ -87,11 +87,11 @@#define ADIS16209_DIAG_STAT_POWER_LOW_BIT 0/* GLOB_CMD */ -#define ADIS16209_GLOB_CMD_SW_RESET (1<<7) -#define ADIS16209_GLOB_CMD_CLEAR_STAT (1<<4) -#define ADIS16209_GLOB_CMD_FACTORY_CAL (1<<1) +#define ADIS16209_GLOB_CMD_SW_RESET BIT(7) +#define ADIS16209_GLOB_CMD_CLEAR_STAT BIT(4) +#define ADIS16209_GLOB_CMD_FACTORY_CAL BIT(1) -#define ADIS16209_ERROR_ACTIVE (1<<14) +#define ADIS16209_ERROR_ACTIVE BIT(14)#define ADIS16209_SCAN_SUPPLY 0#define ADIS16209_SCAN_ACC_X 1
drivers/staging/iio/accel/adis16220.h +20 -20
@@ -71,35 +71,35 @@#define ADIS16220_CAPTURE_SIZE 2048/* MSC_CTRL */ -#define ADIS16220_MSC_CTRL_SELF_TEST_EN (1 << 8) -#define ADIS16220_MSC_CTRL_POWER_SUP_COM_AIN1 (1 << 1) -#define ADIS16220_MSC_CTRL_POWER_SUP_COM_AIN2 (1 << 0) +#define ADIS16220_MSC_CTRL_SELF_TEST_EN BIT(8) +#define ADIS16220_MSC_CTRL_POWER_SUP_COM_AIN1 BIT(1) +#define ADIS16220_MSC_CTRL_POWER_SUP_COM_AIN2 BIT(0)/* DIO_CTRL */ -#define ADIS16220_MSC_CTRL_DIO2_BUSY_IND (3<<4) -#define ADIS16220_MSC_CTRL_DIO1_BUSY_IND (3<<2) -#define ADIS16220_MSC_CTRL_DIO2_ACT_HIGH (1<<1) -#define ADIS16220_MSC_CTRL_DIO1_ACT_HIGH (1<<0) +#define ADIS16220_MSC_CTRL_DIO2_BUSY_IND (BIT(5) | BIT(4)) +#define ADIS16220_MSC_CTRL_DIO1_BUSY_IND (BIT(3) | BIT(2)) +#define ADIS16220_MSC_CTRL_DIO2_ACT_HIGH BIT(1) +#define ADIS16220_MSC_CTRL_DIO1_ACT_HIGH BIT(0)/* DIAG_STAT */ /* AIN2 sample > ALM_MAG2 */ -#define ADIS16220_DIAG_STAT_ALM_MAG2 (1<<14) +#define ADIS16220_DIAG_STAT_ALM_MAG2 BIT(14)/* AIN1 sample > ALM_MAG1 */ -#define ADIS16220_DIAG_STAT_ALM_MAG1 (1<<13) +#define ADIS16220_DIAG_STAT_ALM_MAG1 BIT(13)/* Acceleration sample > ALM_MAGA */ -#define ADIS16220_DIAG_STAT_ALM_MAGA (1<<12) +#define ADIS16220_DIAG_STAT_ALM_MAGA BIT(12)/* Error condition programmed into ALM_MAGS[11:0] and ALM_CTRL[5:4] is true */ -#define ADIS16220_DIAG_STAT_ALM_MAGS (1<<11) +#define ADIS16220_DIAG_STAT_ALM_MAGS BIT(11)/* |Peak value in AIN2 data capture| > ALM_MAG2 */ -#define ADIS16220_DIAG_STAT_PEAK_AIN2 (1<<10) +#define ADIS16220_DIAG_STAT_PEAK_AIN2 BIT(10)/* |Peak value in AIN1 data capture| > ALM_MAG1 */ -#define ADIS16220_DIAG_STAT_PEAK_AIN1 (1<<9) +#define ADIS16220_DIAG_STAT_PEAK_AIN1 BIT(9)/* |Peak value in acceleration data capture| > ALM_MAGA */ -#define ADIS16220_DIAG_STAT_PEAK_ACCEL (1<<8) +#define ADIS16220_DIAG_STAT_PEAK_ACCEL BIT(8)/* Data ready, capture complete */ -#define ADIS16220_DIAG_STAT_DATA_RDY (1<<7) -#define ADIS16220_DIAG_STAT_FLASH_CHK (1<<6) -#define ADIS16220_DIAG_STAT_SELF_TEST (1<<5) +#define ADIS16220_DIAG_STAT_DATA_RDY BIT(7) +#define ADIS16220_DIAG_STAT_FLASH_CHK BIT(6) +#define ADIS16220_DIAG_STAT_SELF_TEST BIT(5)/* Capture period violation/interruption */ #define ADIS16220_DIAG_STAT_VIOLATION_BIT 4/* SPI communications failure */
@@ -112,9 +112,9 @@#define ADIS16220_DIAG_STAT_POWER_LOW_BIT 0/* GLOB_CMD */ -#define ADIS16220_GLOB_CMD_SW_RESET (1<<7) -#define ADIS16220_GLOB_CMD_SELF_TEST (1<<2) -#define ADIS16220_GLOB_CMD_PWR_DOWN (1<<1) +#define ADIS16220_GLOB_CMD_SW_RESET BIT(7) +#define ADIS16220_GLOB_CMD_SELF_TEST BIT(2) +#define ADIS16220_GLOB_CMD_PWR_DOWN BIT(1)#define ADIS16220_MAX_TX 2048#define ADIS16220_MAX_RX 2048
drivers/staging/iio/accel/adis16240.h +15 -15
@@ -74,31 +74,31 @@/* MSC_CTRL */ /* Enables sum-of-squares output (XYZPEAK_OUT) */ -#define ADIS16240_MSC_CTRL_XYZPEAK_OUT_EN (1 << 15) +#define ADIS16240_MSC_CTRL_XYZPEAK_OUT_EN BIT(15)/* Enables peak tracking output (XPEAK_OUT, YPEAK_OUT, and ZPEAK_OUT) */ -#define ADIS16240_MSC_CTRL_X_Y_ZPEAK_OUT_EN (1 << 14) +#define ADIS16240_MSC_CTRL_X_Y_ZPEAK_OUT_EN BIT(14)/* Self-test enable: 1 = apply electrostatic force, 0 = disabled */ -#define ADIS16240_MSC_CTRL_SELF_TEST_EN (1 << 8) +#define ADIS16240_MSC_CTRL_SELF_TEST_EN BIT(8)/* Data-ready enable: 1 = enabled, 0 = disabled */ -#define ADIS16240_MSC_CTRL_DATA_RDY_EN (1 << 2) +#define ADIS16240_MSC_CTRL_DATA_RDY_EN BIT(2)/* Data-ready polarity: 1 = active high, 0 = active low */ -#define ADIS16240_MSC_CTRL_ACTIVE_HIGH (1 << 1) +#define ADIS16240_MSC_CTRL_ACTIVE_HIGH BIT(1)/* Data-ready line selection: 1 = DIO2, 0 = DIO1 */ -#define ADIS16240_MSC_CTRL_DATA_RDY_DIO2 (1 << 0) +#define ADIS16240_MSC_CTRL_DATA_RDY_DIO2 BIT(0)/* DIAG_STAT */ /* Alarm 2 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16240_DIAG_STAT_ALARM2 (1<<9) +#define ADIS16240_DIAG_STAT_ALARM2 BIT(9)/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16240_DIAG_STAT_ALARM1 (1<<8) +#define ADIS16240_DIAG_STAT_ALARM1 BIT(8)/* Capture buffer full: 1 = capture buffer is full */ -#define ADIS16240_DIAG_STAT_CPT_BUF_FUL (1<<7) +#define ADIS16240_DIAG_STAT_CPT_BUF_FUL BIT(7)/* Flash test, checksum flag: 1 = mismatch, 0 = match */ -#define ADIS16240_DIAG_STAT_CHKSUM (1<<6) +#define ADIS16240_DIAG_STAT_CHKSUM BIT(6)/* Power-on, self-test flag: 1 = failure, 0 = pass */ #define ADIS16240_DIAG_STAT_PWRON_FAIL_BIT 5/* Power-on self-test: 1 = in-progress, 0 = complete */ -#define ADIS16240_DIAG_STAT_PWRON_BUSY (1<<4) +#define ADIS16240_DIAG_STAT_PWRON_BUSY BIT(4)/* SPI communications failure */ #define ADIS16240_DIAG_STAT_SPI_FAIL_BIT 3/* Flash update failure */
@@ -109,11 +109,11 @@#define ADIS16240_DIAG_STAT_POWER_LOW_BIT 0/* GLOB_CMD */ -#define ADIS16240_GLOB_CMD_RESUME (1<<8) -#define ADIS16240_GLOB_CMD_SW_RESET (1<<7) -#define ADIS16240_GLOB_CMD_STANDBY (1<<2) +#define ADIS16240_GLOB_CMD_RESUME BIT(8) +#define ADIS16240_GLOB_CMD_SW_RESET BIT(7) +#define ADIS16240_GLOB_CMD_STANDBY BIT(2) -#define ADIS16240_ERROR_ACTIVE (1<<14) +#define ADIS16240_ERROR_ACTIVE BIT(14)/* At the moment triggers are only used for ring buffer * filling. This may change!
drivers/staging/iio/adc/ad7280a.h +4 -4
@@ -23,10 +23,10 @@#define AD7280A_CONV_AVG_4 2#define AD7280A_CONV_AVG_8 3 -#define AD7280A_ALERT_REMOVE_VIN5 (1 << 2) -#define AD7280A_ALERT_REMOVE_VIN4_VIN5 (2 << 2) -#define AD7280A_ALERT_REMOVE_AUX5 (1 << 0) -#define AD7280A_ALERT_REMOVE_AUX4_AUX5 (2 << 0) +#define AD7280A_ALERT_REMOVE_VIN5 BIT(2) +#define AD7280A_ALERT_REMOVE_VIN4_VIN5 BIT(3) +#define AD7280A_ALERT_REMOVE_AUX5 BIT(0) +#define AD7280A_ALERT_REMOVE_AUX4_AUX5 BIT(1)struct ad7280_platform_data {unsigned acquisition_time;
Signature · 1 line
1.9.1
PATCH 2/2 Staging: iio: use the BIT macro in adc
In reply to Haneen MohammedThis patch replace bit shifting on 0,1,2, and 3 with the BIT(x) macro. Issue addressed by checkpatcg.pl.
This was done with the help of Coccinelle:
@r1@
constant int g;
@@
(
0<<g
|
1<<g
|
2<<g
|
3<<g
)
@script:python b@
g2 <<r1.g;
y;
@@
coccinelle.y = int(g2) + 1
@c@
constant int r1.g;
identifier b.y;
@@
(
-(1 << g)
+BIT(g)
|
-(0 << g)
+ 0
|
-(2 << g)
+BIT(y)
|
-(3 << g)
+(BIT(y)| BIT(g))
)
--- drivers/staging/iio/adc/ad7192.c | 64 ++++++++++++++++++------------------ drivers/staging/iio/adc/ad7280a.c | 58 ++++++++++++++++----------------- drivers/staging/iio/adc/ad7780.c | 18 +++++----- drivers/staging/iio/adc/ad7816.c | 2 +- drivers/staging/iio/adc/mxs-lradc.c | 65 +++++++++++++++++++------------------ drivers/staging/iio/adc/spear_adc.c | 6 ++-- 6 files changed, 107 insertions(+), 106 deletions(-)
drivers/staging/iio/adc/ad7192.c +32 -32
@@ -41,32 +41,32 @@* (RW, 16-bit (AD7792)/24-bit (AD7192)) */ /* Communications Register Bit Designations (AD7192_REG_COMM) */ -#define AD7192_COMM_WEN (1 << 7)/* Write Enable */ -#define AD7192_COMM_WRITE (0 << 6)/* Write Operation */ -#define AD7192_COMM_READ (1 << 6)/* Read Operation */ +#define AD7192_COMM_WEN BIT(7)/* Write Enable */ +#define AD7192_COMM_WRITE 0/* Write Operation */ +#define AD7192_COMM_READ BIT(6)/* Read Operation */ #define AD7192_COMM_ADDR (x) (((x) & 0x7) << 3)/* Register Address */ -#define AD7192_COMM_CREAD (1 << 2)/* Continuous Read of Data Register */ +#define AD7192_COMM_CREAD BIT(2)/* Continuous Read of Data Register */ /* Status Register Bit Designations (AD7192_REG_STAT) */ -#define AD7192_STAT_RDY (1 << 7)/* Ready */ -#define AD7192_STAT_ERR (1 << 6)/* Error (Overrange, Underrange) */ -#define AD7192_STAT_NOREF (1 << 5)/* Error no external reference */ -#define AD7192_STAT_PARITY (1 << 4)/* Parity */ -#define AD7192_STAT_CH3 (1 << 2)/* Channel 3 */ -#define AD7192_STAT_CH2 (1 << 1)/* Channel 2 */ -#define AD7192_STAT_CH1 (1 << 0)/* Channel 1 */ +#define AD7192_STAT_RDY BIT(7)/* Ready */ +#define AD7192_STAT_ERR BIT(6)/* Error (Overrange, Underrange) */ +#define AD7192_STAT_NOREF BIT(5)/* Error no external reference */ +#define AD7192_STAT_PARITY BIT(4)/* Parity */ +#define AD7192_STAT_CH3 BIT(2)/* Channel 3 */ +#define AD7192_STAT_CH2 BIT(1)/* Channel 2 */ +#define AD7192_STAT_CH1 BIT(0)/* Channel 1 */ /* Mode Register Bit Designations (AD7192_REG_MODE) */ #define AD7192_MODE_SEL (x) (((x) & 0x7) << 21)/* Operation Mode Select */ #define AD7192_MODE_SEL_MASK (0x7 << 21)/* Operation Mode Select Mask */ -#define AD7192_MODE_DAT_STA (1 << 20)/* Status Register transmission */ +#define AD7192_MODE_DAT_STA BIT(20)/* Status Register transmission */ #define AD7192_MODE_CLKSRC (x) (((x) & 0x3) << 18)/* Clock Source Select */ -#define AD7192_MODE_SINC3 (1 << 15)/* SINC3 Filter Select */ -#define AD7192_MODE_ACX (1 << 14)/* AC excitation enable(AD7195 only)*/ -#define AD7192_MODE_ENPAR (1 << 13)/* Parity Enable */ -#define AD7192_MODE_CLKDIV (1 << 12)/* Clock divide by 2 (AD7190/2 only)*/ -#define AD7192_MODE_SCYCLE (1 << 11)/* Single cycle conversion */ -#define AD7192_MODE_REJ60 (1 << 10)/* 50/60Hz notch filter */ +#define AD7192_MODE_SINC3 BIT(15)/* SINC3 Filter Select */ +#define AD7192_MODE_ACX BIT(14)/* AC excitation enable(AD7195 only)*/ +#define AD7192_MODE_ENPAR BIT(13)/* Parity Enable */ +#define AD7192_MODE_CLKDIV BIT(12)/* Clock divide by 2 (AD7190/2 only)*/ +#define AD7192_MODE_SCYCLE BIT(11)/* Single cycle conversion */ +#define AD7192_MODE_REJ60 BIT(10)/* 50/60Hz notch filter */ #define AD7192_MODE_RATE (x) ((x) & 0x3FF)/* Filter Update Rate Select */ /* Mode Register: AD7192_MODE_SEL options */
@@ -91,14 +91,14 @@/* Configuration Register Bit Designations (AD7192_REG_CONF) */ -#define AD7192_CONF_CHOP (1 << 23)/* CHOP enable */ -#define AD7192_CONF_REFSEL (1 << 20)/* REFIN1/REFIN2 Reference Select */ +#define AD7192_CONF_CHOP BIT(23)/* CHOP enable */ +#define AD7192_CONF_REFSEL BIT(20)/* REFIN1/REFIN2 Reference Select */ #define AD7192_CONF_CHAN (x) (((1 << (x)) & 0xFF) << 8)/* Channel select */ #define AD7192_CONF_CHAN_MASK (0xFF << 8)/* Channel select mask */ -#define AD7192_CONF_BURN (1 << 7)/* Burnout current enable */ -#define AD7192_CONF_REFDET (1 << 6)/* Reference detect enable */ -#define AD7192_CONF_BUF (1 << 4)/* Buffered Mode Enable */ -#define AD7192_CONF_UNIPOLAR (1 << 3)/* Unipolar/Bipolar Enable */ +#define AD7192_CONF_BURN BIT(7)/* Burnout current enable */ +#define AD7192_CONF_REFDET BIT(6)/* Reference detect enable */ +#define AD7192_CONF_BUF BIT(4)/* Buffered Mode Enable */ +#define AD7192_CONF_UNIPOLAR BIT(3)/* Unipolar/Bipolar Enable */ #define AD7192_CONF_GAIN (x) ((x) & 0x7)/* Gain Select */ #define AD7192_CH_AIN1P_AIN2M 0/* AIN1(+) - AIN2(-) */
@@ -117,13 +117,13 @@#define AD7192_ID_MASK 0x0F/* GPOCON Register Bit Designations (AD7192_REG_GPOCON) */ -#define AD7192_GPOCON_BPDSW (1 << 6)/* Bridge power-down switch enable */ -#define AD7192_GPOCON_GP32EN (1 << 5)/* Digital Output P3 and P2 enable */ -#define AD7192_GPOCON_GP10EN (1 << 4)/* Digital Output P1 and P0 enable */ -#define AD7192_GPOCON_P3DAT (1 << 3)/* P3 state */ -#define AD7192_GPOCON_P2DAT (1 << 2)/* P2 state */ -#define AD7192_GPOCON_P1DAT (1 << 1)/* P1 state */ -#define AD7192_GPOCON_P0DAT (1 << 0)/* P0 state */ +#define AD7192_GPOCON_BPDSW BIT(6)/* Bridge power-down switch enable */ +#define AD7192_GPOCON_GP32EN BIT(5)/* Digital Output P3 and P2 enable */ +#define AD7192_GPOCON_GP10EN BIT(4)/* Digital Output P1 and P0 enable */ +#define AD7192_GPOCON_P3DAT BIT(3)/* P3 state */ +#define AD7192_GPOCON_P2DAT BIT(2)/* P2 state */ +#define AD7192_GPOCON_P1DAT BIT(1)/* P1 state */ +#define AD7192_GPOCON_P0DAT BIT(0)/* P0 state */ #define AD7192_INT_FREQ_MHz 4915200
@@ -516,7 +516,7 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, }case IIO_CHAN_INFO_OFFSET :if (!unipolar) - *val = -(1 << (chan->scan_type.realbits -1 )); + *val = -BIT (chan->scan_type.realbits -1 );else *val =0 ;/* Kelvin to Celsius */
drivers/staging/iio/adc/ad7280a.c +29 -29
80 lines not on this page · raw message
drivers/staging/iio/adc/ad7780.c +9 -9
@@ -24,14 +24,14 @@#include "ad7780.h" -#define AD7780_RDY (1 << 7) -#define AD7780_FILTER (1 << 6) -#define AD7780_ERR (1 << 5) -#define AD7780_ID1 (1 << 4) -#define AD7780_ID0 (1 << 3) -#define AD7780_GAIN (1 << 2) -#define AD7780_PAT1 (1 << 1) -#define AD7780_PAT0 (1 << 0) +#define AD7780_RDY BIT(7) +#define AD7780_FILTER BIT(6) +#define AD7780_ERR BIT(5) +#define AD7780_ID1 BIT(4) +#define AD7780_ID0 BIT(3) +#define AD7780_GAIN BIT(2) +#define AD7780_PAT1 BIT(1) +#define AD7780_PAT0 BIT(0)struct ad7780_chip_info {struct iio_chan_spec channel;
@@ -99,7 +99,7 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, *val2 = chan->scan_type.realbits -1 ;return IIO_VAL_FRACTIONAL_LOG2 ;case IIO_CHAN_INFO_OFFSET : - *val -= (1 << (chan->scan_type.realbits -1 )); + *val -=BIT (chan->scan_type.realbits -1 );return IIO_VAL_INT ; }
drivers/staging/iio/adc/ad7816.c +1 -1
@@ -224,7 +224,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/adc/mxs-lradc.c +33 -32
157 lines not on this page · raw message
drivers/staging/iio/adc/spear_adc.c +3 -3
@@ -29,11 +29,11 @@#define SPEAR_ADC_CLK_HIGH (x) (((x) & 0xf) << 4)/* Bit definitions for SPEAR_ADC_STATUS */ -#define SPEAR_ADC_STATUS_START_CONVERSION (1 << 0) +#define SPEAR_ADC_STATUS_START_CONVERSION BIT(0)#define SPEAR_ADC_STATUS_CHANNEL_NUM (x) ((x) << 1) -#define SPEAR_ADC_STATUS_ADC_ENABLE (1 << 4) +#define SPEAR_ADC_STATUS_ADC_ENABLE BIT(4)#define SPEAR_ADC_STATUS_AVG_SAMPLE (x) ((x) << 5) -#define SPEAR_ADC_STATUS_VREF_INTERNAL (1 << 9) +#define SPEAR_ADC_STATUS_VREF_INTERNAL BIT(9)#define SPEAR_ADC_DATA_MASK 0x03ff#define SPEAR_ADC_DATA_BITS 10
Signature · 1 line
1.9.1
Greg KH
maintainerRe: [Outreachy kernel] [PATCH 2/2] Staging: iio: use the BIT macro in adc
Quoted 46 lines · Haneen Mohammed
This patch replace bit shifting on 0,1,2, and 3 with the BIT(x) macro. Issue addressed by checkpatcg.pl.
This was done with the help of Coccinelle:
@r1@
constant int g;
@@(
0<<g
|
1<<g
|
2<<g
|
3<<g
)@script:python b@
g2 <<r1.g;
y;
@@coccinelle.y = int(g2) + 1
@c@
constant int r1.g;
identifier b.y;
@@(
(quoted diff) +1
-1-(1 << g) +BIT(g)|
-(0 << g)
+ 0
|(quoted diff) +1
-1-(2 << g) +BIT(y)|
(quoted diff) +1
-1-(3 << g) +(BIT(y)| BIT(g)))
Signed-off-by Haneen Mohammed <[email protected]>
Quoted 8 lines
--- drivers/staging/iio/adc/ad7192.c | 64 ++++++++++++++++++------------------ drivers/staging/iio/adc/ad7280a.c | 58 ++++++++++++++++----------------- drivers/staging/iio/adc/ad7780.c | 18 +++++----- drivers/staging/iio/adc/ad7816.c | 2 +- drivers/staging/iio/adc/mxs-lradc.c | 65 +++++++++++++++++++------------------ drivers/staging/iio/adc/spear_adc.c | 6 ++-- 6 files changed, 107 insertions(+), 106 deletions(-)
This patch causes a bunch of compiler warnings to suddenly show up. I know it's not directly your fault, but I can't take this patch because of it. Feel free to break up your patch to not include the offending file (hint, I'm not going to tell you because you should have caught this yourself), or send a patch series that includes this one and then fixes up those warnings.
thanks,
greg k-h
PATCH v2 1/1 Staging: iio: use the BIT macro in adc
This patch replaces bit shifting on:
0,1,2, and 3 with the BIT(x) macro.
Issue addressed by checkpatcg.pl.
This was done with the help of Coccinelle:
@r1@
constant int g;
@@
(
0<<g
|
1<<g
|
2<<g
|
3<<g
)
@script:python b@
g2 <<r1.g;
y;
@@
coccinelle.y = int(g2) + 1
@c@
constant int r1.g;
identifier b.y;
@@
(
-(1 << g)
+BIT(g)
|
-(0 << g)
+ 0
|
-(2 << g)
+BIT(y)
|
-(3 << g)
+(BIT(y)| BIT(g))
)---
v2: addressed compiler warnings due to prev change by undoing the change that triggered them
drivers/staging/iio/adc/ad7192.c | 62 ++++++++++++++++++------------------- drivers/staging/iio/adc/ad7280a.c | 58 +++++++++++++++++----------------- drivers/staging/iio/adc/ad7280a.h | 8 ++--- drivers/staging/iio/adc/ad7780.c | 18 +++++------ drivers/staging/iio/adc/ad7816.c | 2 +- drivers/staging/iio/adc/mxs-lradc.c | 49 +++++++++++++++-------------- drivers/staging/iio/adc/spear_adc.c | 6 ++-- 7 files changed, 102 insertions(+), 101 deletions(-)
drivers/staging/iio/adc/ad7192.c +31 -31
@@ -41,32 +41,32 @@* (RW, 16-bit (AD7792)/24-bit (AD7192)) */ /* Communications Register Bit Designations (AD7192_REG_COMM) */ -#define AD7192_COMM_WEN (1 << 7)/* Write Enable */ -#define AD7192_COMM_WRITE (0 << 6)/* Write Operation */ -#define AD7192_COMM_READ (1 << 6)/* Read Operation */ +#define AD7192_COMM_WEN BIT(7)/* Write Enable */ +#define AD7192_COMM_WRITE 0/* Write Operation */ +#define AD7192_COMM_READ BIT(6)/* Read Operation */ #define AD7192_COMM_ADDR (x) (((x) & 0x7) << 3)/* Register Address */ -#define AD7192_COMM_CREAD (1 << 2)/* Continuous Read of Data Register */ +#define AD7192_COMM_CREAD BIT(2)/* Continuous Read of Data Register */ /* Status Register Bit Designations (AD7192_REG_STAT) */ -#define AD7192_STAT_RDY (1 << 7)/* Ready */ -#define AD7192_STAT_ERR (1 << 6)/* Error (Overrange, Underrange) */ -#define AD7192_STAT_NOREF (1 << 5)/* Error no external reference */ -#define AD7192_STAT_PARITY (1 << 4)/* Parity */ -#define AD7192_STAT_CH3 (1 << 2)/* Channel 3 */ -#define AD7192_STAT_CH2 (1 << 1)/* Channel 2 */ -#define AD7192_STAT_CH1 (1 << 0)/* Channel 1 */ +#define AD7192_STAT_RDY BIT(7)/* Ready */ +#define AD7192_STAT_ERR BIT(6)/* Error (Overrange, Underrange) */ +#define AD7192_STAT_NOREF BIT(5)/* Error no external reference */ +#define AD7192_STAT_PARITY BIT(4)/* Parity */ +#define AD7192_STAT_CH3 BIT(2)/* Channel 3 */ +#define AD7192_STAT_CH2 BIT(1)/* Channel 2 */ +#define AD7192_STAT_CH1 BIT(0)/* Channel 1 */ /* Mode Register Bit Designations (AD7192_REG_MODE) */ #define AD7192_MODE_SEL (x) (((x) & 0x7) << 21)/* Operation Mode Select */ #define AD7192_MODE_SEL_MASK (0x7 << 21)/* Operation Mode Select Mask */ #define AD7192_MODE_DAT_STA (1 << 20)/* Status Register transmission */ #define AD7192_MODE_CLKSRC (x) (((x) & 0x3) << 18)/* Clock Source Select */ -#define AD7192_MODE_SINC3 (1 << 15)/* SINC3 Filter Select */ -#define AD7192_MODE_ACX (1 << 14)/* AC excitation enable(AD7195 only)*/ -#define AD7192_MODE_ENPAR (1 << 13)/* Parity Enable */ -#define AD7192_MODE_CLKDIV (1 << 12)/* Clock divide by 2 (AD7190/2 only)*/ -#define AD7192_MODE_SCYCLE (1 << 11)/* Single cycle conversion */ -#define AD7192_MODE_REJ60 (1 << 10)/* 50/60Hz notch filter */ +#define AD7192_MODE_SINC3 BIT(15)/* SINC3 Filter Select */ +#define AD7192_MODE_ACX BIT(14)/* AC excitation enable(AD7195 only)*/ +#define AD7192_MODE_ENPAR BIT(13)/* Parity Enable */ +#define AD7192_MODE_CLKDIV BIT(12)/* Clock divide by 2 (AD7190/2 only)*/ +#define AD7192_MODE_SCYCLE BIT(11)/* Single cycle conversion */ +#define AD7192_MODE_REJ60 BIT(10)/* 50/60Hz notch filter */ #define AD7192_MODE_RATE (x) ((x) & 0x3FF)/* Filter Update Rate Select */ /* Mode Register: AD7192_MODE_SEL options */
@@ -91,14 +91,14 @@/* Configuration Register Bit Designations (AD7192_REG_CONF) */ -#define AD7192_CONF_CHOP (1 << 23)/* CHOP enable */ -#define AD7192_CONF_REFSEL (1 << 20)/* REFIN1/REFIN2 Reference Select */ +#define AD7192_CONF_CHOP BIT(23)/* CHOP enable */ +#define AD7192_CONF_REFSEL BIT(20)/* REFIN1/REFIN2 Reference Select */ #define AD7192_CONF_CHAN (x) (((1 << (x)) & 0xFF) << 8)/* Channel select */ #define AD7192_CONF_CHAN_MASK (0xFF << 8)/* Channel select mask */ -#define AD7192_CONF_BURN (1 << 7)/* Burnout current enable */ -#define AD7192_CONF_REFDET (1 << 6)/* Reference detect enable */ -#define AD7192_CONF_BUF (1 << 4)/* Buffered Mode Enable */ -#define AD7192_CONF_UNIPOLAR (1 << 3)/* Unipolar/Bipolar Enable */ +#define AD7192_CONF_BURN BIT(7)/* Burnout current enable */ +#define AD7192_CONF_REFDET BIT(6)/* Reference detect enable */ +#define AD7192_CONF_BUF BIT(4)/* Buffered Mode Enable */ +#define AD7192_CONF_UNIPOLAR BIT(3)/* Unipolar/Bipolar Enable */ #define AD7192_CONF_GAIN (x) ((x) & 0x7)/* Gain Select */ #define AD7192_CH_AIN1P_AIN2M 0/* AIN1(+) - AIN2(-) */
@@ -117,13 +117,13 @@#define AD7192_ID_MASK 0x0F/* GPOCON Register Bit Designations (AD7192_REG_GPOCON) */ -#define AD7192_GPOCON_BPDSW (1 << 6)/* Bridge power-down switch enable */ -#define AD7192_GPOCON_GP32EN (1 << 5)/* Digital Output P3 and P2 enable */ -#define AD7192_GPOCON_GP10EN (1 << 4)/* Digital Output P1 and P0 enable */ -#define AD7192_GPOCON_P3DAT (1 << 3)/* P3 state */ -#define AD7192_GPOCON_P2DAT (1 << 2)/* P2 state */ -#define AD7192_GPOCON_P1DAT (1 << 1)/* P1 state */ -#define AD7192_GPOCON_P0DAT (1 << 0)/* P0 state */ +#define AD7192_GPOCON_BPDSW BIT(6)/* Bridge power-down switch enable */ +#define AD7192_GPOCON_GP32EN BIT(5)/* Digital Output P3 and P2 enable */ +#define AD7192_GPOCON_GP10EN BIT(4)/* Digital Output P1 and P0 enable */ +#define AD7192_GPOCON_P3DAT BIT(3)/* P3 state */ +#define AD7192_GPOCON_P2DAT BIT(2)/* P2 state */ +#define AD7192_GPOCON_P1DAT BIT(1)/* P1 state */ +#define AD7192_GPOCON_P0DAT BIT(0)/* P0 state */ #define AD7192_INT_FREQ_MHz 4915200
@@ -516,7 +516,7 @@ static int ad7192_read_raw(struct iio_dev *indio_dev, }case IIO_CHAN_INFO_OFFSET :if (!unipolar) - *val = -(1 << (chan->scan_type.realbits -1 )); + *val = -BIT (chan->scan_type.realbits -1 );else *val =0 ;/* Kelvin to Celsius */
drivers/staging/iio/adc/ad7280a.c +29 -29
80 lines not on this page · raw message
drivers/staging/iio/adc/ad7280a.h +4 -4
@@ -23,10 +23,10 @@#define AD7280A_CONV_AVG_4 2#define AD7280A_CONV_AVG_8 3 -#define AD7280A_ALERT_REMOVE_VIN5 (1 << 2) -#define AD7280A_ALERT_REMOVE_VIN4_VIN5 (2 << 2) -#define AD7280A_ALERT_REMOVE_AUX5 (1 << 0) -#define AD7280A_ALERT_REMOVE_AUX4_AUX5 (2 << 0) +#define AD7280A_ALERT_REMOVE_VIN5 BIT(2) +#define AD7280A_ALERT_REMOVE_VIN4_VIN5 BIT(3) +#define AD7280A_ALERT_REMOVE_AUX5 BIT(0) +#define AD7280A_ALERT_REMOVE_AUX4_AUX5 BIT(1)struct ad7280_platform_data {unsigned acquisition_time;
drivers/staging/iio/adc/ad7780.c +9 -9
@@ -24,14 +24,14 @@#include "ad7780.h" -#define AD7780_RDY (1 << 7) -#define AD7780_FILTER (1 << 6) -#define AD7780_ERR (1 << 5) -#define AD7780_ID1 (1 << 4) -#define AD7780_ID0 (1 << 3) -#define AD7780_GAIN (1 << 2) -#define AD7780_PAT1 (1 << 1) -#define AD7780_PAT0 (1 << 0) +#define AD7780_RDY BIT(7) +#define AD7780_FILTER BIT(6) +#define AD7780_ERR BIT(5) +#define AD7780_ID1 BIT(4) +#define AD7780_ID0 BIT(3) +#define AD7780_GAIN BIT(2) +#define AD7780_PAT1 BIT(1) +#define AD7780_PAT0 BIT(0)struct ad7780_chip_info {struct iio_chan_spec channel;
@@ -99,7 +99,7 @@ static int ad7780_read_raw(struct iio_dev *indio_dev, *val2 = chan->scan_type.realbits -1 ;return IIO_VAL_FRACTIONAL_LOG2 ;case IIO_CHAN_INFO_OFFSET : - *val -= (1 << (chan->scan_type.realbits -1 )); + *val -=BIT (chan->scan_type.realbits -1 );return IIO_VAL_INT ; }
drivers/staging/iio/adc/ad7816.c +1 -1
@@ -224,7 +224,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/adc/mxs-lradc.c +25 -24
110 lines not on this page · raw message
drivers/staging/iio/adc/spear_adc.c +3 -3
@@ -29,11 +29,11 @@#define SPEAR_ADC_CLK_HIGH (x) (((x) & 0xf) << 4)/* Bit definitions for SPEAR_ADC_STATUS */ -#define SPEAR_ADC_STATUS_START_CONVERSION (1 << 0) +#define SPEAR_ADC_STATUS_START_CONVERSION BIT(0)#define SPEAR_ADC_STATUS_CHANNEL_NUM (x) ((x) << 1) -#define SPEAR_ADC_STATUS_ADC_ENABLE (1 << 4) +#define SPEAR_ADC_STATUS_ADC_ENABLE BIT(4)#define SPEAR_ADC_STATUS_AVG_SAMPLE (x) ((x) << 5) -#define SPEAR_ADC_STATUS_VREF_INTERNAL (1 << 9) +#define SPEAR_ADC_STATUS_VREF_INTERNAL BIT(9)#define SPEAR_ADC_DATA_MASK 0x03ff#define SPEAR_ADC_DATA_BITS 10
Signature · 1 line
1.9.1
Greg KH
maintainerRe: [Outreachy kernel] [PATCH v2] Staging: iio: use the BIT macro in adc
Quoted 44 lines · Haneen Mohammed
This patch replaces bit shifting on:
0,1,2, and 3 with the BIT(x) macro.
Issue addressed by checkpatcg.pl.
This was done with the help of Coccinelle:@r1@ constant int g; @@ ( 0<<g | 1<<g | 2<<g | 3<<g ) @script:python b@ g2 <<r1.g; y; @@ coccinelle.y = int(g2) + 1 @c@ constant int r1.g; identifier b.y; @@ ( -(1 << g) +BIT(g) | -(0 << g) + 0 | -(2 << g) +BIT(y) | -(3 << g) +(BIT(y)| BIT(g)) )
Quoted 3 lines
Signed-off-by Haneen Mohammed <[email protected]>---
v2: addressed compiler warnings due to prev change by undoing the change that triggered them
This patch doesn't apply to my tree, please redo it against a "clean" version of my staging-testing branch of staging.git and resend.
thanks,
greg k-h
PATCH v3 1/1 Staging: iio: use the BIT macro in adc
In reply to Haneen MohammedThis patch replaces bit shifting on:
0,1,2, and 3 with the BIT(x) macro.
Issue addressed by checkpatcg.pl.
This was done with the help of Coccinelle:
@r1@
identifier x;
constant int g;
@@
(
0<<\(x\|g\)
|
1<<\(x\|g\)
|
2<<\(x\|g\)
|
3<<\(x\|g\)
)
@script:python b@
g2 <<r1.g;
y;
@@
coccinelle.y = int(g2) + 1
@c@
constant int r1.g;
identifier b.y;
@@
(
-(1 << g)
+BIT(g)
|
-(0 << g)
+ 0
|
-(2 << g)
+BIT(y)
|
-(3 << g)
+(BIT(y)| BIT(g))
)
---
v3: redo against updated staging tree
v2: addressed compiler warnings due to prev change by undoing the change that triggered them
drivers/staging/iio/adc/ad7192.c | 62 ++++++++++++++++++------------------- drivers/staging/iio/adc/ad7280a.c | 56 ++++++++++++++++----------------- drivers/staging/iio/adc/ad7780.c | 16 +++++----- drivers/staging/iio/adc/mxs-lradc.c | 46 +++++++++++++-------------- drivers/staging/iio/adc/spear_adc.c | 6 ++-- 5 files changed, 93 insertions(+), 93 deletions(-)
drivers/staging/iio/adc/ad7192.c +31 -31
@@ -41,32 +41,32 @@* (RW, 16-bit (AD7792)/24-bit (AD7192)) */ /* Communications Register Bit Designations (AD7192_REG_COMM) */ -#define AD7192_COMM_WEN (1 << 7)/* Write Enable */ -#define AD7192_COMM_WRITE (0 << 6)/* Write Operation */ -#define AD7192_COMM_READ (1 << 6)/* Read Operation */ +#define AD7192_COMM_WEN BIT(7)/* Write Enable */ +#define AD7192_COMM_WRITE 0/* Write Operation */ +#define AD7192_COMM_READ BIT(6)/* Read Operation */ #define AD7192_COMM_ADDR (x) (((x) & 0x7) << 3)/* Register Address */ -#define AD7192_COMM_CREAD (1 << 2)/* Continuous Read of Data Register */ +#define AD7192_COMM_CREAD BIT(2)/* Continuous Read of Data Register */ /* Status Register Bit Designations (AD7192_REG_STAT) */ -#define AD7192_STAT_RDY (1 << 7)/* Ready */ -#define AD7192_STAT_ERR (1 << 6)/* Error (Overrange, Underrange) */ -#define AD7192_STAT_NOREF (1 << 5)/* Error no external reference */ -#define AD7192_STAT_PARITY (1 << 4)/* Parity */ -#define AD7192_STAT_CH3 (1 << 2)/* Channel 3 */ -#define AD7192_STAT_CH2 (1 << 1)/* Channel 2 */ -#define AD7192_STAT_CH1 (1 << 0)/* Channel 1 */ +#define AD7192_STAT_RDY BIT(7)/* Ready */ +#define AD7192_STAT_ERR BIT(6)/* Error (Overrange, Underrange) */ +#define AD7192_STAT_NOREF BIT(5)/* Error no external reference */ +#define AD7192_STAT_PARITY BIT(4)/* Parity */ +#define AD7192_STAT_CH3 BIT(2)/* Channel 3 */ +#define AD7192_STAT_CH2 BIT(1)/* Channel 2 */ +#define AD7192_STAT_CH1 BIT(0)/* Channel 1 */ /* Mode Register Bit Designations (AD7192_REG_MODE) */ #define AD7192_MODE_SEL (x) (((x) & 0x7) << 21)/* Operation Mode Select */ #define AD7192_MODE_SEL_MASK (0x7 << 21)/* Operation Mode Select Mask */ -#define AD7192_MODE_DAT_STA (1 << 20)/* Status Register transmission */ +#define AD7192_MODE_DAT_STA BIT(20)/* Status Register transmission */ #define AD7192_MODE_CLKSRC (x) (((x) & 0x3) << 18)/* Clock Source Select */ -#define AD7192_MODE_SINC3 (1 << 15)/* SINC3 Filter Select */ -#define AD7192_MODE_ACX (1 << 14)/* AC excitation enable(AD7195 only)*/ -#define AD7192_MODE_ENPAR (1 << 13)/* Parity Enable */ -#define AD7192_MODE_CLKDIV (1 << 12)/* Clock divide by 2 (AD7190/2 only)*/ -#define AD7192_MODE_SCYCLE (1 << 11)/* Single cycle conversion */ -#define AD7192_MODE_REJ60 (1 << 10)/* 50/60Hz notch filter */ +#define AD7192_MODE_SINC3 BIT(15)/* SINC3 Filter Select */ +#define AD7192_MODE_ACX BIT(14)/* AC excitation enable(AD7195 only)*/ +#define AD7192_MODE_ENPAR BIT(13)/* Parity Enable */ +#define AD7192_MODE_CLKDIV BIT(12)/* Clock divide by 2 (AD7190/2 only)*/ +#define AD7192_MODE_SCYCLE BIT(11)/* Single cycle conversion */ +#define AD7192_MODE_REJ60 BIT(10)/* 50/60Hz notch filter */ #define AD7192_MODE_RATE (x) ((x) & 0x3FF)/* Filter Update Rate Select */ /* Mode Register: AD7192_MODE_SEL options */
@@ -91,14 +91,14 @@/* Configuration Register Bit Designations (AD7192_REG_CONF) */ -#define AD7192_CONF_CHOP (1 << 23)/* CHOP enable */ -#define AD7192_CONF_REFSEL (1 << 20)/* REFIN1/REFIN2 Reference Select */ +#define AD7192_CONF_CHOP BIT(23)/* CHOP enable */ +#define AD7192_CONF_REFSEL BIT(20)/* REFIN1/REFIN2 Reference Select */ #define AD7192_CONF_CHAN (x) (((1 << (x)) & 0xFF) << 8)/* Channel select */ #define AD7192_CONF_CHAN_MASK (0xFF << 8)/* Channel select mask */ -#define AD7192_CONF_BURN (1 << 7)/* Burnout current enable */ -#define AD7192_CONF_REFDET (1 << 6)/* Reference detect enable */ -#define AD7192_CONF_BUF (1 << 4)/* Buffered Mode Enable */ -#define AD7192_CONF_UNIPOLAR (1 << 3)/* Unipolar/Bipolar Enable */ +#define AD7192_CONF_BURN BIT(7)/* Burnout current enable */ +#define AD7192_CONF_REFDET BIT(6)/* Reference detect enable */ +#define AD7192_CONF_BUF BIT(4)/* Buffered Mode Enable */ +#define AD7192_CONF_UNIPOLAR BIT(3)/* Unipolar/Bipolar Enable */ #define AD7192_CONF_GAIN (x) ((x) & 0x7)/* Gain Select */ #define AD7192_CH_AIN1P_AIN2M 0/* AIN1(+) - AIN2(-) */
@@ -117,13 +117,13 @@#define AD7192_ID_MASK 0x0F/* GPOCON Register Bit Designations (AD7192_REG_GPOCON) */ -#define AD7192_GPOCON_BPDSW (1 << 6)/* Bridge power-down switch enable */ -#define AD7192_GPOCON_GP32EN (1 << 5)/* Digital Output P3 and P2 enable */ -#define AD7192_GPOCON_GP10EN (1 << 4)/* Digital Output P1 and P0 enable */ -#define AD7192_GPOCON_P3DAT (1 << 3)/* P3 state */ -#define AD7192_GPOCON_P2DAT (1 << 2)/* P2 state */ -#define AD7192_GPOCON_P1DAT (1 << 1)/* P1 state */ -#define AD7192_GPOCON_P0DAT (1 << 0)/* P0 state */ +#define AD7192_GPOCON_BPDSW BIT(6)/* Bridge power-down switch enable */ +#define AD7192_GPOCON_GP32EN BIT(5)/* Digital Output P3 and P2 enable */ +#define AD7192_GPOCON_GP10EN BIT(4)/* Digital Output P1 and P0 enable */ +#define AD7192_GPOCON_P3DAT BIT(3)/* P3 state */ +#define AD7192_GPOCON_P2DAT BIT(2)/* P2 state */ +#define AD7192_GPOCON_P1DAT BIT(1)/* P1 state */ +#define AD7192_GPOCON_P0DAT BIT(0)/* P0 state */ #define AD7192_INT_FREQ_MHz 4915200
drivers/staging/iio/adc/ad7280a.c +28 -28
65 lines not on this page · raw message
drivers/staging/iio/adc/ad7780.c +8 -8
@@ -24,14 +24,14 @@#include "ad7780.h" -#define AD7780_RDY (1 << 7) -#define AD7780_FILTER (1 << 6) -#define AD7780_ERR (1 << 5) -#define AD7780_ID1 (1 << 4) -#define AD7780_ID0 (1 << 3) -#define AD7780_GAIN (1 << 2) -#define AD7780_PAT1 (1 << 1) -#define AD7780_PAT0 (1 << 0) +#define AD7780_RDY BIT(7) +#define AD7780_FILTER BIT(6) +#define AD7780_ERR BIT(5) +#define AD7780_ID1 BIT(4) +#define AD7780_ID0 BIT(3) +#define AD7780_GAIN BIT(2) +#define AD7780_PAT1 BIT(1) +#define AD7780_PAT0 BIT(0)struct ad7780_chip_info {struct iio_chan_spec channel;
drivers/staging/iio/adc/mxs-lradc.c +23 -23
96 lines not on this page · raw message
drivers/staging/iio/adc/spear_adc.c +3 -3
@@ -29,11 +29,11 @@#define SPEAR_ADC_CLK_HIGH (x) (((x) & 0xf) << 4)/* Bit definitions for SPEAR_ADC_STATUS */ -#define SPEAR_ADC_STATUS_START_CONVERSION (1 << 0) +#define SPEAR_ADC_STATUS_START_CONVERSION BIT(0)#define SPEAR_ADC_STATUS_CHANNEL_NUM (x) ((x) << 1) -#define SPEAR_ADC_STATUS_ADC_ENABLE (1 << 4) +#define SPEAR_ADC_STATUS_ADC_ENABLE BIT(4)#define SPEAR_ADC_STATUS_AVG_SAMPLE (x) ((x) << 5) -#define SPEAR_ADC_STATUS_VREF_INTERNAL (1 << 9) +#define SPEAR_ADC_STATUS_VREF_INTERNAL BIT(9)#define SPEAR_ADC_DATA_MASK 0x03ff#define SPEAR_ADC_DATA_BITS 10
Signature · 1 line
1.9.1