From: "Chhao Chang (常浩)" <ot_chhao.chang@mediatek.com>
To: "matthias.bgg@gmail.com" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"seann.wang@kernel.org" <seann.wang@kernel.org>,
"linus.walleij@linaro.org" <linus.walleij@linaro.org>
Cc: "linux-mediatek@lists.infradead.org"
<linux-mediatek@lists.infradead.org>,
"Chunhui Li (李春辉)" <chunhui.li@mediatek.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Wenbin Mei (梅文彬)" <Wenbin.Mei@mediatek.com>,
"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
"Hanks Chen (陳彥廷)" <Hanks.Chen@mediatek.com>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"Qingliang Li (黎晴亮)" <Qingliang.Li@mediatek.com>,
"Axe Yang (杨磊)" <Axe.Yang@mediatek.com>
Subject: Re: [RESEND v3 2/2] pinctrl: mediatek: adapt to multi-base design
Date: Wed, 19 Feb 2025 07:28:35 +0000 [thread overview]
Message-ID: <8c62eca41c042425f575314ce88096e2fdb92ceb.camel@mediatek.com> (raw)
In-Reply-To: <bfce3aea-490b-4311-ad4a-ab567d2a0572@collabora.com>
On Mon, 2025-01-27 at 12:48 +0100, AngeloGioacchino Del Regno wrote:
> External email : Please do not click links or open attachments until
> you have verified the sender or the content.
>
>
> Il 25/01/25 03:51, Hao Chang ha scritto:
> > The eint num will obtain the operation address through pins.
> > Change the traversal method of irq handle from traversing a set of
> > registers to traversing one by one.
> >
> > Change-Id: I3962b78042d32501a73153201cddf52c6b62a695
> > Signed-off-by: Hao Chang <ot_chhao.chang@mediatek.com>
> > Signed-off-by: Qingliang Li <qingliang.li@mediatek.com>
> > ---
> > drivers/pinctrl/mediatek/mtk-eint.c | 38 +++++++++++++++++++-----
> > -----
> > 1 file changed, 25 insertions(+), 13 deletions(-)
> >
> > diff --git a/drivers/pinctrl/mediatek/mtk-eint.c
> > b/drivers/pinctrl/mediatek/mtk-eint.c
> > index 540245c3128d..949a20196f74 100644
> > --- a/drivers/pinctrl/mediatek/mtk-eint.c
> > +++ b/drivers/pinctrl/mediatek/mtk-eint.c
> > @@ -513,6 +513,7 @@ EXPORT_SYMBOL_GPL(mtk_eint_find_irq);
> > int mtk_eint_do_init(struct mtk_eint *eint)
> > {
> > unsigned int size, i, port;
> > + struct mtk_pinctrl *hw = (struct mtk_pinctrl *)eint->pctl;
> >
> > /* If clients don't assign a specific regs, let's use generic
> > one */
> > if (!eint->regs)
> > @@ -523,11 +524,11 @@ int mtk_eint_do_init(struct mtk_eint *eint)
> > if (!eint->base_pin_num)
> > return -ENOMEM;
> >
> > - if (!eint->pins) {
> > + if (eint->nbase == 1) {
> > size = eint->hw->ap_num * sizeof(struct
> > mtk_eint_pin);
> > eint->pins = devm_kmalloc(eint->dev, size,
> > GFP_KERNEL);
> > if (!eint->pins)
> > - return -ENOMEM;
> > + goto err_eint;
> >
> > eint->base_pin_num[0] = eint->hw->ap_num;
> > for (i = 0; i < eint->hw->ap_num; i++) {
> > @@ -536,34 +537,29 @@ int mtk_eint_do_init(struct mtk_eint *eint)
> > eint->pins[i].debounce = (i < eint->hw-
> > >db_cnt) ? 1 : 0;
> > }
> > } else {
> > + eint->pins = hw->soc->eint_pin;
> > for (i = 0; i < eint->hw->ap_num; i++)
> > eint->base_pin_num[eint->pins[i].instance]++;
> > }
> >
> > eint->wake_mask = devm_kmalloc(eint->dev, eint->nbase *
> > sizeof(u32 *), GFP_KERNEL);
> > - if (!eint->wake_mask)
> > - return -ENOMEM;
> > -
> > eint->cur_mask = devm_kmalloc(eint->dev, eint->nbase *
> > sizeof(u32 *), GFP_KERNEL);
> > - if (!eint->wake_mask)
> > - return -ENOMEM;
>
> This error checking was fine. Please keep it correct.
>
> if (!eint->wake_mask) {
> ret = -ENOMEM;
> goto err_wake_mask_alloc;
> }
>
> and
>
> if (!eint->cur_mask) {
> ret = -ENOMEM;
> goto err_cur_mask_alloc;
> }
>
> > + if (!eint->wake_mask || !eint->wake_mask)
> > + goto err_eint;
> >
> > for (i = 0; i < eint->nbase; i++) {
> > port = (eint->base_pin_num[i] + 31) / 32;
> > eint->wake_mask[i] = devm_kzalloc(eint->dev, port *
> > sizeof(u32), GFP_KERNEL);
> > - if (!eint->wake_mask[i])
> > - return -ENOMEM;
> > -
> > eint->cur_mask[i] = devm_kzalloc(eint->dev, port *
> > sizeof(u32), GFP_KERNEL);
> > - if (!eint->cur_mask[i])
> > - return -ENOMEM;
> > + if (!eint->cur_mask[i] || !eint->wake_mask[i])
> > + goto err_eint;
>
> same here
>
> > }
> >
> > eint->domain = irq_domain_add_linear(eint->dev->of_node,
> > eint->hw->ap_num,
> > &irq_domain_simple_ops,
> > NULL);
> > if (!eint->domain)
> > - return -ENOMEM;
> > + goto err_eint;
> >
> > if (eint->hw->db_time) {
> > for (i = 0; i < MTK_EINT_DBNC_MAX; i++)
> > @@ -585,6 +581,22 @@ int mtk_eint_do_init(struct mtk_eint *eint)
> > eint);
> >
> > return 0;
> > +
> > +err_eint:
> > + for (i = 0; i < eint->nbase; i++) {
> > + if (eint->wake_mask[i])
> > + devm_kfree(eint->dev, eint->wake_mask[i]);
> > + if (eint->cur_mask[i])
> > + devm_kfree(eint->dev, eint->cur_mask[i]);
> > + }
> > + if (eint->cur_mask)
> > + devm_kfree(eint->dev, eint->cur_mask);
> > + if (eint->wake_mask)
> > + devm_kfree(eint->dev, eint->wake_mask);
> > + if (eint->nbase == 1)
> > + devm_kfree(eint->dev, eint->pins);
> > + devm_kfree(eint->dev, eint->base_pin_num);
>
> ...and you should only kfree what was successfully allocated before.
Thanks,I will fix this isssue.
>
> Regards,
> Angelo
>
> > + return -ENOMEM;
> > }
> > EXPORT_SYMBOL_GPL(mtk_eint_do_init);
> >
>
>
next prev parent reply other threads:[~2025-02-19 7:28 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-25 2:51 [RESEND v3 0/2] Hao Chang
2025-01-25 2:51 ` [RESEND v3 1/2] pinctrl: mediatek: update EINT base retrieval method Hao Chang
2025-01-25 2:51 ` [RESEND v3 2/2] pinctrl: mediatek: adapt to multi-base design Hao Chang
2025-01-27 11:48 ` AngeloGioacchino Del Regno
2025-02-19 7:28 ` Chhao Chang (常浩) [this message]
2025-02-19 7:53 ` Chen-Yu Tsai
2025-02-19 8:02 ` Chhao 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=8c62eca41c042425f575314ce88096e2fdb92ceb.camel@mediatek.com \
--to=ot_chhao.chang@mediatek.com \
--cc=Axe.Yang@mediatek.com \
--cc=Hanks.Chen@mediatek.com \
--cc=Qingliang.Li@mediatek.com \
--cc=Wenbin.Mei@mediatek.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chunhui.li@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=seann.wang@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).