From: Bartosz Golaszewski <[email protected]>

GPIOLIB is now aware of shared GPIOs and - for platforms where access to
such pins is managed internally - we don't need to keep track of the
enable count.

Once all users in the kernel switch to using the new mechanism, we'll be
able to drop the internal counting of users from the regulator code.

Acked-by: Mark Brown <[email protected]>
Acked-by: Linus Walleij <[email protected]>
Signed-off-by: Bartosz Golaszewski <[email protected]>
---
 drivers/regulator/core.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 
2eab56df042e6b05abf0989f425dc161c7b0e66d..53b2b2d3746f9f2419234912d49bd8b4f21a893d
 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -2742,6 +2742,13 @@ static int regulator_ena_gpio_request(struct 
regulator_dev *rdev,
 
        mutex_lock(&regulator_list_mutex);
 
+       if (gpiod_is_shared(gpiod))
+               /*
+                * The sharing of this GPIO pin is managed internally by
+                * GPIOLIB. We don't need to keep track of its enable count.
+                */
+               goto skip_compare;
+
        list_for_each_entry(pin, &regulator_ena_gpio_list, list) {
                if (gpiod_is_equal(pin->gpiod, gpiod)) {
                        rdev_dbg(rdev, "GPIO is already used\n");
@@ -2754,6 +2761,7 @@ static int regulator_ena_gpio_request(struct 
regulator_dev *rdev,
                return -ENOMEM;
        }
 
+skip_compare:
        pin = new_pin;
        new_pin = NULL;
 

-- 
2.51.0


Reply via email to