All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andy.shevchenko@gmail.com>
To: Eddie James <eajames@linux.ibm.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Lars-Peter Clausen <lars@metafoo.de>,
	linux-iio <linux-iio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Joel Stanley <joel@jms.id.au>
Subject: Re: [PATCH v6 2/2] iio: pressure: dps310: Reset chip after timeout
Date: Tue, 6 Sep 2022 23:36:28 +0300	[thread overview]
Message-ID: <CAHp75VcLiCRy_m35Sd4AGpOKQ+5WTXMzHZA7hcwDR-t1v46t2Q@mail.gmail.com> (raw)
In-Reply-To: <20220906200535.1919398-3-eajames@linux.ibm.com>

On Tue, Sep 6, 2022 at 11:05 PM Eddie James <eajames@linux.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.

If the previous patch is a dependency to this one, you need to use its
Subject in a Cc: stable@ tag as it's pointed out in the documentation.
Otherwise, Fixes go first in the series.

...

> +static int dps310_reset_reinit(struct dps310_data *data)
> +{
> +       int rc;
> +
> +       rc = dps310_reset_wait(data);
> +       if (rc)
> +               return rc;

> +       rc = dps310_startup(data);
> +       if (rc)
> +               return rc;
> +
> +       return 0;

Can be simply return _startup(...);

> +}

...

Can it be a helper here?

int dps310_get_ready_status(data, ready_bit, timeout)
{
  sleep = ...
  int ready;

 return regmap_read_poll_timeout(...);

}

> +static int dps310_ready(struct dps310_data *data, int ready_bit, int timeout)
> +{
> +       int rc;
> +       int ready;
> +       int sleep = DPS310_POLL_SLEEP_US(timeout);

> +       rc = regmap_read_poll_timeout(data->regmap, DPS310_MEAS_CFG, ready, ready & ready_bit,
> +                                     sleep, timeout);

rc = dps310_get_ready_status(...);

> +       if (rc) {
> +               if (rc == -ETIMEDOUT && !data->timeout_recovery_failed) {
> +                       int rc2;
> +
> +                       /* Reset and reinitialize the chip. */
> +                       rc2 = dps310_reset_reinit(data);
> +                       if (rc2) {
> +                               data->timeout_recovery_failed = true;
> +                       } else {

> +                               /* Try again to get sensor ready status. */
> +                               rc2 = regmap_read_poll_timeout(data->regmap, DPS310_MEAS_CFG,
> +                                                              ready, ready & ready_bit, sleep,
> +                                                              timeout);

rc2 = dps310_get_ready_status(...);

> +                               if (rc2)
> +                                       data->timeout_recovery_failed = true;
> +                               else
> +                                       return 0;
> +                       }
> +               }
> +
> +               return rc;
> +       }
> +
> +       data->timeout_recovery_failed = false;
> +       return 0;
> +}

--
With Best Regards,
Andy Shevchenko

      reply	other threads:[~2022-09-06 20:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-06 20:05 [PATCH v6 0/2] iio: pressure: dps310: Reset chip if MEAS_CFG is corrupt Eddie James
2022-09-06 20:05 ` [PATCH v6 1/2] iio: pressure: dps310: Refactor startup procedure Eddie James
2022-09-06 20:05 ` [PATCH v6 2/2] iio: pressure: dps310: Reset chip after timeout Eddie James
2022-09-06 20:36   ` Andy Shevchenko [this message]

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=CAHp75VcLiCRy_m35Sd4AGpOKQ+5WTXMzHZA7hcwDR-t1v46t2Q@mail.gmail.com \
    --to=andy.shevchenko@gmail.com \
    --cc=eajames@linux.ibm.com \
    --cc=jic23@kernel.org \
    --cc=joel@jms.id.au \
    --cc=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.