power: supply: bq24190_charger: using pm_runtime_resume_and_get instead of pm_runtime_get_sync

Using pm_runtime_resume_and_get is more appropriate
for simplifing code

Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
Minghao Chi 2022-04-12 08:30:44 +00:00 committed by Sebastian Reichel
parent 68fdbe090c
commit d96a89407e

View File

@ -455,11 +455,9 @@ static ssize_t bq24190_sysfs_show(struct device *dev,
if (!info)
return -EINVAL;
ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0)
return ret;
}
ret = bq24190_read_mask(bdi, info->reg, info->mask, info->shift, &v);
if (ret)
@ -490,11 +488,9 @@ static ssize_t bq24190_sysfs_store(struct device *dev,
if (ret < 0)
return ret;
ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0)
return ret;
}
ret = bq24190_write_mask(bdi, info->reg, info->mask, info->shift, v);
if (ret)
@ -512,10 +508,9 @@ static int bq24190_set_otg_vbus(struct bq24190_dev_info *bdi, bool enable)
union power_supply_propval val = { .intval = bdi->charge_type };
int ret;
ret = pm_runtime_get_sync(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0) {
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
pm_runtime_put_noidle(bdi->dev);
return ret;
}
@ -551,10 +546,9 @@ static int bq24190_vbus_is_enabled(struct regulator_dev *dev)
int ret;
u8 val;
ret = pm_runtime_get_sync(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0) {
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
pm_runtime_put_noidle(bdi->dev);
return ret;
}
@ -1128,11 +1122,9 @@ static int bq24190_charger_get_property(struct power_supply *psy,
dev_dbg(bdi->dev, "prop: %d\n", psp);
ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0)
return ret;
}
switch (psp) {
case POWER_SUPPLY_PROP_CHARGE_TYPE:
@ -1204,11 +1196,9 @@ static int bq24190_charger_set_property(struct power_supply *psy,
dev_dbg(bdi->dev, "prop: %d\n", psp);
ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0)
return ret;
}
switch (psp) {
case POWER_SUPPLY_PROP_ONLINE:
@ -1477,11 +1467,9 @@ static int bq24190_battery_get_property(struct power_supply *psy,
dev_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n");
dev_dbg(bdi->dev, "prop: %d\n", psp);
ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0)
return ret;
}
switch (psp) {
case POWER_SUPPLY_PROP_STATUS:
@ -1525,11 +1513,9 @@ static int bq24190_battery_set_property(struct power_supply *psy,
dev_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n");
dev_dbg(bdi->dev, "prop: %d\n", psp);
ret = pm_runtime_get_sync(bdi->dev);
if (ret < 0) {
pm_runtime_put_noidle(bdi->dev);
ret = pm_runtime_resume_and_get(bdi->dev);
if (ret < 0)
return ret;
}
switch (psp) {
case POWER_SUPPLY_PROP_ONLINE:
@ -1683,10 +1669,9 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
int error;
bdi->irq_event = true;
error = pm_runtime_get_sync(bdi->dev);
error = pm_runtime_resume_and_get(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);
@ -1921,11 +1906,9 @@ static int bq24190_remove(struct i2c_client *client)
struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
int error;
error = pm_runtime_get_sync(bdi->dev);
if (error < 0) {
error = pm_runtime_resume_and_get(bdi->dev);
if (error < 0)
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
pm_runtime_put_noidle(bdi->dev);
}
bq24190_register_reset(bdi);
if (bdi->battery)
@ -1982,11 +1965,9 @@ static __maybe_unused int bq24190_pm_suspend(struct device *dev)
struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
int error;
error = pm_runtime_get_sync(bdi->dev);
if (error < 0) {
error = pm_runtime_resume_and_get(bdi->dev);
if (error < 0)
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
pm_runtime_put_noidle(bdi->dev);
}
bq24190_register_reset(bdi);
@ -2007,11 +1988,9 @@ static __maybe_unused int bq24190_pm_resume(struct device *dev)
bdi->f_reg = 0;
bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */
error = pm_runtime_get_sync(bdi->dev);
if (error < 0) {
error = pm_runtime_resume_and_get(bdi->dev);
if (error < 0)
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
pm_runtime_put_noidle(bdi->dev);
}
bq24190_register_reset(bdi);
bq24190_set_config(bdi);