All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rhyland Klein <rklein@nvidia.com>
To: Olof Johansson <olof@lixom.net>
Cc: Anton Vorontsov <cbou@mail.ru>,
	David Woodhouse <dwmw2@infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] sbs-battery: probe should try talking to the device
Date: Thu, 6 Sep 2012 14:35:30 -0400	[thread overview]
Message-ID: <5048ECF2.8050307@nvidia.com> (raw)
In-Reply-To: <1346956349-21980-1-git-send-email-olof@lixom.net>

On 09/06/2012 02:32 PM, Olof Johansson wrote:
> Turns out this driver doesn't actually try talking to the device at
> probe time, so if it's incorrectly configured in the device tree or
> platform data (or if the battery has been removed from the system), then
> probe will succeed and every access will sit there and time out. The
> end result is a possibly laggy system that thinks it has a battery but
> can never read status, which isn't very useful.
>
> Instead, just read any register (I chose status) at probe, and if that
> fails, don't register the device.
>
> Signed-off-by: Olof Johansson <olof@lixom.net>
> ---
>   drivers/power/sbs-battery.c | 10 ++++++++++
>   1 file changed, 10 insertions(+)
>
> diff --git a/drivers/power/sbs-battery.c b/drivers/power/sbs-battery.c
> index a65e8f5..2f24253 100644
> --- a/drivers/power/sbs-battery.c
> +++ b/drivers/power/sbs-battery.c
> @@ -760,6 +760,16 @@ static int __devinit sbs_probe(struct i2c_client *client,
>
>   skip_gpio:
>
> +	/* Before we register, we need to make sure we can actually talk
> +	 * to the battery.
> +	 */
> +	rc = sbs_read_word_data(client, sbs_data[REG_STATUS].addr);
> +	if (rc < 0) {
> +		dev_err(&client->dev, "%s: Failed to get device status\n",
> +			__func__);
> +		goto exit_psupply;
> +	}
> +
>   	rc = power_supply_register(&client->dev, &chip->power_supply);
>   	if (rc) {
>   		dev_err(&client->dev,
>

Acked-by: Rhyland Klein <rklein@nvidia.com>

-- 
nvpublic

  reply	other threads:[~2012-09-06 18:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-06 18:32 [PATCH] sbs-battery: probe should try talking to the device Olof Johansson
2012-09-06 18:35 ` Rhyland Klein [this message]
2012-09-20 21:59   ` Anton Vorontsov

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=5048ECF2.8050307@nvidia.com \
    --to=rklein@nvidia.com \
    --cc=cbou@mail.ru \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=olof@lixom.net \
    /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.