mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 20:51:44 +00:00
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:
parent
68fdbe090c
commit
d96a89407e
@ -455,11 +455,9 @@ static ssize_t bq24190_sysfs_show(struct device *dev,
|
|||||||
if (!info)
|
if (!info)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
ret = pm_runtime_get_sync(bdi->dev);
|
ret = pm_runtime_resume_and_get(bdi->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
pm_runtime_put_noidle(bdi->dev);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
ret = bq24190_read_mask(bdi, info->reg, info->mask, info->shift, &v);
|
ret = bq24190_read_mask(bdi, info->reg, info->mask, info->shift, &v);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -490,11 +488,9 @@ static ssize_t bq24190_sysfs_store(struct device *dev,
|
|||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = pm_runtime_get_sync(bdi->dev);
|
ret = pm_runtime_resume_and_get(bdi->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
pm_runtime_put_noidle(bdi->dev);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
ret = bq24190_write_mask(bdi, info->reg, info->mask, info->shift, v);
|
ret = bq24190_write_mask(bdi, info->reg, info->mask, info->shift, v);
|
||||||
if (ret)
|
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 };
|
union power_supply_propval val = { .intval = bdi->charge_type };
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = pm_runtime_get_sync(bdi->dev);
|
ret = pm_runtime_resume_and_get(bdi->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
|
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
|
||||||
pm_runtime_put_noidle(bdi->dev);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,10 +546,9 @@ static int bq24190_vbus_is_enabled(struct regulator_dev *dev)
|
|||||||
int ret;
|
int ret;
|
||||||
u8 val;
|
u8 val;
|
||||||
|
|
||||||
ret = pm_runtime_get_sync(bdi->dev);
|
ret = pm_runtime_resume_and_get(bdi->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
|
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
|
||||||
pm_runtime_put_noidle(bdi->dev);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1128,11 +1122,9 @@ static int bq24190_charger_get_property(struct power_supply *psy,
|
|||||||
|
|
||||||
dev_dbg(bdi->dev, "prop: %d\n", psp);
|
dev_dbg(bdi->dev, "prop: %d\n", psp);
|
||||||
|
|
||||||
ret = pm_runtime_get_sync(bdi->dev);
|
ret = pm_runtime_resume_and_get(bdi->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
pm_runtime_put_noidle(bdi->dev);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
switch (psp) {
|
switch (psp) {
|
||||||
case POWER_SUPPLY_PROP_CHARGE_TYPE:
|
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);
|
dev_dbg(bdi->dev, "prop: %d\n", psp);
|
||||||
|
|
||||||
ret = pm_runtime_get_sync(bdi->dev);
|
ret = pm_runtime_resume_and_get(bdi->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
pm_runtime_put_noidle(bdi->dev);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
switch (psp) {
|
switch (psp) {
|
||||||
case POWER_SUPPLY_PROP_ONLINE:
|
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_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n");
|
||||||
dev_dbg(bdi->dev, "prop: %d\n", psp);
|
dev_dbg(bdi->dev, "prop: %d\n", psp);
|
||||||
|
|
||||||
ret = pm_runtime_get_sync(bdi->dev);
|
ret = pm_runtime_resume_and_get(bdi->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
pm_runtime_put_noidle(bdi->dev);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
switch (psp) {
|
switch (psp) {
|
||||||
case POWER_SUPPLY_PROP_STATUS:
|
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_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n");
|
||||||
dev_dbg(bdi->dev, "prop: %d\n", psp);
|
dev_dbg(bdi->dev, "prop: %d\n", psp);
|
||||||
|
|
||||||
ret = pm_runtime_get_sync(bdi->dev);
|
ret = pm_runtime_resume_and_get(bdi->dev);
|
||||||
if (ret < 0) {
|
if (ret < 0)
|
||||||
pm_runtime_put_noidle(bdi->dev);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
|
||||||
|
|
||||||
switch (psp) {
|
switch (psp) {
|
||||||
case POWER_SUPPLY_PROP_ONLINE:
|
case POWER_SUPPLY_PROP_ONLINE:
|
||||||
@ -1683,10 +1669,9 @@ static irqreturn_t bq24190_irq_handler_thread(int irq, void *data)
|
|||||||
int error;
|
int error;
|
||||||
|
|
||||||
bdi->irq_event = true;
|
bdi->irq_event = true;
|
||||||
error = pm_runtime_get_sync(bdi->dev);
|
error = pm_runtime_resume_and_get(bdi->dev);
|
||||||
if (error < 0) {
|
if (error < 0) {
|
||||||
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
|
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
|
||||||
pm_runtime_put_noidle(bdi->dev);
|
|
||||||
return IRQ_NONE;
|
return IRQ_NONE;
|
||||||
}
|
}
|
||||||
bq24190_check_status(bdi);
|
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);
|
struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = pm_runtime_get_sync(bdi->dev);
|
error = pm_runtime_resume_and_get(bdi->dev);
|
||||||
if (error < 0) {
|
if (error < 0)
|
||||||
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
|
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
|
||||||
pm_runtime_put_noidle(bdi->dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
bq24190_register_reset(bdi);
|
bq24190_register_reset(bdi);
|
||||||
if (bdi->battery)
|
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);
|
struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = pm_runtime_get_sync(bdi->dev);
|
error = pm_runtime_resume_and_get(bdi->dev);
|
||||||
if (error < 0) {
|
if (error < 0)
|
||||||
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
|
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
|
||||||
pm_runtime_put_noidle(bdi->dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
bq24190_register_reset(bdi);
|
bq24190_register_reset(bdi);
|
||||||
|
|
||||||
@ -2007,11 +1988,9 @@ static __maybe_unused int bq24190_pm_resume(struct device *dev)
|
|||||||
bdi->f_reg = 0;
|
bdi->f_reg = 0;
|
||||||
bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */
|
bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */
|
||||||
|
|
||||||
error = pm_runtime_get_sync(bdi->dev);
|
error = pm_runtime_resume_and_get(bdi->dev);
|
||||||
if (error < 0) {
|
if (error < 0)
|
||||||
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
|
dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
|
||||||
pm_runtime_put_noidle(bdi->dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
bq24190_register_reset(bdi);
|
bq24190_register_reset(bdi);
|
||||||
bq24190_set_config(bdi);
|
bq24190_set_config(bdi);
|
||||||
|
Loading…
Reference in New Issue
Block a user