Skip to contentSkip to conversation

power: supply: bq24190_charger.c: call pm_runtime_put in pm_runtime_get_sync failed case

PATCH New Navid 1 participant 1 message Jun 1, 2020 Power supply

lore
Share & tools
lore

Navid

author
#0 lore raw

PATCH 1/1 power: supply: bq24190_charger.c: call pm_runtime_put in pm_runtime_get_sync failed case

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.

---
 drivers/power/supply/bq24190_charger.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/power/supply/bq24190_charger.c +18 -8
index 453d6332d43a..502ccdac2443 100644
@@ -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;
Signature · 1 line
2.17.1