Skip to content

Commit bfb5711

Browse files
Minghao Chibroonie
authored andcommitted
regulator: stm32-vrefbuf: 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 <[email protected]> Signed-off-by: Minghao Chi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent 619fdc4 commit bfb5711

File tree

1 file changed

+10
-20
lines changed

1 file changed

+10
-20
lines changed

drivers/regulator/stm32-vrefbuf.c

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ static int stm32_vrefbuf_enable(struct regulator_dev *rdev)
4444
u32 val;
4545
int ret;
4646

47-
ret = pm_runtime_get_sync(priv->dev);
48-
if (ret < 0) {
49-
pm_runtime_put_noidle(priv->dev);
47+
ret = pm_runtime_resume_and_get(priv->dev);
48+
if (ret < 0)
5049
return ret;
51-
}
5250

5351
val = readl_relaxed(priv->base + STM32_VREFBUF_CSR);
5452
val = (val & ~STM32_HIZ) | STM32_ENVR;
@@ -81,11 +79,9 @@ static int stm32_vrefbuf_disable(struct regulator_dev *rdev)
8179
u32 val;
8280
int ret;
8381

84-
ret = pm_runtime_get_sync(priv->dev);
85-
if (ret < 0) {
86-
pm_runtime_put_noidle(priv->dev);
82+
ret = pm_runtime_resume_and_get(priv->dev);
83+
if (ret < 0)
8784
return ret;
88-
}
8985

9086
val = readl_relaxed(priv->base + STM32_VREFBUF_CSR);
9187
val &= ~STM32_ENVR;
@@ -102,11 +98,9 @@ static int stm32_vrefbuf_is_enabled(struct regulator_dev *rdev)
10298
struct stm32_vrefbuf *priv = rdev_get_drvdata(rdev);
10399
int ret;
104100

105-
ret = pm_runtime_get_sync(priv->dev);
106-
if (ret < 0) {
107-
pm_runtime_put_noidle(priv->dev);
101+
ret = pm_runtime_resume_and_get(priv->dev);
102+
if (ret < 0)
108103
return ret;
109-
}
110104

111105
ret = readl_relaxed(priv->base + STM32_VREFBUF_CSR) & STM32_ENVR;
112106

@@ -123,11 +117,9 @@ static int stm32_vrefbuf_set_voltage_sel(struct regulator_dev *rdev,
123117
u32 val;
124118
int ret;
125119

126-
ret = pm_runtime_get_sync(priv->dev);
127-
if (ret < 0) {
128-
pm_runtime_put_noidle(priv->dev);
120+
ret = pm_runtime_resume_and_get(priv->dev);
121+
if (ret < 0)
129122
return ret;
130-
}
131123

132124
val = readl_relaxed(priv->base + STM32_VREFBUF_CSR);
133125
val = (val & ~STM32_VRS) | FIELD_PREP(STM32_VRS, sel);
@@ -145,11 +137,9 @@ static int stm32_vrefbuf_get_voltage_sel(struct regulator_dev *rdev)
145137
u32 val;
146138
int ret;
147139

148-
ret = pm_runtime_get_sync(priv->dev);
149-
if (ret < 0) {
150-
pm_runtime_put_noidle(priv->dev);
140+
ret = pm_runtime_resume_and_get(priv->dev);
141+
if (ret < 0)
151142
return ret;
152-
}
153143

154144
val = readl_relaxed(priv->base + STM32_VREFBUF_CSR);
155145
ret = FIELD_GET(STM32_VRS, val);

0 commit comments

Comments
 (0)