devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hsin-hsiung Wang <hsin-hsiung.wang@mediatek.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: Rob Herring <robh+dt@kernel.org>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Frank Wunderlich <frank-w@public-files.de>,
	"Josef Friedl" <josef.friedl@speed.at>,
	<devicetree@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-mediatek@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>,
	srv_heupstream <srv_heupstream@mediatek.com>,
	<hsin-hsiung.wang@mediatek.com>
Subject: Re: [PATCH 1/8] mfd: mt6358: refine interrupt code
Date: Mon, 3 Aug 2020 16:29:39 +0800	[thread overview]
Message-ID: <1596443379.31084.3.camel@mtksdaap41> (raw)
In-Reply-To: <20200727154840.GY1850026@dell>

Hi,

On Mon, 2020-07-27 at 16:48 +0100, Lee Jones wrote:
> On Thu, 23 Jul 2020, Hsin-Hsiung Wang wrote:
> 
> > This patch refines the interrupt related code to support new chips.
> 
> Refines in what way?
> 
> What makes this better?
> 

Thanks for the comment. I will add more information into comment message
based on my below explanation.

> > Signed-off-by: Hsin-Hsiung Wang <hsin-hsiung.wang@mediatek.com>
> > ---
> >  drivers/mfd/mt6358-irq.c        | 65 ++++++++++++++++++++++++-----------------
> >  include/linux/mfd/mt6358/core.h |  8 ++---
> >  2 files changed, 41 insertions(+), 32 deletions(-)
> > 
> > diff --git a/drivers/mfd/mt6358-irq.c b/drivers/mfd/mt6358-irq.c
> > index db734f2..4b094e5 100644
> > --- a/drivers/mfd/mt6358-irq.c
> > +++ b/drivers/mfd/mt6358-irq.c
> > @@ -13,7 +13,9 @@
> >  #include <linux/platform_device.h>
> >  #include <linux/regmap.h>
> >  
> > -static struct irq_top_t mt6358_ints[] = {
> > +#define MTK_PMIC_REG_WIDTH 16
> > +
> > +static const struct irq_top_t mt6358_ints[] = {
> >  	MT6358_TOP_GEN(BUCK),
> >  	MT6358_TOP_GEN(LDO),
> >  	MT6358_TOP_GEN(PSC),
> > @@ -24,6 +26,13 @@ static struct irq_top_t mt6358_ints[] = {
> >  	MT6358_TOP_GEN(MISC),
> >  };
> >  
> > +static struct pmic_irq_data mt6358_irqd = {
> > +	.num_top = ARRAY_SIZE(mt6358_ints),
> > +	.num_pmic_irqs = MT6358_IRQ_NR,
> > +	.top_int_status_reg = MT6358_TOP_INT_STATUS0,
> > +	.pmic_ints = mt6358_ints,
> > +};
> 
> Dynamically assigned driver data is usually preferred.
> 
> Why have you gone static?
> 

Do you consider the memory allocation?
Below modification is to assign necessary data dynamically and the code
will become longer with more chips if we assign every member of the
structure.

@@ -180,17 +190,18 @@  int mt6358_irq_init(struct mt6397_chip *chip)
               int i, j, ret;
               struct pmic_irq_data *irqd;

-              irqd = devm_kzalloc(chip->dev, sizeof(*irqd),
GFP_KERNEL);
-              if (!irqd)
-                              return -ENOMEM;
+             switch (chip->chip_id) {
+             case MT6358_CHIP_ID:
+                             chip->irq_data = &mt6358_irqd;
+                             break;

-              chip->irq_data = irqd;
+             default:
+                             dev_err(chip->dev, "unsupported chip: 0x%x
\n", chip->chip_id);
+                             return -ENODEV;
+             }

                mutex_init(&chip->irqlock);
-              irqd->top_int_status_reg = MT6358_TOP_INT_STATUS0;
-              irqd->num_pmic_irqs = MT6358_IRQ_NR;
-              irqd->num_top = ARRAY_SIZE(mt6358_ints);
-
+             irqd = chip->irq_data;
               irqd->enable_hwirq = devm_kcalloc(chip->dev,

irqd->num_pmic_irqs,

sizeof(*irqd->enable_hwirq),


  reply	other threads:[~2020-08-03  8:29 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-23 12:58 [PATCH 0/8] Add Support for MediaTek PMIC MT6359 Hsin-Hsiung Wang
2020-07-23 12:58 ` [PATCH 1/8] mfd: mt6358: refine interrupt code Hsin-Hsiung Wang
2020-07-27 15:48   ` Lee Jones
2020-08-03  8:29     ` Hsin-hsiung Wang [this message]
2020-08-10  7:31       ` Lee Jones
2020-07-23 12:58 ` [PATCH 2/8] dt-bindings: mfd: Add compatible for the MediaTek MT6359 PMIC Hsin-Hsiung Wang
2020-07-23 21:31   ` Rob Herring
2020-07-28  6:33   ` Lee Jones
2020-07-23 12:58 ` [PATCH 3/8] dt-bindings: regulator: Add document for MT6359 regulator Hsin-Hsiung Wang
2020-07-23 12:58 ` [PATCH 4/8] mfd: Add support for the MediaTek MT6359 PMIC Hsin-Hsiung Wang
2020-07-28  6:42   ` Lee Jones
2020-07-23 12:58 ` [PATCH 5/8] regulator: mt6359: Add support for MT6359 regulator Hsin-Hsiung Wang
2020-07-24 12:21   ` Mark Brown
2020-07-23 12:58 ` [PATCH 6/8] regulator: mt6359: Set the enable time for LDOs Hsin-Hsiung Wang
2020-07-24 12:22   ` Mark Brown
2020-07-23 12:58 ` [PATCH 7/8] regulator: mt6359: Add support for MT6359P regulator Hsin-Hsiung Wang
2020-07-24 12:23   ` Mark Brown
2020-07-23 12:58 ` [PATCH 8/8] arm64: dts: mt6359: add PMIC MT6359 related nodes Hsin-Hsiung Wang

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=1596443379.31084.3.camel@mtksdaap41 \
    --to=hsin-hsiung.wang@mediatek.com \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=frank-w@public-files.de \
    --cc=josef.friedl@speed.at \
    --cc=lee.jones@linaro.org \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    --cc=robh+dt@kernel.org \
    --cc=srv_heupstream@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;
as well as URLs for NNTP newsgroup(s).