All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] power: bq24190_charger: Uniform pm_runtime_get() failure handling
@ 2017-03-29  1:49 Liam Breck
  2017-03-29 16:30 ` Tony Lindgren
  2017-03-29 18:01 ` kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Liam Breck @ 2017-03-29  1:49 UTC (permalink / raw)
  To: Sebastian Reichel; +Cc: linux-pm, Tony Lindgren, Hans de Goede, Liam Breck

From: Liam Breck <kernel@networkimprov.net>

On pm_runtime_get() failure, always emit an error message.
Prevent unbalanced pm_runtime_get by calling:
  pm_runtime_put_noidle() in irq handler
  pm_runtime_put_sync() on any probe() failure
Rename probe() out labels instead of renumbering them.

Fixes: 13d6fa8447fa power: bq24190_charger: Use PM runtime autosuspend
Cc: Tony Lindgren <tony@atomide.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Liam Breck <kernel@networkimprov.net>
---
v2: not rebased to Hans' extcon patch, which needs some work.

 drivers/power/supply/bq24190_charger.c | 35 +++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index 64a48b9..b1c1ee8 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -1278,12 +1278,13 @@ static void bq24190_check_status(struct bq24190_dev_info *bdi)
 static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
 {
 	struct bq24190_dev_info *bdi = data;
-	int ret;
+	int error;
 
 	bdi->irq_event = true;
-	ret = pm_runtime_get_sync(bdi->dev);
-	if (ret < 0) {
-		dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
+	error = pm_runtime_get_sync(bdi->dev);
+	if (error < 0) {
+		dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
+		pm_runtime_put_noidle(bdi->dev);
 		return IRQ_NONE;
 	}
 	bq24190_check_status(bdi);
@@ -1447,13 +1448,15 @@ static int bq24190_probe(struct i2c_client *client,
 	pm_runtime_use_autosuspend(dev);
 	pm_runtime_set_autosuspend_delay(dev, 600);
 	ret = pm_runtime_get_sync(dev);
-	if (ret < 0)
-		goto out1;
+	if (ret < 0) {
+		dev_err(dev, "pm_runtime_get failed: %i\n", ret);
+		goto out_pmrt;
+	}
 
 	ret = bq24190_hw_init(bdi);
 	if (ret < 0) {
 		dev_err(dev, "Hardware init failed\n");
-		goto out2;
+		goto out_pmrt;
 	}
 
 	charger_cfg.drv_data = bdi;
@@ -1464,7 +1467,7 @@ static int bq24190_probe(struct i2c_client *client,
 	if (IS_ERR(bdi->charger)) {
 		dev_err(dev, "Can't register charger\n");
 		ret = PTR_ERR(bdi->charger);
-		goto out2;
+		goto out_pmrt;
 	}
 
 	battery_cfg.drv_data = bdi;
@@ -1473,13 +1476,13 @@ static int bq24190_probe(struct i2c_client *client,
 	if (IS_ERR(bdi->battery)) {
 		dev_err(dev, "Can't register battery\n");
 		ret = PTR_ERR(bdi->battery);
-		goto out3;
+		goto out_charger;
 	}
 
 	ret = bq24190_sysfs_create_group(bdi);
 	if (ret) {
 		dev_err(dev, "Can't create sysfs entries\n");
-		goto out4;
+		goto out_battery;
 	}
 
 	bdi->initialized = true;
@@ -1490,7 +1493,7 @@ static int bq24190_probe(struct i2c_client *client,
 			"bq24190-charger", bdi);
 	if (ret < 0) {
 		dev_err(dev, "Can't set up irq handler\n");
-		goto out5;
+		goto out_sysfs;
 	}
 
 	if (bdi->extcon) {
@@ -1512,19 +1515,17 @@ static int bq24190_probe(struct i2c_client *client,
 
 	return 0;
 
-out5:
+out_sysfs:
 	bq24190_sysfs_remove_group(bdi);
 
-out4:
+out_battery:
 	power_supply_unregister(bdi->battery);
 
-out3:
+out_charger:
 	power_supply_unregister(bdi->charger);
 
-out2:
+out_pmrt:
 	pm_runtime_put_sync(dev);
-
-out1:
 	pm_runtime_dont_use_autosuspend(dev);
 	pm_runtime_disable(dev);
 	return ret;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] power: bq24190_charger: Uniform pm_runtime_get() failure handling
  2017-03-29  1:49 [PATCH v2] power: bq24190_charger: Uniform pm_runtime_get() failure handling Liam Breck
@ 2017-03-29 16:30 ` Tony Lindgren
  2017-03-29 18:01 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: Tony Lindgren @ 2017-03-29 16:30 UTC (permalink / raw)
  To: Liam Breck; +Cc: Sebastian Reichel, linux-pm, Hans de Goede, Liam Breck

* Liam Breck <liam@networkimprov.net> [170328 18:52]:
> From: Liam Breck <kernel@networkimprov.net>
> 
> On pm_runtime_get() failure, always emit an error message.
> Prevent unbalanced pm_runtime_get by calling:
>   pm_runtime_put_noidle() in irq handler
>   pm_runtime_put_sync() on any probe() failure
> Rename probe() out labels instead of renumbering them.
> 
> Fixes: 13d6fa8447fa power: bq24190_charger: Use PM runtime autosuspend
> Cc: Tony Lindgren <tony@atomide.com>
> Cc: Hans de Goede <hdegoede@redhat.com>
> Signed-off-by: Liam Breck <kernel@networkimprov.net>
> ---
> v2: not rebased to Hans' extcon patch, which needs some work.

Looks OK to me:

Acked-by: Tony Lindgren <tony@atomide.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] power: bq24190_charger: Uniform pm_runtime_get() failure handling
  2017-03-29  1:49 [PATCH v2] power: bq24190_charger: Uniform pm_runtime_get() failure handling Liam Breck
  2017-03-29 16:30 ` Tony Lindgren
@ 2017-03-29 18:01 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2017-03-29 18:01 UTC (permalink / raw)
  To: Liam Breck
  Cc: kbuild-all, Sebastian Reichel, linux-pm, Tony Lindgren,
	Hans de Goede, Liam Breck

[-- Attachment #1: Type: text/plain, Size: 2050 bytes --]

Hi Liam,

[auto build test ERROR on next-20170328]
[cannot apply to battery/master power-supply/next v4.9-rc8 v4.9-rc7 v4.9-rc6 v4.11-rc4]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Liam-Breck/power-bq24190_charger-Uniform-pm_runtime_get-failure-handling/20170330-002331
config: i386-randconfig-x013-201713 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/power/supply/bq24190_charger.c: In function 'bq24190_probe':
>> drivers/power/supply/bq24190_charger.c:1505:4: error: label 'out5' used but not defined
       goto out5;
       ^~~~

vim +/out5 +1505 drivers/power/supply/bq24190_charger.c

4db249b6 Hans de Goede 2017-03-23  1499  	if (bdi->extcon) {
4db249b6 Hans de Goede 2017-03-23  1500  		INIT_DELAYED_WORK(&bdi->extcon_work, bq24190_extcon_work);
4db249b6 Hans de Goede 2017-03-23  1501  		bdi->extcon_nb.notifier_call = bq24190_extcon_event;
4db249b6 Hans de Goede 2017-03-23  1502  		ret = devm_extcon_register_notifier(dev, bdi->extcon, -1,
4db249b6 Hans de Goede 2017-03-23  1503  						    &bdi->extcon_nb);
4db249b6 Hans de Goede 2017-03-23  1504  		if (ret)
4db249b6 Hans de Goede 2017-03-23 @1505  			goto out5;
4db249b6 Hans de Goede 2017-03-23  1506  
4db249b6 Hans de Goede 2017-03-23  1507  		/* Sync initial cable state */
4db249b6 Hans de Goede 2017-03-23  1508  		queue_delayed_work(system_wq, &bdi->extcon_work, 0);

:::::: The code at line 1505 was first introduced by commit
:::::: 4db249b6f3b47c28c361cf8598954b12403ce94c power: supply: bq24190_charger: Use extcon to determine ilimit, 5v boost

:::::: TO: Hans de Goede <hdegoede@redhat.com>
:::::: CC: Sebastian Reichel <sre@kernel.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29594 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-03-29 18:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-29  1:49 [PATCH v2] power: bq24190_charger: Uniform pm_runtime_get() failure handling Liam Breck
2017-03-29 16:30 ` Tony Lindgren
2017-03-29 18:01 ` kbuild test robot

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.