* [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2
@ 2013-01-16 12:48 Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 02/15] staging:iio:adis16400: Fix and cleanup 3db filter setting Lars-Peter Clausen
` (14 more replies)
0 siblings, 15 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
ilog2 is not defined for 0, so we need to handle the case where the requested
frequency is larger than the base sampling rate. In this case we'll round down
and set the sampling rate to the base sampling rate.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/imu/adis16400_core.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index 9c8f5ab..cb66225 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -178,7 +178,11 @@ static int adis16334_set_freq(struct iio_dev *indio_dev, unsigned int freq)
{
unsigned int t;
- t = ilog2(8192 / (freq * 10));
+ freq *= 10;
+ if (freq < 8192)
+ t = ilog2(8192 / freq);
+ else
+ t = 0;
if (t > 0x31)
t = 0x31;
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 02/15] staging:iio:adis16400: Fix and cleanup 3db filter setting
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 03/15] staging:iio:adis16400: Remove unused default_scan_mask Lars-Peter Clausen
` (13 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
The 3db divisors table is partially wrong and incomplete. Also the code rounds
up to the next higher frequency if the requested frequency would matches one of
the available frequencies. These two issues are fixed by this patch. The patch
also changes the driver to round down the filter frequency if it is larger than
the largest supported frequency instead of rejecting it as an invalid value.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/imu/adis16400_core.c | 41 ++++++++++++++++----------------
1 file changed, 20 insertions(+), 21 deletions(-)
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index cb66225..7114de9 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -242,33 +242,32 @@ static ssize_t adis16400_read_frequency(struct device *dev,
static const unsigned adis16400_3db_divisors[] = {
[0] = 2, /* Special case */
- [1] = 5,
- [2] = 10,
- [3] = 50,
- [4] = 200,
+ [1] = 6,
+ [2] = 12,
+ [3] = 25,
+ [4] = 50,
+ [5] = 100,
+ [6] = 200,
+ [7] = 200, /* Not a valid setting */
};
static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int val)
{
int i, ret;
u16 val16;
- for (i = ARRAY_SIZE(adis16400_3db_divisors) - 1; i >= 0; i--)
- if (sps/adis16400_3db_divisors[i] > val)
+
+ for (i = ARRAY_SIZE(adis16400_3db_divisors) - 1; i >= 1; i--) {
+ if (sps / adis16400_3db_divisors[i] >= val)
break;
- if (i == -1)
- ret = -EINVAL;
- else {
- ret = adis16400_spi_read_reg_16(indio_dev,
- ADIS16400_SENS_AVG,
+ }
+
+ ret = adis16400_spi_read_reg_16(indio_dev, ADIS16400_SENS_AVG,
&val16);
- if (ret < 0)
- goto error_ret;
+ if (ret < 0)
+ return ret;
- ret = adis16400_spi_write_reg_16(indio_dev,
- ADIS16400_SENS_AVG,
- (val16 & ~0x03) | i);
- }
-error_ret:
+ ret = adis16400_spi_write_reg_16(indio_dev, ADIS16400_SENS_AVG,
+ (val16 & ~0x07) | i);
return ret;
}
@@ -653,9 +652,9 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
mutex_unlock(&indio_dev->mlock);
return ret;
}
- val16 = st->variant->get_freq(indio_dev);
- if (ret > 0)
- *val = ret/adis16400_3db_divisors[val16 & 0x03];
+ ret = st->variant->get_freq(indio_dev);
+ if (ret >= 0)
+ *val = ret / adis16400_3db_divisors[val16 & 0x07];
*val2 = 0;
mutex_unlock(&indio_dev->mlock);
if (ret < 0)
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 03/15] staging:iio:adis16400: Remove unused default_scan_mask
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 02/15] staging:iio:adis16400: Fix and cleanup 3db filter setting Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 04/15] staging:iio:adis16400: Use adis library Lars-Peter Clausen
` (12 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
The chip_info struct for contains a defaul_scan_mask field. But it is never
actually used in the code, so remove it from the chip_info struct.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/imu/adis16400.h | 1 -
drivers/staging/iio/imu/adis16400_core.c | 15 ---------------
2 files changed, 16 deletions(-)
diff --git a/drivers/staging/iio/imu/adis16400.h b/drivers/staging/iio/imu/adis16400.h
index 7a105e9..3efafcb 100644
--- a/drivers/staging/iio/imu/adis16400.h
+++ b/drivers/staging/iio/imu/adis16400.h
@@ -145,7 +145,6 @@ struct adis16400_chip_info {
unsigned int accel_scale_micro;
int temp_scale_nano;
int temp_offset;
- unsigned long default_scan_mask;
int (*set_freq)(struct iio_dev *indio_dev, unsigned int freq);
int (*get_freq)(struct iio_dev *indio_dev);
};
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index 7114de9..24fca10 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -1116,12 +1116,6 @@ static struct adis16400_chip_info adis16400_chips[] = {
.accel_scale_micro = 5884,
.temp_scale_nano = 140000000, /* 0.14 C */
.temp_offset = 25000000 / 140000, /* 25 C = 0x00 */
- .default_scan_mask = (1 << ADIS16400_SCAN_SUPPLY) |
- (1 << ADIS16400_SCAN_GYRO_X) | (1 << ADIS16400_SCAN_ACC_X) |
- (1 << ADIS16400_SCAN_ACC_Y) | (1 << ADIS16400_SCAN_ACC_Z) |
- (1 << ADIS16400_SCAN_TEMP) | (1 << ADIS16400_SCAN_ADC_0) |
- (1 << ADIS16300_SCAN_INCLI_X) | (1 << ADIS16300_SCAN_INCLI_Y) |
- (1 << 14),
.set_freq = adis16400_set_freq,
.get_freq = adis16400_get_freq,
},
@@ -1133,10 +1127,6 @@ static struct adis16400_chip_info adis16400_chips[] = {
.accel_scale_micro = IIO_G_TO_M_S_2(1000), /* 1 mg */
.temp_scale_nano = 67850000, /* 0.06785 C */
.temp_offset = 25000000 / 67850, /* 25 C = 0x00 */
- .default_scan_mask = (1 << ADIS16400_SCAN_GYRO_X) |
- (1 << ADIS16400_SCAN_GYRO_Y) | (1 << ADIS16400_SCAN_GYRO_Z) |
- (1 << ADIS16400_SCAN_ACC_X) | (1 << ADIS16400_SCAN_ACC_Y) |
- (1 << ADIS16400_SCAN_ACC_Z),
.set_freq = adis16334_set_freq,
.get_freq = adis16334_get_freq,
},
@@ -1147,7 +1137,6 @@ static struct adis16400_chip_info adis16400_chips[] = {
.accel_scale_micro = IIO_G_TO_M_S_2(2522), /* 0.002522 g */
.temp_scale_nano = 145300000, /* 0.1453 C */
.temp_offset = 25000000 / 145300, /* 25 C = 0x00 */
- .default_scan_mask = 0x7FF,
.flags = ADIS16400_NO_BURST | ADIS16400_HAS_SLOW_MODE,
.set_freq = adis16400_set_freq,
.get_freq = adis16400_get_freq,
@@ -1160,7 +1149,6 @@ static struct adis16400_chip_info adis16400_chips[] = {
.accel_scale_micro = IIO_G_TO_M_S_2(3333), /* 3.333 mg */
.temp_scale_nano = 136000000, /* 0.136 C */
.temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
- .default_scan_mask = 0x7FF,
.set_freq = adis16400_set_freq,
.get_freq = adis16400_get_freq,
},
@@ -1172,7 +1160,6 @@ static struct adis16400_chip_info adis16400_chips[] = {
.accel_scale_micro = IIO_G_TO_M_S_2(333), /* 0.333 mg */
.temp_scale_nano = 136000000, /* 0.136 C */
.temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
- .default_scan_mask = 0x7FF,
.set_freq = adis16400_set_freq,
.get_freq = adis16400_get_freq,
},
@@ -1184,7 +1171,6 @@ static struct adis16400_chip_info adis16400_chips[] = {
.accel_scale_micro = IIO_G_TO_M_S_2(1000), /* 1 mg */
.temp_scale_nano = 136000000, /* 0.136 C */
.temp_offset = 25000000 / 136000, /* 25 C = 0x00 */
- .default_scan_mask = 0x7FF,
.set_freq = adis16400_set_freq,
.get_freq = adis16400_get_freq,
},
@@ -1194,7 +1180,6 @@ static struct adis16400_chip_info adis16400_chips[] = {
.flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE,
.gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
.accel_scale_micro = IIO_G_TO_M_S_2(3333), /* 3.333 mg */
- .default_scan_mask = 0xFFF,
.temp_scale_nano = 140000000, /* 0.14 C */
.temp_offset = 25000000 / 140000, /* 25 C = 0x00 */
.set_freq = adis16400_set_freq,
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 04/15] staging:iio:adis16400: Use adis library
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 02/15] staging:iio:adis16400: Fix and cleanup 3db filter setting Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 03/15] staging:iio:adis16400: Remove unused default_scan_mask Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 05/15] staging:iio:adis16400: Use triggered buffer setup helper function Lars-Peter Clausen
` (11 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Use the new adis library for the adis16400 driver. This allows us to completely
scrap the adis16400 trigger code and more than half of the core driver code. For
now we can not make use of the generic adis buffer implementation since the
adis16400 driver has special requirements due to its burst mode support. But
we will eventually get to this.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/imu/Kconfig | 4 +-
drivers/staging/iio/imu/Makefile | 2 +-
drivers/staging/iio/imu/adis16400.h | 109 +++---
drivers/staging/iio/imu/adis16400_core.c | 535 ++++++++--------------------
drivers/staging/iio/imu/adis16400_ring.c | 59 +--
drivers/staging/iio/imu/adis16400_trigger.c | 74 ----
6 files changed, 225 insertions(+), 558 deletions(-)
delete mode 100644 drivers/staging/iio/imu/adis16400_trigger.c
diff --git a/drivers/staging/iio/imu/Kconfig b/drivers/staging/iio/imu/Kconfig
index 2c2f47d..096afc8 100644
--- a/drivers/staging/iio/imu/Kconfig
+++ b/drivers/staging/iio/imu/Kconfig
@@ -6,8 +6,8 @@ menu "Inertial measurement units"
config ADIS16400
tristate "Analog Devices ADIS16400 and similar IMU SPI driver"
depends on SPI
- select IIO_SW_RING if IIO_BUFFER
- select IIO_TRIGGER if IIO_BUFFER
+ select IIO_ADIS_LIB
+ select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
help
Say yes here to build support for Analog Devices adis16300, adis16344,
adis16350, adis16354, adis16355, adis16360, adis16362, adis16364,
diff --git a/drivers/staging/iio/imu/Makefile b/drivers/staging/iio/imu/Makefile
index 3400a13..c9988f6 100644
--- a/drivers/staging/iio/imu/Makefile
+++ b/drivers/staging/iio/imu/Makefile
@@ -3,5 +3,5 @@
#
adis16400-y := adis16400_core.o
-adis16400-$(CONFIG_IIO_BUFFER) += adis16400_ring.o adis16400_trigger.o
+adis16400-$(CONFIG_IIO_BUFFER) += adis16400_ring.o
obj-$(CONFIG_ADIS16400) += adis16400.o
diff --git a/drivers/staging/iio/imu/adis16400.h b/drivers/staging/iio/imu/adis16400.h
index 3efafcb..ce63ced 100644
--- a/drivers/staging/iio/imu/adis16400.h
+++ b/drivers/staging/iio/imu/adis16400.h
@@ -17,12 +17,11 @@
#ifndef SPI_ADIS16400_H_
#define SPI_ADIS16400_H_
+#include <linux/iio/imu/adis.h>
+
#define ADIS16400_STARTUP_DELAY 290 /* ms */
#define ADIS16400_MTEST_DELAY 90 /* ms */
-#define ADIS16400_READ_REG(a) a
-#define ADIS16400_WRITE_REG(a) ((a) | 0x80)
-
#define ADIS16400_FLASH_CNT 0x00 /* Flash memory write count */
#define ADIS16400_SUPPLY_OUT 0x02 /* Power supply measurement */
#define ADIS16400_XGYRO_OUT 0x04 /* X-axis gyroscope output */
@@ -96,21 +95,21 @@
#define ADIS16400_SMPL_PRD_DIV_MASK 0x7F
/* DIAG_STAT */
-#define ADIS16400_DIAG_STAT_ZACCL_FAIL (1<<15)
-#define ADIS16400_DIAG_STAT_YACCL_FAIL (1<<14)
-#define ADIS16400_DIAG_STAT_XACCL_FAIL (1<<13)
-#define ADIS16400_DIAG_STAT_XGYRO_FAIL (1<<12)
-#define ADIS16400_DIAG_STAT_YGYRO_FAIL (1<<11)
-#define ADIS16400_DIAG_STAT_ZGYRO_FAIL (1<<10)
-#define ADIS16400_DIAG_STAT_ALARM2 (1<<9)
-#define ADIS16400_DIAG_STAT_ALARM1 (1<<8)
-#define ADIS16400_DIAG_STAT_FLASH_CHK (1<<6)
-#define ADIS16400_DIAG_STAT_SELF_TEST (1<<5)
-#define ADIS16400_DIAG_STAT_OVERFLOW (1<<4)
-#define ADIS16400_DIAG_STAT_SPI_FAIL (1<<3)
-#define ADIS16400_DIAG_STAT_FLASH_UPT (1<<2)
-#define ADIS16400_DIAG_STAT_POWER_HIGH (1<<1)
-#define ADIS16400_DIAG_STAT_POWER_LOW (1<<0)
+#define ADIS16400_DIAG_STAT_ZACCL_FAIL 15
+#define ADIS16400_DIAG_STAT_YACCL_FAIL 14
+#define ADIS16400_DIAG_STAT_XACCL_FAIL 13
+#define ADIS16400_DIAG_STAT_XGYRO_FAIL 12
+#define ADIS16400_DIAG_STAT_YGYRO_FAIL 11
+#define ADIS16400_DIAG_STAT_ZGYRO_FAIL 10
+#define ADIS16400_DIAG_STAT_ALARM2 9
+#define ADIS16400_DIAG_STAT_ALARM1 8
+#define ADIS16400_DIAG_STAT_FLASH_CHK 6
+#define ADIS16400_DIAG_STAT_SELF_TEST 5
+#define ADIS16400_DIAG_STAT_OVERFLOW 4
+#define ADIS16400_DIAG_STAT_SPI_FAIL 3
+#define ADIS16400_DIAG_STAT_FLASH_UPT 2
+#define ADIS16400_DIAG_STAT_POWER_HIGH 1
+#define ADIS16400_DIAG_STAT_POWER_LOW 0
/* GLOB_CMD */
#define ADIS16400_GLOB_CMD_SW_RESET (1<<7)
@@ -126,9 +125,6 @@
#define ADIS16334_RATE_DIV_SHIFT 8
#define ADIS16334_RATE_INT_CLK BIT(0)
-#define ADIS16400_MAX_TX 24
-#define ADIS16400_MAX_RX 24
-
#define ADIS16400_SPI_SLOW (u32)(300 * 1000)
#define ADIS16400_SPI_BURST (u32)(1000 * 1000)
#define ADIS16400_SPI_FAST (u32)(2000 * 1000)
@@ -137,6 +133,8 @@
#define ADIS16400_NO_BURST BIT(1)
#define ADIS16400_HAS_SLOW_MODE BIT(2)
+struct adis16400_state;
+
struct adis16400_chip_info {
const struct iio_chan_spec *channels;
const int num_channels;
@@ -145,58 +143,47 @@ struct adis16400_chip_info {
unsigned int accel_scale_micro;
int temp_scale_nano;
int temp_offset;
- int (*set_freq)(struct iio_dev *indio_dev, unsigned int freq);
- int (*get_freq)(struct iio_dev *indio_dev);
+ int (*set_freq)(struct adis16400_state *st, unsigned int freq);
+ int (*get_freq)(struct adis16400_state *st);
};
/**
* struct adis16400_state - device instance specific data
- * @us: actual spi_device
- * @trig: data ready trigger registered with iio
- * @tx: transmit buffer
- * @rx: receive buffer
- * @buf_lock: mutex to protect tx and rx
- * @filt_int: integer part of requested filter frequency
+ * @variant: chip variant info
+ * @filt_int: integer part of requested filter frequency
+ * @adis: adis device
**/
struct adis16400_state {
- struct spi_device *us;
- struct iio_trigger *trig;
- struct mutex buf_lock;
struct adis16400_chip_info *variant;
int filt_int;
- u8 tx[ADIS16400_MAX_TX] ____cacheline_aligned;
- u8 rx[ADIS16400_MAX_RX] ____cacheline_aligned;
+ struct adis adis;
};
-int adis16400_set_irq(struct iio_dev *indio_dev, bool enable);
-
/* At the moment triggers are only used for ring buffer
* filling. This may change!
*/
-#define ADIS16400_SCAN_SUPPLY 0
-#define ADIS16400_SCAN_GYRO_X 1
-#define ADIS16400_SCAN_GYRO_Y 2
-#define ADIS16400_SCAN_GYRO_Z 3
-#define ADIS16400_SCAN_ACC_X 4
-#define ADIS16400_SCAN_ACC_Y 5
-#define ADIS16400_SCAN_ACC_Z 6
-#define ADIS16400_SCAN_MAGN_X 7
-#define ADIS16350_SCAN_TEMP_X 7
-#define ADIS16400_SCAN_MAGN_Y 8
-#define ADIS16350_SCAN_TEMP_Y 8
-#define ADIS16400_SCAN_MAGN_Z 9
-#define ADIS16350_SCAN_TEMP_Z 9
-#define ADIS16400_SCAN_TEMP 10
-#define ADIS16350_SCAN_ADC_0 10
-#define ADIS16400_SCAN_ADC_0 11
-#define ADIS16300_SCAN_INCLI_X 12
-#define ADIS16300_SCAN_INCLI_Y 13
+enum {
+ ADIS16400_SCAN_SUPPLY,
+ ADIS16400_SCAN_GYRO_X,
+ ADIS16400_SCAN_GYRO_Y,
+ ADIS16400_SCAN_GYRO_Z,
+ ADIS16400_SCAN_ACC_X,
+ ADIS16400_SCAN_ACC_Y,
+ ADIS16400_SCAN_ACC_Z,
+ ADIS16400_SCAN_MAGN_X,
+ ADIS16400_SCAN_MAGN_Y,
+ ADIS16400_SCAN_MAGN_Z,
+ ADIS16350_SCAN_TEMP_X,
+ ADIS16350_SCAN_TEMP_Y,
+ ADIS16350_SCAN_TEMP_Z,
+ ADIS16300_SCAN_INCLI_X,
+ ADIS16300_SCAN_INCLI_Y,
+ ADIS16400_SCAN_ADC,
+};
#ifdef CONFIG_IIO_BUFFER
-void adis16400_remove_trigger(struct iio_dev *indio_dev);
-int adis16400_probe_trigger(struct iio_dev *indio_dev);
ssize_t adis16400_read_data_from_ring(struct device *dev,
struct device_attribute *attr,
@@ -208,15 +195,6 @@ void adis16400_unconfigure_ring(struct iio_dev *indio_dev);
#else /* CONFIG_IIO_BUFFER */
-static inline void adis16400_remove_trigger(struct iio_dev *indio_dev)
-{
-}
-
-static inline int adis16400_probe_trigger(struct iio_dev *indio_dev)
-{
- return 0;
-}
-
static inline ssize_t
adis16400_read_data_from_ring(struct device *dev,
struct device_attribute *attr,
@@ -235,4 +213,5 @@ static inline void adis16400_unconfigure_ring(struct iio_dev *indio_dev)
}
#endif /* CONFIG_IIO_BUFFER */
+
#endif /* SPI_ADIS16400_H_ */
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index 24fca10..a948472 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -29,6 +29,7 @@
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
#include <linux/iio/buffer.h>
+
#include "adis16400.h"
enum adis16400_chip_variant {
@@ -41,131 +42,12 @@ enum adis16400_chip_variant {
ADIS16400,
};
-/**
- * adis16400_spi_write_reg_8() - write single byte to a register
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @reg_address: the address of the register to be written
- * @val: the value to write
- */
-static int adis16400_spi_write_reg_8(struct iio_dev *indio_dev,
- u8 reg_address,
- u8 val)
-{
- int ret;
- struct adis16400_state *st = iio_priv(indio_dev);
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADIS16400_WRITE_REG(reg_address);
- st->tx[1] = val;
-
- ret = spi_write(st->us, st->tx, 2);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-/**
- * adis16400_spi_write_reg_16() - write 2 bytes to a pair of registers
- * @dev: device associated with child of actual device (iio_dev or iio_trig)
- * @reg_address: the address of the lower of the two registers. Second register
- * is assumed to have address one greater.
- * @val: value to be written
- *
- * At the moment the spi framework doesn't allow global setting of cs_change.
- * This means that use cannot be made of spi_write.
- */
-static int adis16400_spi_write_reg_16(struct iio_dev *indio_dev,
- u8 lower_reg_address,
- u16 value)
-{
- int ret;
- struct spi_message msg;
- struct adis16400_state *st = iio_priv(indio_dev);
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 2,
- .cs_change = 1,
- }, {
- .tx_buf = st->tx + 2,
- .bits_per_word = 8,
- .len = 2,
- },
- };
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADIS16400_WRITE_REG(lower_reg_address);
- st->tx[1] = value & 0xFF;
- st->tx[2] = ADIS16400_WRITE_REG(lower_reg_address + 1);
- st->tx[3] = (value >> 8) & 0xFF;
-
- spi_message_init(&msg);
- spi_message_add_tail(&xfers[0], &msg);
- spi_message_add_tail(&xfers[1], &msg);
- ret = spi_sync(st->us, &msg);
- mutex_unlock(&st->buf_lock);
-
- return ret;
-}
-
-/**
- * adis16400_spi_read_reg_16() - read 2 bytes from a 16-bit register
- * @indio_dev: iio device
- * @reg_address: the address of the lower of the two registers. Second register
- * is assumed to have address one greater.
- * @val: somewhere to pass back the value read
- *
- * At the moment the spi framework doesn't allow global setting of cs_change.
- * This means that use cannot be made of spi_read.
- **/
-static int adis16400_spi_read_reg_16(struct iio_dev *indio_dev,
- u8 lower_reg_address,
- u16 *val)
-{
- struct spi_message msg;
- struct adis16400_state *st = iio_priv(indio_dev);
- int ret;
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->tx,
- .bits_per_word = 8,
- .len = 2,
- .cs_change = 1,
- }, {
- .rx_buf = st->rx,
- .bits_per_word = 8,
- .len = 2,
- },
- };
-
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADIS16400_READ_REG(lower_reg_address);
- st->tx[1] = 0;
-
- spi_message_init(&msg);
- spi_message_add_tail(&xfers[0], &msg);
- spi_message_add_tail(&xfers[1], &msg);
- ret = spi_sync(st->us, &msg);
- if (ret) {
- dev_err(&st->us->dev,
- "problem when reading 16 bit register 0x%02X",
- lower_reg_address);
- goto error_ret;
- }
- *val = (st->rx[0] << 8) | st->rx[1];
-
-error_ret:
- mutex_unlock(&st->buf_lock);
- return ret;
-}
-
-static int adis16334_get_freq(struct iio_dev *indio_dev)
+static int adis16334_get_freq(struct adis16400_state *st)
{
int ret;
u16 t;
- ret = adis16400_spi_read_reg_16(indio_dev, ADIS16400_SMPL_PRD, &t);
+ ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
if (ret < 0)
return ret;
@@ -174,7 +56,7 @@ static int adis16334_get_freq(struct iio_dev *indio_dev)
return (8192 >> t) / 10;
}
-static int adis16334_set_freq(struct iio_dev *indio_dev, unsigned int freq)
+static int adis16334_set_freq(struct adis16400_state *st, unsigned int freq)
{
unsigned int t;
@@ -190,15 +72,15 @@ static int adis16334_set_freq(struct iio_dev *indio_dev, unsigned int freq)
t <<= ADIS16334_RATE_DIV_SHIFT;
t |= ADIS16334_RATE_INT_CLK;
- return adis16400_spi_write_reg_16(indio_dev, ADIS16400_SMPL_PRD, t);
+ return adis_write_reg_16(&st->adis, ADIS16400_SMPL_PRD, t);
}
-static int adis16400_get_freq(struct iio_dev *indio_dev)
+static int adis16400_get_freq(struct adis16400_state *st)
{
int sps, ret;
u16 t;
- ret = adis16400_spi_read_reg_16(indio_dev, ADIS16400_SMPL_PRD, &t);
+ ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
if (ret < 0)
return ret;
sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
@@ -207,9 +89,8 @@ static int adis16400_get_freq(struct iio_dev *indio_dev)
return sps;
}
-static int adis16400_set_freq(struct iio_dev *indio_dev, unsigned int freq)
+static int adis16400_set_freq(struct adis16400_state *st, unsigned int freq)
{
- struct adis16400_state *st = iio_priv(indio_dev);
unsigned int t;
t = 1638 / freq;
@@ -217,12 +98,11 @@ static int adis16400_set_freq(struct iio_dev *indio_dev, unsigned int freq)
t--;
t &= ADIS16400_SMPL_PRD_DIV_MASK;
if ((t & ADIS16400_SMPL_PRD_DIV_MASK) >= 0x0A)
- st->us->max_speed_hz = ADIS16400_SPI_SLOW;
+ st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW;
else
- st->us->max_speed_hz = ADIS16400_SPI_FAST;
+ st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST;
- return adis16400_spi_write_reg_8(indio_dev,
- ADIS16400_SMPL_PRD, t);
+ return adis_write_reg_8(&st->adis, ADIS16400_SMPL_PRD, t);
}
static ssize_t adis16400_read_frequency(struct device *dev,
@@ -233,7 +113,7 @@ static ssize_t adis16400_read_frequency(struct device *dev,
struct adis16400_state *st = iio_priv(indio_dev);
int ret, len = 0;
- ret = st->variant->get_freq(indio_dev);
+ ret = st->variant->get_freq(st);
if (ret < 0)
return ret;
len = sprintf(buf, "%d SPS\n", ret);
@@ -253,6 +133,7 @@ static const unsigned adis16400_3db_divisors[] = {
static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int val)
{
+ struct adis16400_state *st = iio_priv(indio_dev);
int i, ret;
u16 val16;
@@ -261,12 +142,11 @@ static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int val)
break;
}
- ret = adis16400_spi_read_reg_16(indio_dev, ADIS16400_SENS_AVG,
- &val16);
+ ret = adis_read_reg_16(&st->adis, ADIS16400_SENS_AVG, &val16);
if (ret < 0)
return ret;
- ret = adis16400_spi_write_reg_16(indio_dev, ADIS16400_SENS_AVG,
+ ret = adis_write_reg_16(&st->adis, ADIS16400_SENS_AVG,
(val16 & ~0x07) | i);
return ret;
}
@@ -289,7 +169,7 @@ static ssize_t adis16400_write_frequency(struct device *dev,
mutex_lock(&indio_dev->mlock);
- st->variant->set_freq(indio_dev, val);
+ st->variant->set_freq(st, val);
/* Also update the filter */
mutex_unlock(&indio_dev->mlock);
@@ -297,48 +177,14 @@ static ssize_t adis16400_write_frequency(struct device *dev,
return ret ? ret : len;
}
-static int adis16400_reset(struct iio_dev *indio_dev)
-{
- int ret;
- ret = adis16400_spi_write_reg_8(indio_dev,
- ADIS16400_GLOB_CMD,
- ADIS16400_GLOB_CMD_SW_RESET);
- if (ret)
- dev_err(&indio_dev->dev, "problem resetting device");
-
- return ret;
-}
-
-int adis16400_set_irq(struct iio_dev *indio_dev, bool enable)
-{
- int ret;
- u16 msc;
-
- ret = adis16400_spi_read_reg_16(indio_dev, ADIS16400_MSC_CTRL, &msc);
- if (ret)
- goto error_ret;
-
- msc |= ADIS16400_MSC_CTRL_DATA_RDY_POL_HIGH;
- if (enable)
- msc |= ADIS16400_MSC_CTRL_DATA_RDY_EN;
- else
- msc &= ~ADIS16400_MSC_CTRL_DATA_RDY_EN;
-
- ret = adis16400_spi_write_reg_16(indio_dev, ADIS16400_MSC_CTRL, msc);
- if (ret)
- goto error_ret;
-
-error_ret:
- return ret;
-}
-
/* Power down the device */
static int adis16400_stop_device(struct iio_dev *indio_dev)
{
+ struct adis16400_state *st = iio_priv(indio_dev);
int ret;
u16 val = ADIS16400_SLP_CNT_POWER_OFF;
- ret = adis16400_spi_write_reg_16(indio_dev, ADIS16400_SLP_CNT, val);
+ ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT, val);
if (ret)
dev_err(&indio_dev->dev,
"problem with turning device off: SLP_CNT");
@@ -346,73 +192,6 @@ static int adis16400_stop_device(struct iio_dev *indio_dev)
return ret;
}
-static int adis16400_check_status(struct iio_dev *indio_dev)
-{
- u16 status;
- int ret;
- struct device *dev = &indio_dev->dev;
-
- ret = adis16400_spi_read_reg_16(indio_dev,
- ADIS16400_DIAG_STAT, &status);
-
- if (ret < 0) {
- dev_err(dev, "Reading status failed\n");
- goto error_ret;
- }
- ret = status;
- if (status & ADIS16400_DIAG_STAT_ZACCL_FAIL)
- dev_err(dev, "Z-axis accelerometer self-test failure\n");
- if (status & ADIS16400_DIAG_STAT_YACCL_FAIL)
- dev_err(dev, "Y-axis accelerometer self-test failure\n");
- if (status & ADIS16400_DIAG_STAT_XACCL_FAIL)
- dev_err(dev, "X-axis accelerometer self-test failure\n");
- if (status & ADIS16400_DIAG_STAT_XGYRO_FAIL)
- dev_err(dev, "X-axis gyroscope self-test failure\n");
- if (status & ADIS16400_DIAG_STAT_YGYRO_FAIL)
- dev_err(dev, "Y-axis gyroscope self-test failure\n");
- if (status & ADIS16400_DIAG_STAT_ZGYRO_FAIL)
- dev_err(dev, "Z-axis gyroscope self-test failure\n");
- if (status & ADIS16400_DIAG_STAT_ALARM2)
- dev_err(dev, "Alarm 2 active\n");
- if (status & ADIS16400_DIAG_STAT_ALARM1)
- dev_err(dev, "Alarm 1 active\n");
- if (status & ADIS16400_DIAG_STAT_FLASH_CHK)
- dev_err(dev, "Flash checksum error\n");
- if (status & ADIS16400_DIAG_STAT_SELF_TEST)
- dev_err(dev, "Self test error\n");
- if (status & ADIS16400_DIAG_STAT_OVERFLOW)
- dev_err(dev, "Sensor overrange\n");
- if (status & ADIS16400_DIAG_STAT_SPI_FAIL)
- dev_err(dev, "SPI failure\n");
- if (status & ADIS16400_DIAG_STAT_FLASH_UPT)
- dev_err(dev, "Flash update failed\n");
- if (status & ADIS16400_DIAG_STAT_POWER_HIGH)
- dev_err(dev, "Power supply above 5.25V\n");
- if (status & ADIS16400_DIAG_STAT_POWER_LOW)
- dev_err(dev, "Power supply below 4.75V\n");
-
-error_ret:
- return ret;
-}
-
-static int adis16400_self_test(struct iio_dev *indio_dev)
-{
- int ret;
- ret = adis16400_spi_write_reg_16(indio_dev,
- ADIS16400_MSC_CTRL,
- ADIS16400_MSC_CTRL_MEM_TEST);
- if (ret) {
- dev_err(&indio_dev->dev, "problem starting self test");
- goto err_ret;
- }
-
- msleep(ADIS16400_MTEST_DELAY);
- adis16400_check_status(indio_dev);
-
-err_ret:
- return ret;
-}
-
static int adis16400_initial_setup(struct iio_dev *indio_dev)
{
int ret;
@@ -422,37 +201,18 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev)
/* use low spi speed for init if the device has a slow mode */
if (st->variant->flags & ADIS16400_HAS_SLOW_MODE)
- st->us->max_speed_hz = ADIS16400_SPI_SLOW;
+ st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW;
else
- st->us->max_speed_hz = ADIS16400_SPI_FAST;
- st->us->mode = SPI_MODE_3;
- spi_setup(st->us);
-
- ret = adis16400_set_irq(indio_dev, false);
- if (ret) {
- dev_err(&indio_dev->dev, "disable irq failed");
- goto err_ret;
- }
+ st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST;
+ st->adis.spi->mode = SPI_MODE_3;
+ spi_setup(st->adis.spi);
- ret = adis16400_self_test(indio_dev);
- if (ret) {
- dev_err(&indio_dev->dev, "self test failure");
- goto err_ret;
- }
+ ret = adis_initial_startup(&st->adis);
+ if (ret)
+ return ret;
- ret = adis16400_check_status(indio_dev);
- if (ret) {
- adis16400_reset(indio_dev);
- dev_err(&indio_dev->dev, "device not playing ball -> reset");
- msleep(ADIS16400_STARTUP_DELAY);
- ret = adis16400_check_status(indio_dev);
- if (ret) {
- dev_err(&indio_dev->dev, "giving up");
- goto err_ret;
- }
- }
if (st->variant->flags & ADIS16400_HAS_PROD_ID) {
- ret = adis16400_spi_read_reg_16(indio_dev,
+ ret = adis_read_reg_16(&st->adis,
ADIS16400_PRODUCT_ID, &prod_id);
if (ret)
goto err_ret;
@@ -465,18 +225,17 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev)
dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n",
indio_dev->name, prod_id,
- st->us->chip_select, st->us->irq);
+ st->adis.spi->chip_select, st->adis.spi->irq);
}
/* use high spi speed if possible */
if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {
- ret = adis16400_spi_read_reg_16(indio_dev,
- ADIS16400_SMPL_PRD, &smp_prd);
+ ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &smp_prd);
if (ret)
goto err_ret;
if ((smp_prd & ADIS16400_SMPL_PRD_DIV_MASK) < 0x0A) {
- st->us->max_speed_hz = ADIS16400_SPI_FAST;
- spi_setup(st->us);
+ st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST;
+ spi_setup(st->adis.spi);
}
}
@@ -490,47 +249,15 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638");
-enum adis16400_chan {
- in_supply,
- gyro_x,
- gyro_y,
- gyro_z,
- accel_x,
- accel_y,
- accel_z,
- magn_x,
- magn_y,
- magn_z,
- temp,
- temp0, temp1, temp2,
- in1,
- in2,
- incli_x,
- incli_y,
-};
-
-static u8 adis16400_addresses[18][2] = {
- [in_supply] = { ADIS16400_SUPPLY_OUT },
- [gyro_x] = { ADIS16400_XGYRO_OUT, ADIS16400_XGYRO_OFF },
- [gyro_y] = { ADIS16400_YGYRO_OUT, ADIS16400_YGYRO_OFF },
- [gyro_z] = { ADIS16400_ZGYRO_OUT, ADIS16400_ZGYRO_OFF },
- [accel_x] = { ADIS16400_XACCL_OUT, ADIS16400_XACCL_OFF },
- [accel_y] = { ADIS16400_YACCL_OUT, ADIS16400_YACCL_OFF },
- [accel_z] = { ADIS16400_ZACCL_OUT, ADIS16400_ZACCL_OFF },
- [magn_x] = { ADIS16400_XMAGN_OUT },
- [magn_y] = { ADIS16400_YMAGN_OUT },
- [magn_z] = { ADIS16400_ZMAGN_OUT },
- [temp] = { ADIS16400_TEMP_OUT },
- [temp0] = { ADIS16350_XTEMP_OUT },
- [temp1] = { ADIS16350_YTEMP_OUT },
- [temp2] = { ADIS16350_ZTEMP_OUT },
- [in1] = { ADIS16300_AUX_ADC },
- [in2] = { ADIS16400_AUX_ADC },
- [incli_x] = { ADIS16300_PITCH_OUT },
- [incli_y] = { ADIS16300_ROLL_OUT }
+static const u8 adis16400_addresses[] = {
+ [ADIS16400_SCAN_GYRO_X] = ADIS16400_XGYRO_OFF,
+ [ADIS16400_SCAN_GYRO_Y] = ADIS16400_YGYRO_OFF,
+ [ADIS16400_SCAN_GYRO_Z] = ADIS16400_ZGYRO_OFF,
+ [ADIS16400_SCAN_ACC_X] = ADIS16400_XACCL_OFF,
+ [ADIS16400_SCAN_ACC_Y] = ADIS16400_YACCL_OFF,
+ [ADIS16400_SCAN_ACC_Z] = ADIS16400_ZACCL_OFF,
};
-
static int adis16400_write_raw(struct iio_dev *indio_dev,
struct iio_chan_spec const *chan,
int val,
@@ -543,9 +270,8 @@ static int adis16400_write_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_CALIBBIAS:
mutex_lock(&indio_dev->mlock);
- ret = adis16400_spi_write_reg_16(indio_dev,
- adis16400_addresses[chan->address][1],
- val);
+ ret = adis_write_reg_16(&st->adis,
+ adis16400_addresses[chan->scan_index], val);
mutex_unlock(&indio_dev->mlock);
return ret;
case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
@@ -554,7 +280,7 @@ static int adis16400_write_raw(struct iio_dev *indio_dev,
mutex_lock(&indio_dev->mlock);
st->filt_int = val;
/* Work out update to current value */
- sps = st->variant->get_freq(indio_dev);
+ sps = st->variant->get_freq(st);
if (sps < 0) {
mutex_unlock(&indio_dev->mlock);
return sps;
@@ -575,27 +301,12 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
long mask)
{
struct adis16400_state *st = iio_priv(indio_dev);
- int ret, shift;
+ int ret;
s16 val16;
switch (mask) {
case IIO_CHAN_INFO_RAW:
- mutex_lock(&indio_dev->mlock);
- ret = adis16400_spi_read_reg_16(indio_dev,
- adis16400_addresses[chan->address][0],
- &val16);
- if (ret) {
- mutex_unlock(&indio_dev->mlock);
- return ret;
- }
- val16 &= (1 << chan->scan_type.realbits) - 1;
- if (chan->scan_type.sign == 's') {
- shift = 16 - chan->scan_type.realbits;
- val16 = (s16)(val16 << shift) >> shift;
- }
- *val = val16;
- mutex_unlock(&indio_dev->mlock);
- return IIO_VAL_INT;
+ return adis_single_conversion(indio_dev, chan, 0, val);
case IIO_CHAN_INFO_SCALE:
switch (chan->type) {
case IIO_ANGL_VEL:
@@ -629,9 +340,8 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
}
case IIO_CHAN_INFO_CALIBBIAS:
mutex_lock(&indio_dev->mlock);
- ret = adis16400_spi_read_reg_16(indio_dev,
- adis16400_addresses[chan->address][1],
- &val16);
+ ret = adis_read_reg_16(&st->adis,
+ adis16400_addresses[chan->scan_index], &val16);
mutex_unlock(&indio_dev->mlock);
if (ret)
return ret;
@@ -645,14 +355,14 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
mutex_lock(&indio_dev->mlock);
/* Need both the number of taps and the sampling frequency */
- ret = adis16400_spi_read_reg_16(indio_dev,
+ ret = adis_read_reg_16(&st->adis,
ADIS16400_SENS_AVG,
&val16);
if (ret < 0) {
mutex_unlock(&indio_dev->mlock);
return ret;
}
- ret = st->variant->get_freq(indio_dev);
+ ret = st->variant->get_freq(st);
if (ret >= 0)
*val = ret / adis16400_3db_divisors[val16 & 0x07];
*val2 = 0;
@@ -673,7 +383,7 @@ static const struct iio_chan_spec adis16400_channels[] = {
.extend_name = "supply",
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = in_supply,
+ .address = ADIS16400_SUPPLY_OUT,
.scan_index = ADIS16400_SCAN_SUPPLY,
.scan_type = IIO_ST('u', 14, 16, 0),
}, {
@@ -684,7 +394,7 @@ static const struct iio_chan_spec adis16400_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = gyro_x,
+ .address = ADIS16400_XGYRO_OUT,
.scan_index = ADIS16400_SCAN_GYRO_X,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -695,7 +405,7 @@ static const struct iio_chan_spec adis16400_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = gyro_y,
+ .address = ADIS16400_YGYRO_OUT,
.scan_index = ADIS16400_SCAN_GYRO_Y,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -706,7 +416,7 @@ static const struct iio_chan_spec adis16400_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = gyro_z,
+ .address = ADIS16400_ZGYRO_OUT,
.scan_index = ADIS16400_SCAN_GYRO_Z,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -717,7 +427,7 @@ static const struct iio_chan_spec adis16400_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = accel_x,
+ .address = ADIS16400_XACCL_OUT,
.scan_index = ADIS16400_SCAN_ACC_X,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -728,7 +438,7 @@ static const struct iio_chan_spec adis16400_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = accel_y,
+ .address = ADIS16400_YACCL_OUT,
.scan_index = ADIS16400_SCAN_ACC_Y,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -739,7 +449,7 @@ static const struct iio_chan_spec adis16400_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = accel_z,
+ .address = ADIS16400_ZACCL_OUT,
.scan_index = ADIS16400_SCAN_ACC_Z,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -749,7 +459,7 @@ static const struct iio_chan_spec adis16400_channels[] = {
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = magn_x,
+ .address = ADIS16400_XMAGN_OUT,
.scan_index = ADIS16400_SCAN_MAGN_X,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -759,7 +469,7 @@ static const struct iio_chan_spec adis16400_channels[] = {
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = magn_y,
+ .address = ADIS16400_YMAGN_OUT,
.scan_index = ADIS16400_SCAN_MAGN_Y,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -769,7 +479,7 @@ static const struct iio_chan_spec adis16400_channels[] = {
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = magn_z,
+ .address = ADIS16400_ZMAGN_OUT,
.scan_index = ADIS16400_SCAN_MAGN_Z,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -779,8 +489,8 @@ static const struct iio_chan_spec adis16400_channels[] = {
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = temp,
- .scan_index = ADIS16400_SCAN_TEMP,
+ .address = ADIS16400_TEMP_OUT,
+ .scan_index = ADIS16350_SCAN_TEMP_X,
.scan_type = IIO_ST('s', 12, 16, 0),
}, {
.type = IIO_VOLTAGE,
@@ -788,8 +498,8 @@ static const struct iio_chan_spec adis16400_channels[] = {
.channel = 1,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = in2,
- .scan_index = ADIS16400_SCAN_ADC_0,
+ .address = ADIS16400_AUX_ADC,
+ .scan_index = ADIS16400_SCAN_ADC,
.scan_type = IIO_ST('s', 12, 16, 0),
},
IIO_CHAN_SOFT_TIMESTAMP(12)
@@ -803,7 +513,7 @@ static const struct iio_chan_spec adis16350_channels[] = {
.extend_name = "supply",
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = in_supply,
+ .address = ADIS16400_SUPPLY_OUT,
.scan_index = ADIS16400_SCAN_SUPPLY,
.scan_type = IIO_ST('u', 12, 16, 0),
}, {
@@ -814,7 +524,7 @@ static const struct iio_chan_spec adis16350_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = gyro_x,
+ .address = ADIS16400_XGYRO_OUT,
.scan_index = ADIS16400_SCAN_GYRO_X,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -825,7 +535,7 @@ static const struct iio_chan_spec adis16350_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = gyro_y,
+ .address = ADIS16400_YGYRO_OUT,
.scan_index = ADIS16400_SCAN_GYRO_Y,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -836,7 +546,7 @@ static const struct iio_chan_spec adis16350_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = gyro_z,
+ .address = ADIS16400_ZGYRO_OUT,
.scan_index = ADIS16400_SCAN_GYRO_Z,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -847,7 +557,7 @@ static const struct iio_chan_spec adis16350_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = accel_x,
+ .address = ADIS16400_XACCL_OUT,
.scan_index = ADIS16400_SCAN_ACC_X,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -858,7 +568,7 @@ static const struct iio_chan_spec adis16350_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = accel_y,
+ .address = ADIS16400_YACCL_OUT,
.scan_index = ADIS16400_SCAN_ACC_Y,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -869,7 +579,7 @@ static const struct iio_chan_spec adis16350_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = accel_z,
+ .address = ADIS16400_ZACCL_OUT,
.scan_index = ADIS16400_SCAN_ACC_Z,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -881,7 +591,7 @@ static const struct iio_chan_spec adis16350_channels[] = {
IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = temp0,
+ .address = ADIS16350_XTEMP_OUT,
.scan_index = ADIS16350_SCAN_TEMP_X,
.scan_type = IIO_ST('s', 12, 16, 0),
}, {
@@ -893,7 +603,7 @@ static const struct iio_chan_spec adis16350_channels[] = {
IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = temp1,
+ .address = ADIS16350_YTEMP_OUT,
.scan_index = ADIS16350_SCAN_TEMP_Y,
.scan_type = IIO_ST('s', 12, 16, 0),
}, {
@@ -904,7 +614,7 @@ static const struct iio_chan_spec adis16350_channels[] = {
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = temp2,
+ .address = ADIS16350_ZTEMP_OUT,
.scan_index = ADIS16350_SCAN_TEMP_Z,
.scan_type = IIO_ST('s', 12, 16, 0),
}, {
@@ -913,8 +623,8 @@ static const struct iio_chan_spec adis16350_channels[] = {
.channel = 1,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = in1,
- .scan_index = ADIS16350_SCAN_ADC_0,
+ .address = ADIS16300_AUX_ADC,
+ .scan_index = ADIS16400_SCAN_ADC,
.scan_type = IIO_ST('s', 12, 16, 0),
},
IIO_CHAN_SOFT_TIMESTAMP(11)
@@ -928,7 +638,7 @@ static const struct iio_chan_spec adis16300_channels[] = {
.extend_name = "supply",
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = in_supply,
+ .address = ADIS16400_SUPPLY_OUT,
.scan_index = ADIS16400_SCAN_SUPPLY,
.scan_type = IIO_ST('u', 12, 16, 0),
}, {
@@ -939,7 +649,7 @@ static const struct iio_chan_spec adis16300_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = gyro_x,
+ .address = ADIS16400_XGYRO_OUT,
.scan_index = ADIS16400_SCAN_GYRO_X,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -950,7 +660,7 @@ static const struct iio_chan_spec adis16300_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = accel_x,
+ .address = ADIS16400_XACCL_OUT,
.scan_index = ADIS16400_SCAN_ACC_X,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -961,7 +671,7 @@ static const struct iio_chan_spec adis16300_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = accel_y,
+ .address = ADIS16400_YACCL_OUT,
.scan_index = ADIS16400_SCAN_ACC_Y,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -972,7 +682,7 @@ static const struct iio_chan_spec adis16300_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = accel_z,
+ .address = ADIS16400_ZACCL_OUT,
.scan_index = ADIS16400_SCAN_ACC_Z,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -982,8 +692,8 @@ static const struct iio_chan_spec adis16300_channels[] = {
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = temp0,
- .scan_index = ADIS16400_SCAN_TEMP,
+ .address = ADIS16350_XTEMP_OUT,
+ .scan_index = ADIS16350_SCAN_TEMP_X,
.scan_type = IIO_ST('s', 12, 16, 0),
}, {
.type = IIO_VOLTAGE,
@@ -991,8 +701,8 @@ static const struct iio_chan_spec adis16300_channels[] = {
.channel = 1,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = in1,
- .scan_index = ADIS16350_SCAN_ADC_0,
+ .address = ADIS16300_AUX_ADC,
+ .scan_index = ADIS16400_SCAN_ADC,
.scan_type = IIO_ST('s', 12, 16, 0),
}, {
.type = IIO_INCLI,
@@ -1000,7 +710,7 @@ static const struct iio_chan_spec adis16300_channels[] = {
.channel2 = IIO_MOD_X,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT,
- .address = incli_x,
+ .address = ADIS16300_PITCH_OUT,
.scan_index = ADIS16300_SCAN_INCLI_X,
.scan_type = IIO_ST('s', 13, 16, 0),
}, {
@@ -1009,7 +719,7 @@ static const struct iio_chan_spec adis16300_channels[] = {
.channel2 = IIO_MOD_Y,
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT,
- .address = incli_y,
+ .address = ADIS16300_ROLL_OUT,
.scan_index = ADIS16300_SCAN_INCLI_Y,
.scan_type = IIO_ST('s', 13, 16, 0),
},
@@ -1025,7 +735,7 @@ static const struct iio_chan_spec adis16334_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = gyro_x,
+ .address = ADIS16400_XGYRO_OUT,
.scan_index = ADIS16400_SCAN_GYRO_X,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -1036,7 +746,7 @@ static const struct iio_chan_spec adis16334_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = gyro_y,
+ .address = ADIS16400_YGYRO_OUT,
.scan_index = ADIS16400_SCAN_GYRO_Y,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -1047,7 +757,7 @@ static const struct iio_chan_spec adis16334_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = gyro_z,
+ .address = ADIS16400_ZGYRO_OUT,
.scan_index = ADIS16400_SCAN_GYRO_Z,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -1058,7 +768,7 @@ static const struct iio_chan_spec adis16334_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = accel_x,
+ .address = ADIS16400_XACCL_OUT,
.scan_index = ADIS16400_SCAN_ACC_X,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -1069,7 +779,7 @@ static const struct iio_chan_spec adis16334_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = accel_y,
+ .address = ADIS16400_YACCL_OUT,
.scan_index = ADIS16400_SCAN_ACC_Y,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -1080,7 +790,7 @@ static const struct iio_chan_spec adis16334_channels[] = {
IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT |
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = accel_z,
+ .address = ADIS16400_ZACCL_OUT,
.scan_index = ADIS16400_SCAN_ACC_Z,
.scan_type = IIO_ST('s', 14, 16, 0),
}, {
@@ -1090,8 +800,8 @@ static const struct iio_chan_spec adis16334_channels[] = {
.info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
IIO_CHAN_INFO_SCALE_SHARED_BIT,
- .address = temp0,
- .scan_index = ADIS16400_SCAN_TEMP,
+ .address = ADIS16350_XTEMP_OUT,
+ .scan_index = ADIS16350_SCAN_TEMP_X,
.scan_type = IIO_ST('s', 14, 16, 0),
},
IIO_CHAN_SOFT_TIMESTAMP(12)
@@ -1194,6 +904,53 @@ static const struct iio_info adis16400_info = {
.attrs = &adis16400_attribute_group,
};
+static const char * const adis16400_status_error_msgs[] = {
+ [ADIS16400_DIAG_STAT_ZACCL_FAIL] = "Z-axis accelerometer self-test failure",
+ [ADIS16400_DIAG_STAT_YACCL_FAIL] = "Y-axis accelerometer self-test failure",
+ [ADIS16400_DIAG_STAT_XACCL_FAIL] = "X-axis accelerometer self-test failure",
+ [ADIS16400_DIAG_STAT_XGYRO_FAIL] = "X-axis gyroscope self-test failure",
+ [ADIS16400_DIAG_STAT_YGYRO_FAIL] = "Y-axis gyroscope self-test failure",
+ [ADIS16400_DIAG_STAT_ZGYRO_FAIL] = "Z-axis gyroscope self-test failure",
+ [ADIS16400_DIAG_STAT_ALARM2] = "Alarm 2 active",
+ [ADIS16400_DIAG_STAT_ALARM1] = "Alarm 1 active",
+ [ADIS16400_DIAG_STAT_FLASH_CHK] = "Flash checksum error",
+ [ADIS16400_DIAG_STAT_SELF_TEST] = "Self test error",
+ [ADIS16400_DIAG_STAT_OVERFLOW] = "Sensor overrange",
+ [ADIS16400_DIAG_STAT_SPI_FAIL] = "SPI failure",
+ [ADIS16400_DIAG_STAT_FLASH_UPT] = "Flash update failed",
+ [ADIS16400_DIAG_STAT_POWER_HIGH] = "Power supply above 5.25V",
+ [ADIS16400_DIAG_STAT_POWER_LOW] = "Power supply below 4.75V",
+};
+
+static const struct adis_data adis16400_data = {
+ .msc_ctrl_reg = ADIS16400_MSC_CTRL,
+ .glob_cmd_reg = ADIS16400_GLOB_CMD,
+ .diag_stat_reg = ADIS16400_DIAG_STAT,
+
+ .read_delay = 50,
+ .write_delay = 50,
+
+ .self_test_mask = ADIS16400_MSC_CTRL_MEM_TEST,
+ .startup_delay = ADIS16400_STARTUP_DELAY,
+
+ .status_error_msgs = adis16400_status_error_msgs,
+ .status_error_mask = BIT(ADIS16400_DIAG_STAT_ZACCL_FAIL) |
+ BIT(ADIS16400_DIAG_STAT_YACCL_FAIL) |
+ BIT(ADIS16400_DIAG_STAT_XACCL_FAIL) |
+ BIT(ADIS16400_DIAG_STAT_XGYRO_FAIL) |
+ BIT(ADIS16400_DIAG_STAT_YGYRO_FAIL) |
+ BIT(ADIS16400_DIAG_STAT_ZGYRO_FAIL) |
+ BIT(ADIS16400_DIAG_STAT_ALARM2) |
+ BIT(ADIS16400_DIAG_STAT_ALARM1) |
+ BIT(ADIS16400_DIAG_STAT_FLASH_CHK) |
+ BIT(ADIS16400_DIAG_STAT_SELF_TEST) |
+ BIT(ADIS16400_DIAG_STAT_OVERFLOW) |
+ BIT(ADIS16400_DIAG_STAT_SPI_FAIL) |
+ BIT(ADIS16400_DIAG_STAT_FLASH_UPT) |
+ BIT(ADIS16400_DIAG_STAT_POWER_HIGH) |
+ BIT(ADIS16400_DIAG_STAT_POWER_LOW),
+};
+
static int adis16400_probe(struct spi_device *spi)
{
int ret;
@@ -1207,9 +964,6 @@ static int adis16400_probe(struct spi_device *spi)
/* this is only used for removal purposes */
spi_set_drvdata(spi, indio_dev);
- st->us = spi;
- mutex_init(&st->buf_lock);
-
/* setup the industrialio driver allocated elements */
st->variant = &adis16400_chips[spi_get_device_id(spi)->driver_data];
indio_dev->dev.parent = &spi->dev;
@@ -1219,6 +973,10 @@ static int adis16400_probe(struct spi_device *spi)
indio_dev->info = &adis16400_info;
indio_dev->modes = INDIO_DIRECT_MODE;
+ ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data);
+ if (ret)
+ goto error_free_dev;
+
ret = adis16400_configure_ring(indio_dev);
if (ret)
goto error_free_dev;
@@ -1232,7 +990,7 @@ static int adis16400_probe(struct spi_device *spi)
}
if (spi->irq) {
- ret = adis16400_probe_trigger(indio_dev);
+ ret = adis_probe_trigger(&st->adis, indio_dev);
if (ret)
goto error_uninitialize_ring;
}
@@ -1249,7 +1007,7 @@ static int adis16400_probe(struct spi_device *spi)
error_remove_trigger:
if (spi->irq)
- adis16400_remove_trigger(indio_dev);
+ adis_remove_trigger(&st->adis);
error_uninitialize_ring:
iio_buffer_unregister(indio_dev);
error_unreg_ring_funcs:
@@ -1264,13 +1022,16 @@ error_ret:
static int adis16400_remove(struct spi_device *spi)
{
struct iio_dev *indio_dev = spi_get_drvdata(spi);
+ struct adis16400_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
adis16400_stop_device(indio_dev);
- adis16400_remove_trigger(indio_dev);
+ if (spi->irq)
+ adis_remove_trigger(&st->adis);
iio_buffer_unregister(indio_dev);
adis16400_unconfigure_ring(indio_dev);
+
iio_device_free(indio_dev);
return 0;
diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c
index d46c1e3..6c5b0be 100644
--- a/drivers/staging/iio/imu/adis16400_ring.c
+++ b/drivers/staging/iio/imu/adis16400_ring.c
@@ -9,6 +9,7 @@
#include <linux/iio/iio.h>
#include "../ring_sw.h"
#include <linux/iio/trigger_consumer.h>
+
#include "adis16400.h"
/**
@@ -20,12 +21,12 @@ static int adis16400_spi_read_burst(struct iio_dev *indio_dev, u8 *rx)
{
struct spi_message msg;
struct adis16400_state *st = iio_priv(indio_dev);
- u32 old_speed_hz = st->us->max_speed_hz;
+ u32 old_speed_hz = st->adis.spi->max_speed_hz;
int ret;
struct spi_transfer xfers[] = {
{
- .tx_buf = st->tx,
+ .tx_buf = st->adis.tx,
.bits_per_word = 8,
.len = 2,
}, {
@@ -35,39 +36,39 @@ static int adis16400_spi_read_burst(struct iio_dev *indio_dev, u8 *rx)
},
};
- mutex_lock(&st->buf_lock);
- st->tx[0] = ADIS16400_READ_REG(ADIS16400_GLOB_CMD);
- st->tx[1] = 0;
+ mutex_lock(&st->adis.txrx_lock);
+ st->adis.tx[0] = ADIS_READ_REG(ADIS16400_GLOB_CMD);
+ st->adis.tx[1] = 0;
spi_message_init(&msg);
spi_message_add_tail(&xfers[0], &msg);
spi_message_add_tail(&xfers[1], &msg);
- st->us->max_speed_hz = min(ADIS16400_SPI_BURST, old_speed_hz);
- spi_setup(st->us);
+ st->adis.spi->max_speed_hz = min(ADIS16400_SPI_BURST, old_speed_hz);
+ spi_setup(st->adis.spi);
- ret = spi_sync(st->us, &msg);
+ ret = spi_sync(st->adis.spi, &msg);
if (ret)
- dev_err(&st->us->dev, "problem when burst reading");
+ dev_err(&st->adis.spi->dev, "problem when burst reading");
- st->us->max_speed_hz = old_speed_hz;
- spi_setup(st->us);
- mutex_unlock(&st->buf_lock);
+ st->adis.spi->max_speed_hz = old_speed_hz;
+ spi_setup(st->adis.spi);
+ mutex_unlock(&st->adis.txrx_lock);
return ret;
}
static const u16 read_all_tx_array[] = {
- cpu_to_be16(ADIS16400_READ_REG(ADIS16400_SUPPLY_OUT)),
- cpu_to_be16(ADIS16400_READ_REG(ADIS16400_XGYRO_OUT)),
- cpu_to_be16(ADIS16400_READ_REG(ADIS16400_YGYRO_OUT)),
- cpu_to_be16(ADIS16400_READ_REG(ADIS16400_ZGYRO_OUT)),
- cpu_to_be16(ADIS16400_READ_REG(ADIS16400_XACCL_OUT)),
- cpu_to_be16(ADIS16400_READ_REG(ADIS16400_YACCL_OUT)),
- cpu_to_be16(ADIS16400_READ_REG(ADIS16400_ZACCL_OUT)),
- cpu_to_be16(ADIS16400_READ_REG(ADIS16350_XTEMP_OUT)),
- cpu_to_be16(ADIS16400_READ_REG(ADIS16350_YTEMP_OUT)),
- cpu_to_be16(ADIS16400_READ_REG(ADIS16350_ZTEMP_OUT)),
- cpu_to_be16(ADIS16400_READ_REG(ADIS16400_AUX_ADC)),
+ cpu_to_be16(ADIS_READ_REG(ADIS16400_SUPPLY_OUT)),
+ cpu_to_be16(ADIS_READ_REG(ADIS16400_XGYRO_OUT)),
+ cpu_to_be16(ADIS_READ_REG(ADIS16400_YGYRO_OUT)),
+ cpu_to_be16(ADIS_READ_REG(ADIS16400_ZGYRO_OUT)),
+ cpu_to_be16(ADIS_READ_REG(ADIS16400_XACCL_OUT)),
+ cpu_to_be16(ADIS_READ_REG(ADIS16400_YACCL_OUT)),
+ cpu_to_be16(ADIS_READ_REG(ADIS16400_ZACCL_OUT)),
+ cpu_to_be16(ADIS_READ_REG(ADIS16350_XTEMP_OUT)),
+ cpu_to_be16(ADIS_READ_REG(ADIS16350_YTEMP_OUT)),
+ cpu_to_be16(ADIS_READ_REG(ADIS16350_ZTEMP_OUT)),
+ cpu_to_be16(ADIS_READ_REG(ADIS16400_AUX_ADC)),
};
static int adis16350_spi_read_all(struct iio_dev *indio_dev, u8 *rx)
@@ -100,7 +101,7 @@ static int adis16350_spi_read_all(struct iio_dev *indio_dev, u8 *rx)
for (j = 0; j < scan_count + 1; j++)
spi_message_add_tail(&xfers[j], &msg);
- ret = spi_sync(st->us, &msg);
+ ret = spi_sync(st->adis.spi, &msg);
kfree(xfers);
return ret;
@@ -123,26 +124,26 @@ static irqreturn_t adis16400_trigger_handler(int irq, void *p)
indio_dev->masklength);
data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
if (data == NULL) {
- dev_err(&st->us->dev, "memory alloc failed in ring bh");
+ dev_err(&st->adis.spi->dev, "memory alloc failed in ring bh");
goto done;
}
if (scan_count) {
if (st->variant->flags & ADIS16400_NO_BURST) {
- ret = adis16350_spi_read_all(indio_dev, st->rx);
+ ret = adis16350_spi_read_all(indio_dev, st->adis.rx);
if (ret < 0)
goto done;
for (; i < scan_count; i++)
- data[i] = *(s16 *)(st->rx + i*2);
+ data[i] = *(s16 *)(st->adis.rx + i*2);
} else {
- ret = adis16400_spi_read_burst(indio_dev, st->rx);
+ ret = adis16400_spi_read_burst(indio_dev, st->adis.rx);
if (ret < 0)
goto done;
for (; i < scan_count; i++) {
j = __ffs(mask);
mask &= ~(1 << j);
data[i] = be16_to_cpup(
- (__be16 *)&(st->rx[j*2]));
+ (__be16 *)&(st->adis.rx[j*2]));
}
}
}
diff --git a/drivers/staging/iio/imu/adis16400_trigger.c b/drivers/staging/iio/imu/adis16400_trigger.c
deleted file mode 100644
index 42a678e..0000000
--- a/drivers/staging/iio/imu/adis16400_trigger.c
+++ /dev/null
@@ -1,74 +0,0 @@
-#include <linux/interrupt.h>
-#include <linux/kernel.h>
-#include <linux/spi/spi.h>
-#include <linux/export.h>
-
-#include <linux/iio/iio.h>
-#include <linux/iio/trigger.h>
-#include "adis16400.h"
-
-/**
- * adis16400_data_rdy_trigger_set_state() set datardy interrupt state
- **/
-static int adis16400_data_rdy_trigger_set_state(struct iio_trigger *trig,
- bool state)
-{
- struct iio_dev *indio_dev = trig->private_data;
-
- dev_dbg(&indio_dev->dev, "%s (%d)\n", __func__, state);
- return adis16400_set_irq(indio_dev, state);
-}
-
-static const struct iio_trigger_ops adis16400_trigger_ops = {
- .owner = THIS_MODULE,
- .set_trigger_state = &adis16400_data_rdy_trigger_set_state,
-};
-
-int adis16400_probe_trigger(struct iio_dev *indio_dev)
-{
- int ret;
- struct adis16400_state *st = iio_priv(indio_dev);
-
- st->trig = iio_trigger_alloc("%s-dev%d",
- indio_dev->name,
- indio_dev->id);
- if (st->trig == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
-
- ret = request_irq(st->us->irq,
- &iio_trigger_generic_data_rdy_poll,
- IRQF_TRIGGER_RISING,
- "adis16400",
- st->trig);
- if (ret)
- goto error_free_trig;
- st->trig->dev.parent = &st->us->dev;
- st->trig->private_data = indio_dev;
- st->trig->ops = &adis16400_trigger_ops;
- ret = iio_trigger_register(st->trig);
-
- /* select default trigger */
- indio_dev->trig = st->trig;
- if (ret)
- goto error_free_irq;
-
- return 0;
-
-error_free_irq:
- free_irq(st->us->irq, st->trig);
-error_free_trig:
- iio_trigger_free(st->trig);
-error_ret:
- return ret;
-}
-
-void adis16400_remove_trigger(struct iio_dev *indio_dev)
-{
- struct adis16400_state *st = iio_priv(indio_dev);
-
- iio_trigger_unregister(st->trig);
- free_irq(st->us->irq, st->trig);
- iio_trigger_free(st->trig);
-}
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 05/15] staging:iio:adis16400: Use triggered buffer setup helper function
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
` (2 preceding siblings ...)
2013-01-16 12:48 ` [PATCH 04/15] staging:iio:adis16400: Use adis library Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 06/15] staging:iio:adis16400: Add helper macros for channel declaration Lars-Peter Clausen
` (10 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Use the triggered buffer helper functions to setup and tear down the buffer for
the adis16400 instead of doing this manually. This also means that we switch
away from the deprecated sw_ring buffer and use the kfifo buffer now instead.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/imu/adis16400_core.c | 13 +--------
drivers/staging/iio/imu/adis16400_ring.c | 47 +++++---------------------------
2 files changed, 8 insertions(+), 52 deletions(-)
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index a948472..c545cd9 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -981,18 +981,10 @@ static int adis16400_probe(struct spi_device *spi)
if (ret)
goto error_free_dev;
- ret = iio_buffer_register(indio_dev,
- st->variant->channels,
- st->variant->num_channels);
- if (ret) {
- dev_err(&spi->dev, "failed to initialize the ring\n");
- goto error_unreg_ring_funcs;
- }
-
if (spi->irq) {
ret = adis_probe_trigger(&st->adis, indio_dev);
if (ret)
- goto error_uninitialize_ring;
+ goto error_unreg_ring_funcs;
}
/* Get the device into a sane initial state */
@@ -1008,8 +1000,6 @@ static int adis16400_probe(struct spi_device *spi)
error_remove_trigger:
if (spi->irq)
adis_remove_trigger(&st->adis);
-error_uninitialize_ring:
- iio_buffer_unregister(indio_dev);
error_unreg_ring_funcs:
adis16400_unconfigure_ring(indio_dev);
error_free_dev:
@@ -1029,7 +1019,6 @@ static int adis16400_remove(struct spi_device *spi)
if (spi->irq)
adis_remove_trigger(&st->adis);
- iio_buffer_unregister(indio_dev);
adis16400_unconfigure_ring(indio_dev);
iio_device_free(indio_dev);
diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c
index 6c5b0be..e421278 100644
--- a/drivers/staging/iio/imu/adis16400_ring.c
+++ b/drivers/staging/iio/imu/adis16400_ring.c
@@ -7,7 +7,8 @@
#include <linux/export.h>
#include <linux/iio/iio.h>
-#include "../ring_sw.h"
+#include <linux/iio/buffer.h>
+#include <linux/iio/triggered_buffer.h>
#include <linux/iio/trigger_consumer.h>
#include "adis16400.h"
@@ -159,47 +160,13 @@ done:
return IRQ_HANDLED;
}
-void adis16400_unconfigure_ring(struct iio_dev *indio_dev)
+int adis16400_configure_ring(struct iio_dev *indio_dev)
{
- iio_dealloc_pollfunc(indio_dev->pollfunc);
- iio_sw_rb_free(indio_dev->buffer);
+ return iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
+ &adis16400_trigger_handler, NULL);
}
-static const struct iio_buffer_setup_ops adis16400_ring_setup_ops = {
- .preenable = &iio_sw_buffer_preenable,
- .postenable = &iio_triggered_buffer_postenable,
- .predisable = &iio_triggered_buffer_predisable,
-};
-
-int adis16400_configure_ring(struct iio_dev *indio_dev)
+void adis16400_unconfigure_ring(struct iio_dev *indio_dev)
{
- int ret = 0;
- struct iio_buffer *ring;
-
- ring = iio_sw_rb_allocate(indio_dev);
- if (!ring) {
- ret = -ENOMEM;
- return ret;
- }
- indio_dev->buffer = ring;
- ring->scan_timestamp = true;
- indio_dev->setup_ops = &adis16400_ring_setup_ops;
-
- indio_dev->pollfunc = iio_alloc_pollfunc(&iio_pollfunc_store_time,
- &adis16400_trigger_handler,
- IRQF_ONESHOT,
- indio_dev,
- "%s_consumer%d",
- indio_dev->name,
- indio_dev->id);
- if (indio_dev->pollfunc == NULL) {
- ret = -ENOMEM;
- goto error_iio_sw_rb_free;
- }
-
- indio_dev->modes |= INDIO_BUFFER_TRIGGERED;
- return 0;
-error_iio_sw_rb_free:
- iio_sw_rb_free(indio_dev->buffer);
- return ret;
+ iio_triggered_buffer_cleanup(indio_dev);
}
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 06/15] staging:iio:adis16400: Add helper macros for channel declaration
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
` (3 preceding siblings ...)
2013-01-16 12:48 ` [PATCH 05/15] staging:iio:adis16400: Use triggered buffer setup helper function Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 07/15] staging:iio:adis16400: Preallocate transfer message Lars-Peter Clausen
` (9 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Most of the channels declared in the adis16400 driver look quite similar. This
patch adds a bunch of helper macros to initialize the channel spec for this
driver. This allows us to drastically reduce the number of lines of code needed
for the channel spec declaration.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/imu/adis16400_core.c | 557 ++++++++-----------------------
1 file changed, 140 insertions(+), 417 deletions(-)
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index c545cd9..f1d747a 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -375,436 +375,159 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
}
}
+#define ADIS16400_VOLTAGE_CHAN(addr, bits, name, si) { \
+ .type = IIO_VOLTAGE, \
+ .indexed = 1, \
+ .channel = 0, \
+ .extend_name = name, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
+ .address = (addr), \
+ .scan_index = (si), \
+ .scan_type = IIO_ST('u', (bits), 16, 0), \
+}
+
+#define ADIS16400_SUPPLY_CHAN(addr, bits) \
+ ADIS16400_VOLTAGE_CHAN(addr, bits, "supply", ADIS16400_SCAN_SUPPLY)
+
+#define ADIS16400_AUX_ADC_CHAN(addr, bits) \
+ ADIS16400_VOLTAGE_CHAN(addr, bits, NULL, ADIS16400_SCAN_ADC)
+
+#define ADIS16400_GYRO_CHAN(mod, addr, bits) { \
+ .type = IIO_ANGL_VEL, \
+ .modified = 1, \
+ .channel2 = IIO_MOD_ ## mod, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT | \
+ IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, \
+ .address = addr, \
+ .scan_index = ADIS16400_SCAN_GYRO_ ## mod, \
+ .scan_type = IIO_ST('s', (bits), 16, 0), \
+}
+
+#define ADIS16400_ACCEL_CHAN(mod, addr, bits) { \
+ .type = IIO_ACCEL, \
+ .modified = 1, \
+ .channel2 = IIO_MOD_ ## mod, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT | \
+ IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, \
+ .address = (addr), \
+ .scan_index = ADIS16400_SCAN_ACC_ ## mod, \
+ .scan_type = IIO_ST('s', (bits), 16, 0), \
+}
+
+#define ADIS16400_MAGN_CHAN(mod, addr, bits) { \
+ .type = IIO_MAGN, \
+ .modified = 1, \
+ .channel2 = IIO_MOD_ ## mod, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT | \
+ IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, \
+ .address = (addr), \
+ .scan_index = ADIS16400_SCAN_MAGN_ ## mod, \
+ .scan_type = IIO_ST('s', (bits), 16, 0), \
+}
+
+#define ADIS16400_MOD_TEMP_NAME_X "x"
+#define ADIS16400_MOD_TEMP_NAME_Y "y"
+#define ADIS16400_MOD_TEMP_NAME_Z "z"
+
+#define ADIS16400_MOD_TEMP_CHAN(mod, addr, bits) { \
+ .type = IIO_TEMP, \
+ .indexed = 1, \
+ .channel = 0, \
+ .extend_name = ADIS16400_MOD_TEMP_NAME_ ## mod, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT | \
+ IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, \
+ .address = (addr), \
+ .scan_index = ADIS16350_SCAN_TEMP_ ## mod, \
+ .scan_type = IIO_ST('s', (bits), 16, 0), \
+}
+
+#define ADIS16400_TEMP_CHAN(addr, bits) { \
+ .type = IIO_TEMP, \
+ .indexed = 1, \
+ .channel = 0, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_OFFSET_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
+ .address = (addr), \
+ .scan_index = ADIS16350_SCAN_TEMP_X, \
+ .scan_type = IIO_ST('s', (bits), 16, 0), \
+}
+
+#define ADIS16400_INCLI_CHAN(mod, addr, bits) { \
+ .type = IIO_INCLI, \
+ .modified = 1, \
+ .channel2 = IIO_MOD_ ## mod, \
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \
+ IIO_CHAN_INFO_SCALE_SHARED_BIT, \
+ .address = (addr), \
+ .scan_index = ADIS16300_SCAN_INCLI_ ## mod, \
+ .scan_type = IIO_ST('s', (bits), 16, 0), \
+}
+
static const struct iio_chan_spec adis16400_channels[] = {
- {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 0,
- .extend_name = "supply",
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = ADIS16400_SUPPLY_OUT,
- .scan_index = ADIS16400_SCAN_SUPPLY,
- .scan_type = IIO_ST('u', 14, 16, 0),
- }, {
- .type = IIO_ANGL_VEL,
- .modified = 1,
- .channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_XGYRO_OUT,
- .scan_index = ADIS16400_SCAN_GYRO_X,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ANGL_VEL,
- .modified = 1,
- .channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_YGYRO_OUT,
- .scan_index = ADIS16400_SCAN_GYRO_Y,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ANGL_VEL,
- .modified = 1,
- .channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_ZGYRO_OUT,
- .scan_index = ADIS16400_SCAN_GYRO_Z,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ACCEL,
- .modified = 1,
- .channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_XACCL_OUT,
- .scan_index = ADIS16400_SCAN_ACC_X,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ACCEL,
- .modified = 1,
- .channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_YACCL_OUT,
- .scan_index = ADIS16400_SCAN_ACC_Y,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ACCEL,
- .modified = 1,
- .channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_ZACCL_OUT,
- .scan_index = ADIS16400_SCAN_ACC_Z,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_MAGN,
- .modified = 1,
- .channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_XMAGN_OUT,
- .scan_index = ADIS16400_SCAN_MAGN_X,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_MAGN,
- .modified = 1,
- .channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_YMAGN_OUT,
- .scan_index = ADIS16400_SCAN_MAGN_Y,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_MAGN,
- .modified = 1,
- .channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_ZMAGN_OUT,
- .scan_index = ADIS16400_SCAN_MAGN_Z,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_TEMP,
- .indexed = 1,
- .channel = 0,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = ADIS16400_TEMP_OUT,
- .scan_index = ADIS16350_SCAN_TEMP_X,
- .scan_type = IIO_ST('s', 12, 16, 0),
- }, {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 1,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = ADIS16400_AUX_ADC,
- .scan_index = ADIS16400_SCAN_ADC,
- .scan_type = IIO_ST('s', 12, 16, 0),
- },
+ ADIS16400_SUPPLY_CHAN(ADIS16400_SUPPLY_OUT, 14),
+ ADIS16400_GYRO_CHAN(X, ADIS16400_XGYRO_OUT, 14),
+ ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 14),
+ ADIS16400_GYRO_CHAN(Z, ADIS16400_ZGYRO_OUT, 14),
+ ADIS16400_ACCEL_CHAN(X, ADIS16400_XACCL_OUT, 14),
+ ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 14),
+ ADIS16400_ACCEL_CHAN(Z, ADIS16400_ZACCL_OUT, 14),
+ ADIS16400_MAGN_CHAN(X, ADIS16400_XMAGN_OUT, 14),
+ ADIS16400_MAGN_CHAN(Y, ADIS16400_YMAGN_OUT, 14),
+ ADIS16400_MAGN_CHAN(Z, ADIS16400_ZMAGN_OUT, 14),
+ ADIS16400_TEMP_CHAN(ADIS16400_TEMP_OUT, 12),
+ ADIS16400_AUX_ADC_CHAN(ADIS16400_AUX_ADC, 12),
IIO_CHAN_SOFT_TIMESTAMP(12)
};
static const struct iio_chan_spec adis16350_channels[] = {
- {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 0,
- .extend_name = "supply",
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = ADIS16400_SUPPLY_OUT,
- .scan_index = ADIS16400_SCAN_SUPPLY,
- .scan_type = IIO_ST('u', 12, 16, 0),
- }, {
- .type = IIO_ANGL_VEL,
- .modified = 1,
- .channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_XGYRO_OUT,
- .scan_index = ADIS16400_SCAN_GYRO_X,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ANGL_VEL,
- .modified = 1,
- .channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_YGYRO_OUT,
- .scan_index = ADIS16400_SCAN_GYRO_Y,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ANGL_VEL,
- .modified = 1,
- .channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_ZGYRO_OUT,
- .scan_index = ADIS16400_SCAN_GYRO_Z,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ACCEL,
- .modified = 1,
- .channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_XACCL_OUT,
- .scan_index = ADIS16400_SCAN_ACC_X,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ACCEL,
- .modified = 1,
- .channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_YACCL_OUT,
- .scan_index = ADIS16400_SCAN_ACC_Y,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ACCEL,
- .modified = 1,
- .channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_ZACCL_OUT,
- .scan_index = ADIS16400_SCAN_ACC_Z,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_TEMP,
- .indexed = 1,
- .channel = 0,
- .extend_name = "x",
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16350_XTEMP_OUT,
- .scan_index = ADIS16350_SCAN_TEMP_X,
- .scan_type = IIO_ST('s', 12, 16, 0),
- }, {
- .type = IIO_TEMP,
- .indexed = 1,
- .channel = 1,
- .extend_name = "y",
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16350_YTEMP_OUT,
- .scan_index = ADIS16350_SCAN_TEMP_Y,
- .scan_type = IIO_ST('s', 12, 16, 0),
- }, {
- .type = IIO_TEMP,
- .indexed = 1,
- .channel = 2,
- .extend_name = "z",
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = ADIS16350_ZTEMP_OUT,
- .scan_index = ADIS16350_SCAN_TEMP_Z,
- .scan_type = IIO_ST('s', 12, 16, 0),
- }, {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 1,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = ADIS16300_AUX_ADC,
- .scan_index = ADIS16400_SCAN_ADC,
- .scan_type = IIO_ST('s', 12, 16, 0),
- },
+ ADIS16400_SUPPLY_CHAN(ADIS16400_SUPPLY_OUT, 12),
+ ADIS16400_GYRO_CHAN(X, ADIS16400_XGYRO_OUT, 14),
+ ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 14),
+ ADIS16400_GYRO_CHAN(Z, ADIS16400_ZGYRO_OUT, 14),
+ ADIS16400_ACCEL_CHAN(X, ADIS16400_XACCL_OUT, 14),
+ ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 14),
+ ADIS16400_ACCEL_CHAN(Z, ADIS16400_ZACCL_OUT, 14),
+ ADIS16400_MAGN_CHAN(X, ADIS16400_XMAGN_OUT, 14),
+ ADIS16400_MAGN_CHAN(Y, ADIS16400_YMAGN_OUT, 14),
+ ADIS16400_MAGN_CHAN(Z, ADIS16400_ZMAGN_OUT, 14),
+ ADIS16400_AUX_ADC_CHAN(ADIS16300_AUX_ADC, 12),
+ ADIS16400_MOD_TEMP_CHAN(X, ADIS16350_XTEMP_OUT, 12),
+ ADIS16400_MOD_TEMP_CHAN(Y, ADIS16350_YTEMP_OUT, 12),
+ ADIS16400_MOD_TEMP_CHAN(Z, ADIS16350_ZTEMP_OUT, 12),
IIO_CHAN_SOFT_TIMESTAMP(11)
};
static const struct iio_chan_spec adis16300_channels[] = {
- {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 0,
- .extend_name = "supply",
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = ADIS16400_SUPPLY_OUT,
- .scan_index = ADIS16400_SCAN_SUPPLY,
- .scan_type = IIO_ST('u', 12, 16, 0),
- }, {
- .type = IIO_ANGL_VEL,
- .modified = 1,
- .channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_XGYRO_OUT,
- .scan_index = ADIS16400_SCAN_GYRO_X,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ACCEL,
- .modified = 1,
- .channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_XACCL_OUT,
- .scan_index = ADIS16400_SCAN_ACC_X,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ACCEL,
- .modified = 1,
- .channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_YACCL_OUT,
- .scan_index = ADIS16400_SCAN_ACC_Y,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ACCEL,
- .modified = 1,
- .channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_ZACCL_OUT,
- .scan_index = ADIS16400_SCAN_ACC_Z,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_TEMP,
- .indexed = 1,
- .channel = 0,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = ADIS16350_XTEMP_OUT,
- .scan_index = ADIS16350_SCAN_TEMP_X,
- .scan_type = IIO_ST('s', 12, 16, 0),
- }, {
- .type = IIO_VOLTAGE,
- .indexed = 1,
- .channel = 1,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SEPARATE_BIT,
- .address = ADIS16300_AUX_ADC,
- .scan_index = ADIS16400_SCAN_ADC,
- .scan_type = IIO_ST('s', 12, 16, 0),
- }, {
- .type = IIO_INCLI,
- .modified = 1,
- .channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- .address = ADIS16300_PITCH_OUT,
- .scan_index = ADIS16300_SCAN_INCLI_X,
- .scan_type = IIO_ST('s', 13, 16, 0),
- }, {
- .type = IIO_INCLI,
- .modified = 1,
- .channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- .address = ADIS16300_ROLL_OUT,
- .scan_index = ADIS16300_SCAN_INCLI_Y,
- .scan_type = IIO_ST('s', 13, 16, 0),
- },
+ ADIS16400_SUPPLY_CHAN(ADIS16400_SUPPLY_OUT, 12),
+ ADIS16400_GYRO_CHAN(X, ADIS16400_XGYRO_OUT, 14),
+ ADIS16400_ACCEL_CHAN(X, ADIS16400_XACCL_OUT, 14),
+ ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 14),
+ ADIS16400_ACCEL_CHAN(Z, ADIS16400_ZACCL_OUT, 14),
+ ADIS16400_TEMP_CHAN(ADIS16350_XTEMP_OUT, 12),
+ ADIS16400_AUX_ADC_CHAN(ADIS16300_AUX_ADC, 12),
+ ADIS16400_INCLI_CHAN(X, ADIS16300_PITCH_OUT, 13),
+ ADIS16400_INCLI_CHAN(Y, ADIS16300_ROLL_OUT, 13),
IIO_CHAN_SOFT_TIMESTAMP(14)
};
static const struct iio_chan_spec adis16334_channels[] = {
- {
- .type = IIO_ANGL_VEL,
- .modified = 1,
- .channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_XGYRO_OUT,
- .scan_index = ADIS16400_SCAN_GYRO_X,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ANGL_VEL,
- .modified = 1,
- .channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_YGYRO_OUT,
- .scan_index = ADIS16400_SCAN_GYRO_Y,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ANGL_VEL,
- .modified = 1,
- .channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_ZGYRO_OUT,
- .scan_index = ADIS16400_SCAN_GYRO_Z,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ACCEL,
- .modified = 1,
- .channel2 = IIO_MOD_X,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_XACCL_OUT,
- .scan_index = ADIS16400_SCAN_ACC_X,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ACCEL,
- .modified = 1,
- .channel2 = IIO_MOD_Y,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_YACCL_OUT,
- .scan_index = ADIS16400_SCAN_ACC_Y,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_ACCEL,
- .modified = 1,
- .channel2 = IIO_MOD_Z,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_CALIBBIAS_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT |
- IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT,
- .address = ADIS16400_ZACCL_OUT,
- .scan_index = ADIS16400_SCAN_ACC_Z,
- .scan_type = IIO_ST('s', 14, 16, 0),
- }, {
- .type = IIO_TEMP,
- .indexed = 1,
- .channel = 0,
- .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
- IIO_CHAN_INFO_OFFSET_SEPARATE_BIT |
- IIO_CHAN_INFO_SCALE_SHARED_BIT,
- .address = ADIS16350_XTEMP_OUT,
- .scan_index = ADIS16350_SCAN_TEMP_X,
- .scan_type = IIO_ST('s', 14, 16, 0),
- },
- IIO_CHAN_SOFT_TIMESTAMP(12)
+ ADIS16400_GYRO_CHAN(X, ADIS16400_XGYRO_OUT, 14),
+ ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 14),
+ ADIS16400_GYRO_CHAN(Z, ADIS16400_ZGYRO_OUT, 14),
+ ADIS16400_ACCEL_CHAN(X, ADIS16400_XACCL_OUT, 14),
+ ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 14),
+ ADIS16400_ACCEL_CHAN(Z, ADIS16400_ZACCL_OUT, 14),
+ ADIS16400_TEMP_CHAN(ADIS16350_XTEMP_OUT, 12),
+ IIO_CHAN_SOFT_TIMESTAMP(8)
};
static struct attribute *adis16400_attributes[] = {
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 07/15] staging:iio:adis16400: Preallocate transfer message
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
` (4 preceding siblings ...)
2013-01-16 12:48 ` [PATCH 06/15] staging:iio:adis16400: Add helper macros for channel declaration Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 08/15] staging:iio:adis16400: Remove unit suffix from samplerate attribute Lars-Peter Clausen
` (8 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Similar to like we already did for the generic adis library preallocate and
pre-construct the SPI transfer message for the adis16400. For devices which do
not support burst mode sampling does not differ from other adis devices and so
we use the generic functions of the adis library in this case. In burst mode we
can only sample all channels at once, so use the IIO cores demux facility
instead of doing this manually.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/imu/adis16400.h | 23 +---
drivers/staging/iio/imu/adis16400_core.c | 89 ++++++++++----
drivers/staging/iio/imu/adis16400_ring.c | 192 ++++++++++---------------------
3 files changed, 128 insertions(+), 176 deletions(-)
diff --git a/drivers/staging/iio/imu/adis16400.h b/drivers/staging/iio/imu/adis16400.h
index ce63ced..a3b9e56 100644
--- a/drivers/staging/iio/imu/adis16400.h
+++ b/drivers/staging/iio/imu/adis16400.h
@@ -190,27 +190,14 @@ ssize_t adis16400_read_data_from_ring(struct device *dev,
char *buf);
-int adis16400_configure_ring(struct iio_dev *indio_dev);
-void adis16400_unconfigure_ring(struct iio_dev *indio_dev);
+int adis16400_update_scan_mode(struct iio_dev *indio_dev,
+ const unsigned long *scan_mask);
+irqreturn_t adis16400_trigger_handler(int irq, void *p);
#else /* CONFIG_IIO_BUFFER */
-static inline ssize_t
-adis16400_read_data_from_ring(struct device *dev,
- struct device_attribute *attr,
- char *buf)
-{
- return 0;
-}
-
-static int adis16400_configure_ring(struct iio_dev *indio_dev)
-{
- return 0;
-}
-
-static inline void adis16400_unconfigure_ring(struct iio_dev *indio_dev)
-{
-}
+#define adis16400_update_scan_mode NULL
+#define adis16400_trigger_handler NULL
#endif /* CONFIG_IIO_BUFFER */
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index f1d747a..aa4ffcf 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -384,7 +384,13 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
.address = (addr), \
.scan_index = (si), \
- .scan_type = IIO_ST('u', (bits), 16, 0), \
+ .scan_type = { \
+ .sign = 'u', \
+ .realbits = (bits), \
+ .storagebits = 16, \
+ .shift = 0, \
+ .endianness = IIO_BE, \
+ }, \
}
#define ADIS16400_SUPPLY_CHAN(addr, bits) \
@@ -403,7 +409,13 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, \
.address = addr, \
.scan_index = ADIS16400_SCAN_GYRO_ ## mod, \
- .scan_type = IIO_ST('s', (bits), 16, 0), \
+ .scan_type = { \
+ .sign = 's', \
+ .realbits = (bits), \
+ .storagebits = 16, \
+ .shift = 0, \
+ .endianness = IIO_BE, \
+ }, \
}
#define ADIS16400_ACCEL_CHAN(mod, addr, bits) { \
@@ -416,7 +428,13 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, \
.address = (addr), \
.scan_index = ADIS16400_SCAN_ACC_ ## mod, \
- .scan_type = IIO_ST('s', (bits), 16, 0), \
+ .scan_type = { \
+ .sign = 's', \
+ .realbits = (bits), \
+ .storagebits = 16, \
+ .shift = 0, \
+ .endianness = IIO_BE, \
+ }, \
}
#define ADIS16400_MAGN_CHAN(mod, addr, bits) { \
@@ -428,7 +446,13 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, \
.address = (addr), \
.scan_index = ADIS16400_SCAN_MAGN_ ## mod, \
- .scan_type = IIO_ST('s', (bits), 16, 0), \
+ .scan_type = { \
+ .sign = 's', \
+ .realbits = (bits), \
+ .storagebits = 16, \
+ .shift = 0, \
+ .endianness = IIO_BE, \
+ }, \
}
#define ADIS16400_MOD_TEMP_NAME_X "x"
@@ -446,7 +470,13 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY_SHARED_BIT, \
.address = (addr), \
.scan_index = ADIS16350_SCAN_TEMP_ ## mod, \
- .scan_type = IIO_ST('s', (bits), 16, 0), \
+ .scan_type = { \
+ .sign = 's', \
+ .realbits = (bits), \
+ .storagebits = 16, \
+ .shift = 0, \
+ .endianness = IIO_BE, \
+ }, \
}
#define ADIS16400_TEMP_CHAN(addr, bits) { \
@@ -458,7 +488,13 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
IIO_CHAN_INFO_SCALE_SEPARATE_BIT, \
.address = (addr), \
.scan_index = ADIS16350_SCAN_TEMP_X, \
- .scan_type = IIO_ST('s', (bits), 16, 0), \
+ .scan_type = { \
+ .sign = 's', \
+ .realbits = (bits), \
+ .storagebits = 16, \
+ .shift = 0, \
+ .endianness = IIO_BE, \
+ }, \
}
#define ADIS16400_INCLI_CHAN(mod, addr, bits) { \
@@ -469,7 +505,13 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
IIO_CHAN_INFO_SCALE_SHARED_BIT, \
.address = (addr), \
.scan_index = ADIS16300_SCAN_INCLI_ ## mod, \
- .scan_type = IIO_ST('s', (bits), 16, 0), \
+ .scan_type = { \
+ .sign = 's', \
+ .realbits = (bits), \
+ .storagebits = 16, \
+ .shift = 0, \
+ .endianness = IIO_BE, \
+ }, \
}
static const struct iio_chan_spec adis16400_channels[] = {
@@ -625,6 +667,12 @@ static const struct iio_info adis16400_info = {
.read_raw = &adis16400_read_raw,
.write_raw = &adis16400_write_raw,
.attrs = &adis16400_attribute_group,
+ .update_scan_mode = adis16400_update_scan_mode,
+};
+
+static const unsigned long adis16400_burst_scan_mask[] = {
+ ~0UL,
+ 0,
};
static const char * const adis16400_status_error_msgs[] = {
@@ -696,35 +744,30 @@ static int adis16400_probe(struct spi_device *spi)
indio_dev->info = &adis16400_info;
indio_dev->modes = INDIO_DIRECT_MODE;
+ if (!(st->variant->flags & ADIS16400_NO_BURST))
+ indio_dev->available_scan_masks = adis16400_burst_scan_mask;
+
ret = adis_init(&st->adis, indio_dev, spi, &adis16400_data);
if (ret)
goto error_free_dev;
- ret = adis16400_configure_ring(indio_dev);
+ ret = adis_setup_buffer_and_trigger(&st->adis, indio_dev,
+ adis16400_trigger_handler);
if (ret)
goto error_free_dev;
- if (spi->irq) {
- ret = adis_probe_trigger(&st->adis, indio_dev);
- if (ret)
- goto error_unreg_ring_funcs;
- }
-
/* Get the device into a sane initial state */
ret = adis16400_initial_setup(indio_dev);
if (ret)
- goto error_remove_trigger;
+ goto error_cleanup_buffer;
ret = iio_device_register(indio_dev);
if (ret)
- goto error_remove_trigger;
+ goto error_cleanup_buffer;
return 0;
-error_remove_trigger:
- if (spi->irq)
- adis_remove_trigger(&st->adis);
-error_unreg_ring_funcs:
- adis16400_unconfigure_ring(indio_dev);
+error_cleanup_buffer:
+ adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
error_free_dev:
iio_device_free(indio_dev);
error_ret:
@@ -740,9 +783,7 @@ static int adis16400_remove(struct spi_device *spi)
iio_device_unregister(indio_dev);
adis16400_stop_device(indio_dev);
- if (spi->irq)
- adis_remove_trigger(&st->adis);
- adis16400_unconfigure_ring(indio_dev);
+ adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
iio_device_free(indio_dev);
diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/staging/iio/imu/adis16400_ring.c
index e421278..054c01d 100644
--- a/drivers/staging/iio/imu/adis16400_ring.c
+++ b/drivers/staging/iio/imu/adis16400_ring.c
@@ -13,160 +13,84 @@
#include "adis16400.h"
-/**
- * adis16400_spi_read_burst() - read all data registers
- * @indio_dev: the IIO device
- * @rx: somewhere to pass back the value read (min size is 24 bytes)
- **/
-static int adis16400_spi_read_burst(struct iio_dev *indio_dev, u8 *rx)
+int adis16400_update_scan_mode(struct iio_dev *indio_dev,
+ const unsigned long *scan_mask)
{
- struct spi_message msg;
struct adis16400_state *st = iio_priv(indio_dev);
- u32 old_speed_hz = st->adis.spi->max_speed_hz;
- int ret;
+ struct adis *adis = &st->adis;
+ uint16_t *tx, *rx;
- struct spi_transfer xfers[] = {
- {
- .tx_buf = st->adis.tx,
- .bits_per_word = 8,
- .len = 2,
- }, {
- .rx_buf = rx,
- .bits_per_word = 8,
- .len = 24,
- },
- };
-
- mutex_lock(&st->adis.txrx_lock);
- st->adis.tx[0] = ADIS_READ_REG(ADIS16400_GLOB_CMD);
- st->adis.tx[1] = 0;
-
- spi_message_init(&msg);
- spi_message_add_tail(&xfers[0], &msg);
- spi_message_add_tail(&xfers[1], &msg);
-
- st->adis.spi->max_speed_hz = min(ADIS16400_SPI_BURST, old_speed_hz);
- spi_setup(st->adis.spi);
-
- ret = spi_sync(st->adis.spi, &msg);
- if (ret)
- dev_err(&st->adis.spi->dev, "problem when burst reading");
+ if (st->variant->flags & ADIS16400_NO_BURST)
+ return adis_update_scan_mode(indio_dev, scan_mask);
- st->adis.spi->max_speed_hz = old_speed_hz;
- spi_setup(st->adis.spi);
- mutex_unlock(&st->adis.txrx_lock);
- return ret;
-}
-
-static const u16 read_all_tx_array[] = {
- cpu_to_be16(ADIS_READ_REG(ADIS16400_SUPPLY_OUT)),
- cpu_to_be16(ADIS_READ_REG(ADIS16400_XGYRO_OUT)),
- cpu_to_be16(ADIS_READ_REG(ADIS16400_YGYRO_OUT)),
- cpu_to_be16(ADIS_READ_REG(ADIS16400_ZGYRO_OUT)),
- cpu_to_be16(ADIS_READ_REG(ADIS16400_XACCL_OUT)),
- cpu_to_be16(ADIS_READ_REG(ADIS16400_YACCL_OUT)),
- cpu_to_be16(ADIS_READ_REG(ADIS16400_ZACCL_OUT)),
- cpu_to_be16(ADIS_READ_REG(ADIS16350_XTEMP_OUT)),
- cpu_to_be16(ADIS_READ_REG(ADIS16350_YTEMP_OUT)),
- cpu_to_be16(ADIS_READ_REG(ADIS16350_ZTEMP_OUT)),
- cpu_to_be16(ADIS_READ_REG(ADIS16400_AUX_ADC)),
-};
-
-static int adis16350_spi_read_all(struct iio_dev *indio_dev, u8 *rx)
-{
- struct adis16400_state *st = iio_priv(indio_dev);
+ kfree(adis->xfer);
+ kfree(adis->buffer);
- struct spi_message msg;
- int i, j = 0, ret;
- struct spi_transfer *xfers;
- int scan_count = bitmap_weight(indio_dev->active_scan_mask,
- indio_dev->masklength);
+ adis->xfer = kcalloc(2, sizeof(*adis->xfer), GFP_KERNEL);
+ if (!adis->xfer)
+ return -ENOMEM;
- xfers = kzalloc(sizeof(*xfers)*(scan_count + 1),
- GFP_KERNEL);
- if (xfers == NULL)
+ adis->buffer = kzalloc(indio_dev->scan_bytes + sizeof(u16),
+ GFP_KERNEL);
+ if (!adis->buffer)
return -ENOMEM;
- for (i = 0; i < ARRAY_SIZE(read_all_tx_array); i++)
- if (test_bit(i, indio_dev->active_scan_mask)) {
- xfers[j].tx_buf = &read_all_tx_array[i];
- xfers[j].bits_per_word = 16;
- xfers[j].len = 2;
- xfers[j + 1].rx_buf = rx + j*2;
- j++;
- }
- xfers[j].bits_per_word = 16;
- xfers[j].len = 2;
-
- spi_message_init(&msg);
- for (j = 0; j < scan_count + 1; j++)
- spi_message_add_tail(&xfers[j], &msg);
-
- ret = spi_sync(st->adis.spi, &msg);
- kfree(xfers);
-
- return ret;
+ rx = adis->buffer;
+ tx = adis->buffer + indio_dev->scan_bytes;
+
+ tx[0] = ADIS_READ_REG(ADIS16400_GLOB_CMD);
+ tx[1] = 0;
+
+ adis->xfer[0].tx_buf = tx;
+ adis->xfer[0].bits_per_word = 8;
+ adis->xfer[0].len = 2;
+ adis->xfer[1].tx_buf = tx;
+ adis->xfer[1].bits_per_word = 8;
+ adis->xfer[1].len = indio_dev->scan_bytes;
+
+ spi_message_init(&adis->msg);
+ spi_message_add_tail(&adis->xfer[0], &adis->msg);
+ spi_message_add_tail(&adis->xfer[1], &adis->msg);
+
+ return 0;
}
-/* Whilst this makes a lot of calls to iio_sw_ring functions - it is to device
- * specific to be rolled into the core.
- */
-static irqreturn_t adis16400_trigger_handler(int irq, void *p)
+irqreturn_t adis16400_trigger_handler(int irq, void *p)
{
struct iio_poll_func *pf = p;
struct iio_dev *indio_dev = pf->indio_dev;
struct adis16400_state *st = iio_priv(indio_dev);
- int i = 0, j, ret = 0;
- s16 *data;
-
- /* Asumption that long is enough for maximum channels */
- unsigned long mask = *indio_dev->active_scan_mask;
- int scan_count = bitmap_weight(indio_dev->active_scan_mask,
- indio_dev->masklength);
- data = kmalloc(indio_dev->scan_bytes, GFP_KERNEL);
- if (data == NULL) {
- dev_err(&st->adis.spi->dev, "memory alloc failed in ring bh");
- goto done;
+ struct adis *adis = &st->adis;
+ u32 old_speed_hz = st->adis.spi->max_speed_hz;
+ int ret;
+
+ if (!adis->buffer)
+ return -ENOMEM;
+
+ if (!(st->variant->flags & ADIS16400_NO_BURST) &&
+ st->adis.spi->max_speed_hz > ADIS16400_SPI_BURST) {
+ st->adis.spi->max_speed_hz = ADIS16400_SPI_BURST;
+ spi_setup(st->adis.spi);
}
- if (scan_count) {
- if (st->variant->flags & ADIS16400_NO_BURST) {
- ret = adis16350_spi_read_all(indio_dev, st->adis.rx);
- if (ret < 0)
- goto done;
- for (; i < scan_count; i++)
- data[i] = *(s16 *)(st->adis.rx + i*2);
- } else {
- ret = adis16400_spi_read_burst(indio_dev, st->adis.rx);
- if (ret < 0)
- goto done;
- for (; i < scan_count; i++) {
- j = __ffs(mask);
- mask &= ~(1 << j);
- data[i] = be16_to_cpup(
- (__be16 *)&(st->adis.rx[j*2]));
- }
- }
+ ret = spi_sync(adis->spi, &adis->msg);
+ if (ret)
+ dev_err(&adis->spi->dev, "Failed to read data: %d\n", ret);
+
+ if (!(st->variant->flags & ADIS16400_NO_BURST)) {
+ st->adis.spi->max_speed_hz = old_speed_hz;
+ spi_setup(st->adis.spi);
}
+
/* Guaranteed to be aligned with 8 byte boundary */
- if (indio_dev->scan_timestamp)
- *((s64 *)(data + ((i + 3)/4)*4)) = pf->timestamp;
- iio_push_to_buffers(indio_dev, (u8 *) data);
+ if (indio_dev->scan_timestamp) {
+ void *b = adis->buffer + indio_dev->scan_bytes - sizeof(s64);
+ *(s64 *)b = pf->timestamp;
+ }
+
+ iio_push_to_buffers(indio_dev, adis->buffer);
-done:
- kfree(data);
iio_trigger_notify_done(indio_dev->trig);
return IRQ_HANDLED;
}
-
-int adis16400_configure_ring(struct iio_dev *indio_dev)
-{
- return iio_triggered_buffer_setup(indio_dev, &iio_pollfunc_store_time,
- &adis16400_trigger_handler, NULL);
-}
-
-void adis16400_unconfigure_ring(struct iio_dev *indio_dev)
-{
- iio_triggered_buffer_cleanup(indio_dev);
-}
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 08/15] staging:iio:adis16400: Remove unit suffix from samplerate attribute
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
` (5 preceding siblings ...)
2013-01-16 12:48 ` [PATCH 07/15] staging:iio:adis16400: Preallocate transfer message Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 09/15] staging:iio:adis16400: Remove samplerate_available attribute Lars-Peter Clausen
` (7 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
To be compliant to the IIO specification we should not include the "SPS" suffix
in the "samplerate" attribute contents.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/imu/adis16400_core.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index aa4ffcf..9429072 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -116,7 +116,7 @@ static ssize_t adis16400_read_frequency(struct device *dev,
ret = st->variant->get_freq(st);
if (ret < 0)
return ret;
- len = sprintf(buf, "%d SPS\n", ret);
+ len = sprintf(buf, "%d\n", ret);
return len;
}
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 09/15] staging:iio:adis16400: Remove samplerate_available attribute
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
` (6 preceding siblings ...)
2013-01-16 12:48 ` [PATCH 08/15] staging:iio:adis16400: Remove unit suffix from samplerate attribute Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 10/15] staging:iio:adis16400: Code style cleanup Lars-Peter Clausen
` (6 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
While the samplerate supported by the devices which are supported by this driver
is not continuous it supports a wide range, much more than currently listed in
the samplerate_available attribute. Also it accepts all values written to the
samplerate attribute and will round-up them to the nearest supported sample
rate. So remove the samplerate_available attribute.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/imu/adis16400_core.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index 9429072..c08490b 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -247,8 +247,6 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
adis16400_read_frequency,
adis16400_write_frequency);
-static IIO_CONST_ATTR_SAMP_FREQ_AVAIL("409 546 819 1638");
-
static const u8 adis16400_addresses[] = {
[ADIS16400_SCAN_GYRO_X] = ADIS16400_XGYRO_OFF,
[ADIS16400_SCAN_GYRO_Y] = ADIS16400_YGYRO_OFF,
@@ -574,7 +572,6 @@ static const struct iio_chan_spec adis16334_channels[] = {
static struct attribute *adis16400_attributes[] = {
&iio_dev_attr_sampling_frequency.dev_attr.attr,
- &iio_const_attr_sampling_frequency_available.dev_attr.attr,
NULL
};
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 10/15] staging:iio:adis16400: Code style cleanup
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
` (7 preceding siblings ...)
2013-01-16 12:48 ` [PATCH 09/15] staging:iio:adis16400: Remove samplerate_available attribute Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-16 12:58 ` Jonathan Cameron
2013-01-16 12:48 ` [PATCH 11/15] staging:iio: Move adis16400 out of staging Lars-Peter Clausen
` (5 subsequent siblings)
14 siblings, 1 reply; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Do a set of minor miscellaneous code style cleanups for the adis16400 before
moving it out of staging. Delete outdated comments, removed excess whitespace,
add missing whitespace, replace u{8,16} with uint{8,16}_t.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/staging/iio/imu/adis16400_core.c | 81 +++++++++++++++-----------------
1 file changed, 37 insertions(+), 44 deletions(-)
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
index c08490b..1bbe5ee 100644
--- a/drivers/staging/iio/imu/adis16400_core.c
+++ b/drivers/staging/iio/imu/adis16400_core.c
@@ -45,7 +45,7 @@ enum adis16400_chip_variant {
static int adis16334_get_freq(struct adis16400_state *st)
{
int ret;
- u16 t;
+ uint16_t t;
ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
if (ret < 0)
@@ -78,12 +78,13 @@ static int adis16334_set_freq(struct adis16400_state *st, unsigned int freq)
static int adis16400_get_freq(struct adis16400_state *st)
{
int sps, ret;
- u16 t;
+ uint16_t t;
ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
if (ret < 0)
return ret;
- sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
+
+ sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
sps /= (t & ADIS16400_SMPL_PRD_DIV_MASK) + 1;
return sps;
@@ -97,6 +98,7 @@ static int adis16400_set_freq(struct adis16400_state *st, unsigned int freq)
if (t > 0)
t--;
t &= ADIS16400_SMPL_PRD_DIV_MASK;
+
if ((t & ADIS16400_SMPL_PRD_DIV_MASK) >= 0x0A)
st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW;
else
@@ -111,13 +113,13 @@ static ssize_t adis16400_read_frequency(struct device *dev,
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct adis16400_state *st = iio_priv(indio_dev);
- int ret, len = 0;
+ int ret;
ret = st->variant->get_freq(st);
if (ret < 0)
return ret;
- len = sprintf(buf, "%d\n", ret);
- return len;
+
+ return sprintf(buf, "%d\n", ret);
}
static const unsigned adis16400_3db_divisors[] = {
@@ -134,8 +136,8 @@ static const unsigned adis16400_3db_divisors[] = {
static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int val)
{
struct adis16400_state *st = iio_priv(indio_dev);
+ uint16_t val16;
int i, ret;
- u16 val16;
for (i = ARRAY_SIZE(adis16400_3db_divisors) - 1; i >= 1; i--) {
if (sps / adis16400_3db_divisors[i] >= val)
@@ -152,26 +154,22 @@ static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int val)
}
static ssize_t adis16400_write_frequency(struct device *dev,
- struct device_attribute *attr,
- const char *buf,
- size_t len)
+ struct device_attribute *attr, const char *buf, size_t len)
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct adis16400_state *st = iio_priv(indio_dev);
long val;
int ret;
- ret = strict_strtol(buf, 10, &val);
+ ret = kstrtol(buf, 10, &val);
if (ret)
return ret;
+
if (val == 0)
return -EINVAL;
mutex_lock(&indio_dev->mlock);
-
st->variant->set_freq(st, val);
-
- /* Also update the filter */
mutex_unlock(&indio_dev->mlock);
return ret ? ret : len;
@@ -182,9 +180,9 @@ static int adis16400_stop_device(struct iio_dev *indio_dev)
{
struct adis16400_state *st = iio_priv(indio_dev);
int ret;
- u16 val = ADIS16400_SLP_CNT_POWER_OFF;
- ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT, val);
+ ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT,
+ ADIS16400_SLP_CNT_POWER_OFF);
if (ret)
dev_err(&indio_dev->dev,
"problem with turning device off: SLP_CNT");
@@ -194,10 +192,10 @@ static int adis16400_stop_device(struct iio_dev *indio_dev)
static int adis16400_initial_setup(struct iio_dev *indio_dev)
{
- int ret;
- u16 prod_id, smp_prd;
- unsigned int device_id;
struct adis16400_state *st = iio_priv(indio_dev);
+ uint16_t prod_id, smp_prd;
+ unsigned int device_id;
+ int ret;
/* use low spi speed for init if the device has a slow mode */
if (st->variant->flags & ADIS16400_HAS_SLOW_MODE)
@@ -224,8 +222,8 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev)
device_id, prod_id);
dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n",
- indio_dev->name, prod_id,
- st->adis.spi->chip_select, st->adis.spi->irq);
+ indio_dev->name, prod_id,
+ st->adis.spi->chip_select, st->adis.spi->irq);
}
/* use high spi speed if possible */
if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {
@@ -247,7 +245,7 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
adis16400_read_frequency,
adis16400_write_frequency);
-static const u8 adis16400_addresses[] = {
+static const uint8_t adis16400_addresses[] = {
[ADIS16400_SCAN_GYRO_X] = ADIS16400_XGYRO_OFF,
[ADIS16400_SCAN_GYRO_Y] = ADIS16400_YGYRO_OFF,
[ADIS16400_SCAN_GYRO_Z] = ADIS16400_ZGYRO_OFF,
@@ -257,15 +255,12 @@ static const u8 adis16400_addresses[] = {
};
static int adis16400_write_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int val,
- int val2,
- long mask)
+ struct iio_chan_spec const *chan, int val, int val2, long info)
{
struct adis16400_state *st = iio_priv(indio_dev);
int ret, sps;
- switch (mask) {
+ switch (info) {
case IIO_CHAN_INFO_CALIBBIAS:
mutex_lock(&indio_dev->mlock);
ret = adis_write_reg_16(&st->adis,
@@ -273,8 +268,10 @@ static int adis16400_write_raw(struct iio_dev *indio_dev,
mutex_unlock(&indio_dev->mlock);
return ret;
case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
- /* Need to cache values so we can update if the frequency
- changes */
+ /*
+ * Need to cache values so we can update if the frequency
+ * changes.
+ */
mutex_lock(&indio_dev->mlock);
st->filt_int = val;
/* Work out update to current value */
@@ -293,16 +290,13 @@ static int adis16400_write_raw(struct iio_dev *indio_dev,
}
static int adis16400_read_raw(struct iio_dev *indio_dev,
- struct iio_chan_spec const *chan,
- int *val,
- int *val2,
- long mask)
+ struct iio_chan_spec const *chan, int *val, int *val2, long info)
{
struct adis16400_state *st = iio_priv(indio_dev);
+ int16_t val16;
int ret;
- s16 val16;
- switch (mask) {
+ switch (info) {
case IIO_CHAN_INFO_RAW:
return adis_single_conversion(indio_dev, chan, 0, val);
case IIO_CHAN_INFO_SCALE:
@@ -721,13 +715,14 @@ static const struct adis_data adis16400_data = {
static int adis16400_probe(struct spi_device *spi)
{
- int ret;
struct adis16400_state *st;
- struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
- if (indio_dev == NULL) {
- ret = -ENOMEM;
- goto error_ret;
- }
+ struct iio_dev *indio_dev;
+ int ret;
+
+ indio_dev = iio_device_alloc(sizeof(*st));
+ if (indio_dev == NULL)
+ return -ENOMEM;
+
st = iio_priv(indio_dev);
/* this is only used for removal purposes */
spi_set_drvdata(spi, indio_dev);
@@ -767,14 +762,12 @@ error_cleanup_buffer:
adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
error_free_dev:
iio_device_free(indio_dev);
-error_ret:
return ret;
}
-/* fixme, confirm ordering in this function */
static int adis16400_remove(struct spi_device *spi)
{
- struct iio_dev *indio_dev = spi_get_drvdata(spi);
+ struct iio_dev *indio_dev = spi_get_drvdata(spi);
struct adis16400_state *st = iio_priv(indio_dev);
iio_device_unregister(indio_dev);
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 11/15] staging:iio: Move adis16400 out of staging
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
` (8 preceding siblings ...)
2013-01-16 12:48 ` [PATCH 10/15] staging:iio:adis16400: Code style cleanup Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 12/15] iio:adis16400: Increase samplerate precession Lars-Peter Clausen
` (4 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
This adis16400 driver is in pretty good shape now, so move it out of staging.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/imu/Kconfig | 11 +++++++++++
drivers/iio/imu/Makefile | 3 +++
drivers/{staging => }/iio/imu/adis16400.h | 0
.../imu/adis16400_ring.c => iio/imu/adis16400_buffer.c} | 0
drivers/{staging => }/iio/imu/adis16400_core.c | 0
drivers/staging/iio/Kconfig | 1 -
drivers/staging/iio/Makefile | 1 -
drivers/staging/iio/imu/Kconfig | 17 -----------------
drivers/staging/iio/imu/Makefile | 7 -------
9 files changed, 14 insertions(+), 26 deletions(-)
rename drivers/{staging => }/iio/imu/adis16400.h (100%)
rename drivers/{staging/iio/imu/adis16400_ring.c => iio/imu/adis16400_buffer.c} (100%)
rename drivers/{staging => }/iio/imu/adis16400_core.c (100%)
delete mode 100644 drivers/staging/iio/imu/Kconfig
delete mode 100644 drivers/staging/iio/imu/Makefile
diff --git a/drivers/iio/imu/Kconfig b/drivers/iio/imu/Kconfig
index 3d79a40..47f66ed 100644
--- a/drivers/iio/imu/Kconfig
+++ b/drivers/iio/imu/Kconfig
@@ -3,6 +3,17 @@
#
menu "Inertial measurement units"
+config ADIS16400
+ tristate "Analog Devices ADIS16400 and similar IMU SPI driver"
+ depends on SPI
+ select IIO_ADIS_LIB
+ select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
+ help
+ Say yes here to build support for Analog Devices adis16300, adis16344,
+ adis16350, adis16354, adis16355, adis16360, adis16362, adis16364,
+ adis16365, adis16400 and adis16405 triaxial inertial sensors
+ (adis16400 series also have magnetometers).
+
config ADIS16480
tristate "Analog Devices ADIS16480 and similar IMU driver"
depends on SPI
diff --git a/drivers/iio/imu/Makefile b/drivers/iio/imu/Makefile
index cfe5763..019b717 100644
--- a/drivers/iio/imu/Makefile
+++ b/drivers/iio/imu/Makefile
@@ -2,6 +2,9 @@
# Makefile for Inertial Measurement Units
#
+adis16400-y := adis16400_core.o
+adis16400-$(CONFIG_IIO_BUFFER) += adis16400_buffer.o
+obj-$(CONFIG_ADIS16400) += adis16400.o
obj-$(CONFIG_ADIS16480) += adis16480.o
adis_lib-y += adis.o
diff --git a/drivers/staging/iio/imu/adis16400.h b/drivers/iio/imu/adis16400.h
similarity index 100%
rename from drivers/staging/iio/imu/adis16400.h
rename to drivers/iio/imu/adis16400.h
diff --git a/drivers/staging/iio/imu/adis16400_ring.c b/drivers/iio/imu/adis16400_buffer.c
similarity index 100%
rename from drivers/staging/iio/imu/adis16400_ring.c
rename to drivers/iio/imu/adis16400_buffer.c
diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c
similarity index 100%
rename from drivers/staging/iio/imu/adis16400_core.c
rename to drivers/iio/imu/adis16400_core.c
diff --git a/drivers/staging/iio/Kconfig b/drivers/staging/iio/Kconfig
index ca56c75..94d60d5 100644
--- a/drivers/staging/iio/Kconfig
+++ b/drivers/staging/iio/Kconfig
@@ -32,7 +32,6 @@ source "drivers/staging/iio/cdc/Kconfig"
source "drivers/staging/iio/frequency/Kconfig"
source "drivers/staging/iio/gyro/Kconfig"
source "drivers/staging/iio/impedance-analyzer/Kconfig"
-source "drivers/staging/iio/imu/Kconfig"
source "drivers/staging/iio/light/Kconfig"
source "drivers/staging/iio/magnetometer/Kconfig"
source "drivers/staging/iio/meter/Kconfig"
diff --git a/drivers/staging/iio/Makefile b/drivers/staging/iio/Makefile
index fa6937d..468b7f8 100644
--- a/drivers/staging/iio/Makefile
+++ b/drivers/staging/iio/Makefile
@@ -20,7 +20,6 @@ obj-y += cdc/
obj-y += frequency/
obj-y += gyro/
obj-y += impedance-analyzer/
-obj-y += imu/
obj-y += light/
obj-y += magnetometer/
obj-y += meter/
diff --git a/drivers/staging/iio/imu/Kconfig b/drivers/staging/iio/imu/Kconfig
deleted file mode 100644
index 096afc8..0000000
--- a/drivers/staging/iio/imu/Kconfig
+++ /dev/null
@@ -1,17 +0,0 @@
-#
-# IIO imu drivers configuration
-#
-menu "Inertial measurement units"
-
-config ADIS16400
- tristate "Analog Devices ADIS16400 and similar IMU SPI driver"
- depends on SPI
- select IIO_ADIS_LIB
- select IIO_ADIS_LIB_BUFFER if IIO_BUFFER
- help
- Say yes here to build support for Analog Devices adis16300, adis16344,
- adis16350, adis16354, adis16355, adis16360, adis16362, adis16364,
- adis16365, adis16400 and adis16405 triaxial inertial sensors
- (adis16400 series also have magnetometers).
-
-endmenu
diff --git a/drivers/staging/iio/imu/Makefile b/drivers/staging/iio/imu/Makefile
deleted file mode 100644
index c9988f6..0000000
--- a/drivers/staging/iio/imu/Makefile
+++ /dev/null
@@ -1,7 +0,0 @@
-#
-# Makefile for Inertial Measurement Units
-#
-
-adis16400-y := adis16400_core.o
-adis16400-$(CONFIG_IIO_BUFFER) += adis16400_ring.o
-obj-$(CONFIG_ADIS16400) += adis16400.o
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 12/15] iio:adis16400: Increase samplerate precession
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
` (9 preceding siblings ...)
2013-01-16 12:48 ` [PATCH 11/15] staging:iio: Move adis16400 out of staging Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 13/15] iio:adis16400: Add support for the 52.85 Hz base sampling rate Lars-Peter Clausen
` (3 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
The devices supported by this drivers support sample rates with less than one
sample per second. To support this increase the samplerate precession to allow
setting (and reading) the samplerate with a milli-HZ precession.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/imu/adis16400_core.c | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c
index 1bbe5ee..8551fde 100644
--- a/drivers/iio/imu/adis16400_core.c
+++ b/drivers/iio/imu/adis16400_core.c
@@ -53,16 +53,15 @@ static int adis16334_get_freq(struct adis16400_state *st)
t >>= ADIS16334_RATE_DIV_SHIFT;
- return (8192 >> t) / 10;
+ return 819200 >> t;
}
static int adis16334_set_freq(struct adis16400_state *st, unsigned int freq)
{
unsigned int t;
- freq *= 10;
- if (freq < 8192)
- t = ilog2(8192 / freq);
+ if (freq < 819200)
+ t = ilog2(819200 / freq);
else
t = 0;
@@ -84,7 +83,7 @@ static int adis16400_get_freq(struct adis16400_state *st)
if (ret < 0)
return ret;
- sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
+ sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 52851 : 1638404;
sps /= (t & ADIS16400_SMPL_PRD_DIV_MASK) + 1;
return sps;
@@ -94,7 +93,7 @@ static int adis16400_set_freq(struct adis16400_state *st, unsigned int freq)
{
unsigned int t;
- t = 1638 / freq;
+ t = 1638404 / freq;
if (t > 0)
t--;
t &= ADIS16400_SMPL_PRD_DIV_MASK;
@@ -119,7 +118,7 @@ static ssize_t adis16400_read_frequency(struct device *dev,
if (ret < 0)
return ret;
- return sprintf(buf, "%d\n", ret);
+ return sprintf(buf, "%d.%.3d\n", ret / 1000, ret % 1000);
}
static const unsigned adis16400_3db_divisors[] = {
@@ -158,14 +157,16 @@ static ssize_t adis16400_write_frequency(struct device *dev,
{
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
struct adis16400_state *st = iio_priv(indio_dev);
- long val;
+ int i, f, val;
int ret;
- ret = kstrtol(buf, 10, &val);
+ ret = iio_str_to_fixpoint(buf, 100, &i, &f);
if (ret)
return ret;
- if (val == 0)
+ val = i * 1000 + f;
+
+ if (val <= 0)
return -EINVAL;
mutex_lock(&indio_dev->mlock);
@@ -281,7 +282,8 @@ static int adis16400_write_raw(struct iio_dev *indio_dev,
return sps;
}
- ret = adis16400_set_filter(indio_dev, sps, val);
+ ret = adis16400_set_filter(indio_dev, sps,
+ val * 1000 + val2 / 1000);
mutex_unlock(&indio_dev->mlock);
return ret;
default:
@@ -355,9 +357,11 @@ static int adis16400_read_raw(struct iio_dev *indio_dev,
return ret;
}
ret = st->variant->get_freq(st);
- if (ret >= 0)
- *val = ret / adis16400_3db_divisors[val16 & 0x07];
- *val2 = 0;
+ if (ret >= 0) {
+ ret /= adis16400_3db_divisors[val16 & 0x07];
+ *val = ret / 1000;
+ *val2 = (ret % 1000) * 1000;
+ }
mutex_unlock(&indio_dev->mlock);
if (ret < 0)
return ret;
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 13/15] iio:adis16400: Add support for the 52.85 Hz base sampling rate
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
` (10 preceding siblings ...)
2013-01-16 12:48 ` [PATCH 12/15] iio:adis16400: Increase samplerate precession Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 14/15] iio:adis16400: Expose some debug information in debugfs Lars-Peter Clausen
` (2 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
The adis16400 and similar have two different base sampling rate available, from
which the actual sampling rate is derived. 1638 Hz and 52.85 Hz, switching to
the lower base sampling rate allows to support lower sampling rates.
This patch adds support for switching to the lower base sampling rate if the
requested sampling frequency is outside of the range which can be supported by
the higher base sampling rate.
The function which is used to read the current sampling rate already has support
for the lower sampling rate, so no changes are required there.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/imu/adis16400_core.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c
index 8551fde..58699ac 100644
--- a/drivers/iio/imu/adis16400_core.c
+++ b/drivers/iio/imu/adis16400_core.c
@@ -92,18 +92,26 @@ static int adis16400_get_freq(struct adis16400_state *st)
static int adis16400_set_freq(struct adis16400_state *st, unsigned int freq)
{
unsigned int t;
+ uint8_t val = 0;
t = 1638404 / freq;
- if (t > 0)
+ if (t >= 128) {
+ val |= ADIS16400_SMPL_PRD_TIME_BASE;
+ t = 52851 / freq;
+ if (t >= 128)
+ t = 127;
+ } else if (t != 0) {
t--;
- t &= ADIS16400_SMPL_PRD_DIV_MASK;
+ }
+
+ val |= t;
- if ((t & ADIS16400_SMPL_PRD_DIV_MASK) >= 0x0A)
+ if (t >= 0x0A || (val & ADIS16400_SMPL_PRD_TIME_BASE))
st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW;
else
st->adis.spi->max_speed_hz = ADIS16400_SPI_FAST;
- return adis_write_reg_8(&st->adis, ADIS16400_SMPL_PRD, t);
+ return adis_write_reg_8(&st->adis, ADIS16400_SMPL_PRD, val);
}
static ssize_t adis16400_read_frequency(struct device *dev,
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 14/15] iio:adis16400: Expose some debug information in debugfs
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
` (11 preceding siblings ...)
2013-01-16 12:48 ` [PATCH 13/15] iio:adis16400: Add support for the 52.85 Hz base sampling rate Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 15/15] iio:adis16400: Add support for the adis16448 Lars-Peter Clausen
2013-01-19 13:50 ` [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Jonathan Cameron
14 siblings, 0 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
Expose some information useful for debugging a device in debugfs. This includes
for now the flash count, the product id and the serial number and raw register
access.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/imu/adis16400.h | 4 ++
drivers/iio/imu/adis16400_core.c | 113 +++++++++++++++++++++++++++++++++++++--
2 files changed, 113 insertions(+), 4 deletions(-)
diff --git a/drivers/iio/imu/adis16400.h b/drivers/iio/imu/adis16400.h
index a3b9e56..6270185 100644
--- a/drivers/iio/imu/adis16400.h
+++ b/drivers/iio/imu/adis16400.h
@@ -74,7 +74,10 @@
#define ADIS16400_ALM_CTRL 0x48 /* Alarm control */
#define ADIS16400_AUX_DAC 0x4A /* Auxiliary DAC data */
+#define ADIS16334_LOT_ID1 0x52 /* Lot identification code 1 */
+#define ADIS16334_LOT_ID2 0x54 /* Lot identification code 2 */
#define ADIS16400_PRODUCT_ID 0x56 /* Product identifier */
+#define ADIS16334_SERIAL_NUMBER 0x58 /* Serial number, lot specific */
#define ADIS16400_ERROR_ACTIVE (1<<14)
#define ADIS16400_NEW_DATA (1<<14)
@@ -132,6 +135,7 @@
#define ADIS16400_HAS_PROD_ID BIT(0)
#define ADIS16400_NO_BURST BIT(1)
#define ADIS16400_HAS_SLOW_MODE BIT(2)
+#define ADIS16400_HAS_SERIAL_NUMBER BIT(3)
struct adis16400_state;
diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c
index 58699ac..e8f84c9 100644
--- a/drivers/iio/imu/adis16400_core.c
+++ b/drivers/iio/imu/adis16400_core.c
@@ -25,6 +25,7 @@
#include <linux/sysfs.h>
#include <linux/list.h>
#include <linux/module.h>
+#include <linux/debugfs.h>
#include <linux/iio/iio.h>
#include <linux/iio/sysfs.h>
@@ -32,6 +33,104 @@
#include "adis16400.h"
+#ifdef CONFIG_DEBUG_FS
+
+static ssize_t adis16400_show_serial_number(struct file *file,
+ char __user *userbuf, size_t count, loff_t *ppos)
+{
+ struct adis16400_state *st = file->private_data;
+ u16 lot1, lot2, serial_number;
+ char buf[16];
+ size_t len;
+ int ret;
+
+ ret = adis_read_reg_16(&st->adis, ADIS16334_LOT_ID1, &lot1);
+ if (ret < 0)
+ return ret;
+
+ ret = adis_read_reg_16(&st->adis, ADIS16334_LOT_ID2, &lot2);
+ if (ret < 0)
+ return ret;
+
+ ret = adis_read_reg_16(&st->adis, ADIS16334_SERIAL_NUMBER,
+ &serial_number);
+ if (ret < 0)
+ return ret;
+
+ len = snprintf(buf, sizeof(buf), "%.4x-%.4x-%.4x\n", lot1, lot2,
+ serial_number);
+
+ return simple_read_from_buffer(userbuf, count, ppos, buf, len);
+}
+
+static const struct file_operations adis16400_serial_number_fops = {
+ .open = simple_open,
+ .read = adis16400_show_serial_number,
+ .llseek = default_llseek,
+ .owner = THIS_MODULE,
+};
+
+static int adis16400_show_product_id(void *arg, u64 *val)
+{
+ struct adis16400_state *st = arg;
+ uint16_t prod_id;
+ int ret;
+
+ ret = adis_read_reg_16(&st->adis, ADIS16400_PRODUCT_ID, &prod_id);
+ if (ret < 0)
+ return ret;
+
+ *val = prod_id;
+
+ return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(adis16400_product_id_fops,
+ adis16400_show_product_id, NULL, "%lld\n");
+
+static int adis16400_show_flash_count(void *arg, u64 *val)
+{
+ struct adis16400_state *st = arg;
+ uint16_t flash_count;
+ int ret;
+
+ ret = adis_read_reg_16(&st->adis, ADIS16400_FLASH_CNT, &flash_count);
+ if (ret < 0)
+ return ret;
+
+ *val = flash_count;
+
+ return 0;
+}
+DEFINE_SIMPLE_ATTRIBUTE(adis16400_flash_count_fops,
+ adis16400_show_flash_count, NULL, "%lld\n");
+
+static int adis16400_debugfs_init(struct iio_dev *indio_dev)
+{
+ struct adis16400_state *st = iio_priv(indio_dev);
+
+ if (st->variant->flags & ADIS16400_HAS_SERIAL_NUMBER)
+ debugfs_create_file("serial_number", 0400,
+ indio_dev->debugfs_dentry, st,
+ &adis16400_serial_number_fops);
+ if (st->variant->flags & ADIS16400_HAS_PROD_ID)
+ debugfs_create_file("product_id", 0400,
+ indio_dev->debugfs_dentry, st,
+ &adis16400_product_id_fops);
+ debugfs_create_file("flash_count", 0400, indio_dev->debugfs_dentry,
+ st, &adis16400_flash_count_fops);
+
+ return 0;
+}
+
+#else
+
+static int adis16400_debugfs_init(struct iio_dev *indio_dev)
+{
+ return 0;
+}
+
+#endif
+
enum adis16400_chip_variant {
ADIS16300,
ADIS16334,
@@ -600,7 +699,8 @@ static struct adis16400_chip_info adis16400_chips[] = {
[ADIS16334] = {
.channels = adis16334_channels,
.num_channels = ARRAY_SIZE(adis16334_channels),
- .flags = ADIS16400_HAS_PROD_ID,
+ .flags = ADIS16400_HAS_PROD_ID | ADIS16400_NO_BURST |
+ ADIS16400_HAS_SERIAL_NUMBER,
.gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
.accel_scale_micro = IIO_G_TO_M_S_2(1000), /* 1 mg */
.temp_scale_nano = 67850000, /* 0.06785 C */
@@ -622,7 +722,8 @@ static struct adis16400_chip_info adis16400_chips[] = {
[ADIS16360] = {
.channels = adis16350_channels,
.num_channels = ARRAY_SIZE(adis16350_channels),
- .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE,
+ .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE |
+ ADIS16400_HAS_SERIAL_NUMBER,
.gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
.accel_scale_micro = IIO_G_TO_M_S_2(3333), /* 3.333 mg */
.temp_scale_nano = 136000000, /* 0.136 C */
@@ -633,7 +734,8 @@ static struct adis16400_chip_info adis16400_chips[] = {
[ADIS16362] = {
.channels = adis16350_channels,
.num_channels = ARRAY_SIZE(adis16350_channels),
- .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE,
+ .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE |
+ ADIS16400_HAS_SERIAL_NUMBER,
.gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
.accel_scale_micro = IIO_G_TO_M_S_2(333), /* 0.333 mg */
.temp_scale_nano = 136000000, /* 0.136 C */
@@ -644,7 +746,8 @@ static struct adis16400_chip_info adis16400_chips[] = {
[ADIS16364] = {
.channels = adis16350_channels,
.num_channels = ARRAY_SIZE(adis16350_channels),
- .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE,
+ .flags = ADIS16400_HAS_PROD_ID | ADIS16400_HAS_SLOW_MODE |
+ ADIS16400_HAS_SERIAL_NUMBER,
.gyro_scale_micro = IIO_DEGREE_TO_RAD(50000), /* 0.05 deg/s */
.accel_scale_micro = IIO_G_TO_M_S_2(1000), /* 1 mg */
.temp_scale_nano = 136000000, /* 0.136 C */
@@ -671,6 +774,7 @@ static const struct iio_info adis16400_info = {
.write_raw = &adis16400_write_raw,
.attrs = &adis16400_attribute_group,
.update_scan_mode = adis16400_update_scan_mode,
+ .debugfs_reg_access = adis_debugfs_reg_access,
};
static const unsigned long adis16400_burst_scan_mask[] = {
@@ -768,6 +872,7 @@ static int adis16400_probe(struct spi_device *spi)
if (ret)
goto error_cleanup_buffer;
+ adis16400_debugfs_init(indio_dev);
return 0;
error_cleanup_buffer:
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* [PATCH 15/15] iio:adis16400: Add support for the adis16448
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
` (12 preceding siblings ...)
2013-01-16 12:48 ` [PATCH 14/15] iio:adis16400: Expose some debug information in debugfs Lars-Peter Clausen
@ 2013-01-16 12:48 ` Lars-Peter Clausen
2013-01-19 13:50 ` [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Jonathan Cameron
14 siblings, 0 replies; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 12:48 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: linux-iio, Lars-Peter Clausen
The adis16448 is more or less from the same family of devices as supported by
this driver. It features three acceleration channels, three angular velocity
channels, three magnetometer channels, one temperature channels and one
barometric pressure channel.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
---
drivers/iio/imu/adis16400.h | 4 ++++
drivers/iio/imu/adis16400_core.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+)
diff --git a/drivers/iio/imu/adis16400.h b/drivers/iio/imu/adis16400.h
index 6270185..2f8f9d6 100644
--- a/drivers/iio/imu/adis16400.h
+++ b/drivers/iio/imu/adis16400.h
@@ -44,6 +44,9 @@
#define ADIS16300_ROLL_OUT 0x14 /* Y axis inclinometer output measurement */
#define ADIS16300_AUX_ADC 0x16 /* Auxiliary ADC measurement */
+#define ADIS16448_BARO_OUT 0x16 /* Barometric pressure output */
+#define ADIS16448_TEMP_OUT 0x18 /* Temperature output */
+
/* Calibration parameters */
#define ADIS16400_XGYRO_OFF 0x1A /* X-axis gyroscope bias offset factor */
#define ADIS16400_YGYRO_OFF 0x1C /* Y-axis gyroscope bias offset factor */
@@ -179,6 +182,7 @@ enum {
ADIS16400_SCAN_MAGN_X,
ADIS16400_SCAN_MAGN_Y,
ADIS16400_SCAN_MAGN_Z,
+ ADIS16400_SCAN_BARO,
ADIS16350_SCAN_TEMP_X,
ADIS16350_SCAN_TEMP_Y,
ADIS16350_SCAN_TEMP_Z,
diff --git a/drivers/iio/imu/adis16400_core.c b/drivers/iio/imu/adis16400_core.c
index e8f84c9..b7f215e 100644
--- a/drivers/iio/imu/adis16400_core.c
+++ b/drivers/iio/imu/adis16400_core.c
@@ -139,6 +139,7 @@ enum adis16400_chip_variant {
ADIS16362,
ADIS16364,
ADIS16400,
+ ADIS16448,
};
static int adis16334_get_freq(struct adis16400_state *st)
@@ -633,6 +634,28 @@ static const struct iio_chan_spec adis16400_channels[] = {
IIO_CHAN_SOFT_TIMESTAMP(12)
};
+static const struct iio_chan_spec adis16448_channels[] = {
+ ADIS16400_GYRO_CHAN(X, ADIS16400_XGYRO_OUT, 16),
+ ADIS16400_GYRO_CHAN(Y, ADIS16400_YGYRO_OUT, 16),
+ ADIS16400_GYRO_CHAN(Z, ADIS16400_ZGYRO_OUT, 16),
+ ADIS16400_ACCEL_CHAN(X, ADIS16400_XACCL_OUT, 16),
+ ADIS16400_ACCEL_CHAN(Y, ADIS16400_YACCL_OUT, 16),
+ ADIS16400_ACCEL_CHAN(Z, ADIS16400_ZACCL_OUT, 16),
+ ADIS16400_MAGN_CHAN(X, ADIS16400_XMAGN_OUT, 16),
+ ADIS16400_MAGN_CHAN(Y, ADIS16400_YMAGN_OUT, 16),
+ ADIS16400_MAGN_CHAN(Z, ADIS16400_ZMAGN_OUT, 16),
+ {
+ .type = IIO_PRESSURE,
+ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT |
+ IIO_CHAN_INFO_SCALE_SHARED_BIT,
+ .address = ADIS16448_BARO_OUT,
+ .scan_index = ADIS16400_SCAN_BARO,
+ .scan_type = IIO_ST('s', 16, 16, 0),
+ },
+ ADIS16400_TEMP_CHAN(ADIS16448_TEMP_OUT, 12),
+ IIO_CHAN_SOFT_TIMESTAMP(11)
+};
+
static const struct iio_chan_spec adis16350_channels[] = {
ADIS16400_SUPPLY_CHAN(ADIS16400_SUPPLY_OUT, 12),
ADIS16400_GYRO_CHAN(X, ADIS16400_XGYRO_OUT, 14),
@@ -765,6 +788,18 @@ static struct adis16400_chip_info adis16400_chips[] = {
.temp_offset = 25000000 / 140000, /* 25 C = 0x00 */
.set_freq = adis16400_set_freq,
.get_freq = adis16400_get_freq,
+ },
+ [ADIS16448] = {
+ .channels = adis16448_channels,
+ .num_channels = ARRAY_SIZE(adis16448_channels),
+ .flags = ADIS16400_HAS_PROD_ID |
+ ADIS16400_HAS_SERIAL_NUMBER,
+ .gyro_scale_micro = IIO_DEGREE_TO_RAD(10000), /* 0.01 deg/s */
+ .accel_scale_micro = IIO_G_TO_M_S_2(833), /* 1/1200 g */
+ .temp_scale_nano = 73860000, /* 0.07386 C */
+ .temp_offset = 31000000 / 73860, /* 31 C = 0x00 */
+ .set_freq = adis16334_set_freq,
+ .get_freq = adis16334_get_freq,
}
};
@@ -909,6 +944,7 @@ static const struct spi_device_id adis16400_id[] = {
{"adis16365", ADIS16360},
{"adis16400", ADIS16400},
{"adis16405", ADIS16400},
+ {"adis16448", ADIS16448},
{}
};
MODULE_DEVICE_TABLE(spi, adis16400_id);
--
1.8.0
^ permalink raw reply related [flat|nested] 23+ messages in thread
* Re: [PATCH 10/15] staging:iio:adis16400: Code style cleanup
2013-01-16 12:48 ` [PATCH 10/15] staging:iio:adis16400: Code style cleanup Lars-Peter Clausen
@ 2013-01-16 12:58 ` Jonathan Cameron
2013-01-16 13:11 ` Lars-Peter Clausen
0 siblings, 1 reply; 23+ messages in thread
From: Jonathan Cameron @ 2013-01-16 12:58 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio
On 16/01/13 12:48, Lars-Peter Clausen wrote:
> Do a set of minor miscellaneous code style cleanups for the adis16400 before
> moving it out of staging. Delete outdated comments, removed excess whitespace,
> add missing whitespace, replace u{8,16} with uint{8,16}_t.
Is there a move that I've missed to move away from u8 and friends?
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> ---
> drivers/staging/iio/imu/adis16400_core.c | 81 +++++++++++++++-----------------
> 1 file changed, 37 insertions(+), 44 deletions(-)
>
> diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
> index c08490b..1bbe5ee 100644
> --- a/drivers/staging/iio/imu/adis16400_core.c
> +++ b/drivers/staging/iio/imu/adis16400_core.c
> @@ -45,7 +45,7 @@ enum adis16400_chip_variant {
> static int adis16334_get_freq(struct adis16400_state *st)
> {
> int ret;
> - u16 t;
> + uint16_t t;
>
> ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
> if (ret < 0)
> @@ -78,12 +78,13 @@ static int adis16334_set_freq(struct adis16400_state *st, unsigned int freq)
> static int adis16400_get_freq(struct adis16400_state *st)
> {
> int sps, ret;
> - u16 t;
> + uint16_t t;
>
> ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
> if (ret < 0)
> return ret;
> - sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
> +
> + sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
> sps /= (t & ADIS16400_SMPL_PRD_DIV_MASK) + 1;
>
> return sps;
> @@ -97,6 +98,7 @@ static int adis16400_set_freq(struct adis16400_state *st, unsigned int freq)
> if (t > 0)
> t--;
> t &= ADIS16400_SMPL_PRD_DIV_MASK;
> +
> if ((t & ADIS16400_SMPL_PRD_DIV_MASK) >= 0x0A)
> st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW;
> else
> @@ -111,13 +113,13 @@ static ssize_t adis16400_read_frequency(struct device *dev,
> {
> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> struct adis16400_state *st = iio_priv(indio_dev);
> - int ret, len = 0;
> + int ret;
>
> ret = st->variant->get_freq(st);
> if (ret < 0)
> return ret;
> - len = sprintf(buf, "%d\n", ret);
> - return len;
> +
> + return sprintf(buf, "%d\n", ret);
> }
>
> static const unsigned adis16400_3db_divisors[] = {
> @@ -134,8 +136,8 @@ static const unsigned adis16400_3db_divisors[] = {
> static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int val)
> {
> struct adis16400_state *st = iio_priv(indio_dev);
> + uint16_t val16;
> int i, ret;
> - u16 val16;
>
> for (i = ARRAY_SIZE(adis16400_3db_divisors) - 1; i >= 1; i--) {
> if (sps / adis16400_3db_divisors[i] >= val)
> @@ -152,26 +154,22 @@ static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int val)
> }
>
> static ssize_t adis16400_write_frequency(struct device *dev,
> - struct device_attribute *attr,
> - const char *buf,
> - size_t len)
> + struct device_attribute *attr, const char *buf, size_t len)
> {
> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> struct adis16400_state *st = iio_priv(indio_dev);
> long val;
> int ret;
>
> - ret = strict_strtol(buf, 10, &val);
> + ret = kstrtol(buf, 10, &val);
> if (ret)
> return ret;
> +
> if (val == 0)
> return -EINVAL;
>
> mutex_lock(&indio_dev->mlock);
> -
> st->variant->set_freq(st, val);
> -
> - /* Also update the filter */
> mutex_unlock(&indio_dev->mlock);
>
> return ret ? ret : len;
> @@ -182,9 +180,9 @@ static int adis16400_stop_device(struct iio_dev *indio_dev)
> {
> struct adis16400_state *st = iio_priv(indio_dev);
> int ret;
> - u16 val = ADIS16400_SLP_CNT_POWER_OFF;
>
> - ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT, val);
> + ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT,
> + ADIS16400_SLP_CNT_POWER_OFF);
> if (ret)
> dev_err(&indio_dev->dev,
> "problem with turning device off: SLP_CNT");
> @@ -194,10 +192,10 @@ static int adis16400_stop_device(struct iio_dev *indio_dev)
>
> static int adis16400_initial_setup(struct iio_dev *indio_dev)
> {
> - int ret;
> - u16 prod_id, smp_prd;
> - unsigned int device_id;
> struct adis16400_state *st = iio_priv(indio_dev);
> + uint16_t prod_id, smp_prd;
> + unsigned int device_id;
> + int ret;
>
> /* use low spi speed for init if the device has a slow mode */
> if (st->variant->flags & ADIS16400_HAS_SLOW_MODE)
> @@ -224,8 +222,8 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev)
> device_id, prod_id);
>
> dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n",
> - indio_dev->name, prod_id,
> - st->adis.spi->chip_select, st->adis.spi->irq);
> + indio_dev->name, prod_id,
> + st->adis.spi->chip_select, st->adis.spi->irq);
> }
> /* use high spi speed if possible */
> if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {
> @@ -247,7 +245,7 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
> adis16400_read_frequency,
> adis16400_write_frequency);
>
> -static const u8 adis16400_addresses[] = {
> +static const uint8_t adis16400_addresses[] = {
> [ADIS16400_SCAN_GYRO_X] = ADIS16400_XGYRO_OFF,
> [ADIS16400_SCAN_GYRO_Y] = ADIS16400_YGYRO_OFF,
> [ADIS16400_SCAN_GYRO_Z] = ADIS16400_ZGYRO_OFF,
> @@ -257,15 +255,12 @@ static const u8 adis16400_addresses[] = {
> };
>
> static int adis16400_write_raw(struct iio_dev *indio_dev,
> - struct iio_chan_spec const *chan,
> - int val,
> - int val2,
> - long mask)
> + struct iio_chan_spec const *chan, int val, int val2, long info)
> {
> struct adis16400_state *st = iio_priv(indio_dev);
> int ret, sps;
>
> - switch (mask) {
> + switch (info) {
> case IIO_CHAN_INFO_CALIBBIAS:
> mutex_lock(&indio_dev->mlock);
> ret = adis_write_reg_16(&st->adis,
> @@ -273,8 +268,10 @@ static int adis16400_write_raw(struct iio_dev *indio_dev,
> mutex_unlock(&indio_dev->mlock);
> return ret;
> case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
> - /* Need to cache values so we can update if the frequency
> - changes */
> + /*
> + * Need to cache values so we can update if the frequency
> + * changes.
> + */
> mutex_lock(&indio_dev->mlock);
> st->filt_int = val;
> /* Work out update to current value */
> @@ -293,16 +290,13 @@ static int adis16400_write_raw(struct iio_dev *indio_dev,
> }
>
> static int adis16400_read_raw(struct iio_dev *indio_dev,
> - struct iio_chan_spec const *chan,
> - int *val,
> - int *val2,
> - long mask)
> + struct iio_chan_spec const *chan, int *val, int *val2, long info)
> {
> struct adis16400_state *st = iio_priv(indio_dev);
> + int16_t val16;
> int ret;
> - s16 val16;
>
> - switch (mask) {
> + switch (info) {
> case IIO_CHAN_INFO_RAW:
> return adis_single_conversion(indio_dev, chan, 0, val);
> case IIO_CHAN_INFO_SCALE:
> @@ -721,13 +715,14 @@ static const struct adis_data adis16400_data = {
>
> static int adis16400_probe(struct spi_device *spi)
> {
> - int ret;
> struct adis16400_state *st;
> - struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
> - if (indio_dev == NULL) {
> - ret = -ENOMEM;
> - goto error_ret;
> - }
> + struct iio_dev *indio_dev;
> + int ret;
> +
> + indio_dev = iio_device_alloc(sizeof(*st));
> + if (indio_dev == NULL)
> + return -ENOMEM;
> +
> st = iio_priv(indio_dev);
> /* this is only used for removal purposes */
> spi_set_drvdata(spi, indio_dev);
> @@ -767,14 +762,12 @@ error_cleanup_buffer:
> adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
> error_free_dev:
> iio_device_free(indio_dev);
> -error_ret:
> return ret;
> }
>
> -/* fixme, confirm ordering in this function */
> static int adis16400_remove(struct spi_device *spi)
> {
> - struct iio_dev *indio_dev = spi_get_drvdata(spi);
> + struct iio_dev *indio_dev = spi_get_drvdata(spi);
> struct adis16400_state *st = iio_priv(indio_dev);
>
> iio_device_unregister(indio_dev);
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 10/15] staging:iio:adis16400: Code style cleanup
2013-01-16 12:58 ` Jonathan Cameron
@ 2013-01-16 13:11 ` Lars-Peter Clausen
2013-01-16 13:57 ` Manuel Stahl
0 siblings, 1 reply; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 13:11 UTC (permalink / raw)
To: Jonathan Cameron; +Cc: Jonathan Cameron, linux-iio
On 01/16/2013 01:58 PM, Jonathan Cameron wrote:
> On 16/01/13 12:48, Lars-Peter Clausen wrote:
>> Do a set of minor miscellaneous code style cleanups for the adis16400 before
>> moving it out of staging. Delete outdated comments, removed excess
>> whitespace,
>> add missing whitespace, replace u{8,16} with uint{8,16}_t.
>
> Is there a move that I've missed to move away from u8 and friends?
Unfortunately not. I think the policy is more or less use whichever you
like. But I definitely prefer uint16_t and friends since it's the official C
type for that type. Also most of the other adis drivers including the
library use uint{8,16,32}_t so it's only consistent.
I wouldn't have done this if it had been the only style issue, but since the
file needed a cleanup anyway I thought I'd include this as well.
- Lars
>>
>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>> ---
>> drivers/staging/iio/imu/adis16400_core.c | 81
>> +++++++++++++++-----------------
>> 1 file changed, 37 insertions(+), 44 deletions(-)
>>
>> diff --git a/drivers/staging/iio/imu/adis16400_core.c
>> b/drivers/staging/iio/imu/adis16400_core.c
>> index c08490b..1bbe5ee 100644
>> --- a/drivers/staging/iio/imu/adis16400_core.c
>> +++ b/drivers/staging/iio/imu/adis16400_core.c
>> @@ -45,7 +45,7 @@ enum adis16400_chip_variant {
>> static int adis16334_get_freq(struct adis16400_state *st)
>> {
>> int ret;
>> - u16 t;
>> + uint16_t t;
>>
>> ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
>> if (ret < 0)
>> @@ -78,12 +78,13 @@ static int adis16334_set_freq(struct adis16400_state
>> *st, unsigned int freq)
>> static int adis16400_get_freq(struct adis16400_state *st)
>> {
>> int sps, ret;
>> - u16 t;
>> + uint16_t t;
>>
>> ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
>> if (ret < 0)
>> return ret;
>> - sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
>> +
>> + sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
>> sps /= (t & ADIS16400_SMPL_PRD_DIV_MASK) + 1;
>>
>> return sps;
>> @@ -97,6 +98,7 @@ static int adis16400_set_freq(struct adis16400_state
>> *st, unsigned int freq)
>> if (t > 0)
>> t--;
>> t &= ADIS16400_SMPL_PRD_DIV_MASK;
>> +
>> if ((t & ADIS16400_SMPL_PRD_DIV_MASK) >= 0x0A)
>> st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW;
>> else
>> @@ -111,13 +113,13 @@ static ssize_t adis16400_read_frequency(struct
>> device *dev,
>> {
>> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>> struct adis16400_state *st = iio_priv(indio_dev);
>> - int ret, len = 0;
>> + int ret;
>>
>> ret = st->variant->get_freq(st);
>> if (ret < 0)
>> return ret;
>> - len = sprintf(buf, "%d\n", ret);
>> - return len;
>> +
>> + return sprintf(buf, "%d\n", ret);
>> }
>>
>> static const unsigned adis16400_3db_divisors[] = {
>> @@ -134,8 +136,8 @@ static const unsigned adis16400_3db_divisors[] = {
>> static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int
>> val)
>> {
>> struct adis16400_state *st = iio_priv(indio_dev);
>> + uint16_t val16;
>> int i, ret;
>> - u16 val16;
>>
>> for (i = ARRAY_SIZE(adis16400_3db_divisors) - 1; i >= 1; i--) {
>> if (sps / adis16400_3db_divisors[i] >= val)
>> @@ -152,26 +154,22 @@ static int adis16400_set_filter(struct iio_dev
>> *indio_dev, int sps, int val)
>> }
>>
>> static ssize_t adis16400_write_frequency(struct device *dev,
>> - struct device_attribute *attr,
>> - const char *buf,
>> - size_t len)
>> + struct device_attribute *attr, const char *buf, size_t len)
>> {
>> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>> struct adis16400_state *st = iio_priv(indio_dev);
>> long val;
>> int ret;
>>
>> - ret = strict_strtol(buf, 10, &val);
>> + ret = kstrtol(buf, 10, &val);
>> if (ret)
>> return ret;
>> +
>> if (val == 0)
>> return -EINVAL;
>>
>> mutex_lock(&indio_dev->mlock);
>> -
>> st->variant->set_freq(st, val);
>> -
>> - /* Also update the filter */
>> mutex_unlock(&indio_dev->mlock);
>>
>> return ret ? ret : len;
>> @@ -182,9 +180,9 @@ static int adis16400_stop_device(struct iio_dev
>> *indio_dev)
>> {
>> struct adis16400_state *st = iio_priv(indio_dev);
>> int ret;
>> - u16 val = ADIS16400_SLP_CNT_POWER_OFF;
>>
>> - ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT, val);
>> + ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT,
>> + ADIS16400_SLP_CNT_POWER_OFF);
>> if (ret)
>> dev_err(&indio_dev->dev,
>> "problem with turning device off: SLP_CNT");
>> @@ -194,10 +192,10 @@ static int adis16400_stop_device(struct iio_dev
>> *indio_dev)
>>
>> static int adis16400_initial_setup(struct iio_dev *indio_dev)
>> {
>> - int ret;
>> - u16 prod_id, smp_prd;
>> - unsigned int device_id;
>> struct adis16400_state *st = iio_priv(indio_dev);
>> + uint16_t prod_id, smp_prd;
>> + unsigned int device_id;
>> + int ret;
>>
>> /* use low spi speed for init if the device has a slow mode */
>> if (st->variant->flags & ADIS16400_HAS_SLOW_MODE)
>> @@ -224,8 +222,8 @@ static int adis16400_initial_setup(struct iio_dev
>> *indio_dev)
>> device_id, prod_id);
>>
>> dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n",
>> - indio_dev->name, prod_id,
>> - st->adis.spi->chip_select, st->adis.spi->irq);
>> + indio_dev->name, prod_id,
>> + st->adis.spi->chip_select, st->adis.spi->irq);
>> }
>> /* use high spi speed if possible */
>> if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {
>> @@ -247,7 +245,7 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
>> adis16400_read_frequency,
>> adis16400_write_frequency);
>>
>> -static const u8 adis16400_addresses[] = {
>> +static const uint8_t adis16400_addresses[] = {
>> [ADIS16400_SCAN_GYRO_X] = ADIS16400_XGYRO_OFF,
>> [ADIS16400_SCAN_GYRO_Y] = ADIS16400_YGYRO_OFF,
>> [ADIS16400_SCAN_GYRO_Z] = ADIS16400_ZGYRO_OFF,
>> @@ -257,15 +255,12 @@ static const u8 adis16400_addresses[] = {
>> };
>>
>> static int adis16400_write_raw(struct iio_dev *indio_dev,
>> - struct iio_chan_spec const *chan,
>> - int val,
>> - int val2,
>> - long mask)
>> + struct iio_chan_spec const *chan, int val, int val2, long info)
>> {
>> struct adis16400_state *st = iio_priv(indio_dev);
>> int ret, sps;
>>
>> - switch (mask) {
>> + switch (info) {
>> case IIO_CHAN_INFO_CALIBBIAS:
>> mutex_lock(&indio_dev->mlock);
>> ret = adis_write_reg_16(&st->adis,
>> @@ -273,8 +268,10 @@ static int adis16400_write_raw(struct iio_dev
>> *indio_dev,
>> mutex_unlock(&indio_dev->mlock);
>> return ret;
>> case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
>> - /* Need to cache values so we can update if the frequency
>> - changes */
>> + /*
>> + * Need to cache values so we can update if the frequency
>> + * changes.
>> + */
>> mutex_lock(&indio_dev->mlock);
>> st->filt_int = val;
>> /* Work out update to current value */
>> @@ -293,16 +290,13 @@ static int adis16400_write_raw(struct iio_dev
>> *indio_dev,
>> }
>>
>> static int adis16400_read_raw(struct iio_dev *indio_dev,
>> - struct iio_chan_spec const *chan,
>> - int *val,
>> - int *val2,
>> - long mask)
>> + struct iio_chan_spec const *chan, int *val, int *val2, long info)
>> {
>> struct adis16400_state *st = iio_priv(indio_dev);
>> + int16_t val16;
>> int ret;
>> - s16 val16;
>>
>> - switch (mask) {
>> + switch (info) {
>> case IIO_CHAN_INFO_RAW:
>> return adis_single_conversion(indio_dev, chan, 0, val);
>> case IIO_CHAN_INFO_SCALE:
>> @@ -721,13 +715,14 @@ static const struct adis_data adis16400_data = {
>>
>> static int adis16400_probe(struct spi_device *spi)
>> {
>> - int ret;
>> struct adis16400_state *st;
>> - struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
>> - if (indio_dev == NULL) {
>> - ret = -ENOMEM;
>> - goto error_ret;
>> - }
>> + struct iio_dev *indio_dev;
>> + int ret;
>> +
>> + indio_dev = iio_device_alloc(sizeof(*st));
>> + if (indio_dev == NULL)
>> + return -ENOMEM;
>> +
>> st = iio_priv(indio_dev);
>> /* this is only used for removal purposes */
>> spi_set_drvdata(spi, indio_dev);
>> @@ -767,14 +762,12 @@ error_cleanup_buffer:
>> adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
>> error_free_dev:
>> iio_device_free(indio_dev);
>> -error_ret:
>> return ret;
>> }
>>
>> -/* fixme, confirm ordering in this function */
>> static int adis16400_remove(struct spi_device *spi)
>> {
>> - struct iio_dev *indio_dev = spi_get_drvdata(spi);
>> + struct iio_dev *indio_dev = spi_get_drvdata(spi);
>> struct adis16400_state *st = iio_priv(indio_dev);
>>
>> iio_device_unregister(indio_dev);
>>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 10/15] staging:iio:adis16400: Code style cleanup
2013-01-16 13:11 ` Lars-Peter Clausen
@ 2013-01-16 13:57 ` Manuel Stahl
2013-01-16 14:07 ` Lars-Peter Clausen
0 siblings, 1 reply; 23+ messages in thread
From: Manuel Stahl @ 2013-01-16 13:57 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, Jonathan Cameron, linux-iio
Hi everyone,
just cought that one up.
I think there was a strong policy to use u8 etc in the kernel. Linus wrote something about it some time ago.
Am Mittwoch, 16. Januar 2013, 14:11:24 schrieb Lars-Peter Clausen:
> On 01/16/2013 01:58 PM, Jonathan Cameron wrote:
> > On 16/01/13 12:48, Lars-Peter Clausen wrote:
> >> Do a set of minor miscellaneous code style cleanups for the adis16400 before
> >> moving it out of staging. Delete outdated comments, removed excess
> >> whitespace,
> >> add missing whitespace, replace u{8,16} with uint{8,16}_t.
> >
> > Is there a move that I've missed to move away from u8 and friends?
>
> Unfortunately not. I think the policy is more or less use whichever you
> like. But I definitely prefer uint16_t and friends since it's the official C
> type for that type. Also most of the other adis drivers including the
> library use uint{8,16,32}_t so it's only consistent.
>
> I wouldn't have done this if it had been the only style issue, but since the
> file needed a cleanup anyway I thought I'd include this as well.
>
> - Lars
>
> >>
> >> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> >> ---
> >> drivers/staging/iio/imu/adis16400_core.c | 81
> >> +++++++++++++++-----------------
> >> 1 file changed, 37 insertions(+), 44 deletions(-)
> >>
> >> diff --git a/drivers/staging/iio/imu/adis16400_core.c
> >> b/drivers/staging/iio/imu/adis16400_core.c
> >> index c08490b..1bbe5ee 100644
> >> --- a/drivers/staging/iio/imu/adis16400_core.c
> >> +++ b/drivers/staging/iio/imu/adis16400_core.c
> >> @@ -45,7 +45,7 @@ enum adis16400_chip_variant {
> >> static int adis16334_get_freq(struct adis16400_state *st)
> >> {
> >> int ret;
> >> - u16 t;
> >> + uint16_t t;
> >>
> >> ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
> >> if (ret < 0)
> >> @@ -78,12 +78,13 @@ static int adis16334_set_freq(struct adis16400_state
> >> *st, unsigned int freq)
> >> static int adis16400_get_freq(struct adis16400_state *st)
> >> {
> >> int sps, ret;
> >> - u16 t;
> >> + uint16_t t;
> >>
> >> ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
> >> if (ret < 0)
> >> return ret;
> >> - sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
> >> +
> >> + sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
> >> sps /= (t & ADIS16400_SMPL_PRD_DIV_MASK) + 1;
> >>
> >> return sps;
> >> @@ -97,6 +98,7 @@ static int adis16400_set_freq(struct adis16400_state
> >> *st, unsigned int freq)
> >> if (t > 0)
> >> t--;
> >> t &= ADIS16400_SMPL_PRD_DIV_MASK;
> >> +
> >> if ((t & ADIS16400_SMPL_PRD_DIV_MASK) >= 0x0A)
> >> st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW;
> >> else
> >> @@ -111,13 +113,13 @@ static ssize_t adis16400_read_frequency(struct
> >> device *dev,
> >> {
> >> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> >> struct adis16400_state *st = iio_priv(indio_dev);
> >> - int ret, len = 0;
> >> + int ret;
> >>
> >> ret = st->variant->get_freq(st);
> >> if (ret < 0)
> >> return ret;
> >> - len = sprintf(buf, "%d\n", ret);
> >> - return len;
> >> +
> >> + return sprintf(buf, "%d\n", ret);
> >> }
> >>
> >> static const unsigned adis16400_3db_divisors[] = {
> >> @@ -134,8 +136,8 @@ static const unsigned adis16400_3db_divisors[] = {
> >> static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int
> >> val)
> >> {
> >> struct adis16400_state *st = iio_priv(indio_dev);
> >> + uint16_t val16;
> >> int i, ret;
> >> - u16 val16;
> >>
> >> for (i = ARRAY_SIZE(adis16400_3db_divisors) - 1; i >= 1; i--) {
> >> if (sps / adis16400_3db_divisors[i] >= val)
> >> @@ -152,26 +154,22 @@ static int adis16400_set_filter(struct iio_dev
> >> *indio_dev, int sps, int val)
> >> }
> >>
> >> static ssize_t adis16400_write_frequency(struct device *dev,
> >> - struct device_attribute *attr,
> >> - const char *buf,
> >> - size_t len)
> >> + struct device_attribute *attr, const char *buf, size_t len)
> >> {
> >> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> >> struct adis16400_state *st = iio_priv(indio_dev);
> >> long val;
> >> int ret;
> >>
> >> - ret = strict_strtol(buf, 10, &val);
> >> + ret = kstrtol(buf, 10, &val);
> >> if (ret)
> >> return ret;
> >> +
> >> if (val == 0)
> >> return -EINVAL;
> >>
> >> mutex_lock(&indio_dev->mlock);
> >> -
> >> st->variant->set_freq(st, val);
> >> -
> >> - /* Also update the filter */
> >> mutex_unlock(&indio_dev->mlock);
> >>
> >> return ret ? ret : len;
> >> @@ -182,9 +180,9 @@ static int adis16400_stop_device(struct iio_dev
> >> *indio_dev)
> >> {
> >> struct adis16400_state *st = iio_priv(indio_dev);
> >> int ret;
> >> - u16 val = ADIS16400_SLP_CNT_POWER_OFF;
> >>
> >> - ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT, val);
> >> + ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT,
> >> + ADIS16400_SLP_CNT_POWER_OFF);
> >> if (ret)
> >> dev_err(&indio_dev->dev,
> >> "problem with turning device off: SLP_CNT");
> >> @@ -194,10 +192,10 @@ static int adis16400_stop_device(struct iio_dev
> >> *indio_dev)
> >>
> >> static int adis16400_initial_setup(struct iio_dev *indio_dev)
> >> {
> >> - int ret;
> >> - u16 prod_id, smp_prd;
> >> - unsigned int device_id;
> >> struct adis16400_state *st = iio_priv(indio_dev);
> >> + uint16_t prod_id, smp_prd;
> >> + unsigned int device_id;
> >> + int ret;
> >>
> >> /* use low spi speed for init if the device has a slow mode */
> >> if (st->variant->flags & ADIS16400_HAS_SLOW_MODE)
> >> @@ -224,8 +222,8 @@ static int adis16400_initial_setup(struct iio_dev
> >> *indio_dev)
> >> device_id, prod_id);
> >>
> >> dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n",
> >> - indio_dev->name, prod_id,
> >> - st->adis.spi->chip_select, st->adis.spi->irq);
> >> + indio_dev->name, prod_id,
> >> + st->adis.spi->chip_select, st->adis.spi->irq);
> >> }
> >> /* use high spi speed if possible */
> >> if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {
> >> @@ -247,7 +245,7 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
> >> adis16400_read_frequency,
> >> adis16400_write_frequency);
> >>
> >> -static const u8 adis16400_addresses[] = {
> >> +static const uint8_t adis16400_addresses[] = {
> >> [ADIS16400_SCAN_GYRO_X] = ADIS16400_XGYRO_OFF,
> >> [ADIS16400_SCAN_GYRO_Y] = ADIS16400_YGYRO_OFF,
> >> [ADIS16400_SCAN_GYRO_Z] = ADIS16400_ZGYRO_OFF,
> >> @@ -257,15 +255,12 @@ static const u8 adis16400_addresses[] = {
> >> };
> >>
> >> static int adis16400_write_raw(struct iio_dev *indio_dev,
> >> - struct iio_chan_spec const *chan,
> >> - int val,
> >> - int val2,
> >> - long mask)
> >> + struct iio_chan_spec const *chan, int val, int val2, long info)
> >> {
> >> struct adis16400_state *st = iio_priv(indio_dev);
> >> int ret, sps;
> >>
> >> - switch (mask) {
> >> + switch (info) {
> >> case IIO_CHAN_INFO_CALIBBIAS:
> >> mutex_lock(&indio_dev->mlock);
> >> ret = adis_write_reg_16(&st->adis,
> >> @@ -273,8 +268,10 @@ static int adis16400_write_raw(struct iio_dev
> >> *indio_dev,
> >> mutex_unlock(&indio_dev->mlock);
> >> return ret;
> >> case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
> >> - /* Need to cache values so we can update if the frequency
> >> - changes */
> >> + /*
> >> + * Need to cache values so we can update if the frequency
> >> + * changes.
> >> + */
> >> mutex_lock(&indio_dev->mlock);
> >> st->filt_int = val;
> >> /* Work out update to current value */
> >> @@ -293,16 +290,13 @@ static int adis16400_write_raw(struct iio_dev
> >> *indio_dev,
> >> }
> >>
> >> static int adis16400_read_raw(struct iio_dev *indio_dev,
> >> - struct iio_chan_spec const *chan,
> >> - int *val,
> >> - int *val2,
> >> - long mask)
> >> + struct iio_chan_spec const *chan, int *val, int *val2, long info)
> >> {
> >> struct adis16400_state *st = iio_priv(indio_dev);
> >> + int16_t val16;
> >> int ret;
> >> - s16 val16;
> >>
> >> - switch (mask) {
> >> + switch (info) {
> >> case IIO_CHAN_INFO_RAW:
> >> return adis_single_conversion(indio_dev, chan, 0, val);
> >> case IIO_CHAN_INFO_SCALE:
> >> @@ -721,13 +715,14 @@ static const struct adis_data adis16400_data = {
> >>
> >> static int adis16400_probe(struct spi_device *spi)
> >> {
> >> - int ret;
> >> struct adis16400_state *st;
> >> - struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
> >> - if (indio_dev == NULL) {
> >> - ret = -ENOMEM;
> >> - goto error_ret;
> >> - }
> >> + struct iio_dev *indio_dev;
> >> + int ret;
> >> +
> >> + indio_dev = iio_device_alloc(sizeof(*st));
> >> + if (indio_dev == NULL)
> >> + return -ENOMEM;
> >> +
> >> st = iio_priv(indio_dev);
> >> /* this is only used for removal purposes */
> >> spi_set_drvdata(spi, indio_dev);
> >> @@ -767,14 +762,12 @@ error_cleanup_buffer:
> >> adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
> >> error_free_dev:
> >> iio_device_free(indio_dev);
> >> -error_ret:
> >> return ret;
> >> }
> >>
> >> -/* fixme, confirm ordering in this function */
> >> static int adis16400_remove(struct spi_device *spi)
> >> {
> >> - struct iio_dev *indio_dev = spi_get_drvdata(spi);
> >> + struct iio_dev *indio_dev = spi_get_drvdata(spi);
> >> struct adis16400_state *st = iio_priv(indio_dev);
> >>
> >> iio_device_unregister(indio_dev);
> >>
> >
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Gruß,
Manuel Stahl
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 10/15] staging:iio:adis16400: Code style cleanup
2013-01-16 13:57 ` Manuel Stahl
@ 2013-01-16 14:07 ` Lars-Peter Clausen
2013-01-16 14:09 ` Manuel Stahl
0 siblings, 1 reply; 23+ messages in thread
From: Lars-Peter Clausen @ 2013-01-16 14:07 UTC (permalink / raw)
To: Manuel Stahl; +Cc: Jonathan Cameron, Jonathan Cameron, linux-iio
On 01/16/2013 02:57 PM, Manuel Stahl wrote:
> Hi everyone,
>
> just cought that one up.
> I think there was a strong policy to use u8 etc in the kernel. Linus wrote something about it some time ago.
>
That's what the advocates of u8, etc like to tell ;)
> Am Mittwoch, 16. Januar 2013, 14:11:24 schrieb Lars-Peter Clausen:
>> On 01/16/2013 01:58 PM, Jonathan Cameron wrote:
>>> On 16/01/13 12:48, Lars-Peter Clausen wrote:
>>>> Do a set of minor miscellaneous code style cleanups for the adis16400 before
>>>> moving it out of staging. Delete outdated comments, removed excess
>>>> whitespace,
>>>> add missing whitespace, replace u{8,16} with uint{8,16}_t.
>>>
>>> Is there a move that I've missed to move away from u8 and friends?
>>
>> Unfortunately not. I think the policy is more or less use whichever you
>> like. But I definitely prefer uint16_t and friends since it's the official C
>> type for that type. Also most of the other adis drivers including the
>> library use uint{8,16,32}_t so it's only consistent.
>>
>> I wouldn't have done this if it had been the only style issue, but since the
>> file needed a cleanup anyway I thought I'd include this as well.
>>
>> - Lars
>>
>>>>
>>>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>>>> ---
>>>> drivers/staging/iio/imu/adis16400_core.c | 81
>>>> +++++++++++++++-----------------
>>>> 1 file changed, 37 insertions(+), 44 deletions(-)
>>>>
>>>> diff --git a/drivers/staging/iio/imu/adis16400_core.c
>>>> b/drivers/staging/iio/imu/adis16400_core.c
>>>> index c08490b..1bbe5ee 100644
>>>> --- a/drivers/staging/iio/imu/adis16400_core.c
>>>> +++ b/drivers/staging/iio/imu/adis16400_core.c
>>>> @@ -45,7 +45,7 @@ enum adis16400_chip_variant {
>>>> static int adis16334_get_freq(struct adis16400_state *st)
>>>> {
>>>> int ret;
>>>> - u16 t;
>>>> + uint16_t t;
>>>>
>>>> ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
>>>> if (ret < 0)
>>>> @@ -78,12 +78,13 @@ static int adis16334_set_freq(struct adis16400_state
>>>> *st, unsigned int freq)
>>>> static int adis16400_get_freq(struct adis16400_state *st)
>>>> {
>>>> int sps, ret;
>>>> - u16 t;
>>>> + uint16_t t;
>>>>
>>>> ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
>>>> if (ret < 0)
>>>> return ret;
>>>> - sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
>>>> +
>>>> + sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
>>>> sps /= (t & ADIS16400_SMPL_PRD_DIV_MASK) + 1;
>>>>
>>>> return sps;
>>>> @@ -97,6 +98,7 @@ static int adis16400_set_freq(struct adis16400_state
>>>> *st, unsigned int freq)
>>>> if (t > 0)
>>>> t--;
>>>> t &= ADIS16400_SMPL_PRD_DIV_MASK;
>>>> +
>>>> if ((t & ADIS16400_SMPL_PRD_DIV_MASK) >= 0x0A)
>>>> st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW;
>>>> else
>>>> @@ -111,13 +113,13 @@ static ssize_t adis16400_read_frequency(struct
>>>> device *dev,
>>>> {
>>>> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>> - int ret, len = 0;
>>>> + int ret;
>>>>
>>>> ret = st->variant->get_freq(st);
>>>> if (ret < 0)
>>>> return ret;
>>>> - len = sprintf(buf, "%d\n", ret);
>>>> - return len;
>>>> +
>>>> + return sprintf(buf, "%d\n", ret);
>>>> }
>>>>
>>>> static const unsigned adis16400_3db_divisors[] = {
>>>> @@ -134,8 +136,8 @@ static const unsigned adis16400_3db_divisors[] = {
>>>> static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int
>>>> val)
>>>> {
>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>> + uint16_t val16;
>>>> int i, ret;
>>>> - u16 val16;
>>>>
>>>> for (i = ARRAY_SIZE(adis16400_3db_divisors) - 1; i >= 1; i--) {
>>>> if (sps / adis16400_3db_divisors[i] >= val)
>>>> @@ -152,26 +154,22 @@ static int adis16400_set_filter(struct iio_dev
>>>> *indio_dev, int sps, int val)
>>>> }
>>>>
>>>> static ssize_t adis16400_write_frequency(struct device *dev,
>>>> - struct device_attribute *attr,
>>>> - const char *buf,
>>>> - size_t len)
>>>> + struct device_attribute *attr, const char *buf, size_t len)
>>>> {
>>>> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>> long val;
>>>> int ret;
>>>>
>>>> - ret = strict_strtol(buf, 10, &val);
>>>> + ret = kstrtol(buf, 10, &val);
>>>> if (ret)
>>>> return ret;
>>>> +
>>>> if (val == 0)
>>>> return -EINVAL;
>>>>
>>>> mutex_lock(&indio_dev->mlock);
>>>> -
>>>> st->variant->set_freq(st, val);
>>>> -
>>>> - /* Also update the filter */
>>>> mutex_unlock(&indio_dev->mlock);
>>>>
>>>> return ret ? ret : len;
>>>> @@ -182,9 +180,9 @@ static int adis16400_stop_device(struct iio_dev
>>>> *indio_dev)
>>>> {
>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>> int ret;
>>>> - u16 val = ADIS16400_SLP_CNT_POWER_OFF;
>>>>
>>>> - ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT, val);
>>>> + ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT,
>>>> + ADIS16400_SLP_CNT_POWER_OFF);
>>>> if (ret)
>>>> dev_err(&indio_dev->dev,
>>>> "problem with turning device off: SLP_CNT");
>>>> @@ -194,10 +192,10 @@ static int adis16400_stop_device(struct iio_dev
>>>> *indio_dev)
>>>>
>>>> static int adis16400_initial_setup(struct iio_dev *indio_dev)
>>>> {
>>>> - int ret;
>>>> - u16 prod_id, smp_prd;
>>>> - unsigned int device_id;
>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>> + uint16_t prod_id, smp_prd;
>>>> + unsigned int device_id;
>>>> + int ret;
>>>>
>>>> /* use low spi speed for init if the device has a slow mode */
>>>> if (st->variant->flags & ADIS16400_HAS_SLOW_MODE)
>>>> @@ -224,8 +222,8 @@ static int adis16400_initial_setup(struct iio_dev
>>>> *indio_dev)
>>>> device_id, prod_id);
>>>>
>>>> dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n",
>>>> - indio_dev->name, prod_id,
>>>> - st->adis.spi->chip_select, st->adis.spi->irq);
>>>> + indio_dev->name, prod_id,
>>>> + st->adis.spi->chip_select, st->adis.spi->irq);
>>>> }
>>>> /* use high spi speed if possible */
>>>> if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {
>>>> @@ -247,7 +245,7 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
>>>> adis16400_read_frequency,
>>>> adis16400_write_frequency);
>>>>
>>>> -static const u8 adis16400_addresses[] = {
>>>> +static const uint8_t adis16400_addresses[] = {
>>>> [ADIS16400_SCAN_GYRO_X] = ADIS16400_XGYRO_OFF,
>>>> [ADIS16400_SCAN_GYRO_Y] = ADIS16400_YGYRO_OFF,
>>>> [ADIS16400_SCAN_GYRO_Z] = ADIS16400_ZGYRO_OFF,
>>>> @@ -257,15 +255,12 @@ static const u8 adis16400_addresses[] = {
>>>> };
>>>>
>>>> static int adis16400_write_raw(struct iio_dev *indio_dev,
>>>> - struct iio_chan_spec const *chan,
>>>> - int val,
>>>> - int val2,
>>>> - long mask)
>>>> + struct iio_chan_spec const *chan, int val, int val2, long info)
>>>> {
>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>> int ret, sps;
>>>>
>>>> - switch (mask) {
>>>> + switch (info) {
>>>> case IIO_CHAN_INFO_CALIBBIAS:
>>>> mutex_lock(&indio_dev->mlock);
>>>> ret = adis_write_reg_16(&st->adis,
>>>> @@ -273,8 +268,10 @@ static int adis16400_write_raw(struct iio_dev
>>>> *indio_dev,
>>>> mutex_unlock(&indio_dev->mlock);
>>>> return ret;
>>>> case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
>>>> - /* Need to cache values so we can update if the frequency
>>>> - changes */
>>>> + /*
>>>> + * Need to cache values so we can update if the frequency
>>>> + * changes.
>>>> + */
>>>> mutex_lock(&indio_dev->mlock);
>>>> st->filt_int = val;
>>>> /* Work out update to current value */
>>>> @@ -293,16 +290,13 @@ static int adis16400_write_raw(struct iio_dev
>>>> *indio_dev,
>>>> }
>>>>
>>>> static int adis16400_read_raw(struct iio_dev *indio_dev,
>>>> - struct iio_chan_spec const *chan,
>>>> - int *val,
>>>> - int *val2,
>>>> - long mask)
>>>> + struct iio_chan_spec const *chan, int *val, int *val2, long info)
>>>> {
>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>> + int16_t val16;
>>>> int ret;
>>>> - s16 val16;
>>>>
>>>> - switch (mask) {
>>>> + switch (info) {
>>>> case IIO_CHAN_INFO_RAW:
>>>> return adis_single_conversion(indio_dev, chan, 0, val);
>>>> case IIO_CHAN_INFO_SCALE:
>>>> @@ -721,13 +715,14 @@ static const struct adis_data adis16400_data = {
>>>>
>>>> static int adis16400_probe(struct spi_device *spi)
>>>> {
>>>> - int ret;
>>>> struct adis16400_state *st;
>>>> - struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
>>>> - if (indio_dev == NULL) {
>>>> - ret = -ENOMEM;
>>>> - goto error_ret;
>>>> - }
>>>> + struct iio_dev *indio_dev;
>>>> + int ret;
>>>> +
>>>> + indio_dev = iio_device_alloc(sizeof(*st));
>>>> + if (indio_dev == NULL)
>>>> + return -ENOMEM;
>>>> +
>>>> st = iio_priv(indio_dev);
>>>> /* this is only used for removal purposes */
>>>> spi_set_drvdata(spi, indio_dev);
>>>> @@ -767,14 +762,12 @@ error_cleanup_buffer:
>>>> adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
>>>> error_free_dev:
>>>> iio_device_free(indio_dev);
>>>> -error_ret:
>>>> return ret;
>>>> }
>>>>
>>>> -/* fixme, confirm ordering in this function */
>>>> static int adis16400_remove(struct spi_device *spi)
>>>> {
>>>> - struct iio_dev *indio_dev = spi_get_drvdata(spi);
>>>> + struct iio_dev *indio_dev = spi_get_drvdata(spi);
>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>>
>>>> iio_device_unregister(indio_dev);
>>>>
>>>
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>
>
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 10/15] staging:iio:adis16400: Code style cleanup
2013-01-16 14:07 ` Lars-Peter Clausen
@ 2013-01-16 14:09 ` Manuel Stahl
2013-01-16 18:34 ` Jonathan Cameron
0 siblings, 1 reply; 23+ messages in thread
From: Manuel Stahl @ 2013-01-16 14:09 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, Jonathan Cameron, linux-iio
I must admit that the only thing I found was this one:
http://yarchive.net/comp/linux/kernel_headers.html
Am Mittwoch, 16. Januar 2013, 15:07:59 schrieb Lars-Peter Clausen:
> On 01/16/2013 02:57 PM, Manuel Stahl wrote:
> > Hi everyone,
> >
> > just cought that one up.
> > I think there was a strong policy to use u8 etc in the kernel. Linus wrote something about it some time ago.
> >
>
> That's what the advocates of u8, etc like to tell ;)
>
>
> > Am Mittwoch, 16. Januar 2013, 14:11:24 schrieb Lars-Peter Clausen:
> >> On 01/16/2013 01:58 PM, Jonathan Cameron wrote:
> >>> On 16/01/13 12:48, Lars-Peter Clausen wrote:
> >>>> Do a set of minor miscellaneous code style cleanups for the adis16400 before
> >>>> moving it out of staging. Delete outdated comments, removed excess
> >>>> whitespace,
> >>>> add missing whitespace, replace u{8,16} with uint{8,16}_t.
> >>>
> >>> Is there a move that I've missed to move away from u8 and friends?
> >>
> >> Unfortunately not. I think the policy is more or less use whichever you
> >> like. But I definitely prefer uint16_t and friends since it's the official C
> >> type for that type. Also most of the other adis drivers including the
> >> library use uint{8,16,32}_t so it's only consistent.
> >>
> >> I wouldn't have done this if it had been the only style issue, but since the
> >> file needed a cleanup anyway I thought I'd include this as well.
> >>
> >> - Lars
> >>
> >>>>
> >>>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
> >>>> ---
> >>>> drivers/staging/iio/imu/adis16400_core.c | 81
> >>>> +++++++++++++++-----------------
> >>>> 1 file changed, 37 insertions(+), 44 deletions(-)
> >>>>
> >>>> diff --git a/drivers/staging/iio/imu/adis16400_core.c
> >>>> b/drivers/staging/iio/imu/adis16400_core.c
> >>>> index c08490b..1bbe5ee 100644
> >>>> --- a/drivers/staging/iio/imu/adis16400_core.c
> >>>> +++ b/drivers/staging/iio/imu/adis16400_core.c
> >>>> @@ -45,7 +45,7 @@ enum adis16400_chip_variant {
> >>>> static int adis16334_get_freq(struct adis16400_state *st)
> >>>> {
> >>>> int ret;
> >>>> - u16 t;
> >>>> + uint16_t t;
> >>>>
> >>>> ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
> >>>> if (ret < 0)
> >>>> @@ -78,12 +78,13 @@ static int adis16334_set_freq(struct adis16400_state
> >>>> *st, unsigned int freq)
> >>>> static int adis16400_get_freq(struct adis16400_state *st)
> >>>> {
> >>>> int sps, ret;
> >>>> - u16 t;
> >>>> + uint16_t t;
> >>>>
> >>>> ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
> >>>> if (ret < 0)
> >>>> return ret;
> >>>> - sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
> >>>> +
> >>>> + sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
> >>>> sps /= (t & ADIS16400_SMPL_PRD_DIV_MASK) + 1;
> >>>>
> >>>> return sps;
> >>>> @@ -97,6 +98,7 @@ static int adis16400_set_freq(struct adis16400_state
> >>>> *st, unsigned int freq)
> >>>> if (t > 0)
> >>>> t--;
> >>>> t &= ADIS16400_SMPL_PRD_DIV_MASK;
> >>>> +
> >>>> if ((t & ADIS16400_SMPL_PRD_DIV_MASK) >= 0x0A)
> >>>> st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW;
> >>>> else
> >>>> @@ -111,13 +113,13 @@ static ssize_t adis16400_read_frequency(struct
> >>>> device *dev,
> >>>> {
> >>>> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> >>>> struct adis16400_state *st = iio_priv(indio_dev);
> >>>> - int ret, len = 0;
> >>>> + int ret;
> >>>>
> >>>> ret = st->variant->get_freq(st);
> >>>> if (ret < 0)
> >>>> return ret;
> >>>> - len = sprintf(buf, "%d\n", ret);
> >>>> - return len;
> >>>> +
> >>>> + return sprintf(buf, "%d\n", ret);
> >>>> }
> >>>>
> >>>> static const unsigned adis16400_3db_divisors[] = {
> >>>> @@ -134,8 +136,8 @@ static const unsigned adis16400_3db_divisors[] = {
> >>>> static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int
> >>>> val)
> >>>> {
> >>>> struct adis16400_state *st = iio_priv(indio_dev);
> >>>> + uint16_t val16;
> >>>> int i, ret;
> >>>> - u16 val16;
> >>>>
> >>>> for (i = ARRAY_SIZE(adis16400_3db_divisors) - 1; i >= 1; i--) {
> >>>> if (sps / adis16400_3db_divisors[i] >= val)
> >>>> @@ -152,26 +154,22 @@ static int adis16400_set_filter(struct iio_dev
> >>>> *indio_dev, int sps, int val)
> >>>> }
> >>>>
> >>>> static ssize_t adis16400_write_frequency(struct device *dev,
> >>>> - struct device_attribute *attr,
> >>>> - const char *buf,
> >>>> - size_t len)
> >>>> + struct device_attribute *attr, const char *buf, size_t len)
> >>>> {
> >>>> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
> >>>> struct adis16400_state *st = iio_priv(indio_dev);
> >>>> long val;
> >>>> int ret;
> >>>>
> >>>> - ret = strict_strtol(buf, 10, &val);
> >>>> + ret = kstrtol(buf, 10, &val);
> >>>> if (ret)
> >>>> return ret;
> >>>> +
> >>>> if (val == 0)
> >>>> return -EINVAL;
> >>>>
> >>>> mutex_lock(&indio_dev->mlock);
> >>>> -
> >>>> st->variant->set_freq(st, val);
> >>>> -
> >>>> - /* Also update the filter */
> >>>> mutex_unlock(&indio_dev->mlock);
> >>>>
> >>>> return ret ? ret : len;
> >>>> @@ -182,9 +180,9 @@ static int adis16400_stop_device(struct iio_dev
> >>>> *indio_dev)
> >>>> {
> >>>> struct adis16400_state *st = iio_priv(indio_dev);
> >>>> int ret;
> >>>> - u16 val = ADIS16400_SLP_CNT_POWER_OFF;
> >>>>
> >>>> - ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT, val);
> >>>> + ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT,
> >>>> + ADIS16400_SLP_CNT_POWER_OFF);
> >>>> if (ret)
> >>>> dev_err(&indio_dev->dev,
> >>>> "problem with turning device off: SLP_CNT");
> >>>> @@ -194,10 +192,10 @@ static int adis16400_stop_device(struct iio_dev
> >>>> *indio_dev)
> >>>>
> >>>> static int adis16400_initial_setup(struct iio_dev *indio_dev)
> >>>> {
> >>>> - int ret;
> >>>> - u16 prod_id, smp_prd;
> >>>> - unsigned int device_id;
> >>>> struct adis16400_state *st = iio_priv(indio_dev);
> >>>> + uint16_t prod_id, smp_prd;
> >>>> + unsigned int device_id;
> >>>> + int ret;
> >>>>
> >>>> /* use low spi speed for init if the device has a slow mode */
> >>>> if (st->variant->flags & ADIS16400_HAS_SLOW_MODE)
> >>>> @@ -224,8 +222,8 @@ static int adis16400_initial_setup(struct iio_dev
> >>>> *indio_dev)
> >>>> device_id, prod_id);
> >>>>
> >>>> dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n",
> >>>> - indio_dev->name, prod_id,
> >>>> - st->adis.spi->chip_select, st->adis.spi->irq);
> >>>> + indio_dev->name, prod_id,
> >>>> + st->adis.spi->chip_select, st->adis.spi->irq);
> >>>> }
> >>>> /* use high spi speed if possible */
> >>>> if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {
> >>>> @@ -247,7 +245,7 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
> >>>> adis16400_read_frequency,
> >>>> adis16400_write_frequency);
> >>>>
> >>>> -static const u8 adis16400_addresses[] = {
> >>>> +static const uint8_t adis16400_addresses[] = {
> >>>> [ADIS16400_SCAN_GYRO_X] = ADIS16400_XGYRO_OFF,
> >>>> [ADIS16400_SCAN_GYRO_Y] = ADIS16400_YGYRO_OFF,
> >>>> [ADIS16400_SCAN_GYRO_Z] = ADIS16400_ZGYRO_OFF,
> >>>> @@ -257,15 +255,12 @@ static const u8 adis16400_addresses[] = {
> >>>> };
> >>>>
> >>>> static int adis16400_write_raw(struct iio_dev *indio_dev,
> >>>> - struct iio_chan_spec const *chan,
> >>>> - int val,
> >>>> - int val2,
> >>>> - long mask)
> >>>> + struct iio_chan_spec const *chan, int val, int val2, long info)
> >>>> {
> >>>> struct adis16400_state *st = iio_priv(indio_dev);
> >>>> int ret, sps;
> >>>>
> >>>> - switch (mask) {
> >>>> + switch (info) {
> >>>> case IIO_CHAN_INFO_CALIBBIAS:
> >>>> mutex_lock(&indio_dev->mlock);
> >>>> ret = adis_write_reg_16(&st->adis,
> >>>> @@ -273,8 +268,10 @@ static int adis16400_write_raw(struct iio_dev
> >>>> *indio_dev,
> >>>> mutex_unlock(&indio_dev->mlock);
> >>>> return ret;
> >>>> case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
> >>>> - /* Need to cache values so we can update if the frequency
> >>>> - changes */
> >>>> + /*
> >>>> + * Need to cache values so we can update if the frequency
> >>>> + * changes.
> >>>> + */
> >>>> mutex_lock(&indio_dev->mlock);
> >>>> st->filt_int = val;
> >>>> /* Work out update to current value */
> >>>> @@ -293,16 +290,13 @@ static int adis16400_write_raw(struct iio_dev
> >>>> *indio_dev,
> >>>> }
> >>>>
> >>>> static int adis16400_read_raw(struct iio_dev *indio_dev,
> >>>> - struct iio_chan_spec const *chan,
> >>>> - int *val,
> >>>> - int *val2,
> >>>> - long mask)
> >>>> + struct iio_chan_spec const *chan, int *val, int *val2, long info)
> >>>> {
> >>>> struct adis16400_state *st = iio_priv(indio_dev);
> >>>> + int16_t val16;
> >>>> int ret;
> >>>> - s16 val16;
> >>>>
> >>>> - switch (mask) {
> >>>> + switch (info) {
> >>>> case IIO_CHAN_INFO_RAW:
> >>>> return adis_single_conversion(indio_dev, chan, 0, val);
> >>>> case IIO_CHAN_INFO_SCALE:
> >>>> @@ -721,13 +715,14 @@ static const struct adis_data adis16400_data = {
> >>>>
> >>>> static int adis16400_probe(struct spi_device *spi)
> >>>> {
> >>>> - int ret;
> >>>> struct adis16400_state *st;
> >>>> - struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
> >>>> - if (indio_dev == NULL) {
> >>>> - ret = -ENOMEM;
> >>>> - goto error_ret;
> >>>> - }
> >>>> + struct iio_dev *indio_dev;
> >>>> + int ret;
> >>>> +
> >>>> + indio_dev = iio_device_alloc(sizeof(*st));
> >>>> + if (indio_dev == NULL)
> >>>> + return -ENOMEM;
> >>>> +
> >>>> st = iio_priv(indio_dev);
> >>>> /* this is only used for removal purposes */
> >>>> spi_set_drvdata(spi, indio_dev);
> >>>> @@ -767,14 +762,12 @@ error_cleanup_buffer:
> >>>> adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
> >>>> error_free_dev:
> >>>> iio_device_free(indio_dev);
> >>>> -error_ret:
> >>>> return ret;
> >>>> }
> >>>>
> >>>> -/* fixme, confirm ordering in this function */
> >>>> static int adis16400_remove(struct spi_device *spi)
> >>>> {
> >>>> - struct iio_dev *indio_dev = spi_get_drvdata(spi);
> >>>> + struct iio_dev *indio_dev = spi_get_drvdata(spi);
> >>>> struct adis16400_state *st = iio_priv(indio_dev);
> >>>>
> >>>> iio_device_unregister(indio_dev);
> >>>>
> >>>
> >>
> >> --
> >> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> >> the body of a message to majordomo@vger.kernel.org
> >> More majordomo info at http://vger.kernel.org/majordomo-info.html
> >>
> >
> >
>
>
--
Gruß,
Manuel Stahl
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 10/15] staging:iio:adis16400: Code style cleanup
2013-01-16 14:09 ` Manuel Stahl
@ 2013-01-16 18:34 ` Jonathan Cameron
2013-01-17 9:18 ` Manuel Stahl
0 siblings, 1 reply; 23+ messages in thread
From: Jonathan Cameron @ 2013-01-16 18:34 UTC (permalink / raw)
To: Manuel Stahl
Cc: Lars-Peter Clausen, Jonathan Cameron, Jonathan Cameron, linux-iio
On 01/16/2013 02:09 PM, Manuel Stahl wrote:
> I must admit that the only thing I found was this one:
> http://yarchive.net/comp/linux/kernel_headers.html
Style guide says you are welcome to use either in new code but
should match whatever is in use in existing code.
Honestly I find myself not caring so unless Manuel minds,
I'll take this patch purely to save Lars-Peter the effort
of regenerating the series with those removed ;)
>
> Am Mittwoch, 16. Januar 2013, 15:07:59 schrieb Lars-Peter Clausen:
>> On 01/16/2013 02:57 PM, Manuel Stahl wrote:
>>> Hi everyone,
>>>
>>> just cought that one up.
>>> I think there was a strong policy to use u8 etc in the kernel. Linus wrote something about it some time ago.
>>>
>>
>> That's what the advocates of u8, etc like to tell ;)
>>
>>
>>> Am Mittwoch, 16. Januar 2013, 14:11:24 schrieb Lars-Peter Clausen:
>>>> On 01/16/2013 01:58 PM, Jonathan Cameron wrote:
>>>>> On 16/01/13 12:48, Lars-Peter Clausen wrote:
>>>>>> Do a set of minor miscellaneous code style cleanups for the adis16400 before
>>>>>> moving it out of staging. Delete outdated comments, removed excess
>>>>>> whitespace,
>>>>>> add missing whitespace, replace u{8,16} with uint{8,16}_t.
>>>>>
>>>>> Is there a move that I've missed to move away from u8 and friends?
>>>>
>>>> Unfortunately not. I think the policy is more or less use whichever you
>>>> like. But I definitely prefer uint16_t and friends since it's the official C
>>>> type for that type. Also most of the other adis drivers including the
>>>> library use uint{8,16,32}_t so it's only consistent.
>>>>
>>>> I wouldn't have done this if it had been the only style issue, but since the
>>>> file needed a cleanup anyway I thought I'd include this as well.
>>>>
>>>> - Lars
>>>>
>>>>>>
>>>>>> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
>>>>>> ---
>>>>>> drivers/staging/iio/imu/adis16400_core.c | 81
>>>>>> +++++++++++++++-----------------
>>>>>> 1 file changed, 37 insertions(+), 44 deletions(-)
>>>>>>
>>>>>> diff --git a/drivers/staging/iio/imu/adis16400_core.c
>>>>>> b/drivers/staging/iio/imu/adis16400_core.c
>>>>>> index c08490b..1bbe5ee 100644
>>>>>> --- a/drivers/staging/iio/imu/adis16400_core.c
>>>>>> +++ b/drivers/staging/iio/imu/adis16400_core.c
>>>>>> @@ -45,7 +45,7 @@ enum adis16400_chip_variant {
>>>>>> static int adis16334_get_freq(struct adis16400_state *st)
>>>>>> {
>>>>>> int ret;
>>>>>> - u16 t;
>>>>>> + uint16_t t;
>>>>>>
>>>>>> ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
>>>>>> if (ret < 0)
>>>>>> @@ -78,12 +78,13 @@ static int adis16334_set_freq(struct adis16400_state
>>>>>> *st, unsigned int freq)
>>>>>> static int adis16400_get_freq(struct adis16400_state *st)
>>>>>> {
>>>>>> int sps, ret;
>>>>>> - u16 t;
>>>>>> + uint16_t t;
>>>>>>
>>>>>> ret = adis_read_reg_16(&st->adis, ADIS16400_SMPL_PRD, &t);
>>>>>> if (ret < 0)
>>>>>> return ret;
>>>>>> - sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
>>>>>> +
>>>>>> + sps = (t & ADIS16400_SMPL_PRD_TIME_BASE) ? 53 : 1638;
>>>>>> sps /= (t & ADIS16400_SMPL_PRD_DIV_MASK) + 1;
>>>>>>
>>>>>> return sps;
>>>>>> @@ -97,6 +98,7 @@ static int adis16400_set_freq(struct adis16400_state
>>>>>> *st, unsigned int freq)
>>>>>> if (t > 0)
>>>>>> t--;
>>>>>> t &= ADIS16400_SMPL_PRD_DIV_MASK;
>>>>>> +
>>>>>> if ((t & ADIS16400_SMPL_PRD_DIV_MASK) >= 0x0A)
>>>>>> st->adis.spi->max_speed_hz = ADIS16400_SPI_SLOW;
>>>>>> else
>>>>>> @@ -111,13 +113,13 @@ static ssize_t adis16400_read_frequency(struct
>>>>>> device *dev,
>>>>>> {
>>>>>> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>>>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>>>> - int ret, len = 0;
>>>>>> + int ret;
>>>>>>
>>>>>> ret = st->variant->get_freq(st);
>>>>>> if (ret < 0)
>>>>>> return ret;
>>>>>> - len = sprintf(buf, "%d\n", ret);
>>>>>> - return len;
>>>>>> +
>>>>>> + return sprintf(buf, "%d\n", ret);
>>>>>> }
>>>>>>
>>>>>> static const unsigned adis16400_3db_divisors[] = {
>>>>>> @@ -134,8 +136,8 @@ static const unsigned adis16400_3db_divisors[] = {
>>>>>> static int adis16400_set_filter(struct iio_dev *indio_dev, int sps, int
>>>>>> val)
>>>>>> {
>>>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>>>> + uint16_t val16;
>>>>>> int i, ret;
>>>>>> - u16 val16;
>>>>>>
>>>>>> for (i = ARRAY_SIZE(adis16400_3db_divisors) - 1; i >= 1; i--) {
>>>>>> if (sps / adis16400_3db_divisors[i] >= val)
>>>>>> @@ -152,26 +154,22 @@ static int adis16400_set_filter(struct iio_dev
>>>>>> *indio_dev, int sps, int val)
>>>>>> }
>>>>>>
>>>>>> static ssize_t adis16400_write_frequency(struct device *dev,
>>>>>> - struct device_attribute *attr,
>>>>>> - const char *buf,
>>>>>> - size_t len)
>>>>>> + struct device_attribute *attr, const char *buf, size_t len)
>>>>>> {
>>>>>> struct iio_dev *indio_dev = dev_to_iio_dev(dev);
>>>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>>>> long val;
>>>>>> int ret;
>>>>>>
>>>>>> - ret = strict_strtol(buf, 10, &val);
>>>>>> + ret = kstrtol(buf, 10, &val);
>>>>>> if (ret)
>>>>>> return ret;
>>>>>> +
>>>>>> if (val == 0)
>>>>>> return -EINVAL;
>>>>>>
>>>>>> mutex_lock(&indio_dev->mlock);
>>>>>> -
>>>>>> st->variant->set_freq(st, val);
>>>>>> -
>>>>>> - /* Also update the filter */
>>>>>> mutex_unlock(&indio_dev->mlock);
>>>>>>
>>>>>> return ret ? ret : len;
>>>>>> @@ -182,9 +180,9 @@ static int adis16400_stop_device(struct iio_dev
>>>>>> *indio_dev)
>>>>>> {
>>>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>>>> int ret;
>>>>>> - u16 val = ADIS16400_SLP_CNT_POWER_OFF;
>>>>>>
>>>>>> - ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT, val);
>>>>>> + ret = adis_write_reg_16(&st->adis, ADIS16400_SLP_CNT,
>>>>>> + ADIS16400_SLP_CNT_POWER_OFF);
>>>>>> if (ret)
>>>>>> dev_err(&indio_dev->dev,
>>>>>> "problem with turning device off: SLP_CNT");
>>>>>> @@ -194,10 +192,10 @@ static int adis16400_stop_device(struct iio_dev
>>>>>> *indio_dev)
>>>>>>
>>>>>> static int adis16400_initial_setup(struct iio_dev *indio_dev)
>>>>>> {
>>>>>> - int ret;
>>>>>> - u16 prod_id, smp_prd;
>>>>>> - unsigned int device_id;
>>>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>>>> + uint16_t prod_id, smp_prd;
>>>>>> + unsigned int device_id;
>>>>>> + int ret;
>>>>>>
>>>>>> /* use low spi speed for init if the device has a slow mode */
>>>>>> if (st->variant->flags & ADIS16400_HAS_SLOW_MODE)
>>>>>> @@ -224,8 +222,8 @@ static int adis16400_initial_setup(struct iio_dev
>>>>>> *indio_dev)
>>>>>> device_id, prod_id);
>>>>>>
>>>>>> dev_info(&indio_dev->dev, "%s: prod_id 0x%04x at CS%d (irq %d)\n",
>>>>>> - indio_dev->name, prod_id,
>>>>>> - st->adis.spi->chip_select, st->adis.spi->irq);
>>>>>> + indio_dev->name, prod_id,
>>>>>> + st->adis.spi->chip_select, st->adis.spi->irq);
>>>>>> }
>>>>>> /* use high spi speed if possible */
>>>>>> if (st->variant->flags & ADIS16400_HAS_SLOW_MODE) {
>>>>>> @@ -247,7 +245,7 @@ static IIO_DEV_ATTR_SAMP_FREQ(S_IWUSR | S_IRUGO,
>>>>>> adis16400_read_frequency,
>>>>>> adis16400_write_frequency);
>>>>>>
>>>>>> -static const u8 adis16400_addresses[] = {
>>>>>> +static const uint8_t adis16400_addresses[] = {
>>>>>> [ADIS16400_SCAN_GYRO_X] = ADIS16400_XGYRO_OFF,
>>>>>> [ADIS16400_SCAN_GYRO_Y] = ADIS16400_YGYRO_OFF,
>>>>>> [ADIS16400_SCAN_GYRO_Z] = ADIS16400_ZGYRO_OFF,
>>>>>> @@ -257,15 +255,12 @@ static const u8 adis16400_addresses[] = {
>>>>>> };
>>>>>>
>>>>>> static int adis16400_write_raw(struct iio_dev *indio_dev,
>>>>>> - struct iio_chan_spec const *chan,
>>>>>> - int val,
>>>>>> - int val2,
>>>>>> - long mask)
>>>>>> + struct iio_chan_spec const *chan, int val, int val2, long info)
>>>>>> {
>>>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>>>> int ret, sps;
>>>>>>
>>>>>> - switch (mask) {
>>>>>> + switch (info) {
>>>>>> case IIO_CHAN_INFO_CALIBBIAS:
>>>>>> mutex_lock(&indio_dev->mlock);
>>>>>> ret = adis_write_reg_16(&st->adis,
>>>>>> @@ -273,8 +268,10 @@ static int adis16400_write_raw(struct iio_dev
>>>>>> *indio_dev,
>>>>>> mutex_unlock(&indio_dev->mlock);
>>>>>> return ret;
>>>>>> case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY:
>>>>>> - /* Need to cache values so we can update if the frequency
>>>>>> - changes */
>>>>>> + /*
>>>>>> + * Need to cache values so we can update if the frequency
>>>>>> + * changes.
>>>>>> + */
>>>>>> mutex_lock(&indio_dev->mlock);
>>>>>> st->filt_int = val;
>>>>>> /* Work out update to current value */
>>>>>> @@ -293,16 +290,13 @@ static int adis16400_write_raw(struct iio_dev
>>>>>> *indio_dev,
>>>>>> }
>>>>>>
>>>>>> static int adis16400_read_raw(struct iio_dev *indio_dev,
>>>>>> - struct iio_chan_spec const *chan,
>>>>>> - int *val,
>>>>>> - int *val2,
>>>>>> - long mask)
>>>>>> + struct iio_chan_spec const *chan, int *val, int *val2, long info)
>>>>>> {
>>>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>>>> + int16_t val16;
>>>>>> int ret;
>>>>>> - s16 val16;
>>>>>>
>>>>>> - switch (mask) {
>>>>>> + switch (info) {
>>>>>> case IIO_CHAN_INFO_RAW:
>>>>>> return adis_single_conversion(indio_dev, chan, 0, val);
>>>>>> case IIO_CHAN_INFO_SCALE:
>>>>>> @@ -721,13 +715,14 @@ static const struct adis_data adis16400_data = {
>>>>>>
>>>>>> static int adis16400_probe(struct spi_device *spi)
>>>>>> {
>>>>>> - int ret;
>>>>>> struct adis16400_state *st;
>>>>>> - struct iio_dev *indio_dev = iio_device_alloc(sizeof(*st));
>>>>>> - if (indio_dev == NULL) {
>>>>>> - ret = -ENOMEM;
>>>>>> - goto error_ret;
>>>>>> - }
>>>>>> + struct iio_dev *indio_dev;
>>>>>> + int ret;
>>>>>> +
>>>>>> + indio_dev = iio_device_alloc(sizeof(*st));
>>>>>> + if (indio_dev == NULL)
>>>>>> + return -ENOMEM;
>>>>>> +
>>>>>> st = iio_priv(indio_dev);
>>>>>> /* this is only used for removal purposes */
>>>>>> spi_set_drvdata(spi, indio_dev);
>>>>>> @@ -767,14 +762,12 @@ error_cleanup_buffer:
>>>>>> adis_cleanup_buffer_and_trigger(&st->adis, indio_dev);
>>>>>> error_free_dev:
>>>>>> iio_device_free(indio_dev);
>>>>>> -error_ret:
>>>>>> return ret;
>>>>>> }
>>>>>>
>>>>>> -/* fixme, confirm ordering in this function */
>>>>>> static int adis16400_remove(struct spi_device *spi)
>>>>>> {
>>>>>> - struct iio_dev *indio_dev = spi_get_drvdata(spi);
>>>>>> + struct iio_dev *indio_dev = spi_get_drvdata(spi);
>>>>>> struct adis16400_state *st = iio_priv(indio_dev);
>>>>>>
>>>>>> iio_device_unregister(indio_dev);
>>>>>>
>>>>>
>>>>
>>>> --
>>>> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
>>>> the body of a message to majordomo@vger.kernel.org
>>>> More majordomo info at http://vger.kernel.org/majordomo-info.html
>>>>
>>>
>>>
>>
>>
>
>
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 10/15] staging:iio:adis16400: Code style cleanup
2013-01-16 18:34 ` Jonathan Cameron
@ 2013-01-17 9:18 ` Manuel Stahl
0 siblings, 0 replies; 23+ messages in thread
From: Manuel Stahl @ 2013-01-17 9:18 UTC (permalink / raw)
To: Jonathan Cameron
Cc: Lars-Peter Clausen, Jonathan Cameron, Jonathan Cameron, linux-iio
Am Mittwoch, 16. Januar 2013, 19:34:09 schrieb Jonathan Cameron:
> On 01/16/2013 02:09 PM, Manuel Stahl wrote:
> > I must admit that the only thing I found was this one:
> > http://yarchive.net/comp/linux/kernel_headers.html
> Style guide says you are welcome to use either in new code but
> should match whatever is in use in existing code.
If that's the current policy I'm absolutely happy with the patch. uint8_t etc is what I'm used to in most projects ;)
--
Regards,
Manuel Stahl
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
` (13 preceding siblings ...)
2013-01-16 12:48 ` [PATCH 15/15] iio:adis16400: Add support for the adis16448 Lars-Peter Clausen
@ 2013-01-19 13:50 ` Jonathan Cameron
14 siblings, 0 replies; 23+ messages in thread
From: Jonathan Cameron @ 2013-01-19 13:50 UTC (permalink / raw)
To: Lars-Peter Clausen; +Cc: Jonathan Cameron, linux-iio
On 01/16/2013 12:48 PM, Lars-Peter Clausen wrote:
> ilog2 is not defined for 0, so we need to handle the case where the requested
> frequency is larger than the base sampling rate. In this case we'll round down
> and set the sampling rate to the base sampling rate.
>
> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Added whole series to togreg branch of iio.git
Also, now these are in, I have applied the sw_ring removal series that
I held at Lars-Peter's request as this series was on its way.
> ---
> drivers/staging/iio/imu/adis16400_core.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/staging/iio/imu/adis16400_core.c b/drivers/staging/iio/imu/adis16400_core.c
> index 9c8f5ab..cb66225 100644
> --- a/drivers/staging/iio/imu/adis16400_core.c
> +++ b/drivers/staging/iio/imu/adis16400_core.c
> @@ -178,7 +178,11 @@ static int adis16334_set_freq(struct iio_dev *indio_dev, unsigned int freq)
> {
> unsigned int t;
>
> - t = ilog2(8192 / (freq * 10));
> + freq *= 10;
> + if (freq < 8192)
> + t = ilog2(8192 / freq);
> + else
> + t = 0;
>
> if (t > 0x31)
> t = 0x31;
>
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2013-01-19 13:50 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-16 12:48 [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 02/15] staging:iio:adis16400: Fix and cleanup 3db filter setting Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 03/15] staging:iio:adis16400: Remove unused default_scan_mask Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 04/15] staging:iio:adis16400: Use adis library Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 05/15] staging:iio:adis16400: Use triggered buffer setup helper function Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 06/15] staging:iio:adis16400: Add helper macros for channel declaration Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 07/15] staging:iio:adis16400: Preallocate transfer message Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 08/15] staging:iio:adis16400: Remove unit suffix from samplerate attribute Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 09/15] staging:iio:adis16400: Remove samplerate_available attribute Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 10/15] staging:iio:adis16400: Code style cleanup Lars-Peter Clausen
2013-01-16 12:58 ` Jonathan Cameron
2013-01-16 13:11 ` Lars-Peter Clausen
2013-01-16 13:57 ` Manuel Stahl
2013-01-16 14:07 ` Lars-Peter Clausen
2013-01-16 14:09 ` Manuel Stahl
2013-01-16 18:34 ` Jonathan Cameron
2013-01-17 9:18 ` Manuel Stahl
2013-01-16 12:48 ` [PATCH 11/15] staging:iio: Move adis16400 out of staging Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 12/15] iio:adis16400: Increase samplerate precession Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 13/15] iio:adis16400: Add support for the 52.85 Hz base sampling rate Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 14/15] iio:adis16400: Expose some debug information in debugfs Lars-Peter Clausen
2013-01-16 12:48 ` [PATCH 15/15] iio:adis16400: Add support for the adis16448 Lars-Peter Clausen
2013-01-19 13:50 ` [PATCH 01/15] staging:iio:adis16400: Don't pass 0 to ilog2 Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).