[v2, 04/12] pinctrl: mediatek: moore: check if pin_desc is valid before use
sean.wang at mediatek.com
sean.wang at mediatek.com
Fri Aug 20 00:01:13 PDT 2021
From: Sean Wang <sean.wang at mediatek.com>
>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 <sam.shih at mediatek.com>
>
>---
>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 <sean.wang at mediatek.com>
>
>---
> 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>
More information about the Linux-mediatek
mailing list