Messages in this thread Patch in this message |  | | From | Joshua Crofts via B4 Relay <> | | Date | Mon, 04 May 2026 11:48:20 +0200 | | Subject | [PATCH v4 08/17] iio: magnetometer: ak8975: avoid using temporary variable |
| |
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
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> --- drivers/iio/magnetometer/ak8975.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/iio/magnetometer/ak8975.c b/drivers/iio/magnetometer/ak8975.c index e399a6508a3e28931ec2efe07924d5f30cebf442..00bee434432f07e8e0bd7fb2b4c97cd2995af7a7 100644 --- a/drivers/iio/magnetometer/ak8975.c +++ b/drivers/iio/magnetometer/ak8975.c @@ -739,7 +739,6 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val) const struct i2c_client *client = data->client; const struct ak_def *def = data->def; __le16 rval; - u16 buff; int ret; pm_runtime_get_sync(&data->client->dev); @@ -776,8 +775,8 @@ static int ak8975_read_axis(struct iio_dev *indio_dev, int index, int *val) pm_runtime_put_autosuspend(&data->client->dev); /* Swap bytes and convert to valid range. */ - buff = le16_to_cpu(rval); - *val = clamp_t(s16, buff, -def->range, def->range); + *val = clamp_t(s16, le16_to_cpu(rval), -def->range, def->range); + return IIO_VAL_INT; exit: -- 2.47.3
|  |