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

Submitted by Paul Kocialkowski on Aug. 28, 2016, 5:34 p.m.

Details

Message ID 20160828173446.32728-1-contact@paulk.fr
State New
Headers show

Commit Message

Paul Kocialkowski Aug. 28, 2016, 5:34 p.m.
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(-)

Comments

Sebastian Reichel Aug. 29, 2016, 12:36 a.m.
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
Paul Kocialkowski Aug. 29, 2016, 6:13 p.m.
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!

Patch hide | download patch | download mbox

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",