Message ID | 098100772163e54fe5ca49576042edbfaf3807a5.1529639050.git.sean.wang@mediatek.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Fri, Jun 22, 2018 at 5:49 AM <sean.wang@mediatek.com> wrote: > From: Sean Wang <sean.wang@mediatek.com> > > If the pinctrl node has the gpio-ranges property, the range will be added > by the gpio core and doesn't need to be added by the pinctrl driver. > > But for keeping backward compatibility, an explicit pinctrl_add_gpio_range > is still needed to be called when there is a missing gpio-ranges in pinctrl > node in old dts files. > > Cc: stable@vger.kernel.org > Fixes: d6ed93551320 ("pinctrl: mediatek: add pinctrl driver for MT7622 SoC") > Signed-off-by: Sean Wang <sean.wang@mediatek.com> Patch applied for fixes. Yours, Linus Walleij
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt7622.c b/drivers/pinctrl/mediatek/pinctrl-mt7622.c index 42155d4..055074bb 100644 --- a/drivers/pinctrl/mediatek/pinctrl-mt7622.c +++ b/drivers/pinctrl/mediatek/pinctrl-mt7622.c @@ -1508,11 +1508,20 @@ static int mtk_build_gpiochip(struct mtk_pinctrl *hw, struct device_node *np) if (ret < 0) return ret; - ret = gpiochip_add_pin_range(chip, dev_name(hw->dev), 0, 0, - chip->ngpio); - if (ret < 0) { - gpiochip_remove(chip); - return ret; + /* Just for backward compatible for these old pinctrl nodes without + * "gpio-ranges" property. Otherwise, called directly from a + * DeviceTree-supported pinctrl driver is DEPRECATED. + * Please see Section 2.1 of + * Documentation/devicetree/bindings/gpio/gpio.txt on how to + * bind pinctrl and gpio drivers via the "gpio-ranges" property. + */ + if (!of_find_property(np, "gpio-ranges", NULL)) { + ret = gpiochip_add_pin_range(chip, dev_name(hw->dev), 0, 0, + chip->ngpio); + if (ret < 0) { + gpiochip_remove(chip); + return ret; + } } return 0;