Re: [PATCH 2/5] irqchip/irq-imx-gpcv2: Share reg offset calculation code

From: Lucas Stach
Date: Thu Dec 06 2018 - 06:11:48 EST


Am Mittwoch, den 05.12.2018, 23:31 -0800 schrieb Andrey Smirnov:
> Move identical offset calculation code into a small helper function
> and make use of it in the rest of the code.
>
> > Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> > Cc: Jason Cooper <jason@xxxxxxxxxxxxxx>
> > Cc: Marc Zyngier <marc.zyngier@xxxxxxx>
> Cc: cphealy@xxxxxxxxx
> Cc: l.stach@xxxxxxxxxxxxxx
> > Cc: Leonard Crestez <leonard.crestez@xxxxxxx>
> > Cc: "A.s. Dong" <aisheng.dong@xxxxxxx>
> > Cc: Richard Zhu <hongxing.zhu@xxxxxxx>
> Cc: linux-imx@xxxxxxx
> Cc: linux-arm-kernel@xxxxxxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx
> Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>

Nice cleanup!

Reviewed-by: Lucas Stach <l.stach@xxxxxxxxxxxxxx>

> ---
> Âdrivers/irqchip/irq-imx-gpcv2.c | 18 ++++++++++--------
> Â1 file changed, 10 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/irqchip/irq-imx-gpcv2.c b/drivers/irqchip/irq-imx-gpcv2.c
> index cbed00319315..b262ba8b2652 100644
> --- a/drivers/irqchip/irq-imx-gpcv2.c
> +++ b/drivers/irqchip/irq-imx-gpcv2.c
> @@ -28,6 +28,11 @@ struct gpcv2_irqchip_data {
> Â
> Âstatic struct gpcv2_irqchip_data *imx_gpcv2_instance;
> Â
> +static void __iomem *gpcv2_idx_to_reg(struct gpcv2_irqchip_data *cd, int i)
> +{
> > + return cd->gpc_base + cd->cpu2wakeup + i * 4;
> +}
> +
> Âstatic int gpcv2_wakeup_source_save(void)
> Â{
> > Â struct gpcv2_irqchip_data *cd;
> @@ -39,7 +44,7 @@ static int gpcv2_wakeup_source_save(void)
> > Â return 0;
> Â
> > Â for (i = 0; i < IMR_NUM; i++) {
> > - reg = cd->gpc_base + cd->cpu2wakeup + i * 4;
> > + reg = gpcv2_idx_to_reg(cd, i);
> > Â cd->saved_irq_mask[i] = readl_relaxed(reg);
> > Â writel_relaxed(cd->wakeup_sources[i], reg);
> > Â }
> @@ -50,17 +55,14 @@ static int gpcv2_wakeup_source_save(void)
> Âstatic void gpcv2_wakeup_source_restore(void)
> Â{
> > Â struct gpcv2_irqchip_data *cd;
> > - void __iomem *reg;
> > Â int i;
> Â
> > Â cd = imx_gpcv2_instance;
> > Â if (!cd)
> > Â return;
> Â
> > - for (i = 0; i < IMR_NUM; i++) {
> > - reg = cd->gpc_base + cd->cpu2wakeup + i * 4;
> > - writel_relaxed(cd->saved_irq_mask[i], reg);
> > - }
> > + for (i = 0; i < IMR_NUM; i++)
> > + writel_relaxed(cd->saved_irq_mask[i], gpcv2_idx_to_reg(cd, i));
> Â}
> Â
> Âstatic struct syscore_ops imx_gpcv2_syscore_ops = {
> @@ -97,7 +99,7 @@ static void imx_gpcv2_irq_unmask(struct irq_data *d)
> > Â u32 val;
> Â
> > Â raw_spin_lock(&cd->rlock);
> > - reg = cd->gpc_base + cd->cpu2wakeup + d->hwirq / 32 * 4;
> > + reg = gpcv2_idx_to_reg(cd, d->hwirq / 32);
> > Â val = readl_relaxed(reg);
> > Â val &= ~(1 << d->hwirq % 32);
> > Â writel_relaxed(val, reg);
> @@ -113,7 +115,7 @@ static void imx_gpcv2_irq_mask(struct irq_data *d)
> > Â u32 val;
> Â
> > Â raw_spin_lock(&cd->rlock);
> > - reg = cd->gpc_base + cd->cpu2wakeup + d->hwirq / 32 * 4;
> > + reg = gpcv2_idx_to_reg(cd, d->hwirq / 32);
> > Â val = readl_relaxed(reg);
> > Â val |= 1 << (d->hwirq % 32);
> > Â writel_relaxed(val, reg);