2021-08-20 07:02:24

by Sean Wang

[permalink] [raw]
Subject: Re: [v2, 04/12] pinctrl: mediatek: moore: check if pin_desc is valid before use

From: Sean Wang <[email protected]>

>Certain SoC are missing the middle part gpios in consecutive pins, it's better to check if mtk_pin_desc is a valid pin for the extensibility
>
>Signed-off-by: Sam Shih <[email protected]>
>


>---
>v2: applied the comment suggested by reviewers:
> - for the pins not ballout, we can fill .name in struct mtk_pin_desc
> as NULL and return -ENOTSUPP in gpio/pinconf ops.

Thanks for take the suggestion and the improvement.
Acked-by: Sean Wang <[email protected]>

>
>---
> drivers/pinctrl/mediatek/pinctrl-moore.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
>diff --git a/drivers/pinctrl/mediatek/pinctrl-moore.c b/drivers/pinctrl/mediatek/pinctrl-moore.c
>index 3a4a23c40a71..ad3b67163973 100644
>--- a/drivers/pinctrl/mediatek/pinctrl-moore.c
>+++ b/drivers/pinctrl/mediatek/pinctrl-moore.c
>@@ -60,6 +60,8 @@ static int mtk_pinmux_set_mux(struct pinctrl_dev *pctldev,
> int pin = grp->pins[i];
>
> desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
>+ if (!desc->name)
>+ return -ENOTSUPP;
>
> mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_MODE,
> pin_modes[i]);
>@@ -76,6 +78,8 @@ static int mtk_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev,
> const struct mtk_pin_desc *desc;
>
> desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];
>+ if (!desc->name)
>+ return -ENOTSUPP;

<snip>