power: bq24190_charger: Uniform pm_runtime_get() failure handling
PATCH v2 1/1 power: bq24190_charger: Uniform pm_runtime_get() failure handling
From: Liam Breck <[email protected]>
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.
---
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(-)
drivers/power/supply/bq24190_charger.c +18 -17
@@ -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;
Signature · 1 line
2.9.3
Quoted 8 lines · Liam Breck
From: Liam Breck <[email protected]>
On
pm_runtime_get()failure, always emit an error message. Prevent unbalancedpm_runtime_getby calling:
pm_runtime_put_noidle()in irq handlerpm_runtime_put_sync()on anyprobe()failure
Renameprobe()out labels instead of renumbering them.
Quoted 6 lines
Fixes 13d6fa8447fa power: bq24190_charger: Use PM runtime autosuspendCc Tony Lindgren <[email protected]>Cc Hans de Goede <[email protected]>Signed-off-by Liam Breck <[email protected]>---
v2: not rebased to Hans' extcon patch, which needs some work.
Looks OK to me:
kbuild test robot
build boturl: 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)…
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 <[email protected]>
:::::: CC: Sebastian Reichel <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation