summaryrefslogtreecommitdiffstats
path: root/drivers/iio
diff options
context:
space:
mode:
authorPeter Meerwald <pmeerw@pmeerw.net>2014-08-19 23:43:00 +0100
committerJonathan Cameron <jic23@kernel.org>2014-09-14 20:26:08 +0100
commit6377aa496a0bc40af4f66574c813bb9a807a7e3a (patch)
tree252856251cc5c6368e4a221a30e0ec890a2c2b0b /drivers/iio
parentc1949ec18e50e1e23f3045a7c3836c289f553bb8 (diff)
downloadop-kernel-dev-6377aa496a0bc40af4f66574c813bb9a807a7e3a.zip
op-kernel-dev-6377aa496a0bc40af4f66574c813bb9a807a7e3a.tar.gz
iio:bma180: Prepare for accelerometer channels with different resolutions
allow to specify channels resolution and compute shift assuming 16-bit registers and MSB allocation Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net> Cc: Oleksandr Kravchenko <o.v.kravchenko@globallogic.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Diffstat (limited to 'drivers/iio')
-rw-r--r--drivers/iio/accel/bma180.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c
index 9336455..f4d2804 100644
--- a/drivers/iio/accel/bma180.c
+++ b/drivers/iio/accel/bma180.c
@@ -476,7 +476,7 @@ static const struct iio_chan_spec_ext_info bma180_ext_info[] = {
{ },
};
-#define BMA180_ACC_CHANNEL(_axis) { \
+#define BMA180_ACC_CHANNEL(_axis, _bits) { \
.type = IIO_ACCEL, \
.modified = 1, \
.channel2 = IIO_MOD_##_axis, \
@@ -486,9 +486,9 @@ static const struct iio_chan_spec_ext_info bma180_ext_info[] = {
.scan_index = AXIS_##_axis, \
.scan_type = { \
.sign = 's', \
- .realbits = 14, \
+ .realbits = _bits, \
.storagebits = 16, \
- .shift = 2, \
+ .shift = 16 - _bits, \
}, \
.ext_info = bma180_ext_info, \
}
@@ -506,9 +506,9 @@ static const struct iio_chan_spec_ext_info bma180_ext_info[] = {
}
static const struct iio_chan_spec bma180_channels[] = {
- BMA180_ACC_CHANNEL(X),
- BMA180_ACC_CHANNEL(Y),
- BMA180_ACC_CHANNEL(Z),
+ BMA180_ACC_CHANNEL(X, 14),
+ BMA180_ACC_CHANNEL(Y, 14),
+ BMA180_ACC_CHANNEL(Z, 14),
BMA180_TEMP_CHANNEL,
IIO_CHAN_SOFT_TIMESTAMP(4),
};
OpenPOWER on IntegriCloud