@@ -1133,8 +1133,7 @@ static int st_accel_write_raw(struct iio_dev *indio_dev,
int gain;
gain = val * 1000000 + val2;
- err = st_sensors_set_fullscale_by_gain(indio_dev, gain);
- break;
+ return st_sensors_set_fullscale_by_gain(indio_dev, gain);
}
case IIO_CHAN_INFO_SAMP_FREQ:
if (val2)
@@ -1146,8 +1145,6 @@ static int st_accel_write_raw(struct iio_dev *indio_dev,
default:
return -EINVAL;
}
-
- return err;
}
static ST_SENSORS_DEV_ATTR_SAMP_FREQ_AVAIL();
@@ -410,8 +410,7 @@ static int st_gyro_write_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_SCALE:
- err = st_sensors_set_fullscale_by_gain(indio_dev, val2);
- break;
+ return st_sensors_set_fullscale_by_gain(indio_dev, val2);
case IIO_CHAN_INFO_SAMP_FREQ:
if (val2)
return -EINVAL;
@@ -420,10 +419,8 @@ static int st_gyro_write_raw(struct iio_dev *indio_dev,
mutex_unlock(&indio_dev->mlock);
return err;
default:
- err = -EINVAL;
+ return -EINVAL;
}
-
- return err;
}
static ST_SENSORS_DEV_ATTR_SAMP_FREQ_AVAIL();
@@ -544,8 +544,7 @@ static int st_magn_write_raw(struct iio_dev *indio_dev,
switch (mask) {
case IIO_CHAN_INFO_SCALE:
- err = st_sensors_set_fullscale_by_gain(indio_dev, val2);
- break;
+ return st_sensors_set_fullscale_by_gain(indio_dev, val2);
case IIO_CHAN_INFO_SAMP_FREQ:
if (val2)
return -EINVAL;
@@ -554,10 +553,8 @@ static int st_magn_write_raw(struct iio_dev *indio_dev,
mutex_unlock(&indio_dev->mlock);
return err;
default:
- err = -EINVAL;
+ return -EINVAL;
}
-
- return err;
}
static ST_SENSORS_DEV_ATTR_SAMP_FREQ_AVAIL();
As there is no cleanup to do, let's return as early as possible in the various ST sensor drivers _write_raw() callback functions. There is no functional change. Suggested-by: Jonathan Cameron <jic23@kernel.org> Cc: Denis Ciocca <denis.ciocca@st.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> --- drivers/iio/accel/st_accel_core.c | 5 +---- drivers/iio/gyro/st_gyro_core.c | 7 ++----- drivers/iio/magnetometer/st_magn_core.c | 7 ++----- 3 files changed, 5 insertions(+), 14 deletions(-)