Skip to content

Commit c944d9d

Browse files
prabhakarladgeertu
authored andcommitted
pinctrl: renesas: rzg2l: Add validation of GPIO pin in rzg2l_gpio_request()
Validate the GPIO pin request in the rzg2l_gpio_request() callback using the rzg2l_validate_gpio_pin() function. This stops any accidental usage of GPIO pins which are not supported by the SoC. Signed-off-by: Lad Prabhakar <[email protected]> Reviewed-by: Claudiu Beznea <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Tested-by: Claudiu Beznea <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Geert Uytterhoeven <[email protected]>
1 parent 84ba513 commit c944d9d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/pinctrl/renesas/pinctrl-rzg2l.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,12 +795,18 @@ static const struct pinconf_ops rzg2l_pinctrl_confops = {
795795
static int rzg2l_gpio_request(struct gpio_chip *chip, unsigned int offset)
796796
{
797797
struct rzg2l_pinctrl *pctrl = gpiochip_get_data(chip);
798+
const struct pinctrl_pin_desc *pin_desc = &pctrl->desc.pins[offset];
798799
u32 port = RZG2L_PIN_ID_TO_PORT(offset);
799800
u8 bit = RZG2L_PIN_ID_TO_PIN(offset);
801+
u32 *pin_data = pin_desc->drv_data;
800802
unsigned long flags;
801803
u8 reg8;
802804
int ret;
803805

806+
ret = rzg2l_validate_gpio_pin(pctrl, *pin_data, port, bit);
807+
if (ret)
808+
return ret;
809+
804810
ret = pinctrl_gpio_request(chip->base + offset);
805811
if (ret)
806812
return ret;

0 commit comments

Comments
 (0)