[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aL5NCVh9WylPhZ1O@sunspire>
Date: Mon, 8 Sep 2025 06:27:05 +0300
From: Petre Rodan <petre.rodan@...dimension.ro>
To: Jonathan Cameron <jic23@...nel.org>
Cc: linux-iio@...r.kernel.org, linux-kernel@...r.kernel.org,
David Lechner <dlechner@...libre.com>,
Nuno S?? <nuno.sa@...log.com>, Andy Shevchenko <andy@...nel.org>
Subject: Re: [PATCH 03/10] iio: accel: BMA220 migrate to regmap API
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
Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)
Powered by blists - more mailing lists