lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <1597916439-26376-1-git-send-email-light.hsieh@mediatek.com>
Date:   Thu, 20 Aug 2020 17:40:39 +0800
From:   <light.hsieh@...iatek.com>
To:     <linus.walleij@...aro.org>
CC:     <linux-mediatek@...ts.infradead.org>, <linux-gpio@...r.kernel.org>,
        <linux-kernel@...r.kernel.org>, <sean.wang@...nel.org>,
        <kuohong.wang@...iatek.com>, Light Hsieh <light.hsieh@...iatek.com>
Subject: [PATCH v1 1/1] pinctrl: mediatek: refine mtk_pmx_get_funcs_cnt()

From: Light Hsieh <light.hsieh@...iatek.com>

Refine implementation of mtk_pmx_get_funcs_cnt().
The original implementation always return ARRAY_SIZE(mtk_gpio_functions)
which is 16.

However, MT6765/MT6779 only support 8 functions per GPIO pin. So returning
16 is improper. The new implementation check member nfuncs of struct
mtk_pin_soc for a platform. If nfuncs is not zero, return nfuncs.
If nfuncs is zero, fallback to original implementation by returning
ARRAY_SIZE(mtk_gpio_functions).

Signed-off-by: Light Hsieh <light.hsieh@...iatek.com>
---
 drivers/pinctrl/mediatek/pinctrl-mt6765.c | 1 +
 drivers/pinctrl/mediatek/pinctrl-mt6779.c | 1 +
 drivers/pinctrl/mediatek/pinctrl-paris.c  | 4 ++++
 3 files changed, 6 insertions(+)

diff --git a/drivers/pinctrl/mediatek/pinctrl-mt6765.c b/drivers/pinctrl/mediatek/pinctrl-mt6765.c
index 2c59d39..8d9f3ea 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt6765.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt6765.c
@@ -1069,6 +1069,7 @@
 	.pins = mtk_pins_mt6765,
 	.npins = ARRAY_SIZE(mtk_pins_mt6765),
 	.ngrps = ARRAY_SIZE(mtk_pins_mt6765),
+	.nfuncs = 8,
 	.eint_hw = &mt6765_eint_hw,
 	.gpio_m = 0,
 	.base_names = mt6765_pinctrl_register_base_names,
diff --git a/drivers/pinctrl/mediatek/pinctrl-mt6779.c b/drivers/pinctrl/mediatek/pinctrl-mt6779.c
index bb0851c..1f26adb 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mt6779.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mt6779.c
@@ -744,6 +744,7 @@
 	.pins = mtk_pins_mt6779,
 	.npins = ARRAY_SIZE(mtk_pins_mt6779),
 	.ngrps = ARRAY_SIZE(mtk_pins_mt6779),
+	.nfuncs = 8,
 	.eint_hw = &mt6779_eint_hw,
 	.gpio_m = 0,
 	.ies_present = true,
diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c
index a23c182..96f9f86 100644
--- a/drivers/pinctrl/mediatek/pinctrl-paris.c
+++ b/drivers/pinctrl/mediatek/pinctrl-paris.c
@@ -657,6 +657,10 @@ static void mtk_pctrl_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
 
 static int mtk_pmx_get_funcs_cnt(struct pinctrl_dev *pctldev)
 {
+	struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev);
+ 
+	if (hw->soc->nfuncs)
+		return (int)hw->soc->nfuncs;
 	return ARRAY_SIZE(mtk_gpio_functions);
 }
 
-- 
1.8.1.1.dirty

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ