lkml.org 
[lkml]   [2020]   [Jun]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] power: supply: bq24190_charger.c: call pm_runtime_put in pm_runtime_get_sync failed case
Date
From: Navid <navid.emamdoost@gmail.com>

Even in failed case of pm_runtime_get_sync, the usage_count
is incremented. In order to keep the usage_count with correct
value call pm_runtime_put_autosuspend.

Signed-off-by: Navid <navid.emamdoost@gmail.com>
---
drivers/power/supply/bq24190_charger.c | 26 ++++++++++++++++++--------
1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/drivers/power/supply/bq24190_charger.c b/drivers/power/supply/bq24190_charger.c
index 453d6332d43a..502ccdac2443 100644
--- a/drivers/power/supply/bq24190_charger.c
+++ b/drivers/power/supply/bq24190_charger.c
@@ -448,8 +448,10 @@ static ssize_t bq24190_sysfs_show(struct device *dev,
return -EINVAL;

ret = pm_runtime_get_sync(bdi->dev);
- if (ret < 0)
- return ret;
+ if (ret < 0) {
+ count = ret;
+ goto out;
+ }

ret = bq24190_read_mask(bdi, info->reg, info->mask, info->shift, &v);
if (ret)
@@ -458,6 +460,7 @@ static ssize_t bq24190_sysfs_show(struct device *dev,
count = scnprintf(buf, PAGE_SIZE, "%hhx\n", v);

pm_runtime_mark_last_busy(bdi->dev);
+out:
pm_runtime_put_autosuspend(bdi->dev);

return count;
@@ -481,14 +484,17 @@ static ssize_t bq24190_sysfs_store(struct device *dev,
return ret;

ret = pm_runtime_get_sync(bdi->dev);
- if (ret < 0)
- return ret;
+ if (ret < 0) {
+ count = ret;
+ goto out;
+ }

ret = bq24190_write_mask(bdi, info->reg, info->mask, info->shift, v);
if (ret)
count = ret;

pm_runtime_mark_last_busy(bdi->dev);
+out:
pm_runtime_put_autosuspend(bdi->dev);

return count;
@@ -1076,7 +1082,7 @@ static int bq24190_charger_get_property(struct power_supply *psy,

ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0)
- return ret;
+ goto out;

switch (psp) {
case POWER_SUPPLY_PROP_CHARGE_TYPE:
@@ -1132,6 +1138,7 @@ static int bq24190_charger_get_property(struct power_supply *psy,
}

pm_runtime_mark_last_busy(bdi->dev);
+out:
pm_runtime_put_autosuspend(bdi->dev);

return ret;
@@ -1148,7 +1155,7 @@ static int bq24190_charger_set_property(struct power_supply *psy,

ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0)
- return ret;
+ goto out;

switch (psp) {
case POWER_SUPPLY_PROP_ONLINE:
@@ -1174,6 +1181,7 @@ static int bq24190_charger_set_property(struct power_supply *psy,
}

pm_runtime_mark_last_busy(bdi->dev);
+out:
pm_runtime_put_autosuspend(bdi->dev);

return ret;
@@ -1409,7 +1417,7 @@ static int bq24190_battery_get_property(struct power_supply *psy,

ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0)
- return ret;
+ goto out;

switch (psp) {
case POWER_SUPPLY_PROP_STATUS:
@@ -1438,6 +1446,7 @@ static int bq24190_battery_get_property(struct power_supply *psy,
}

pm_runtime_mark_last_busy(bdi->dev);
+out:
pm_runtime_put_autosuspend(bdi->dev);

return ret;
@@ -1455,7 +1464,7 @@ static int bq24190_battery_set_property(struct power_supply *psy,

ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0)
- return ret;
+ goto out;

switch (psp) {
case POWER_SUPPLY_PROP_ONLINE:
@@ -1469,6 +1478,7 @@ static int bq24190_battery_set_property(struct power_supply *psy,
}

pm_runtime_mark_last_busy(bdi->dev);
+out:
pm_runtime_put_autosuspend(bdi->dev);

return ret;
--
2.17.1
\
 
 \ /
  Last update: 2020-06-01 09:04    [W:0.035 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site