]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
regulator: don't compare raw GPIO descriptor pointers
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 7 Apr 2025 07:08:15 +0000 (09:08 +0200)
committerMark Brown <broonie@kernel.org>
Wed, 9 Apr 2025 12:46:58 +0000 (13:46 +0100)
There's no API contract saying that two GPIO descriptor pointers
obtained with a call to gpiod_get() (or one of the variants), that refer
to the same physical GPIO pin, always point to the same structure. Use
the dedicated comparator function.

Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Link: https://patch.msgid.link/20250407-gpiod-is-equal-v1-2-7d85f568ae6e@linaro.org
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c

index 90629a756693280414aa00e99948d58ec468e411..7a248dc8d2e2ffd21e7daf729de9b33a5efc1937 100644 (file)
@@ -2617,7 +2617,7 @@ static int regulator_ena_gpio_request(struct regulator_dev *rdev,
        mutex_lock(&regulator_list_mutex);
 
        list_for_each_entry(pin, &regulator_ena_gpio_list, list) {
-               if (pin->gpiod == gpiod) {
+               if (gpiod_is_equal(pin->gpiod, gpiod)) {
                        rdev_dbg(rdev, "GPIO is already used\n");
                        goto update_ena_gpio_to_rdev;
                }