From f53199c0bc62657f7bc253b5dfc9f3d81ed2ca28 Mon Sep 17 00:00:00 2001 From: Gwendal Grignou Date: Thu, 18 Jul 2019 15:22:37 -0700 Subject: 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 Signed-off-by: Jonathan Cameron --- drivers/iio/pressure/cros_ec_baro.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'drivers/iio/pressure/cros_ec_baro.c') 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 */ -- cgit v1.2.3