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>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1596443379.31084.3.camel@mtksdaap41>
Date:   Mon, 3 Aug 2020 16:29:39 +0800
From:   Hsin-hsiung Wang <hsin-hsiung.wang@...iatek.com>
To:     Lee Jones <lee.jones@...aro.org>
CC:     Rob Herring <robh+dt@...nel.org>,
        Matthias Brugger <matthias.bgg@...il.com>,
        Mark Brown <broonie@...nel.org>,
        Liam Girdwood <lgirdwood@...il.com>,
        Frank Wunderlich <frank-w@...lic-files.de>,
        "Josef Friedl" <josef.friedl@...ed.at>,
        <devicetree@...r.kernel.org>,
        <linux-arm-kernel@...ts.infradead.org>,
        <linux-mediatek@...ts.infradead.org>,
        <linux-kernel@...r.kernel.org>,
        srv_heupstream <srv_heupstream@...iatek.com>,
        <hsin-hsiung.wang@...iatek.com>
Subject: Re: [PATCH 1/8] mfd: mt6358: refine interrupt code

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@...iatek.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),

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ