Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1471418 > unrolled thread

[PATCH 1/2] power: bq24735-charger: Request status GPIO with initial input setup

Started byPaul Kocialkowski <contact@paulk.fr>
First post2016-08-28 19:50 +0200
Last post2016-08-29 20:20 +0200
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/2] power: bq24735-charger: Request status GPIO with initial input setup Paul Kocialkowski <contact@paulk.fr> - 2016-08-28 19:50 +0200
    [PATCH 2/2] power: bq24735-charger: Assume not charging when charger is missing Paul Kocialkowski <contact@paulk.fr> - 2016-08-28 19:50 +0200
      Re: [PATCH 2/2] power: bq24735-charger: Assume not charging when  charger is missing Sebastian Reichel <sre@kernel.org> - 2016-08-29 02:50 +0200
    Re: [PATCH 1/2] power: bq24735-charger: Request status GPIO with  initial input setup Sebastian Reichel <sre@kernel.org> - 2016-08-29 02:40 +0200
      Re: [PATCH 1/2] power: bq24735-charger: Request status GPIO with  initial input setup Paul Kocialkowski <contact@paulk.fr> - 2016-08-29 20:20 +0200

#1471418 — [PATCH 1/2] power: bq24735-charger: Request status GPIO with initial input setup

FromPaul Kocialkowski <contact@paulk.fr>
Date2016-08-28 19:50 +0200
Subject[PATCH 1/2] power: bq24735-charger: Request status GPIO with initial input setup
Message-ID<sbcnw-4H8-31@gated-at.bofh.it>
This requests the status GPIO with initial input setup. it is required
to read the GPIO status at probe time and thus correctly avoid sending
i2c messages when AC is not plugged.

When requesting the GPIO without initial input setup, it always reads 0
which causes probe to fail as it assumes the charger is connected, sends
i2c messages and fails.

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

diff --git a/drivers/power/bq24735-charger.c b/drivers/power/bq24735-charger.c
index fa454c1..361a047 100644
--- a/drivers/power/bq24735-charger.c
+++ b/drivers/power/bq24735-charger.c
@@ -393,9 +393,9 @@ static int bq24735_charger_probe(struct i2c_client *client,
 	i2c_set_clientdata(client, charger);
 
 	if (gpio_is_valid(charger->pdata->status_gpio)) {
-		ret = devm_gpio_request(&client->dev,
-					charger->pdata->status_gpio,
-					name);
+		ret = devm_gpio_request_one(&client->dev,
+						charger->pdata->status_gpio,
+						GPIOF_IN, name);
 		if (ret) {
 			dev_err(&client->dev,
 				"Failed GPIO request for GPIO %d: %d\n",
-- 
2.9.3

[toc] | [next] | [standalone]


#1471419 — [PATCH 2/2] power: bq24735-charger: Assume not charging when charger is missing

FromPaul Kocialkowski <contact@paulk.fr>
Date2016-08-28 19:50 +0200
Subject[PATCH 2/2] power: bq24735-charger: Assume not charging when charger is missing
Message-ID<sbcnw-4H8-35@gated-at.bofh.it>
In reply to#1471418
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

[toc] | [prev] | [next] | [standalone]


#1471506 — Re: [PATCH 2/2] power: bq24735-charger: Assume not charging when charger is missing

FromSebastian Reichel <sre@kernel.org>
Date2016-08-29 02:50 +0200
SubjectRe: [PATCH 2/2] power: bq24735-charger: Assume not charging when charger is missing
Message-ID<sbiVX-kL-1@gated-at.bofh.it>
In reply to#1471419

[Multipart message — attachments visible in raw view] — view raw

Hi,

On Sun, Aug 28, 2016 at 07:34:46PM +0200, Paul Kocialkowski wrote:
> 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.

Thanks, I queued this one into my for-next branch.

-- Sebastian

[toc] | [prev] | [next] | [standalone]


#1471505 — Re: [PATCH 1/2] power: bq24735-charger: Request status GPIO with initial input setup

FromSebastian Reichel <sre@kernel.org>
Date2016-08-29 02:40 +0200
SubjectRe: [PATCH 1/2] power: bq24735-charger: Request status GPIO with initial input setup
Message-ID<sbiMh-hG-1@gated-at.bofh.it>
In reply to#1471418

[Multipart message — attachments visible in raw view] — view raw

Hi,

On Sun, Aug 28, 2016 at 07:34:45PM +0200, Paul Kocialkowski wrote:
> This requests the status GPIO with initial input setup. it is required
> to read the GPIO status at probe time and thus correctly avoid sending
> i2c messages when AC is not plugged.
> 
> When requesting the GPIO without initial input setup, it always reads 0
> which causes probe to fail as it assumes the charger is connected, sends
> i2c messages and fails.

Please convert the driver to devm_gpiod_get instead.

-- Sebastian

[toc] | [prev] | [next] | [standalone]


#1472037 — Re: [PATCH 1/2] power: bq24735-charger: Request status GPIO with initial input setup

FromPaul Kocialkowski <contact@paulk.fr>
Date2016-08-29 20:20 +0200
SubjectRe: [PATCH 1/2] power: bq24735-charger: Request status GPIO with initial input setup
Message-ID<sbzk5-2el-1@gated-at.bofh.it>
In reply to#1471505

[Multipart message — attachments visible in raw view] — view raw

Le lundi 29 août 2016 à 02:36 +0200, Sebastian Reichel a écrit :
> Hi,
> 
> On Sun, Aug 28, 2016 at 07:34:45PM +0200, Paul Kocialkowski wrote:
> > 
> > This requests the status GPIO with initial input setup. it is required
> > to read the GPIO status at probe time and thus correctly avoid sending
> > i2c messages when AC is not plugged.
> > 
> > When requesting the GPIO without initial input setup, it always reads 0
> > which causes probe to fail as it assumes the charger is connected, sends
> > i2c messages and fails.
> 
> Please convert the driver to devm_gpiod_get instead.

Sure thing, see v2.

Thanks!

-- 
Paul Kocialkowski, developer of low-level free software for embedded devices

Website: https://www.paulk.fr/
Coding blog: https://code.paulk.fr/
Git repositories: https://git.paulk.fr/ https://git.code.paulk.fr/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web