From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: "Justin Weiss" <justin@justinweiss.com>,
"Alex Lanzano" <lanzano.alex@gmail.com>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
"Derek J . Clark" <derekjohn.clark@gmail.com>,
"Philip Müller" <philm@manjaro.org>
Subject: Re: [PATCH v4 2/4] iio: imu: bmi270: Add scale and sampling frequency to BMI270 IMU
Date: Mon, 28 Oct 2024 20:14:56 +0000 [thread overview]
Message-ID: <20241028201456.0cbfa75b@jic23-huawei> (raw)
In-Reply-To: <Zx9aR2h9pjdIMglO@smile.fi.intel.com>
On Mon, 28 Oct 2024 11:32:55 +0200
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> 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?
Hmm. This was my suggestion :(. For a simple case of match and do
something if true, this is a reasonably common pattern - particularly
in cases where there is a fallback option. I.e. you'd do something
after the loop only if there is no match.
Anyhow, given I suggested it I feel mean asking Justin to revert
to what he had in the first place. I don't feel that strongly about it
though so if the two of you agree this is neater, send a follow up patch.
Tweaked the line wraps whilst applying.
>
> for (i = 0; i < bmi270_odr_item.num; i++) {
> if (bmi270_odr_item.tbl[i].odr == odr ||
> bmi270_odr_item.tbl[i].uodr == uodr)
That would be a bad idea && is fine though .
> 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.
>
next prev parent reply other threads:[~2024-10-28 20:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-27 17:20 [PATCH v4 0/4] Add i2c driver for Bosch BMI260 IMU Justin Weiss
2024-10-27 17:20 ` [PATCH v4 1/4] iio: imu: bmi270: Add triggered buffer for Bosch BMI270 IMU Justin Weiss
2024-10-28 9:25 ` Andy Shevchenko
2024-10-28 20:08 ` Jonathan Cameron
2024-10-27 17:20 ` [PATCH v4 2/4] iio: imu: bmi270: Add scale and sampling frequency to " Justin Weiss
2024-10-28 9:32 ` Andy Shevchenko
2024-10-28 20:14 ` Jonathan Cameron [this message]
2024-10-27 17:20 ` [PATCH v4 3/4] dt-bindings: iio: imu: bmi270: Add Bosch BMI260 Justin Weiss
2024-10-27 20:26 ` Krzysztof Kozlowski
2024-10-27 17:20 ` [PATCH v4 4/4] iio: imu: bmi270: Add support for BMI260 Justin Weiss
2024-10-28 9:23 ` Andy Shevchenko
2024-10-28 20:18 ` [PATCH v4 0/4] Add i2c driver for Bosch BMI260 IMU Jonathan Cameron
2024-10-31 0:22 ` Justin Weiss
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241028201456.0cbfa75b@jic23-huawei \
--to=jic23@kernel.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=conor+dt@kernel.org \
--cc=derekjohn.clark@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=justin@justinweiss.com \
--cc=krzk+dt@kernel.org \
--cc=lanzano.alex@gmail.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=philm@manjaro.org \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox