#include "../iio.h"
#include "../sysfs.h"
-#include "../adc/adc.h"
#include "adxrs450.h"
return ret;
}
-static int adxrs450_read_temp(struct iio_dev *indio_dev, int *val)
-{
- int ret;
- u16 t;
- ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_TEMP1, &t);
- if (ret)
- return ret;
- *val = t;
- return 0;
-}
-
-static int adxrs450_read_quad(struct iio_dev *indio_dev, int *val)
-{
- int ret;
- s16 t;
- ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t);
- if (ret)
- return ret;
- *val = t;
- return 0;
-}
-
-static int adxrs450_read_sensor_data(struct iio_dev *indio_dev, int *val)
-{
- int ret;
- s16 t;
-
- ret = adxrs450_spi_sensor_data(indio_dev, &t);
- if (ret)
- return ret;
-
- *val = t;
- return 0;
-}
-
/* Recommended Startup Sequence by spec */
static int adxrs450_initial_setup(struct iio_dev *indio_dev)
{
long mask)
{
int ret;
+ s16 t;
+ u16 ut;
switch (mask) {
case 0:
switch (chan->type) {
case IIO_GYRO:
- ret = adxrs450_read_sensor_data(indio_dev, val);
- if (ret < 0)
+ ret = adxrs450_spi_sensor_data(indio_dev, &t);
+ if (ret)
break;
- *val = ret;
+ *val = t;
ret = IIO_VAL_INT;
break;
case IIO_TEMP:
- ret = adxrs450_read_temp(indio_dev, val);
- if (ret < 0)
+ ret = adxrs450_spi_read_reg_16(indio_dev,
+ ADXRS450_TEMP1, &ut);
+ if (ret)
break;
- *val = ret;
+ *val = ut;
ret = IIO_VAL_INT;
break;
default:
}
break;
case (1 << IIO_CHAN_INFO_QUADRATURE_CORRECTION_RAW_SEPARATE):
- ret = adxrs450_read_quad(indio_dev, val);
- if (ret < 0)
+ ret = adxrs450_spi_read_reg_16(indio_dev, ADXRS450_QUAD1, &t);
+ if (ret)
break;
- *val = ret;
+ *val = t;
ret = IIO_VAL_INT;
break;
default: