]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
gpio: tegra186: don't call the set() callback directly
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Wed, 2 Jul 2025 09:14:02 +0000 (11:14 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 7 Jul 2025 07:45:29 +0000 (09:45 +0200)
Drivers should not dereference GPIO chip callbacks directly. Move the
module's set() function higher to make it available to the
direction_output() callback and call it instead.

Link: https://lore.kernel.org/r/20250702-gpiochip-set-rv-gpio-round3-v1-1-0d23be74f71d@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpio-tegra186.c

index d27bfac6c9f53d23806725f5fc89fd0331f4afb0..04effccf9ecdf0828bc50455dace3ba8e8bdbbef 100644 (file)
@@ -202,6 +202,26 @@ static int tegra186_init_valid_mask(struct gpio_chip *chip,
        return 0;
 }
 
+static void tegra186_gpio_set(struct gpio_chip *chip, unsigned int offset,
+                             int level)
+{
+       struct tegra_gpio *gpio = gpiochip_get_data(chip);
+       void __iomem *base;
+       u32 value;
+
+       base = tegra186_gpio_get_base(gpio, offset);
+       if (WARN_ON(base == NULL))
+               return;
+
+       value = readl(base + TEGRA186_GPIO_OUTPUT_VALUE);
+       if (level == 0)
+               value &= ~TEGRA186_GPIO_OUTPUT_VALUE_HIGH;
+       else
+               value |= TEGRA186_GPIO_OUTPUT_VALUE_HIGH;
+
+       writel(value, base + TEGRA186_GPIO_OUTPUT_VALUE);
+}
+
 static int tegra186_gpio_get_direction(struct gpio_chip *chip,
                                       unsigned int offset)
 {
@@ -251,7 +271,7 @@ static int tegra186_gpio_direction_output(struct gpio_chip *chip,
        u32 value;
 
        /* configure output level first */
-       chip->set(chip, offset, level);
+       tegra186_gpio_set(chip, offset, level);
 
        base = tegra186_gpio_get_base(gpio, offset);
        if (WARN_ON(base == NULL))
@@ -359,26 +379,6 @@ static int tegra186_gpio_get(struct gpio_chip *chip, unsigned int offset)
        return value & BIT(0);
 }
 
-static void tegra186_gpio_set(struct gpio_chip *chip, unsigned int offset,
-                             int level)
-{
-       struct tegra_gpio *gpio = gpiochip_get_data(chip);
-       void __iomem *base;
-       u32 value;
-
-       base = tegra186_gpio_get_base(gpio, offset);
-       if (WARN_ON(base == NULL))
-               return;
-
-       value = readl(base + TEGRA186_GPIO_OUTPUT_VALUE);
-       if (level == 0)
-               value &= ~TEGRA186_GPIO_OUTPUT_VALUE_HIGH;
-       else
-               value |= TEGRA186_GPIO_OUTPUT_VALUE_HIGH;
-
-       writel(value, base + TEGRA186_GPIO_OUTPUT_VALUE);
-}
-
 static int tegra186_gpio_set_config(struct gpio_chip *chip,
                                    unsigned int offset,
                                    unsigned long config)