linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Kocialkowski <contact@paulk.fr>
To: linux-kernel@vger.kernel.org
Cc: linux-tegra@vger.kernel.org, Sebastian Reichel <sre@kernel.org>,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	linux-pm@vger.kernel.org, Paul Kocialkowski <contact@paulk.fr>
Subject: [PATCH 2/2] power: bq24735-charger: Assume not charging when charger is missing
Date: Sun, 28 Aug 2016 19:34:46 +0200	[thread overview]
Message-ID: <20160828173446.32728-2-contact@paulk.fr> (raw)
In-Reply-To: <20160828173446.32728-1-contact@paulk.fr>

When the charger is missing (disconnected), it is safe to assume that
the charger chip is no charging.

This is especially relevant when a status GPIO is present and the
charger is getting disconnected. bq24735_charger_is_charging will be
triggered due to the interrupt then, it will attempt to read whether it
is charging through i2c, which will fail as the charger is disconnected.

This also fixes that specific issue.

Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
---
 drivers/power/bq24735-charger.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/power/bq24735-charger.c b/drivers/power/bq24735-charger.c
index 361a047..0b5b247 100644
--- a/drivers/power/bq24735-charger.c
+++ b/drivers/power/bq24735-charger.c
@@ -201,8 +201,12 @@ static bool bq24735_charger_is_present(struct bq24735 *charger)
 
 static int bq24735_charger_is_charging(struct bq24735 *charger)
 {
-	int ret = bq24735_read_word(charger->client, BQ24735_CHG_OPT);
+	int ret;
+
+	if (!bq24735_charger_is_present(charger))
+		return 0;
 
+	ret  = bq24735_read_word(charger->client, BQ24735_CHG_OPT);
 	if (ret < 0)
 		return ret;
 
-- 
2.9.3

  reply	other threads:[~2016-08-28 17:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-28 17:34 [PATCH 1/2] power: bq24735-charger: Request status GPIO with initial input setup Paul Kocialkowski
2016-08-28 17:34 ` Paul Kocialkowski [this message]
2016-08-29  0:40   ` [PATCH 2/2] power: bq24735-charger: Assume not charging when charger is missing Sebastian Reichel
2016-08-29  0:36 ` [PATCH 1/2] power: bq24735-charger: Request status GPIO with initial input setup Sebastian Reichel
2016-08-29 18:13   ` Paul Kocialkowski

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=20160828173446.32728-2-contact@paulk.fr \
    --to=contact@paulk.fr \
    --cc=dbaryshkov@gmail.com \
    --cc=dwmw2@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=sre@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 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).