adis16209 driver cleanup
Subsystems (4)
v3 cover adis16209 driver cleanup
This patchset has been introduced for the cleanup of adis16209 driver.
This patchset cleans up miscellaneous code fragments and improves the code readability.
Changes in v3
-Combine some patches into one from the previous series
and add some more comments in patch *[1/4]. Introduce a new patch *[2/3] for more cleanup. Also split the last patch of the previous series into two patches.
Changes in v2
-Split patches and redo the series.
Shreeya Patel (4):
Staging: iio: adis16209: Remove and add some comments and group the
definitions
Staging: iio: adis16209: Change some macro names
Staging: iio: adis16209: Adjust a switch statement
Staging: iio: adis16209: Use sign_extend32 function
drivers/staging/iio/accel/adis16209.c | 183 +++++++++++++--------------------- 1 file changed, 67 insertions(+), 116 deletions(-)
Signature · 1 line
2.7.4
PATCH v3 1/4 Staging: iio: adis16209: Remove and add some comments and group the definitions
Remove some unnecessay comments and group the control register and register field macros together.
Some of the register names does not make it's puporse very clear and hence, add some comments for more information.
Also there are certain unit based comments which are not providing sufficient information, so expand those comments.
---
Changes in v3
-This patch is the combination of two patches from the
previous series. Also add some more comments.
drivers/staging/iio/accel/adis16209.c | 132 ++++++++++------------------------ 1 file changed, 39 insertions(+), 93 deletions(-)
drivers/staging/iio/accel/adis16209.c +39 -93
@@ -21,135 +21,70 @@#include <linux/iio/imu/adis.h> #define ADIS16209_STARTUP_DELAY_MS 220 - -/* Flash memory write count */ #define ADIS16209_FLASH_CNT_REG 0x00 -/* Output, power supply */ +/* Data Output Register Definitions */ #define ADIS16209_SUPPLY_OUT_REG 0x02 - -/* Output, x-axis accelerometer */ #define ADIS16209_XACCL_OUT_REG 0x04 - -/* Output, y-axis accelerometer */ #define ADIS16209_YACCL_OUT_REG 0x06 -/* Output, auxiliary ADC input */ #define ADIS16209_AUX_ADC_REG 0x08 -/* Output, temperature */ #define ADIS16209_TEMP_OUT_REG 0x0A - -/* Output, x-axis inclination */ +/* Output, +/- 90 degrees X-axis inclination */ #define ADIS16209_XINCL_OUT_REG 0x0C - -/* Output, y-axis inclination */ #define ADIS16209_YINCL_OUT_REG 0x0E -/* Output, +/-180 vertical rotational position */ #define ADIS16209_ROT_OUT_REG 0x10 -/* Calibration, x-axis acceleration offset null */ +/* +* Calibration Register Definitions. +* Acceleration, inclination or rotation offset null. +*/ #define ADIS16209_XACCL_NULL_REG 0x12 - -/* Calibration, y-axis acceleration offset null */ #define ADIS16209_YACCL_NULL_REG 0x14 - -/* Calibration, x-axis inclination offset null */ #define ADIS16209_XINCL_NULL_REG 0x16 - -/* Calibration, y-axis inclination offset null */ #define ADIS16209_YINCL_NULL_REG 0x18 - -/* Calibration, vertical rotation offset null */ #define ADIS16209_ROT_NULL_REG 0x1A -/* Alarm 1 amplitude threshold */ +/* Alarm Register Definitions */ #define ADIS16209_ALM_MAG1_REG 0x20 - -/* Alarm 2 amplitude threshold */ #define ADIS16209_ALM_MAG2_REG 0x22 - -/* Alarm 1, sample period */ #define ADIS16209_ALM_SMPL1_REG 0x24 - -/* Alarm 2, sample period */ #define ADIS16209_ALM_SMPL2_REG 0x26 - -/* Alarm control */ #define ADIS16209_ALM_CTRL_REG 0x28 -/* Auxiliary DAC data */ #define ADIS16209_AUX_DAC_REG 0x30 - -/* General-purpose digital input/output control */ #define ADIS16209_GPIO_CTRL_REG 0x32 - -/* Miscellaneous control */ -#define ADIS16209_MSC_CTRL_REG 0x34 - -/* Internal sample period (rate) control */ #define ADIS16209_SMPL_PRD_REG 0x36 - -/* Operation, filter configuration */ #define ADIS16209_AVG_CNT_REG 0x38 - -/* Operation, sleep mode control */ #define ADIS16209_SLP_CNT_REG 0x3A -/* Diagnostics, system status register */ -#define ADIS16209_DIAG_STAT_REG 0x3C - -/* Operation, system command register */ -#define ADIS16209_GLOB_CMD_REG 0x3E - -/* MSC_CTRL */ - -/* Self-test at power-on: 1 = disabled, 0 = enabled */ -#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST BIT(10) - -/* Self-test enable */ -#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) - -/* Data-ready enable: 1 = enabled, 0 = disabled */ -#define ADIS16209_MSC_CTRL_DATA_RDY_EN BIT(2) - +#define ADIS16209_MSC_CTRL_REG 0x34 +#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST BIT(10) +#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) +#define ADIS16209_MSC_CTRL_DATA_RDY_EN BIT(2)/* Data-ready polarity: 1 = active high, 0 = active low */ -#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1) +#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1) +#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) -/* Data-ready line selection: 1 = DIO2, 0 = DIO1 */ -#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 BIT(9) - -/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16209_DIAG_STAT_ALARM1 BIT(8) - -/* Self-test diagnostic error flag: 1 = error condition, 0 = normal operation */ +#define ADIS16209_DIAG_STAT_REG 0x3C +#define ADIS16209_DIAG_STAT_ALARM2 BIT(9) +#define ADIS16209_DIAG_STAT_ALARM1 BIT(8)#define ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT 5 - -/* SPI communications failure */ #define ADIS16209_DIAG_STAT_SPI_FAIL_BIT 3 - -/* Flash update failure */ #define ADIS16209_DIAG_STAT_FLASH_UPT_BIT 2 -/* Power supply above 3.625 V */ #define ADIS16209_DIAG_STAT_POWER_HIGH_BIT 1 -/* Power supply below 3.15 V */ #define ADIS16209_DIAG_STAT_POWER_LOW_BIT 0 -/* GLOB_CMD */ - -#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_GLOB_CMD_REG 0x3E +#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 BIT(14) +#define ADIS16209_ERROR_ACTIVE BIT(14)enum adis16209_scan {ADIS16209_SCAN_SUPPLY ,
@@ -226,24 +161,38 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, *val2 =610500 ;/* 0.6105 mV */ return IIO_VAL_INT_PLUS_MICRO ;case IIO_TEMP : - *val =-470 ;/* -0.47 C */ + *val =-470 ; *val2 =0 ;return IIO_VAL_INT_PLUS_MICRO ;case IIO_ACCEL : +/* +* IIO base unit for sensitivity of accelerometer +* is milli g. +* 1 LSB represents 0.244 mg. +*/ *val =0 ; - *val2 =IIO_G_TO_M_S_2 (244140 );/* 0.244140 mg */ + *val2 =IIO_G_TO_M_S_2 (244140 );return IIO_VAL_INT_PLUS_NANO ;case IIO_INCLI :case IIO_ROT : +/* +* IIO base units for rotation are degrees. +* 1 LSB represents 0.025 milli degrees. +*/ *val =0 ; - *val2 =25000 ;/* 0.025 degree */ + *val2 =25000 ;return IIO_VAL_INT_PLUS_MICRO ;default :return -EINVAL ; }break ;case IIO_CHAN_INFO_OFFSET : - *val =25000 /-470 -0x4FE ;/* 25 C = 0x4FE */ +/* +* The raw ADC value is 0x4FE when the temperature +* is 45 degrees and the scale factor per milli +* degree celcius is -470. +*/ + *val =25000 /-470 -0x4FE ;return IIO_VAL_INT ;case IIO_CHAN_INFO_CALIBBIAS :switch (chan->type) {
@@ -320,12 +269,10 @@ static int adis16209_probe(struct spi_device *spi)struct adis *st;struct iio_dev *indio_dev; -/* setup the industrialio driver allocated elements */ indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (*st));if (!indio_dev)return -ENOMEM ; st =iio_priv (indio_dev); -/* this is only used for removal purposes */ spi_set_drvdata (spi, indio_dev); indio_dev->name = spi->dev.driver->name;
@@ -342,7 +289,6 @@ static int adis16209_probe(struct spi_device *spi)if (ret)return ret; -/* Get the device into a sane initial state */ ret =adis_initial_startup (st);if (ret) goto error_cleanup_buffer_trigger;
Signature · 1 line
2.7.4
PATCH v3 2/4 Staging: iio: adis16209: Change some macro names
In reply to Shreeya PatelMake some of the macro names according to the names given in the datasheet of the adis16209 driver.
---
Changes in v3
-Introduce this new patch for v3 of the series.
drivers/staging/iio/accel/adis16209.c | 48 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-)
drivers/staging/iio/accel/adis16209.c +24 -24
@@ -68,21 +68,21 @@#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1)#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) -#define ADIS16209_DIAG_STAT_REG 0x3C -#define ADIS16209_DIAG_STAT_ALARM2 BIT(9) -#define ADIS16209_DIAG_STAT_ALARM1 BIT(8) -#define ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT 5 -#define ADIS16209_DIAG_STAT_SPI_FAIL_BIT 3 -#define ADIS16209_DIAG_STAT_FLASH_UPT_BIT 2 +#define ADIS16209_STAT_REG 0x3C +#define ADIS16209_STAT_ALARM2 BIT(9) +#define ADIS16209_STAT_ALARM1 BIT(8) +#define ADIS16209_STAT_SELFTEST_FAIL_BIT 5 +#define ADIS16209_STAT_SPI_FAIL_BIT 3 +#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2/* Power supply above 3.625 V */ -#define ADIS16209_DIAG_STAT_POWER_HIGH_BIT 1 +#define ADIS16209_STAT_POWER_HIGH_BIT 1/* Power supply below 3.15 V */ -#define ADIS16209_DIAG_STAT_POWER_LOW_BIT 0 +#define ADIS16209_STAT_POWER_LOW_BIT 0 -#define ADIS16209_GLOB_CMD_REG 0x3E -#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_CMD_REG 0x3E +#define ADIS16209_CMD_SW_RESET BIT(7) +#define ADIS16209_CMD_CLEAR_STAT BIT(4) +#define ADIS16209_CMD_FACTORY_CAL BIT(1)#define ADIS16209_ERROR_ACTIVE BIT(14)
@@ -238,29 +238,29 @@ static const struct iio_info adis16209_info = { };static const char *const adis16209_status_error_msgs[] = { - [ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT ] ="Self test failure" , - [ADIS16209_DIAG_STAT_SPI_FAIL_BIT ] ="SPI failure" , - [ADIS16209_DIAG_STAT_FLASH_UPT_BIT ] ="Flash update failed" , - [ADIS16209_DIAG_STAT_POWER_HIGH_BIT ] ="Power supply above 3.625V" , - [ADIS16209_DIAG_STAT_POWER_LOW_BIT ] ="Power supply below 3.15V" , + [ADIS16209_STAT_SELFTEST_FAIL_BIT ] ="Self test failure" , + [ADIS16209_STAT_SPI_FAIL_BIT ] ="SPI failure" , + [ADIS16209_STAT_FLASH_UPT_FAIL_BIT ] ="Flash update failed" , + [ADIS16209_STAT_POWER_HIGH_BIT ] ="Power supply above 3.625V" , + [ADIS16209_STAT_POWER_LOW_BIT ] ="Power supply below 3.15V" , };static const struct adis_data adis16209_data = { .read_delay =30 , .msc_ctrl_reg =ADIS16209_MSC_CTRL_REG , - .glob_cmd_reg =ADIS16209_GLOB_CMD_REG , - .diag_stat_reg =ADIS16209_DIAG_STAT_REG , + .glob_cmd_reg =ADIS16209_CMD_REG , + .diag_stat_reg =ADIS16209_STAT_REG , .self_test_mask =ADIS16209_MSC_CTRL_SELF_TEST_EN , .self_test_no_autoclear = true, .startup_delay =ADIS16209_STARTUP_DELAY_MS , .status_error_msgs = adis16209_status_error_msgs, - .status_error_mask =BIT (ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT ) | -BIT (ADIS16209_DIAG_STAT_SPI_FAIL_BIT ) | -BIT (ADIS16209_DIAG_STAT_FLASH_UPT_BIT ) | -BIT (ADIS16209_DIAG_STAT_POWER_HIGH_BIT ) | -BIT (ADIS16209_DIAG_STAT_POWER_LOW_BIT ), + .status_error_mask =BIT (ADIS16209_STAT_SELFTEST_FAIL_BIT ) | +BIT (ADIS16209_STAT_SPI_FAIL_BIT ) | +BIT (ADIS16209_STAT_FLASH_UPT_FAIL_BIT ) | +BIT (ADIS16209_STAT_POWER_HIGH_BIT ) | +BIT (ADIS16209_STAT_POWER_LOW_BIT ), };static int adis16209_probe (struct spi_device *spi)
Signature · 1 line
2.7.4
PATCH v3 3/4 Staging: iio: adis16209: Adjust a switch statement
In reply to Shreeya PatelAdjust a switch block to explicitly match channels and return -EINVAL as default case which makes the code semantically more clear.
---
Changes in v3
-After split patch.
drivers/staging/iio/accel/adis16209.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/staging/iio/accel/adis16209.c +8 -2
@@ -155,10 +155,16 @@ static int adis16209_read_raw(struct iio_dev *indio_dev,switch (chan->type) {case IIO_VOLTAGE : *val =0 ; -if (chan->channel ==0 ) +switch (chan->channel) { +case 0 : *val2 =305180 ;/* 0.30518 mV */ -else +break ; +case 1 : *val2 =610500 ;/* 0.6105 mV */ +break ; +default : +return -EINVAL ; + }return IIO_VAL_INT_PLUS_MICRO ;case IIO_TEMP : *val =-470 ;
Signature · 1 line
2.7.4
PATCH v3 4/4 Staging: iio: adis16209: Use sign_extend32 function
In reply to Shreeya PatelUse sign_extend32 function instead of manually coding it.
---
Changes in v3
-After split patch.
drivers/staging/iio/accel/adis16209.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/staging/iio/accel/adis16209.c +2 -3
@@ -212,9 +212,8 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, ret =adis_read_reg_16 (st, addr, &val16);if (ret)return ret; - val16 &= (1 << bits) -1 ; - val16 = (s16)(val16 << (16 - bits)) >> (16 - bits); - *val = val16; + + *val =sign_extend32 (val16, bits -1 );return IIO_VAL_INT ; }return -EINVAL ;
Signature · 1 line
2.7.4
Re: [PATCH v3 1/4] Staging: iio: adis16209: Remove and add some comments and group the definitions
In reply to Shreeya PatelHi Shreeya,
Quoted 208 lines · Shreeya Patel
Remove some unnecessay comments and group the control register and register field macros together.
Some of the register names does not make it's puporse very clear and hence, add some comments for more information.
Also there are certain unit based comments which are not providing sufficient information, so expand those comments.Signed-off-by Shreeya Patel <[email protected]>---
Changes in v3
-This patch is the combination of two patches from the
previous series. Also add some more comments.drivers/staging/iio/accel/adis16209.c | 132 ++++++++++------------------------ 1 file changed, 39 insertions(+), 93 deletions(-)drivers/staging/iio/accel/adis16209.c +33
-89@@ -21,135 +21,70 @@#include <linux/iio/imu/adis.h> #define ADIS16209_STARTUP_DELAY_MS 220 - -/* Flash memory write count */ #define ADIS16209_FLASH_CNT_REG 0x00 -/* Output, power supply */ +/* Data Output Register Definitions */ #define ADIS16209_SUPPLY_OUT_REG 0x02 - -/* Output, x-axis accelerometer */ #define ADIS16209_XACCL_OUT_REG 0x04 - -/* Output, y-axis accelerometer */ #define ADIS16209_YACCL_OUT_REG 0x06 -/* Output, auxiliary ADC input */ #define ADIS16209_AUX_ADC_REG 0x08 -/* Output, temperature */ #define ADIS16209_TEMP_OUT_REG 0x0A - -/* Output, x-axis inclination */ +/* Output, +/- 90 degrees X-axis inclination */ #define ADIS16209_XINCL_OUT_REG 0x0C - -/* Output, y-axis inclination */ #define ADIS16209_YINCL_OUT_REG 0x0E -/* Output, +/-180 vertical rotational position */ #define ADIS16209_ROT_OUT_REG 0x10 -/* Calibration, x-axis acceleration offset null */ +/* +* Calibration Register Definitions. +* Acceleration, inclination or rotation offset null. +*/ #define ADIS16209_XACCL_NULL_REG 0x12 - -/* Calibration, y-axis acceleration offset null */ #define ADIS16209_YACCL_NULL_REG 0x14 - -/* Calibration, x-axis inclination offset null */ #define ADIS16209_XINCL_NULL_REG 0x16 - -/* Calibration, y-axis inclination offset null */ #define ADIS16209_YINCL_NULL_REG 0x18 - -/* Calibration, vertical rotation offset null */ #define ADIS16209_ROT_NULL_REG 0x1A -/* Alarm 1 amplitude threshold */ +/* Alarm Register Definitions */ #define ADIS16209_ALM_MAG1_REG 0x20 - -/* Alarm 2 amplitude threshold */ #define ADIS16209_ALM_MAG2_REG 0x22 - -/* Alarm 1, sample period */ #define ADIS16209_ALM_SMPL1_REG 0x24 - -/* Alarm 2, sample period */ #define ADIS16209_ALM_SMPL2_REG 0x26 - -/* Alarm control */ #define ADIS16209_ALM_CTRL_REG 0x28 -/* Auxiliary DAC data */ #define ADIS16209_AUX_DAC_REG 0x30 - -/* General-purpose digital input/output control */ #define ADIS16209_GPIO_CTRL_REG 0x32 - -/* Miscellaneous control */ -#define ADIS16209_MSC_CTRL_REG 0x34 - -/* Internal sample period (rate) control */ #define ADIS16209_SMPL_PRD_REG 0x36 - -/* Operation, filter configuration */ #define ADIS16209_AVG_CNT_REG 0x38 - -/* Operation, sleep mode control */ #define ADIS16209_SLP_CNT_REG 0x3A -/* Diagnostics, system status register */ -#define ADIS16209_DIAG_STAT_REG 0x3C - -/* Operation, system command register */ -#define ADIS16209_GLOB_CMD_REG 0x3E - -/* MSC_CTRL */ - -/* Self-test at power-on: 1 = disabled, 0 = enabled */ -#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST BIT(10) - -/* Self-test enable */ -#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) - -/* Data-ready enable: 1 = enabled, 0 = disabled */ -#define ADIS16209_MSC_CTRL_DATA_RDY_EN BIT(2) - +#define ADIS16209_MSC_CTRL_REG 0x34 +#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST BIT(10) +#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) +#define ADIS16209_MSC_CTRL_DATA_RDY_EN BIT(2)/* Data-ready polarity: 1 = active high, 0 = active low */ -#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1) +#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1) +#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) -/* Data-ready line selection: 1 = DIO2, 0 = DIO1 */ -#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 BIT(9) - -/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16209_DIAG_STAT_ALARM1 BIT(8) - -/* Self-test diagnostic error flag: 1 = error condition, 0 = normal operation */ +#define ADIS16209_DIAG_STAT_REG 0x3C +#define ADIS16209_DIAG_STAT_ALARM2 BIT(9) +#define ADIS16209_DIAG_STAT_ALARM1 BIT(8)#define ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT 5 - -/* SPI communications failure */ #define ADIS16209_DIAG_STAT_SPI_FAIL_BIT 3 - -/* Flash update failure */ #define ADIS16209_DIAG_STAT_FLASH_UPT_BIT 2 -/* Power supply above 3.625 V */ #define ADIS16209_DIAG_STAT_POWER_HIGH_BIT 1 -/* Power supply below 3.15 V */ #define ADIS16209_DIAG_STAT_POWER_LOW_BIT 0 -/* GLOB_CMD */ - -#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_GLOB_CMD_REG 0x3E +#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 BIT(14) +#define ADIS16209_ERROR_ACTIVE BIT(14)enum adis16209_scan {ADIS16209_SCAN_SUPPLY ,@@ -226,24 +161,38 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, *val2 =610500 ;/* 0.6105 mV */ return IIO_VAL_INT_PLUS_MICRO ;case IIO_TEMP : - *val =-470 ;/* -0.47 C */ + *val =-470 ; *val2 =0 ;return IIO_VAL_INT_PLUS_MICRO ;case IIO_ACCEL : +/* +* IIO base unit for sensitivity of accelerometer +* is milli g. +* 1 LSB represents 0.244 mg. +*/ *val =0 ; - *val2 =IIO_G_TO_M_S_2 (244140 );/* 0.244140 mg */ + *val2 =IIO_G_TO_M_S_2 (244140 );return IIO_VAL_INT_PLUS_NANO ;case IIO_INCLI :case IIO_ROT : +/* +* IIO base units for rotation are degrees. +* 1 LSB represents 0.025 milli degrees. +*/ *val =0 ; - *val2 =25000 ;/* 0.025 degree */ + *val2 =25000 ;return IIO_VAL_INT_PLUS_MICRO ;
drivers/staging/iio/accel/adis16209.c static int adis16209_read_raw(struct iio_dev *indio_dev, · line 193
Quoted 10 lines
drivers/staging/iio/accel/adis16209.c +4
-1default :return -EINVAL ; }break ;case IIO_CHAN_INFO_OFFSET : - *val =25000 /-470 -0x4FE ;/* 25 C = 0x4FE */ +/* +* The raw ADC value is 0x4FE when the temperature +* is 45 degrees and the scale factor per milli +* degree celcius is -470.
Are you sure it is *45 degrees* and not *25 degrees* instead ?
As I can clearly see from the datasheet :
"sensitivity = −0.47°/LSB, 25°C = 1278 LSB = 0x04FE"
Please check it :)
I found this because I'm also doing a similar cleanup for adis16201.
Signature · 2 lines
Thanks Himanshu Jha
Re: [PATCH v3 1/4] Staging: iio: adis16209: Remove and add some comments and group the definitions
Quoted 231 lines · Himanshu Jha
Hi Shreeya,
Quoted 221 lines · Shreeya Patel
Remove some unnecessay comments and group the control register and register field macros together.
Some of the register names does not make it's puporse very clear and hence, add some comments for more information.
Also there are certain unit based comments which are not providing sufficient information, so expand those comments.Signed-off-by Shreeya Patel <[email protected]>---
Changes in v3
-This patch is the combination of two patches from the previous series. Also add some more comments.drivers/staging/iio/accel/adis16209.c | 132 ++++++++++----------
--------------1 file changed, 39 insertions(+), 93 deletions(-)drivers/staging/iio/accel/adis16209.c +0
-0@@ -21,135 +21,70 @@ #include <linux/iio/imu/adis.h>
#defineADIS16209_STARTUP_DELAY_MS220drivers/staging/iio/accel/adis16209.c +0
-2- -/* Flash memory write count */ #define
ADIS16209_FLASH_CNT_REG0x00drivers/staging/iio/accel/adis16209.c +1
-1-/* Output, power supply */ +/* Data Output Register Definitions */ #define
ADIS16209_SUPPLY_OUT_REG0x02drivers/staging/iio/accel/adis16209.c +0
-2- -/* Output, x-axis accelerometer */ #define
ADIS16209_XACCL_OUT_REG0x04drivers/staging/iio/accel/adis16209.c +0
-2- -/* Output, y-axis accelerometer */ #define
ADIS16209_YACCL_OUT_REG0x06
-
/* Output, auxiliary ADC input */
#defineADIS16209_AUX_ADC_REG0x08
-
/* Output, temperature */
#defineADIS16209_TEMP_OUT_REG0x0Adrivers/staging/iio/accel/adis16209.c +1
-2- -/* Output, x-axis inclination */ +/* Output, +/- 90 degrees X-axis inclination */ #define
ADIS16209_XINCL_OUT_REG0x0Cdrivers/staging/iio/accel/adis16209.c +0
-2- -/* Output, y-axis inclination */ #define
ADIS16209_YINCL_OUT_REG0x0E
-
/* Output, +/-180 vertical rotational position */
#defineADIS16209_ROT_OUT_REG0x10drivers/staging/iio/accel/adis16209.c +4
-1-/* Calibration, x-axis acceleration offset null */ +/* +* Calibration Register Definitions. +* Acceleration, inclination or rotation offset null. +*/ #define
ADIS16209_XACCL_NULL_REG0x12drivers/staging/iio/accel/adis16209.c +0
-2- -/* Calibration, y-axis acceleration offset null */ #define
ADIS16209_YACCL_NULL_REG0x14drivers/staging/iio/accel/adis16209.c +0
-2- -/* Calibration, x-axis inclination offset null */ #define
ADIS16209_XINCL_NULL_REG0x16drivers/staging/iio/accel/adis16209.c +0
-2- -/* Calibration, y-axis inclination offset null */ #define
ADIS16209_YINCL_NULL_REG0x18drivers/staging/iio/accel/adis16209.c +0
-2- -/* Calibration, vertical rotation offset null */ #define
ADIS16209_ROT_NULL_REG0x1Adrivers/staging/iio/accel/adis16209.c +1
-1-/* Alarm 1 amplitude threshold */ +/* Alarm Register Definitions */ #define
ADIS16209_ALM_MAG1_REG0x20drivers/staging/iio/accel/adis16209.c +0
-2- -/* Alarm 2 amplitude threshold */ #define
ADIS16209_ALM_MAG2_REG0x22drivers/staging/iio/accel/adis16209.c +0
-2- -/* Alarm 1, sample period */ #define
ADIS16209_ALM_SMPL1_REG0x24drivers/staging/iio/accel/adis16209.c +0
-2- -/* Alarm 2, sample period */ #define
ADIS16209_ALM_SMPL2_REG0x26drivers/staging/iio/accel/adis16209.c +0
-2- -/* Alarm control */ #define
ADIS16209_ALM_CTRL_REG0x28
-/* Auxiliary DAC data */
#defineADIS16209_AUX_DAC_REG0x30drivers/staging/iio/accel/adis16209.c +0
-2- -/* General-purpose digital input/output control */ #define
ADIS16209_GPIO_CTRL_REG0x32drivers/staging/iio/accel/adis16209.c +0
-5- -/* Miscellaneous control */ -#define ADIS16209_MSC_CTRL_REG 0x34 - -/* Internal sample period (rate) control */ #define
ADIS16209_SMPL_PRD_REG0x36drivers/staging/iio/accel/adis16209.c +0
-2- -/* Operation, filter configuration */ #define
ADIS16209_AVG_CNT_REG0x38drivers/staging/iio/accel/adis16209.c +0
-2- -/* Operation, sleep mode control */ #define
ADIS16209_SLP_CNT_REG0x3Adrivers/staging/iio/accel/adis16209.c +4
-17-/* Diagnostics, system status register */ -#define ADIS16209_DIAG_STAT_REG 0x3C - -/* Operation, system command register */ -#define ADIS16209_GLOB_CMD_REG 0x3E - -/* MSC_CTRL */ - -/* Self-test at power-on: 1 = disabled, 0 = enabled */ -#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST BIT(10) - -/* Self-test enable */ -#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) - -/* Data-ready enable: 1 = enabled, 0 = disabled */ -#define ADIS16209_MSC_CTRL_DATA_RDY_EN BIT(2) - +#define ADIS16209_MSC_CTRL_REG 0x34 +#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST BIT(10) +#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) +#define ADIS16209_MSC_CTRL_DATA_RDY_EN BIT(2)/* Data-ready polarity: 1 = active high, 0 = active low */
drivers/staging/iio/accel/adis16209.c +2
-1-#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1) +#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1) +#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0)drivers/staging/iio/accel/adis16209.c +0
-12-/* Data-ready line selection: 1 = DIO2, 0 = DIO1 */ -#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 BIT(9) - -/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16209_DIAG_STAT_ALARM1 BIT(8) - -/* Self-test diagnostic error flag: 1 = error condition, 0 = normal operation */
drivers/staging/iio/accel/adis16209.c +3
-0+#define ADIS16209_DIAG_STAT_REG 0x3C +#define ADIS16209_DIAG_STAT_ALARM2 BIT(9) +#define ADIS16209_DIAG_STAT_ALARM1 BIT(8)#define
ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT5drivers/staging/iio/accel/adis16209.c +0
-2- -/* SPI communications failure */ #define
ADIS16209_DIAG_STAT_SPI_FAIL_BIT3drivers/staging/iio/accel/adis16209.c +0
-2- -/* Flash update failure */ #define
ADIS16209_DIAG_STAT_FLASH_UPT_BIT2
-
/* Power supply above 3.625 V */
#defineADIS16209_DIAG_STAT_POWER_HIGH_BIT1
-
/* Power supply below 3.15 V */
#defineADIS16209_DIAG_STAT_POWER_LOW_BIT0drivers/staging/iio/accel/adis16209.c +4
-5-/* GLOB_CMD */ - -#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_GLOB_CMD_REG 0x3E +#define ADIS16209_GLOB_CMD_SW_RESET BIT(7) +#define ADIS16209_GLOB_CMD_CLEAR_STAT BIT(4) +#define ADIS16209_GLOB_CMD_FACTORY_CAL BIT(1)drivers/staging/iio/accel/adis16209.c +1
-1-#define ADIS16209_ERROR_ACTIVE BIT(14) +#define ADIS16209_ERROR_ACTIVE BIT(14)
enumadis16209_scan{
ADIS16209_SCAN_SUPPLY,drivers/staging/iio/accel/adis16209.c +0
-0@@ -226,24 +161,38 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, *val2 = 610500; /* 0.6105 mV */ return IIO_VAL_INT_PLUS_MICRO;case
IIO_TEMP:drivers/staging/iio/accel/adis16209.c +1
-1- *val =-470 ;/* -0.47 C */ + *val =-470 ;*val2 = 0;
returnIIO_VAL_INT_PLUS_MICRO; caseIIO_ACCEL:drivers/staging/iio/accel/adis16209.c +2
-0+/* +* IIO base unit for sensitivity of accelerometer
drivers/staging/iio/accel/adis16209.c +3
-0+* is milli g. +* 1 LSB represents 0.244 mg. +*/ *val = 0;
drivers/staging/iio/accel/adis16209.c +0
-1- *val2 =IIO_G_TO_M_S_2 (244140 );/* 0.244140 mg */
drivers/staging/iio/accel/adis16209.c +1
-0+ *val2 =IIO_G_TO_M_S_2 (244140 );return
IIO_VAL_INT_PLUS_NANO; caseIIO_INCLI:
caseIIO_ROT:drivers/staging/iio/accel/adis16209.c +2
-0+/* +* IIO base units for rotation are degrees.
drivers/staging/iio/accel/adis16209.c +2
-0+* 1 LSB represents 0.025 milli degrees. +*/ *val = 0;
drivers/staging/iio/accel/adis16209.c +1
-1- *val2 =25000 ;/* 0.025 degree */ + *val2 =25000 ;return
IIO_VAL_INT_PLUS_MICRO; default:
return-EINVAL;
}
break;
caseIIO_CHAN_INFO_OFFSET:drivers/staging/iio/accel/adis16209.c static int adis16209_read_raw(struct iio_dev *indio_dev, · line 193
Quoted 5 lines
drivers/staging/iio/accel/adis16209.c +4
-1- *val =25000 /-470 -0x4FE ;/* 25 C = 0x4FE */ +/* +* The raw ADC value is 0x4FE when the temperature +* is 45 degrees and the scale factor per milli +* degree celcius is -470. Are you sure it is *45 degrees* and not *25 degrees* instead ?
Quoted 7 lines
As I can clearly see from the datasheet :
"sensitivity = −0.47°/LSB, 25°C = 1278 LSB =
0x04FE"Please check it :)
I found this because I'm also doing a similar cleanup for adis16201.
Hi Himanshu,
Thanks for pointing this out :)
Yes it is 25 degrees.
I'll make the change after Jonathan's reviews on the other changes
Thank you
Quoted 1 line
Jonathan Cameron
maintainerRe: [PATCH v3 1/4] Staging: iio: adis16209: Remove and add some comments and group the definitions
Quoted 238 lines · On Sun, 04 Mar 2018 18:37:04 +0530 Shreeya Patel…
Quoted 237 lines · Himanshu Jha
Hi Shreeya,
Quoted 221 lines · Shreeya Patel
Remove some unnecessay comments and group the control register and register field macros together.
Some of the register names does not make it's puporse very clear and hence, add some comments for more information.
Also there are certain unit based comments which are not providing sufficient information, so expand those comments.Signed-off-by Shreeya Patel <[email protected]>---
Changes in v3
-This patch is the combination of two patches from the previous series. Also add some more comments.drivers/staging/iio/accel/adis16209.c | 132 ++++++++++----------
--------------1 file changed, 39 insertions(+), 93 deletions(-)drivers/staging/iio/accel/adis16209.c +0
-0@@ -21,135 +21,70 @@ #include <linux/iio/imu/adis.h>
#defineADIS16209_STARTUP_DELAY_MS220drivers/staging/iio/accel/adis16209.c +0
-2- -/* Flash memory write count */ #define
ADIS16209_FLASH_CNT_REG0x00drivers/staging/iio/accel/adis16209.c +1
-1-/* Output, power supply */ +/* Data Output Register Definitions */ #define
ADIS16209_SUPPLY_OUT_REG0x02drivers/staging/iio/accel/adis16209.c +0
-2- -/* Output, x-axis accelerometer */ #define
ADIS16209_XACCL_OUT_REG0x04drivers/staging/iio/accel/adis16209.c +0
-2- -/* Output, y-axis accelerometer */ #define
ADIS16209_YACCL_OUT_REG0x06
-
/* Output, auxiliary ADC input */
#defineADIS16209_AUX_ADC_REG0x08
-
/* Output, temperature */
#defineADIS16209_TEMP_OUT_REG0x0Adrivers/staging/iio/accel/adis16209.c +1
-2- -/* Output, x-axis inclination */ +/* Output, +/- 90 degrees X-axis inclination */ #define
ADIS16209_XINCL_OUT_REG0x0Cdrivers/staging/iio/accel/adis16209.c +0
-2- -/* Output, y-axis inclination */ #define
ADIS16209_YINCL_OUT_REG0x0E
-
/* Output, +/-180 vertical rotational position */
#defineADIS16209_ROT_OUT_REG0x10drivers/staging/iio/accel/adis16209.c +4
-1-/* Calibration, x-axis acceleration offset null */ +/* +* Calibration Register Definitions. +* Acceleration, inclination or rotation offset null. +*/ #define
ADIS16209_XACCL_NULL_REG0x12drivers/staging/iio/accel/adis16209.c +0
-2- -/* Calibration, y-axis acceleration offset null */ #define
ADIS16209_YACCL_NULL_REG0x14drivers/staging/iio/accel/adis16209.c +0
-2- -/* Calibration, x-axis inclination offset null */ #define
ADIS16209_XINCL_NULL_REG0x16drivers/staging/iio/accel/adis16209.c +0
-2- -/* Calibration, y-axis inclination offset null */ #define
ADIS16209_YINCL_NULL_REG0x18drivers/staging/iio/accel/adis16209.c +0
-2- -/* Calibration, vertical rotation offset null */ #define
ADIS16209_ROT_NULL_REG0x1Adrivers/staging/iio/accel/adis16209.c +1
-1-/* Alarm 1 amplitude threshold */ +/* Alarm Register Definitions */ #define
ADIS16209_ALM_MAG1_REG0x20drivers/staging/iio/accel/adis16209.c +0
-2- -/* Alarm 2 amplitude threshold */ #define
ADIS16209_ALM_MAG2_REG0x22drivers/staging/iio/accel/adis16209.c +0
-2- -/* Alarm 1, sample period */ #define
ADIS16209_ALM_SMPL1_REG0x24drivers/staging/iio/accel/adis16209.c +0
-2- -/* Alarm 2, sample period */ #define
ADIS16209_ALM_SMPL2_REG0x26drivers/staging/iio/accel/adis16209.c +0
-2- -/* Alarm control */ #define
ADIS16209_ALM_CTRL_REG0x28
-/* Auxiliary DAC data */
#defineADIS16209_AUX_DAC_REG0x30drivers/staging/iio/accel/adis16209.c +0
-2- -/* General-purpose digital input/output control */ #define
ADIS16209_GPIO_CTRL_REG0x32drivers/staging/iio/accel/adis16209.c +0
-5- -/* Miscellaneous control */ -#define ADIS16209_MSC_CTRL_REG 0x34 - -/* Internal sample period (rate) control */ #define
ADIS16209_SMPL_PRD_REG0x36drivers/staging/iio/accel/adis16209.c +0
-2- -/* Operation, filter configuration */ #define
ADIS16209_AVG_CNT_REG0x38drivers/staging/iio/accel/adis16209.c +0
-2- -/* Operation, sleep mode control */ #define
ADIS16209_SLP_CNT_REG0x3Adrivers/staging/iio/accel/adis16209.c +4
-17-/* Diagnostics, system status register */ -#define ADIS16209_DIAG_STAT_REG 0x3C - -/* Operation, system command register */ -#define ADIS16209_GLOB_CMD_REG 0x3E - -/* MSC_CTRL */ - -/* Self-test at power-on: 1 = disabled, 0 = enabled */ -#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST BIT(10) - -/* Self-test enable */ -#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) - -/* Data-ready enable: 1 = enabled, 0 = disabled */ -#define ADIS16209_MSC_CTRL_DATA_RDY_EN BIT(2) - +#define ADIS16209_MSC_CTRL_REG 0x34 +#define ADIS16209_MSC_CTRL_PWRUP_SELF_TEST BIT(10) +#define ADIS16209_MSC_CTRL_SELF_TEST_EN BIT(8) +#define ADIS16209_MSC_CTRL_DATA_RDY_EN BIT(2)/* Data-ready polarity: 1 = active high, 0 = active low */
drivers/staging/iio/accel/adis16209.c +2
-1-#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1) +#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1) +#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0)drivers/staging/iio/accel/adis16209.c +0
-12-/* Data-ready line selection: 1 = DIO2, 0 = DIO1 */ -#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 BIT(9) - -/* Alarm 1 status: 1 = alarm active, 0 = alarm inactive */ -#define ADIS16209_DIAG_STAT_ALARM1 BIT(8) - -/* Self-test diagnostic error flag: 1 = error condition, 0 = normal operation */
drivers/staging/iio/accel/adis16209.c +3
-0+#define ADIS16209_DIAG_STAT_REG 0x3C +#define ADIS16209_DIAG_STAT_ALARM2 BIT(9) +#define ADIS16209_DIAG_STAT_ALARM1 BIT(8)#define
ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT5drivers/staging/iio/accel/adis16209.c +0
-2- -/* SPI communications failure */ #define
ADIS16209_DIAG_STAT_SPI_FAIL_BIT3drivers/staging/iio/accel/adis16209.c +0
-2- -/* Flash update failure */ #define
ADIS16209_DIAG_STAT_FLASH_UPT_BIT2
-
/* Power supply above 3.625 V */
#defineADIS16209_DIAG_STAT_POWER_HIGH_BIT1
-
/* Power supply below 3.15 V */
#defineADIS16209_DIAG_STAT_POWER_LOW_BIT0drivers/staging/iio/accel/adis16209.c +4
-5-/* GLOB_CMD */ - -#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_GLOB_CMD_REG 0x3E +#define ADIS16209_GLOB_CMD_SW_RESET BIT(7) +#define ADIS16209_GLOB_CMD_CLEAR_STAT BIT(4) +#define ADIS16209_GLOB_CMD_FACTORY_CAL BIT(1)drivers/staging/iio/accel/adis16209.c +1
-1-#define ADIS16209_ERROR_ACTIVE BIT(14) +#define ADIS16209_ERROR_ACTIVE BIT(14)
enumadis16209_scan{
ADIS16209_SCAN_SUPPLY,drivers/staging/iio/accel/adis16209.c +0
-0@@ -226,24 +161,38 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, *val2 = 610500; /* 0.6105 mV */ return IIO_VAL_INT_PLUS_MICRO;case
IIO_TEMP:drivers/staging/iio/accel/adis16209.c +1
-1- *val =-470 ;/* -0.47 C */ + *val =-470 ;*val2 = 0;
returnIIO_VAL_INT_PLUS_MICRO; caseIIO_ACCEL:drivers/staging/iio/accel/adis16209.c +2
-0+/* +* IIO base unit for sensitivity of accelerometer
drivers/staging/iio/accel/adis16209.c +3
-0+* is milli g. +* 1 LSB represents 0.244 mg. +*/ *val = 0;
drivers/staging/iio/accel/adis16209.c +0
-1- *val2 =IIO_G_TO_M_S_2 (244140 );/* 0.244140 mg */
drivers/staging/iio/accel/adis16209.c +1
-0+ *val2 =IIO_G_TO_M_S_2 (244140 );return
IIO_VAL_INT_PLUS_NANO; caseIIO_INCLI:
caseIIO_ROT:drivers/staging/iio/accel/adis16209.c +2
-0+/* +* IIO base units for rotation are degrees.
drivers/staging/iio/accel/adis16209.c +2
-0+* 1 LSB represents 0.025 milli degrees. +*/ *val = 0;
drivers/staging/iio/accel/adis16209.c +1
-1- *val2 =25000 ;/* 0.025 degree */ + *val2 =25000 ;return
IIO_VAL_INT_PLUS_MICRO; default:
return-EINVAL;
}
break;
caseIIO_CHAN_INFO_OFFSET:drivers/staging/iio/accel/adis16209.c static int adis16209_read_raw(struct iio_dev *indio_dev, · line 193
Quoted 5 lines
drivers/staging/iio/accel/adis16209.c +4
-1- *val =25000 /-470 -0x4FE ;/* 25 C = 0x4FE */ +/* +* The raw ADC value is 0x4FE when the temperature +* is 45 degrees and the scale factor per milli +* degree celcius is -470. Are you sure it is *45 degrees* and not *25 degrees* instead ?
As I can clearly see from the datasheet :
"sensitivity = −0.47°/LSB, 25°C = 1278 LSB =
0x04FE"Please check it :)
Quoted 8 lines
Quoted 1 line
I found this because I'm also doing a similar cleanup for adis16201.
Hi Himanshu,
Thanks for pointing this out :)
Yes it is 25 degrees.I'll make the change after Jonathan's reviews on the other changes
Good catch - I would probably have missed that.
Anyhow the rest of the patch looked good to me so I've applied it to the togreg branch of iio.git (fixed up) and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 4 lines
Thank you
Quoted 1 line
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Jonathan Cameron
maintainerRe: [PATCH v3 2/4] Staging: iio: adis16209: Change some macro names
In reply to Shreeya PatelQuoted 4 lines · On Sun, 4 Mar 2018 18:11:17 +0530 Shreeya Patel…
Make some of the macro names according to the names given in the datasheet of the adis16209 driver.
Signed-off-by Shreeya Patel <[email protected]>
A small comment inline which we should clear up in a follow up patch.
Quoted 18 lines
---
Changes in v3
-Introduce this new patch for v3 of the series.drivers/staging/iio/accel/adis16209.c | 48 +++++++++++++++++------------------ 1 file changed, 24 insertions(+), 24 deletions(-)drivers/staging/iio/accel/adis16209.c +0
-2@@ -68,21 +68,21 @@#define ADIS16209_MSC_CTRL_ACTIVE_HIGH BIT(1)#define ADIS16209_MSC_CTRL_DATA_RDY_DIO2 BIT(0) -#define ADIS16209_DIAG_STAT_REG 0x3C -#define ADIS16209_DIAG_STAT_ALARM2 BIT(9)
drivers/staging/iio/accel/adis16209.c line 76
Quoted 10 lines
drivers/staging/iio/accel/adis16209.c +6
-4-#define ADIS16209_DIAG_STAT_ALARM1 BIT(8) -#define ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT 5 -#define ADIS16209_DIAG_STAT_SPI_FAIL_BIT 3 -#define ADIS16209_DIAG_STAT_FLASH_UPT_BIT 2 +#define ADIS16209_STAT_REG 0x3C +#define ADIS16209_STAT_ALARM2 BIT(9) +#define ADIS16209_STAT_ALARM1 BIT(8) +#define ADIS16209_STAT_SELFTEST_FAIL_BIT 5 +#define ADIS16209_STAT_SPI_FAIL_BIT 3 +#define ADIS16209_STAT_FLASH_UPT_FAIL_BIT 2
Given these are also fields of the STAT_REG, be it defined in a different fashion I think they should also have the small additional indent.
Quoted 50 lines
drivers/staging/iio/accel/adis16209.c +13
-16/* Power supply above 3.625 V */ -#define ADIS16209_DIAG_STAT_POWER_HIGH_BIT 1 +#define ADIS16209_STAT_POWER_HIGH_BIT 1/* Power supply below 3.15 V */ -#define ADIS16209_DIAG_STAT_POWER_LOW_BIT 0 +#define ADIS16209_STAT_POWER_LOW_BIT 0 -#define ADIS16209_GLOB_CMD_REG 0x3E -#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_CMD_REG 0x3E +#define ADIS16209_CMD_SW_RESET BIT(7) +#define ADIS16209_CMD_CLEAR_STAT BIT(4) +#define ADIS16209_CMD_FACTORY_CAL BIT(1)#define ADIS16209_ERROR_ACTIVE BIT(14)@@ -238,29 +238,29 @@ static const struct iio_info adis16209_info = { };static const char *const adis16209_status_error_msgs[] = { - [ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT ] ="Self test failure" , - [ADIS16209_DIAG_STAT_SPI_FAIL_BIT ] ="SPI failure" , - [ADIS16209_DIAG_STAT_FLASH_UPT_BIT ] ="Flash update failed" , - [ADIS16209_DIAG_STAT_POWER_HIGH_BIT ] ="Power supply above 3.625V" , - [ADIS16209_DIAG_STAT_POWER_LOW_BIT ] ="Power supply below 3.15V" , + [ADIS16209_STAT_SELFTEST_FAIL_BIT ] ="Self test failure" , + [ADIS16209_STAT_SPI_FAIL_BIT ] ="SPI failure" , + [ADIS16209_STAT_FLASH_UPT_FAIL_BIT ] ="Flash update failed" , + [ADIS16209_STAT_POWER_HIGH_BIT ] ="Power supply above 3.625V" , + [ADIS16209_STAT_POWER_LOW_BIT ] ="Power supply below 3.15V" , };static const struct adis_data adis16209_data = { .read_delay =30 , .msc_ctrl_reg =ADIS16209_MSC_CTRL_REG , - .glob_cmd_reg =ADIS16209_GLOB_CMD_REG , - .diag_stat_reg =ADIS16209_DIAG_STAT_REG , + .glob_cmd_reg =ADIS16209_CMD_REG , + .diag_stat_reg =ADIS16209_STAT_REG , .self_test_mask =ADIS16209_MSC_CTRL_SELF_TEST_EN , .self_test_no_autoclear = true, .startup_delay =ADIS16209_STARTUP_DELAY_MS , .status_error_msgs = adis16209_status_error_msgs, - .status_error_mask =BIT (ADIS16209_DIAG_STAT_SELFTEST_FAIL_BIT ) | -BIT (ADIS16209_DIAG_STAT_SPI_FAIL_BIT ) | - BIT(ADIS16209_DIAG_STAT_FLASH_UPT_BIT) |
drivers/staging/iio/accel/adis16209.c static const struct iio_info adis16209_info = { · line 266
Quoted 10 lines
drivers/staging/iio/accel/adis16209.c +5
-2-BIT (ADIS16209_DIAG_STAT_POWER_HIGH_BIT ) | - BIT(ADIS16209_DIAG_STAT_POWER_LOW_BIT), + .status_error_mask = BIT(ADIS16209_STAT_SELFTEST_FAIL_BIT) | +BIT (ADIS16209_STAT_SPI_FAIL_BIT ) | +BIT (ADIS16209_STAT_FLASH_UPT_FAIL_BIT ) | +BIT (ADIS16209_STAT_POWER_HIGH_BIT ) | + BIT(ADIS16209_STAT_POWER_LOW_BIT), };static int adis16209_probe (struct spi_device *spi)
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Jonathan Cameron
maintainerRe: [PATCH v3 3/4] Staging: iio: adis16209: Adjust a switch statement
In reply to Shreeya PatelQuoted 5 lines · On Sun, 4 Mar 2018 18:13:12 +0530 Shreeya Patel…
Adjust a switch block to explicitly match channels and return
-EINVALas default case which makes the code semantically more clear.Signed-off-by Shreeya Patel <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan.
Quoted 21 lines
---
Changes in v3
-After split patch.drivers/staging/iio/accel/adis16209.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/staging/iio/accel/adis16209.c +2
-2@@ -155,10 +155,16 @@ static int adis16209_read_raw(struct iio_dev *indio_dev,switch (chan->type) {case IIO_VOLTAGE : *val =0 ; -if (chan->channel ==0 ) +switch (chan->channel) { +case 0 : *val2 =305180 ;/* 0.30518 mV */ -else
drivers/staging/iio/accel/adis16209.c static int adis16209_read_raw(struct iio_dev *indio_dev, · line 170
Quoted 10 lines
drivers/staging/iio/accel/adis16209.c +6
-0+break ; +case 1 : *val2 =610500 ;/* 0.6105 mV */ +break ; +default : +return -EINVAL ; + }return IIO_VAL_INT_PLUS_MICRO ;case IIO_TEMP : *val =-470 ;
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Jonathan Cameron
maintainerRe: [PATCH v3 4/4] Staging: iio: adis16209: Use sign_extend32 function
In reply to Shreeya PatelQuoted 4 lines · On Sun, 4 Mar 2018 18:15:06 +0530 Shreeya Patel…
Use
sign_extend32function instead of manually coding it.Signed-off-by Shreeya Patel <[email protected]>
Applied to the togreg branch of iio.git and pushed out as testing for the autobuilders to play with it.
Thanks,
Jonathan
Quoted 14 lines
---
Changes in v3
-After split patch.drivers/staging/iio/accel/adis16209.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)drivers/staging/iio/accel/adis16209.c +0
-0@@ -212,9 +212,8 @@ static int adis16209_read_raw(struct iio_dev *indio_dev, ret =adis_read_reg_16 (st, addr, &val16);
drivers/staging/iio/accel/adis16209.c static int adis16209_read_raw(struct iio_dev *indio_dev, · line 219
Quoted 10 lines
drivers/staging/iio/accel/adis16209.c +2
-3if (ret)return ret; - val16 &= (1 << bits) -1 ; - val16 = (s16)(val16 << (16 - bits)) >> (16 - bits); - *val = val16; + + *val =sign_extend32 (val16, bits -1 );return IIO_VAL_INT ; }return -EINVAL ;
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel