Skip to content

Commit 7cd925a

Browse files
mszyprowdlezcano
authored andcommitted
clocksource/drivers/exynos_mct: Refactor resources allocation
Move interrupts allocation from exynos4_timer_resources() into separate function together with the interrupt number parsing code from mct_init_dt(), so the code for managing interrupts is kept together. While touching exynos4_timer_resources() function, move of_iomap() to it. No functional changes. Signed-off-by: Marek Szyprowski <[email protected]> Reviewed-by: Chanwoo Choi <[email protected]> Tested-by: Chanwoo Choi <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Signed-off-by: Sam Protsenko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Daniel Lezcano <[email protected]>
1 parent ad253b3 commit 7cd925a

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

drivers/clocksource/exynos_mct.c

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -504,11 +504,14 @@ static int exynos4_mct_dying_cpu(unsigned int cpu)
504504
return 0;
505505
}
506506

507-
static int __init exynos4_timer_resources(struct device_node *np, void __iomem *base)
507+
static int __init exynos4_timer_resources(struct device_node *np)
508508
{
509-
int err, cpu;
510509
struct clk *mct_clk, *tick_clk;
511510

511+
reg_base = of_iomap(np, 0);
512+
if (!reg_base)
513+
panic("%s: unable to ioremap mct address space\n", __func__);
514+
512515
tick_clk = of_clk_get_by_name(np, "fin_pll");
513516
if (IS_ERR(tick_clk))
514517
panic("%s: unable to determine tick clock rate\n", __func__);
@@ -519,9 +522,27 @@ static int __init exynos4_timer_resources(struct device_node *np, void __iomem *
519522
panic("%s: unable to retrieve mct clock instance\n", __func__);
520523
clk_prepare_enable(mct_clk);
521524

522-
reg_base = base;
523-
if (!reg_base)
524-
panic("%s: unable to ioremap mct address space\n", __func__);
525+
return 0;
526+
}
527+
528+
static int __init exynos4_timer_interrupts(struct device_node *np,
529+
unsigned int int_type)
530+
{
531+
int nr_irqs, i, err, cpu;
532+
533+
mct_int_type = int_type;
534+
535+
/* This driver uses only one global timer interrupt */
536+
mct_irqs[MCT_G0_IRQ] = irq_of_parse_and_map(np, MCT_G0_IRQ);
537+
538+
/*
539+
* Find out the number of local irqs specified. The local
540+
* timer irqs are specified after the four global timer
541+
* irqs are specified.
542+
*/
543+
nr_irqs = of_irq_count(np);
544+
for (i = MCT_L0_IRQ; i < nr_irqs; i++)
545+
mct_irqs[i] = irq_of_parse_and_map(np, i);
525546

526547
if (mct_int_type == MCT_INT_PPI) {
527548

@@ -581,24 +602,13 @@ static int __init exynos4_timer_resources(struct device_node *np, void __iomem *
581602

582603
static int __init mct_init_dt(struct device_node *np, unsigned int int_type)
583604
{
584-
u32 nr_irqs, i;
585605
int ret;
586606

587-
mct_int_type = int_type;
588-
589-
/* This driver uses only one global timer interrupt */
590-
mct_irqs[MCT_G0_IRQ] = irq_of_parse_and_map(np, MCT_G0_IRQ);
591-
592-
/*
593-
* Find out the number of local irqs specified. The local
594-
* timer irqs are specified after the four global timer
595-
* irqs are specified.
596-
*/
597-
nr_irqs = of_irq_count(np);
598-
for (i = MCT_L0_IRQ; i < nr_irqs; i++)
599-
mct_irqs[i] = irq_of_parse_and_map(np, i);
607+
ret = exynos4_timer_resources(np);
608+
if (ret)
609+
return ret;
600610

601-
ret = exynos4_timer_resources(np, of_iomap(np, 0));
611+
ret = exynos4_timer_interrupts(np, int_type);
602612
if (ret)
603613
return ret;
604614

0 commit comments

Comments
 (0)