From: Navid Emamdoost <navid.emamdoost@gmail.com>
To: Sebastian Reichel <sre@kernel.org>,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: emamd001@umn.edu, wu000273@umn.edu, kjlu@umn.edu,
mccamant@cs.umn.edu, Navid <navid.emamdoost@gmail.com>
Subject: [PATCH] power: supply: bq24190_charger.c: call pm_runtime_put in pm_runtime_get_sync failed case
Date: Mon, 1 Jun 2020 02:03:35 -0500 [thread overview]
Message-ID: <20200601070335.84800-1-navid.emamdoost@gmail.com> (raw)
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
next reply other threads:[~2020-06-01 7:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-01 7:03 Navid Emamdoost [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-06-01 8:01 [PATCH] power: supply: bq24190_charger.c: call pm_runtime_put in pm_runtime_get_sync failed case Markus Elfring
2020-06-01 6:25 Navid
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200601070335.84800-1-navid.emamdoost@gmail.com \
--to=navid.emamdoost@gmail.com \
--cc=emamd001@umn.edu \
--cc=kjlu@umn.edu \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mccamant@cs.umn.edu \
--cc=sre@kernel.org \
--cc=wu000273@umn.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).