summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinghao Chi <chi.minghao@zte.com.cn>2022-04-12 07:10:30 +0000
committerMark Brown <broonie@kernel.org>2022-04-19 12:04:10 +0100
commitbfb5711e2455a239ad64dd5151fb16d195329d46 (patch)
tree146e04e85034d8d66e672d8326a7ed50568234b6
parent619fdc47f821139f312a87b397a75ff69ec6f8b6 (diff)
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 <zealci@zte.com.cn> Signed-off-by: Minghao Chi <chi.minghao@zte.com.cn> Link: https://lore.kernel.org/r/20220412071030.2532230-1-chi.minghao@zte.com.cn Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--drivers/regulator/stm32-vrefbuf.c30
1 files changed, 10 insertions, 20 deletions
diff --git a/drivers/regulator/stm32-vrefbuf.c b/drivers/regulator/stm32-vrefbuf.c
index 161622ea7259..30ea3bc8ca19 100644
--- a/drivers/regulator/stm32-vrefbuf.c
+++ b/drivers/regulator/stm32-vrefbuf.c
@@ -44,11 +44,9 @@ static int stm32_vrefbuf_enable(struct regulator_dev *rdev)
u32 val;
int ret;
- ret = pm_runtime_get_sync(priv->dev);
- if (ret < 0) {
- pm_runtime_put_noidle(priv->dev);
+ ret = pm_runtime_resume_and_get(priv->dev);
+ if (ret < 0)
return ret;
- }
val = readl_relaxed(priv->base + STM32_VREFBUF_CSR);
val = (val & ~STM32_HIZ) | STM32_ENVR;
@@ -81,11 +79,9 @@ static int stm32_vrefbuf_disable(struct regulator_dev *rdev)
u32 val;
int ret;
- ret = pm_runtime_get_sync(priv->dev);
- if (ret < 0) {
- pm_runtime_put_noidle(priv->dev);
+ ret = pm_runtime_resume_and_get(priv->dev);
+ if (ret < 0)
return ret;
- }
val = readl_relaxed(priv->base + STM32_VREFBUF_CSR);
val &= ~STM32_ENVR;
@@ -102,11 +98,9 @@ static int stm32_vrefbuf_is_enabled(struct regulator_dev *rdev)
struct stm32_vrefbuf *priv = rdev_get_drvdata(rdev);
int ret;
- ret = pm_runtime_get_sync(priv->dev);
- if (ret < 0) {
- pm_runtime_put_noidle(priv->dev);
+ ret = pm_runtime_resume_and_get(priv->dev);
+ if (ret < 0)
return ret;
- }
ret = readl_relaxed(priv->base + STM32_VREFBUF_CSR) & STM32_ENVR;
@@ -123,11 +117,9 @@ static int stm32_vrefbuf_set_voltage_sel(struct regulator_dev *rdev,
u32 val;
int ret;
- ret = pm_runtime_get_sync(priv->dev);
- if (ret < 0) {
- pm_runtime_put_noidle(priv->dev);
+ ret = pm_runtime_resume_and_get(priv->dev);
+ if (ret < 0)
return ret;
- }
val = readl_relaxed(priv->base + STM32_VREFBUF_CSR);
val = (val & ~STM32_VRS) | FIELD_PREP(STM32_VRS, sel);
@@ -145,11 +137,9 @@ static int stm32_vrefbuf_get_voltage_sel(struct regulator_dev *rdev)
u32 val;
int ret;
- ret = pm_runtime_get_sync(priv->dev);
- if (ret < 0) {
- pm_runtime_put_noidle(priv->dev);
+ ret = pm_runtime_resume_and_get(priv->dev);
+ if (ret < 0)
return ret;
- }
val = readl_relaxed(priv->base + STM32_VREFBUF_CSR);
ret = FIELD_GET(STM32_VRS, val);