Skip to content

Commit 4cff988

Browse files
andy-shevjic23
authored andcommitted
iio: magnetometer: ak8975: avoid using temporary variable
Avoid using temporary variable in ak8975_read_axis(). With that being done, the clamp_t() call becomes idiomatic in the driver and can be factored out to a helper later on (and if needed). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Joshua Crofts <joshua.crofts1@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
1 parent c0b3561 commit 4cff988

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

drivers/iio/magnetometer/ak8975.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,6 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
741741
const struct i2c_client *client = data->client;
742742
const struct ak_def *def = data->def;
743743
__le16 rval;
744-
u16 buff;
745744
int ret;
746745

747746
pm_runtime_get_sync(&data->client->dev);
@@ -778,8 +777,8 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val)
778777
pm_runtime_put_autosuspend(&data->client->dev);
779778

780779
/* Swap bytes and convert to valid range. */
781-
buff = le16_to_cpu(rval);
782-
*val = clamp_t(s16, buff, -def->range, def->range);
780+
*val = clamp_t(s16, le16_to_cpu(rval), -def->range, def->range);
781+
783782
return IIO_VAL_INT;
784783

785784
exit:

0 commit comments

Comments
 (0)