1 From stable+bounces-163574-greg=kroah.com@vger.kernel.org Mon Jul 21 13:49:34 2025
2 From: skulkarni@mvista.com
3 Date: Mon, 21 Jul 2025 17:18:45 +0530
4 Subject: power: supply: bq24190_charger: using pm_runtime_resume_and_get instead of pm_runtime_get_sync
5 To: stable@vger.kernel.org
6 Cc: Minghao Chi <chi.minghao@zte.com.cn>, Zeal Robot <zealci@zte.com.cn>, Sebastian Reichel <sebastian.reichel@collabora.com>, Shubham Kulkarni <skulkarni@mvista.com>
7 Message-ID: <20250721114846.1360952-3-skulkarni@mvista.com>
9 From: Minghao Chi <chi.minghao@zte.com.cn>
11 [ Upstream commit d96a89407e5f682d1cb22569d91784506c784863 ]
13 Using pm_runtime_resume_and_get is more appropriate
16 Reported-by: Zeal Robot <zealci@zte.com.cn>
17 Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn>
18 Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
19 [ skulkarni: Minor changes in hunk #3/12 wrt the mainline commit ]
20 Stable-dep-of: 47c29d692129 ("power: supply: bq24190: Fix use after free bug in bq24190_remove due to race condition")
21 Signed-off-by: Shubham Kulkarni <skulkarni@mvista.com>
22 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
24 drivers/power/supply/bq24190_charger.c | 63 +++++++++++----------------------
25 1 file changed, 21 insertions(+), 42 deletions(-)
27 --- a/drivers/power/supply/bq24190_charger.c
28 +++ b/drivers/power/supply/bq24190_charger.c
29 @@ -448,11 +448,9 @@ static ssize_t bq24190_sysfs_show(struct
33 - ret = pm_runtime_get_sync(bdi->dev);
35 - pm_runtime_put_noidle(bdi->dev);
36 + ret = pm_runtime_resume_and_get(bdi->dev);
41 ret = bq24190_read_mask(bdi, info->reg, info->mask, info->shift, &v);
43 @@ -483,11 +481,9 @@ static ssize_t bq24190_sysfs_store(struc
47 - ret = pm_runtime_get_sync(bdi->dev);
49 - pm_runtime_put_noidle(bdi->dev);
50 + ret = pm_runtime_resume_and_get(bdi->dev);
55 ret = bq24190_write_mask(bdi, info->reg, info->mask, info->shift, v);
57 @@ -506,10 +502,9 @@ static int bq24190_set_charge_mode(struc
58 struct bq24190_dev_info *bdi = rdev_get_drvdata(dev);
61 - ret = pm_runtime_get_sync(bdi->dev);
62 + ret = pm_runtime_resume_and_get(bdi->dev);
64 dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
65 - pm_runtime_put_noidle(bdi->dev);
69 @@ -539,10 +534,9 @@ static int bq24190_vbus_is_enabled(struc
73 - ret = pm_runtime_get_sync(bdi->dev);
74 + ret = pm_runtime_resume_and_get(bdi->dev);
76 dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", ret);
77 - pm_runtime_put_noidle(bdi->dev);
81 @@ -1083,11 +1077,9 @@ static int bq24190_charger_get_property(
83 dev_dbg(bdi->dev, "prop: %d\n", psp);
85 - ret = pm_runtime_get_sync(bdi->dev);
87 - pm_runtime_put_noidle(bdi->dev);
88 + ret = pm_runtime_resume_and_get(bdi->dev);
94 case POWER_SUPPLY_PROP_CHARGE_TYPE:
95 @@ -1157,11 +1149,9 @@ static int bq24190_charger_set_property(
97 dev_dbg(bdi->dev, "prop: %d\n", psp);
99 - ret = pm_runtime_get_sync(bdi->dev);
101 - pm_runtime_put_noidle(bdi->dev);
102 + ret = pm_runtime_resume_and_get(bdi->dev);
108 case POWER_SUPPLY_PROP_ONLINE:
109 @@ -1431,11 +1421,9 @@ static int bq24190_battery_get_property(
110 dev_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n");
111 dev_dbg(bdi->dev, "prop: %d\n", psp);
113 - ret = pm_runtime_get_sync(bdi->dev);
115 - pm_runtime_put_noidle(bdi->dev);
116 + ret = pm_runtime_resume_and_get(bdi->dev);
122 case POWER_SUPPLY_PROP_STATUS:
123 @@ -1479,11 +1467,9 @@ static int bq24190_battery_set_property(
124 dev_warn(bdi->dev, "warning: /sys/class/power_supply/bq24190-battery is deprecated\n");
125 dev_dbg(bdi->dev, "prop: %d\n", psp);
127 - ret = pm_runtime_get_sync(bdi->dev);
129 - pm_runtime_put_noidle(bdi->dev);
130 + ret = pm_runtime_resume_and_get(bdi->dev);
136 case POWER_SUPPLY_PROP_ONLINE:
137 @@ -1637,10 +1623,9 @@ static irqreturn_t bq24190_irq_handler_t
140 bdi->irq_event = true;
141 - error = pm_runtime_get_sync(bdi->dev);
142 + error = pm_runtime_resume_and_get(bdi->dev);
144 dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
145 - pm_runtime_put_noidle(bdi->dev);
148 bq24190_check_status(bdi);
149 @@ -1860,11 +1845,9 @@ static int bq24190_remove(struct i2c_cli
150 struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
153 - error = pm_runtime_get_sync(bdi->dev);
155 + error = pm_runtime_resume_and_get(bdi->dev);
157 dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
158 - pm_runtime_put_noidle(bdi->dev);
161 bq24190_register_reset(bdi);
163 @@ -1913,11 +1896,9 @@ static __maybe_unused int bq24190_pm_sus
164 struct bq24190_dev_info *bdi = i2c_get_clientdata(client);
167 - error = pm_runtime_get_sync(bdi->dev);
169 + error = pm_runtime_resume_and_get(bdi->dev);
171 dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
172 - pm_runtime_put_noidle(bdi->dev);
175 bq24190_register_reset(bdi);
177 @@ -1938,11 +1919,9 @@ static __maybe_unused int bq24190_pm_res
179 bdi->ss_reg = BQ24190_REG_SS_VBUS_STAT_MASK; /* impossible state */
181 - error = pm_runtime_get_sync(bdi->dev);
183 + error = pm_runtime_resume_and_get(bdi->dev);
185 dev_warn(bdi->dev, "pm_runtime_get failed: %i\n", error);
186 - pm_runtime_put_noidle(bdi->dev);
189 bq24190_register_reset(bdi);
190 bq24190_set_config(bdi);