Commit ff3fc8eb authored by Jin Feng's avatar Jin Feng Committed by Jonathan Cameron

staging:iio:dummy: Fix mismatch and export sysfs entry

Correct the mismatch bewteen calibscale and calibbias, and export
the in_accel_calibscale sysfs entry

Updated to apply to current tree.
Signed-off-by: default avatarJin Feng <jin88.feng@gmail.com>
Signed-off-by: default avatarJonathan Cameron <jic23@kernel.org>
parent 9f16778c
...@@ -166,11 +166,12 @@ static const struct iio_chan_spec iio_dummy_channels[] = { ...@@ -166,11 +166,12 @@ static const struct iio_chan_spec iio_dummy_channels[] = {
.channel2 = IIO_MOD_X, .channel2 = IIO_MOD_X,
.info_mask_separate = BIT(IIO_CHAN_INFO_RAW) | .info_mask_separate = BIT(IIO_CHAN_INFO_RAW) |
/* /*
* Internal bias correction value. Applied * Internal bias and gain correction values. Applied
* by the hardware or driver prior to userspace * by the hardware or driver prior to userspace
* seeing the readings. Typically part of hardware * seeing the readings. Typically part of hardware
* calibration. * calibration.
*/ */
BIT(IIO_CHAN_INFO_CALIBSCALE) |
BIT(IIO_CHAN_INFO_CALIBBIAS), BIT(IIO_CHAN_INFO_CALIBBIAS),
.scan_index = accelx, .scan_index = accelx,
.scan_type = { /* Description of storage in buffer */ .scan_type = { /* Description of storage in buffer */
...@@ -311,7 +312,7 @@ static int iio_dummy_write_raw(struct iio_dev *indio_dev, ...@@ -311,7 +312,7 @@ static int iio_dummy_write_raw(struct iio_dev *indio_dev,
st->dac_val = val; st->dac_val = val;
mutex_unlock(&st->lock); mutex_unlock(&st->lock);
return 0; return 0;
case IIO_CHAN_INFO_CALIBBIAS: case IIO_CHAN_INFO_CALIBSCALE:
mutex_lock(&st->lock); mutex_lock(&st->lock);
/* Compare against table - hard matching here */ /* Compare against table - hard matching here */
for (i = 0; i < ARRAY_SIZE(dummy_scales); i++) for (i = 0; i < ARRAY_SIZE(dummy_scales); i++)
...@@ -324,6 +325,12 @@ static int iio_dummy_write_raw(struct iio_dev *indio_dev, ...@@ -324,6 +325,12 @@ static int iio_dummy_write_raw(struct iio_dev *indio_dev,
st->accel_calibscale = &dummy_scales[i]; st->accel_calibscale = &dummy_scales[i];
mutex_unlock(&st->lock); mutex_unlock(&st->lock);
return ret; return ret;
case IIO_CHAN_INFO_CALIBBIAS:
mutex_lock(&st->lock);
st->accel_calibbias = val;
mutex_unlock(&st->lock);
return 0;
default: default:
return -EINVAL; return -EINVAL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment