[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zx9aR2h9pjdIMglO@smile.fi.intel.com>
Date: Mon, 28 Oct 2024 11:32:55 +0200
From: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To: Justin Weiss <justin@...tinweiss.com>
Cc: Alex Lanzano <lanzano.alex@...il.com>,
Jonathan Cameron <jic23@...nel.org>,
Lars-Peter Clausen <lars@...afoo.de>, Rob Herring <robh@...nel.org>,
Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, linux-iio@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
"Derek J . Clark" <derekjohn.clark@...il.com>,
Philip Müller <philm@...jaro.org>
Subject: Re: [PATCH v4 2/4] iio: imu: bmi270: Add scale and sampling
frequency to BMI270 IMU
On Sun, Oct 27, 2024 at 10:20:23AM -0700, Justin Weiss wrote:
> Add read and write functions and create _available entries.
...
> +static int bmi270_set_scale(struct bmi270_data *data,
> + int chan_type, int uscale)
There is available space in the previous line, (And I would even join them
despite being 83 characters long.)
...
> +static int bmi270_get_scale(struct bmi270_data *bmi270_device,
> + int chan_type, int *uscale)
Ditto (for chan_type).
...
> +static int bmi270_set_odr(struct bmi270_data *data, int chan_type,
> + int odr, int uodr)
Ditto.
...
> + for (i = 0; i < bmi270_odr_item.num; i++) {
> + if (bmi270_odr_item.tbl[i].odr != odr ||
> + bmi270_odr_item.tbl[i].uodr != uodr)
> + continue;
> +
> + return regmap_update_bits(data->regmap, reg, mask,
> + bmi270_odr_item.vals[i]);
> + }
> +
> + return -EINVAL;
Wouldn't be better to use regular patterns, i.e. checking for errors first?
for (i = 0; i < bmi270_odr_item.num; i++) {
if (bmi270_odr_item.tbl[i].odr == odr ||
bmi270_odr_item.tbl[i].uodr == uodr)
break;
}
if (i == bmi270_odr_item.num)
return -EINVAL;
return regmap_update_bits(data->regmap, reg, mask, bmi270_odr_item.vals[i]);
...
> +static int bmi270_get_odr(struct bmi270_data *data, int chan_type,
> + int *odr, int *uodr)
As per above.
> + for (i = 0; i < bmi270_odr_item.num; i++) {
> + if (val != bmi270_odr_item.vals[i])
> + continue;
> +
> + *odr = bmi270_odr_item.tbl[i].odr;
> + *uodr = bmi270_odr_item.tbl[i].uodr;
> + return 0;
> + }
> +
> + return -EINVAL;
As per above.
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists