summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAdriana Reus <adriana.reus@intel.com>2015-06-12 17:10:23 +0200
committerJonathan Cameron <jic23@kernel.org>2015-06-13 19:57:53 +0200
commit6a3c45bb5a385be7049a7725a4fe93eaa76915f4 (patch)
tree8d12f5508db7aad747d9e30fe629174e1dae134f /drivers
parentiio: twl4030-madc: Pass the IRQF_ONESHOT flag (diff)
downloadlinux-6a3c45bb5a385be7049a7725a4fe93eaa76915f4.tar.xz
linux-6a3c45bb5a385be7049a7725a4fe93eaa76915f4.zip
iio: inv-mpu: Specify the expected format/precision for write channels
The gyroscope needs IIO_VAL_INT_PLUS_NANO for the scale channel and unless specified write returns MICRO by default. This needs to be properly specified so that write operations into scale have the expected behaviour. Signed-off-by: Adriana Reus <adriana.reus@intel.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/iio/imu/inv_mpu6050/inv_mpu_core.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
index 17d4bb15be4d..65ce86837177 100644
--- a/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
+++ b/drivers/iio/imu/inv_mpu6050/inv_mpu_core.c
@@ -431,6 +431,23 @@ static int inv_mpu6050_write_gyro_scale(struct inv_mpu6050_state *st, int val)
return -EINVAL;
}
+static int inv_write_raw_get_fmt(struct iio_dev *indio_dev,
+ struct iio_chan_spec const *chan, long mask)
+{
+ switch (mask) {
+ case IIO_CHAN_INFO_SCALE:
+ switch (chan->type) {
+ case IIO_ANGL_VEL:
+ return IIO_VAL_INT_PLUS_NANO;
+ default:
+ return IIO_VAL_INT_PLUS_MICRO;
+ }
+ default:
+ return IIO_VAL_INT_PLUS_MICRO;
+ }
+
+ return -EINVAL;
+}
static int inv_mpu6050_write_accel_scale(struct inv_mpu6050_state *st, int val)
{
int result, i;
@@ -696,6 +713,7 @@ static const struct iio_info mpu_info = {
.driver_module = THIS_MODULE,
.read_raw = &inv_mpu6050_read_raw,
.write_raw = &inv_mpu6050_write_raw,
+ .write_raw_get_fmt = &inv_write_raw_get_fmt,
.attrs = &inv_attribute_group,
.validate_trigger = inv_mpu6050_validate_trigger,
};