pinctrl: mediatek: Check gpio pin number and use binary search in mtk_hw_pin_field_lo...
authorLight Hsieh <light.hsieh@mediatek.com>
Wed, 22 Jan 2020 06:53:09 +0000 (14:53 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 14 Feb 2020 10:26:29 +0000 (11:26 +0100)
commit3de7deefce693bb9783bca4cb42a81653ebec4e9
tree21f7a9637068f9ecc5ede55f971b3e342c2f58a1
parentef1ea54eab0ecb072700f59701387f839c8c760d
pinctrl: mediatek: Check gpio pin number and use binary search in mtk_hw_pin_field_lookup()

1. Check if gpio pin number is in valid range to prevent from get invalid
   pointer 'desc' in the following code:
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];

2. Improve  mtk_hw_pin_field_lookup()
2.1 Modify mtk_hw_pin_field_lookup() to use binary search for accelerating
     search.
2.2 Correct message after the following check fail:
    if (hw->soc->reg_cal && hw->soc->reg_cal[field].range) {
rc = &hw->soc->reg_cal[field];
    The original message is:
     "Not support field %d for pin %d (%s)\n"
    However, the check is on soc chip level, not on pin level yet.
    So the message is corrected as:
     "Not support field %d for this soc\n"

Signed-off-by: Light Hsieh <light.hsieh@mediatek.com>
Link: https://lore.kernel.org/r/1579675994-7001-1-git-send-email-light.hsieh@mediatek.com
Acked-by: Sean Wang <sean.wang@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
drivers/pinctrl/mediatek/pinctrl-paris.c