From: Matti Vaittinen Date: Wed, 5 Mar 2025 13:13:12 +0000 (+0200) Subject: gpio: gpio-rcar: Drop direct use of valid_mask X-Git-Tag: v6.15-rc1~179^2~41 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43b665c961a6468fa8416805ef71daa5e7a152e7;p=thirdparty%2Fkernel%2Flinux.git gpio: gpio-rcar: Drop direct use of valid_mask The valid_mask member of the struct gpio_chip is unconditionally written by the GPIO core at driver registration. It should not be directly populated by the drivers. Hiding the valid_mask in struct gpio_device makes it clear it is not meant to be directly populated by drivers. This means drivers should not access it directly from the struct gpio_chip. The gpio-rcar checks the valid mask in set/get_multiple() operations. This is no longer needed [1]. Drop these checks. Additionally, the valid_mask is needed for enabling the GPIO inputs at probe time. Use the new valid_mask -getter function instead of accessing it directly from the struct gpio_chip. Signed-off-by: Matti Vaittinen Reviewed-by: Linus Walleij Link: https://lore.kernel.org/r/e46441ba8a2840e6b48ec8d2ecd5919995a5675f.1741180097.git.mazziesaccount@gmail.com Signed-off-by: Bartosz Golaszewski --- diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 2ecee3269a0cc..e32d731d0473e 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -336,9 +336,6 @@ static int gpio_rcar_get_multiple(struct gpio_chip *chip, unsigned long *mask, unsigned long flags; bankmask = mask[0] & GENMASK(chip->ngpio - 1, 0); - if (chip->valid_mask) - bankmask &= chip->valid_mask[0]; - if (!bankmask) return 0; @@ -380,9 +377,6 @@ static void gpio_rcar_set_multiple(struct gpio_chip *chip, unsigned long *mask, u32 val, bankmask; bankmask = mask[0] & GENMASK(chip->ngpio - 1, 0); - if (chip->valid_mask) - bankmask &= chip->valid_mask[0]; - if (!bankmask) return; @@ -482,10 +476,13 @@ static int gpio_rcar_parse_dt(struct gpio_rcar_priv *p, unsigned int *npins) static void gpio_rcar_enable_inputs(struct gpio_rcar_priv *p) { u32 mask = GENMASK(p->gpio_chip.ngpio - 1, 0); + const unsigned long *valid_mask; + + valid_mask = gpiochip_query_valid_mask(&p->gpio_chip); /* Select "Input Enable" in INEN */ - if (p->gpio_chip.valid_mask) - mask &= p->gpio_chip.valid_mask[0]; + if (valid_mask) + mask &= valid_mask[0]; if (mask) gpio_rcar_write(p, INEN, gpio_rcar_read(p, INEN) | mask); }