[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAHp75Vfo4Ke9d-ZJ-BffYDbT9ppEQVOQbVpu1y_F2vXd+52YPQ@mail.gmail.com>
Date: Wed, 14 Sep 2022 13:57:20 +0300
From: Andy Shevchenko <andy.shevchenko@...il.com>
To: Eddie James <eajames@...ux.ibm.com>
Cc: jic23@...nel.org, lars@...afoo.de, linux-iio@...r.kernel.org,
joel@....id.au, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH v7 2/2] iio: pressure: dps310: Reset chip after timeout
On Tue, Sep 13, 2022 at 12:27 AM Eddie James <eajames@...ux.ibm.com> wrote:
>
> The DPS310 chip has been observed to get "stuck" such that pressure
> and temperature measurements are never indicated as "ready" in the
> MEAS_CFG register. The only solution is to reset the device and try
> again. In order to avoid continual failures, use a boolean flag to
> only try the reset after timeout once if errors persist.
...
> +static int dps310_ready_status(struct dps310_data *data, int ready_bit, int timeout)
> +{
> + int ready;
> + int sleep = DPS310_POLL_SLEEP_US(timeout);
Longer line first?
> + return regmap_read_poll_timeout(data->regmap, DPS310_MEAS_CFG, ready, ready & ready_bit,
> + sleep, timeout);
> +}
...
> +static int dps310_ready(struct dps310_data *data, int ready_bit, int timeout)
> +{
> + int rc;
> +
> + rc = dps310_ready_status(data, ready_bit, timeout);
> + if (rc) {
> + if (rc == -ETIMEDOUT && !data->timeout_recovery_failed) {
> + int rc2;
> +
> + /* Reset and reinitialize the chip. */
> + rc2 = dps310_reset_reinit(data);
> + if (rc2) {
With below in mind this might become
if (dps310_reset_init(...))
... = true;
> + data->timeout_recovery_failed = true;
> + } else {
> + /* Try again to get sensor ready status. */
> + rc2 = dps310_ready_status(data, ready_bit, timeout);
> + if (rc2)
> + data->timeout_recovery_failed = true;
Shouldn't you re-use rc here again?
> + else
> + return 0;
> + }
> + }
> +
> + return rc;
> + }
--
With Best Regards,
Andy Shevchenko
Powered by blists - more mailing lists