From: Hao Chang <ot_chhao.chang@mediatek.com>
To: Sean Wang <sean.wang@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>
Cc: Wenbin Mei <wenbin.mei@mediatek.com>,
Axe Yang <axe.yang@mediatek.com>,
Qingliang Li <qingliang.li@mediatek.com>,
Hanks Chen <hanks.chen@mediatek.com>,
Chunhui Li <chunhui.li@mediatek.com>,
<linux-mediatek@lists.infradead.org>,
<linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linux-arm-kernel@lists.infradead.org>,
"Hao Chang" <ot_chhao.chang@mediatek.com>
Subject: [PATCH v3 1/2] pinctrl: mediatek: update EINT base retrieval method
Date: Fri, 24 Jan 2025 21:49:05 +0800 [thread overview]
Message-ID: <20250124134918.2779-2-ot_chhao.chang@mediatek.com> (raw)
In-Reply-To: <20250124134918.2779-1-ot_chhao.chang@mediatek.com>
Change the method of obtaining the EINT base from a single value to
multiple values.
Modify the EINT base and add nbase for counting.
Change-Id: I708f2eaa4c57b5705201025c252a7122914c4a40
Signed-off-by: Hao Chang <ot_chhao.chang@mediatek.com>
Signed-off-by: Qingliang Li <qingliang.li@mediatek.com>
---
.../pinctrl/mediatek/pinctrl-mtk-common-v2.c | 50 +++++++++++++------
1 file changed, 35 insertions(+), 15 deletions(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index 6411c10cb637..e74fc68f631d 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -368,7 +368,7 @@ static const struct mtk_eint_xt mtk_eint_xt = {
int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
- unsigned int i, j, count_reg_names;
+ int ret, i, j, count_reg_names;
if (!IS_ENABLED(CONFIG_EINT_MTK))
return 0;
@@ -377,7 +377,7 @@ int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)
return -ENODEV;
count_reg_names = of_property_count_strings(np, "reg-names");
- if (count_reg_names < 0 || count_reg_names < hw->soc->nbase_names)
+ if (count_reg_names < hw->soc->nbase_names)
return -EINVAL;
hw->eint = devm_kmalloc(hw->dev, sizeof(*hw->eint), GFP_KERNEL);
@@ -385,33 +385,53 @@ int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)
return -ENOMEM;
hw->eint->nbase = count_reg_names - hw->soc->nbase_names;
- hw->eint->base = devm_kmalloc_array(&pdev->dev, hw->eint->nbase,
+ hw->eint->base = devm_kmalloc_array(hw->dev, hw->eint->nbase,
sizeof(*hw->eint->base), GFP_KERNEL);
- if (!hw->eint->base)
- return -ENOMEM;
+ if (!hw->eint->base) {
+ ret = -ENOMEM;
+ goto err_free_eint;
+ }
for (i = hw->soc->nbase_names, j = 0; i < count_reg_names; i++, j++) {
hw->eint->base[j] = of_iomap(np, i);
- if (IS_ERR(hw->eint->base[j]))
- return PTR_ERR(hw->eint->base[j]);
+ if (IS_ERR(hw->eint->base[j])) {
+ ret = PTR_ERR(hw->eint->base[j]);
+ goto err_free_eint;
+ }
}
- if (!of_property_read_bool(np, "interrupt-controller"))
- return -ENODEV;
+ if (!of_property_read_bool(np, "interrupt-controller")) {
+ ret = -ENODEV;
+ goto err_free_eint;
+ }
hw->eint->irq = irq_of_parse_and_map(np, 0);
- if (!hw->eint->irq)
- return -EINVAL;
-
- if (hw->soc->eint_pin)
- hw->eint->pins = hw->soc->eint_pin;
+ if (!hw->eint->irq) {
+ ret = -EINVAL;
+ goto err_free_eint;
+ }
hw->eint->dev = &pdev->dev;
hw->eint->hw = hw->soc->eint_hw;
hw->eint->pctl = hw;
hw->eint->gpio_xlate = &mtk_eint_xt;
- return mtk_eint_do_init(hw->eint);
+ ret = mtk_eint_do_init(hw->eint);
+ if (ret)
+ goto err_free_eint;
+
+ return 0;
+
+err_free_eint:
+ for (j = 0; j < hw->eint->nbase; j++) {
+ if (hw->eint->base[j])
+ iounmap(hw->eint->base[j]);
+ }
+ if (hw->eint->base)
+ devm_kfree(hw->dev, hw->eint->base);
+ devm_kfree(hw->dev, hw->eint);
+ hw->eint = NULL;
+ return ret;
}
EXPORT_SYMBOL_GPL(mtk_build_eint);
--
2.46.0
next prev parent reply other threads:[~2025-01-24 13:57 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-24 13:49 [PATCH v3 0/2] Hao Chang
2025-01-24 13:49 ` Hao Chang [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-01-24 13:40 Hao Chang
2025-01-24 13:40 ` [PATCH v3 1/2] pinctrl: mediatek: update EINT base retrieval method Hao Chang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250124134918.2779-2-ot_chhao.chang@mediatek.com \
--to=ot_chhao.chang@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=axe.yang@mediatek.com \
--cc=chunhui.li@mediatek.com \
--cc=hanks.chen@mediatek.com \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=qingliang.li@mediatek.com \
--cc=sean.wang@kernel.org \
--cc=wenbin.mei@mediatek.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox