linux-i2c.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>
To: Michael Auchter <michael.auchter@ni.com>
Cc: Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-i2c <linux-i2c@vger.kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] misc: eeprom: at24: fix regulator underflow
Date: Wed, 11 Mar 2020 09:26:54 +0100	[thread overview]
Message-ID: <CAMpxmJXBN_qTwHpcD-anHVB-uhatuN-PZDUUe6boD0GoFiMVXw@mail.gmail.com> (raw)
In-Reply-To: <20200310205841.123084-1-michael.auchter@ni.com>

wt., 10 mar 2020 o 21:59 Michael Auchter <michael.auchter@ni.com> napisał(a):
>
> The at24 driver attempts to read a byte from the device to validate that
> it's actually present, and if not, disables the vcc regulator and
> returns -ENODEV. However, between the read and the error handling path,
> pm_runtime_idle() is called and invokes the driver's suspend callback,
> which also disables the vcc regulator. This leads to an underflow of the
> regulator enable count if the EEPROM is not present.
>
> Move the pm_runtime_suspend() call to be after the error handling path
> to resolve this.
>
> Signed-off-by: Michael Auchter <michael.auchter@ni.com>
> ---
>  drivers/misc/eeprom/at24.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
> index 031eb64549af..282c9ef68ed2 100644
> --- a/drivers/misc/eeprom/at24.c
> +++ b/drivers/misc/eeprom/at24.c
> @@ -712,13 +712,14 @@ static int at24_probe(struct i2c_client *client)
>          * chip is functional.
>          */
>         err = at24_read(at24, 0, &test_byte, 1);
> -       pm_runtime_idle(dev);
>         if (err) {
>                 pm_runtime_disable(dev);
>                 regulator_disable(at24->vcc_reg);
>                 return -ENODEV;
>         }
>
> +       pm_runtime_idle(dev);
> +
>         if (writable)
>                 dev_info(dev, "%u byte %s EEPROM, writable, %u bytes/write\n",
>                          byte_len, client->name, at24->write_max);
> --
> 2.24.1
>

Patch applied for fixes.

Bartosz

      reply	other threads:[~2020-03-11  8:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-10 20:58 [PATCH] misc: eeprom: at24: fix regulator underflow Michael Auchter
2020-03-11  8:26 ` Bartosz Golaszewski [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=CAMpxmJXBN_qTwHpcD-anHVB-uhatuN-PZDUUe6boD0GoFiMVXw@mail.gmail.com \
    --to=bgolaszewski@baylibre.com \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.auchter@ni.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;
as well as URLs for NNTP newsgroup(s).