From: Petre Rodan <petre.rodan@subdimension.ro>
To: Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
David Lechner <dlechner@baylibre.com>,
Nuno S?? <nuno.sa@analog.com>, Andy Shevchenko <andy@kernel.org>
Subject: Re: [PATCH 03/10] iio: accel: BMA220 migrate to regmap API
Date: Mon, 8 Sep 2025 06:27:05 +0300 [thread overview]
Message-ID: <aL5NCVh9WylPhZ1O@sunspire> (raw)
In-Reply-To: <20250907134506.580de654@jic23-huawei>
[-- Attachment #1: Type: text/plain, Size: 1485 bytes --]
On Sun, Sep 07, 2025 at 01:45:06PM +0100, Jonathan Cameron wrote:
> > +static int bma220_reset(struct bma220_data *data, bool up)
> > {
> > + int i, ret;
> > + unsigned int val;
> > + guard(mutex)(&data->lock);
> >
> > + /**
> > + * The chip can be reset by a simple register read.
> > + * We need up to 2 register reads of the softreset register
>
> May need? Given you return early if the first one succeeds. If you actually
> need two drop the loop and only check values on second read.
>
> > + * to make sure that the device is in the desired state.
> > + */
> > + for (i = 0; i < 2; i++) {
> > + ret = regmap_read(data->regmap, BMA220_REG_SOFTRESET, &val);
> > + if (ret < 0)
> > + return ret;
I'm not sure how eloquently I can explain this. the sensor can be in
sleep state / non-sleep state
reset state / non-reset state
(these overlap)
the sensor toggles between these states when the master reads the suspend and
the soft_reset registers respectively.
based on the value read one can tell what was the previous state the sensor was in.
bma220_init() simply places the sensor in the non-sleep AND non-reset modes (and
resets all configuration registers so that we start from a known initial condition)
'may need' is used because the sensor might have been left in an unexpected mode
in the previous session.
we need at most two reads of a register to make sure bma220 ends up in the state we need.
best regards,
peter
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2025-09-08 3:27 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-01 19:47 [PATCH 0/10] iio: accel: BMA220 improvements Petre Rodan
2025-09-01 19:47 ` [PATCH 01/10] dt-bindings: iio: accel: bosch,BMA220 improvements Petre Rodan
2025-09-02 5:57 ` Krzysztof Kozlowski
2025-09-02 16:02 ` Petre Rodan
2025-09-02 16:14 ` David Lechner
2025-09-02 19:22 ` Krzysztof Kozlowski
2025-09-05 20:15 ` David Lechner
2025-09-06 2:46 ` Petre Rodan
2025-09-06 14:36 ` David Lechner
2025-09-01 19:47 ` [PATCH 02/10] iio: accel: BMA220 split original spi driver Petre Rodan
2025-09-07 12:29 ` Jonathan Cameron
2025-09-01 19:47 ` [PATCH 03/10] iio: accel: BMA220 migrate to regmap API Petre Rodan
2025-09-07 12:45 ` Jonathan Cameron
2025-09-08 3:27 ` Petre Rodan [this message]
2025-09-09 16:15 ` Jonathan Cameron
2025-09-01 19:47 ` [PATCH 04/10] iio: accel: BMA220 add i2c module Petre Rodan
2025-09-07 12:46 ` Jonathan Cameron
2025-09-01 19:47 ` [PATCH 05/10] iio: accel: BMA220 make use of the watchdog functionality Petre Rodan
2025-09-07 12:48 ` Jonathan Cameron
2025-09-01 19:47 ` [PATCH 06/10] iio: accel: BMA220 add LPF cut-off frequency mapping Petre Rodan
2025-09-05 19:59 ` David Lechner
2025-09-07 12:50 ` Jonathan Cameron
2025-09-01 19:47 ` [PATCH 07/10] iio: accel: BMA220 add debugfs reg access Petre Rodan
2025-09-01 19:47 ` [PATCH 08/10] iio: accel: BMA220 add events Petre Rodan
2025-09-07 13:02 ` Jonathan Cameron
2025-09-01 19:47 ` [PATCH 09/10] iio: accel: BMA220 add event attrs Petre Rodan
2025-09-07 13:15 ` Jonathan Cameron
2025-09-07 13:28 ` Petre Rodan
2025-09-09 16:20 ` Jonathan Cameron
2025-09-01 19:47 ` [PATCH 10/10] iio: accel: BMA220 add maintainer Petre Rodan
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=aL5NCVh9WylPhZ1O@sunspire \
--to=petre.rodan@subdimension.ro \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
/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