]> git.baikalelectronics.ru Git - kernel.git/commit
pinctrl: mediatek: paris: Rework mtk_pinconf_{get,set} switch/case logic
authorChen-Yu Tsai <wenst@chromium.org>
Tue, 8 Mar 2022 10:09:52 +0000 (18:09 +0800)
committerLinus Walleij <linus.walleij@linaro.org>
Tue, 15 Mar 2022 00:24:16 +0000 (01:24 +0100)
commit77a6c9505456d6ebf3874d4c6b618235360d35a5
treec49765380142e4c4b78ee59efae7e8f4c03a652a
parent5fcdd2b96c6a02d2248da0c74a0f3a15cda49381
pinctrl: mediatek: paris: Rework mtk_pinconf_{get,set} switch/case logic

The current code deals with optional features by testing for the
function pointers and returning -ENOTSUPP if it is not valid. This is
done for multiple pin config settings and results in the code that
handles the supporting cases to get indented by one level. This is
aggrevated by the fact that some features require another level of
conditionals.

Instead of assigning the same error code in all unsupported optional
feature cases, simply have that error code as the default, and break
out of the switch/case block whenever a feature is unsupported, or an
error is returned. This reduces indentation by one level for the useful
code.

Also replace the goto statements with break statements. The result is
the same, as the gotos simply exit the switch/case block, which can
also be achieved with a break statement. With the latter the intent
is clear and easier to understand.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://lore.kernel.org/r/20220308100956.2750295-8-wenst@chromium.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/mediatek/pinctrl-paris.c