[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <43306deb3b0200298dded485bfa4057f37f1e7a5.1714399603.git.mirq-linux@rere.qmqm.pl>
Date: Mon, 29 Apr 2024 16:45:29 +0200
From: Michał Mirosław <mirq-linux@...e.qmqm.pl>
To: Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>
Cc: linux-kernel@...r.kernel.org
Subject: [PATCH v2 05/12] regulator/core: regulator_ena_gpio_ctrl: pull in
ena_gpio state handling
Deduplicate `ena_gpio_state` handling by pulling it into
regulator_ena_gpio_ctrl().
Signed-off-by: Michał Mirosław <mirq-linux@...e.qmqm.pl>
---
drivers/regulator/core.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index a1573a7ff2b2..4cb30e49c03d 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2625,6 +2625,10 @@ static int regulator_ena_gpio_ctrl(struct regulator_dev *rdev, bool enable)
if (!pin)
return -EINVAL;
+ if (rdev->ena_gpio_state == enable)
+ return 0;
+ rdev->ena_gpio_state = enable;
+
if (enable) {
/* Enable GPIO at initial use */
if (pin->enable_count == 0)
@@ -2744,12 +2748,9 @@ static int _regulator_do_enable(struct regulator_dev *rdev)
}
if (rdev->ena_pin) {
- if (!rdev->ena_gpio_state) {
- ret = regulator_ena_gpio_ctrl(rdev, true);
- if (ret < 0)
- return ret;
- rdev->ena_gpio_state = 1;
- }
+ ret = regulator_ena_gpio_ctrl(rdev, true);
+ if (ret < 0)
+ return ret;
} else if (rdev->desc->ops->enable) {
ret = rdev->desc->ops->enable(rdev);
if (ret < 0)
@@ -2963,13 +2964,9 @@ static int _regulator_do_disable(struct regulator_dev *rdev)
trace_regulator_disable(rdev_get_name(rdev));
if (rdev->ena_pin) {
- if (rdev->ena_gpio_state) {
- ret = regulator_ena_gpio_ctrl(rdev, false);
- if (ret < 0)
- return ret;
- rdev->ena_gpio_state = 0;
- }
-
+ ret = regulator_ena_gpio_ctrl(rdev, false);
+ if (ret < 0)
+ return ret;
} else if (rdev->desc->ops->disable) {
ret = rdev->desc->ops->disable(rdev);
if (ret != 0)
--
2.39.2
Powered by blists - more mailing lists