summaryrefslogtreecommitdiff
path: root/drivers/power/supply/bq24190_charger.c
diff options
context:
space:
mode:
authorLiam Breck <kernel@networkimprov.net>2017-04-11 14:59:56 +0300
committerSebastian Reichel <sre@kernel.org>2017-04-14 02:41:35 +0300
commite3ebc381a966f7fb41b13c2823ff96f9d6d7a377 (patch)
tree47976f7852ecd77117274b1a5b64bbfef3b47b42 /drivers/power/supply/bq24190_charger.c
parent03add17fe338af82a28b41bda6afeb3b25c0a323 (diff)
downloadlinux-e3ebc381a966f7fb41b13c2823ff96f9d6d7a377.tar.xz
power: supply: bq24190_charger: Uniform pm_runtime_get() failure handling
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") Signed-off-by: Liam Breck <kernel@networkimprov.net> Acked-by: Tony Lindgren <tony@atomide.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Acked-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Sebastian Reichel <sre@kernel.org>
Diffstat (limited to 'drivers/power/supply/bq24190_charger.c')
-rw-r--r--drivers/power/supply/bq24190_charger.c37
1 files changed, 19 insertions, 18 deletions
diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index 145276f5056b..13b22e4a80cd 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -1280,12 +1280,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);
@@ -1453,13 +1454,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;
@@ -1470,7 +1473,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;
@@ -1479,13 +1482,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;
@@ -1496,7 +1499,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) {
@@ -1506,7 +1509,7 @@ static int bq24190_probe(struct i2c_client *client,
&bdi->extcon_nb);
if (ret) {
dev_err(dev, "Can't register extcon\n");
- goto out5;
+ goto out_sysfs;
}
/* Sync initial cable state */
@@ -1520,19 +1523,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;