summaryrefslogtreecommitdiff
path: root/drivers/iio/pressure/cros_ec_baro.c
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2019-07-19 01:22:37 +0300
committerJonathan Cameron <Jonathan.Cameron@huawei.com>2019-07-28 00:52:04 +0300
commitf53199c0bc62657f7bc253b5dfc9f3d81ed2ca28 (patch)
treef181f7b042b95b5b5408ee0b56892674401e2054 /drivers/iio/pressure/cros_ec_baro.c
parented1f2e85da79274f3dc4092953f1359eb732f0c6 (diff)
downloadlinux-f53199c0bc62657f7bc253b5dfc9f3d81ed2ca28.tar.xz
iio: cros_ec: Remove replacing error code with -EIO
Due to an API misread, error code can be different for -EIO when reading a sysfs entry. Return the error reported by the cros_ec stack. Check the proper error message (protocol error, not supported) is reported when there is an error returned by the EC stack. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Diffstat (limited to 'drivers/iio/pressure/cros_ec_baro.c')
-rw-r--r--drivers/iio/pressure/cros_ec_baro.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/iio/pressure/cros_ec_baro.c b/drivers/iio/pressure/cros_ec_baro.c
index d3acba7ba582..70148624db64 100644
--- a/drivers/iio/pressure/cros_ec_baro.c
+++ b/drivers/iio/pressure/cros_ec_baro.c
@@ -39,26 +39,29 @@ static int cros_ec_baro_read(struct iio_dev *indio_dev,
{
struct cros_ec_baro_state *st = iio_priv(indio_dev);
u16 data = 0;
- int ret = IIO_VAL_INT;
+ int ret;
int idx = chan->scan_index;
mutex_lock(&st->core.cmd_lock);
switch (mask) {
case IIO_CHAN_INFO_RAW:
- if (cros_ec_sensors_read_cmd(indio_dev, 1 << idx,
- (s16 *)&data) < 0)
- ret = -EIO;
+ ret = cros_ec_sensors_read_cmd(indio_dev, 1 << idx,
+ (s16 *)&data);
+ if (ret)
+ break;
+
*val = data;
+ ret = IIO_VAL_INT;
break;
case IIO_CHAN_INFO_SCALE:
st->core.param.cmd = MOTIONSENSE_CMD_SENSOR_RANGE;
st->core.param.sensor_range.data = EC_MOTION_SENSE_NO_VALUE;
- if (cros_ec_motion_send_host_cmd(&st->core, 0)) {
- ret = -EIO;
+ ret = cros_ec_motion_send_host_cmd(&st->core, 0);
+ if (ret)
break;
- }
+
*val = st->core.resp->sensor_range.ret;
/* scale * in_pressure_raw --> kPa */