]> Pileus Git - ~andy/linux/commitdiff
ARM: Consolidate clks_register() and similar
authorRussell King <rmk+kernel@arm.linux.org.uk>
Tue, 12 Jan 2010 12:28:00 +0000 (12:28 +0000)
committerRussell King <rmk+kernel@arm.linux.org.uk>
Fri, 12 Feb 2010 17:32:36 +0000 (17:32 +0000)
Most machine classes want some way to register a block of clk_lookup
structures, and most do it by implementing a clks_register() type
function which walks an array, or by open-coding a loop.

Consolidate all this into clkdev_add_table().

Acked-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: Kevin Hilman <khilman@deeprootsystems.com>
Acked-by: Eric Miao <eric.y.miao@gmail.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
33 files changed:
arch/arm/common/clkdev.c
arch/arm/include/asm/clkdev.h
arch/arm/mach-bcmring/core.c
arch/arm/mach-ep93xx/clock.c
arch/arm/mach-integrator/core.c
arch/arm/mach-integrator/integrator_cp.c
arch/arm/mach-mmp/clock.c
arch/arm/mach-mmp/clock.h
arch/arm/mach-mmp/pxa168.c
arch/arm/mach-mmp/pxa910.c
arch/arm/mach-mx1/clock.c
arch/arm/mach-mx2/clock_imx21.c
arch/arm/mach-mx2/clock_imx27.c
arch/arm/mach-mx25/clock.c
arch/arm/mach-mx3/clock-imx35.c
arch/arm/mach-mx3/clock.c
arch/arm/mach-mxc91231/clock.c
arch/arm/mach-pxa/clock.c
arch/arm/mach-pxa/clock.h
arch/arm/mach-pxa/eseries.c
arch/arm/mach-pxa/pxa25x.c
arch/arm/mach-pxa/pxa27x.c
arch/arm/mach-pxa/pxa300.c
arch/arm/mach-pxa/pxa320.c
arch/arm/mach-pxa/pxa3xx.c
arch/arm/mach-realview/core.c
arch/arm/mach-u300/clock.c
arch/arm/mach-ux500/clock.c
arch/arm/mach-versatile/core.c
arch/arm/mach-w90x900/clock.c
arch/arm/mach-w90x900/clock.h
arch/arm/mach-w90x900/cpu.c
arch/arm/plat-stmp3xxx/clock.c

index aae5bc01acc80d20d1f4cfe46c048d78455a67cb..446b696196e363858e66d12983b2bca21126d22d 100644 (file)
@@ -99,6 +99,16 @@ void clkdev_add(struct clk_lookup *cl)
 }
 EXPORT_SYMBOL(clkdev_add);
 
+void __init clkdev_add_table(struct clk_lookup *cl, size_t num)
+{
+       mutex_lock(&clocks_mutex);
+       while (num--) {
+               list_add_tail(&cl->node, &clocks);
+               cl++;
+       }
+       mutex_unlock(&clocks_mutex);
+}
+
 #define MAX_DEV_ID     20
 #define MAX_CON_ID     16
 
index b6ec7c627b393a794d1cfaf5549113d51057a7bc..7a0690da5e63235b6a8b1345adc2f396b29287c8 100644 (file)
@@ -27,4 +27,7 @@ struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
 void clkdev_add(struct clk_lookup *cl);
 void clkdev_drop(struct clk_lookup *cl);
 
+void clkdev_add_table(struct clk_lookup *, size_t);
+int clk_add_alias(const char *, const char *, char *, struct device *);
+
 #endif
index e590bbe0a7b46acb51e42baba1c5344239a29753..72e405df0fb07dd4b363153f149742875725f7ad 100644 (file)
@@ -142,8 +142,7 @@ void __init bcmring_amba_init(void)
 
        chipcHw_busInterfaceClockEnable(bus_clock);
 
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
+       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 
        for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
                struct amba_device *d = amba_devs[i];
index 1d0f9d8aff2e93583ba5ff0793f80d0f991f4786..bb3c621964428512f556edf29817f3e0d4336044 100644 (file)
@@ -445,7 +445,6 @@ static void __init ep93xx_dma_clock_init(void)
 static int __init ep93xx_clock_init(void)
 {
        u32 value;
-       int i;
 
        value = __raw_readl(EP93XX_SYSCON_CLOCK_SET1);
        if (!(value & 0x00800000)) {                    /* PLL1 bypassed?  */
@@ -474,8 +473,7 @@ static int __init ep93xx_clock_init(void)
                clk_f.rate / 1000000, clk_h.rate / 1000000,
                clk_p.rate / 1000000);
 
-       for (i = 0; i < ARRAY_SIZE(clocks); i++)
-               clkdev_add(&clocks[i]);
+       clkdev_add_table(clocks, ARRAY_SIZE(clocks));
        return 0;
 }
 arch_initcall(ep93xx_clock_init);
index a0f60e55da6a8a2bb7c1cf05fc6bd889e605721f..8b390e36ba69db77a44fd228b6e17a1909b4ca8a 100644 (file)
@@ -144,8 +144,7 @@ static int __init integrator_init(void)
 {
        int i;
 
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
+       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 
        for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
                struct amba_device *d = amba_devs[i];
index 3f35293d457a3cf0d44a6dc2ace58a918ea4c520..66ef86d6d9e3d0d80aa46f2e6f09d4314a491426 100644 (file)
@@ -558,9 +558,7 @@ static void __init intcp_init(void)
 {
        int i;
 
-       for (i = 0; i < ARRAY_SIZE(cp_lookups); i++)
-               clkdev_add(&cp_lookups[i]);
-
+       clkdev_add_table(cp_lookups, ARRAY_SIZE(cp_lookups));
        platform_add_devices(intcp_devs, ARRAY_SIZE(intcp_devs));
 
        for (i = 0; i < ARRAY_SIZE(amba_devs); i++) {
index 2a46ed5cc2a297e0356529b7465e0a8c52a06231..886e05648f08a5a4975bc0257b2b0929e9fffc1f 100644 (file)
@@ -88,11 +88,3 @@ unsigned long clk_get_rate(struct clk *clk)
        return rate;
 }
 EXPORT_SYMBOL(clk_get_rate);
-
-void clks_register(struct clk_lookup *clks, size_t num)
-{
-       int i;
-
-       for (i = 0; i < num; i++)
-               clkdev_add(&clks[i]);
-}
index eefffbe683b0263e4c053833b7f1025b3ed83f27..016ae94691c04cd42838c9b0af352b68a6e7cacc 100644 (file)
@@ -68,5 +68,3 @@ struct clk clk_##_name = {                                    \
 
 extern struct clk clk_pxa168_gpio;
 extern struct clk clk_pxa168_timers;
-
-extern void clks_register(struct clk_lookup *, size_t);
index 37dbdde17fac5b83bc739edc5b0493986fd9bf9c..1873c821df9051ebd37fe65a154ed437cb8a3608 100644 (file)
@@ -94,7 +94,7 @@ static int __init pxa168_init(void)
                mfp_init_base(MFPR_VIRT_BASE);
                mfp_init_addr(pxa168_mfp_addr_map);
                pxa_init_dma(IRQ_PXA168_DMA_INT0, 32);
-               clks_register(ARRAY_AND_SIZE(pxa168_clkregs));
+               clkdev_add_table(ARRAY_AND_SIZE(pxa168_clkregs));
        }
 
        return 0;
index d4049508a4df5cf71725bca0178f2ab754fce7bb..46f2d69bef3cf01dd3778a380fa2b1801799cef1 100644 (file)
@@ -131,7 +131,7 @@ static int __init pxa910_init(void)
                mfp_init_base(MFPR_VIRT_BASE);
                mfp_init_addr(pxa910_mfp_addr_map);
                pxa_init_dma(IRQ_PXA910_DMA_INT0, 32);
-               clks_register(ARRAY_AND_SIZE(pxa910_clkregs));
+               clkdev_add_table(ARRAY_AND_SIZE(pxa910_clkregs));
        }
 
        return 0;
index d1b588519ad23b8dc230fb343d8b3596b99f3c96..6cf2d4a7511dc441561c80fe80ca432cf886d3b5 100644 (file)
@@ -570,7 +570,6 @@ static struct clk_lookup lookups[] __initdata = {
 int __init mx1_clocks_init(unsigned long fref)
 {
        unsigned int reg;
-       int i;
 
        /* disable clocks we are able to */
        __raw_writel(0, SCM_GCCR);
@@ -592,8 +591,7 @@ int __init mx1_clocks_init(unsigned long fref)
        reg = (reg & CCM_CSCR_CLKO_MASK) >> CCM_CSCR_CLKO_OFFSET;
        clko_clk.parent = (struct clk *)clko_clocks[reg];
 
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
+       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 
        clk_enable(&hclk);
        clk_enable(&fclk);
index 91901b5d56c2e63a871da04fbb489140f83ec3ea..e82b489d12150fd8a80c362b744538fcb494dca3 100644 (file)
@@ -968,7 +968,6 @@ static struct clk_lookup lookups[] = {
  */
 int __init mx21_clocks_init(unsigned long lref, unsigned long href)
 {
-       int i;
        u32 cscr;
 
        external_low_reference = lref;
@@ -986,8 +985,7 @@ int __init mx21_clocks_init(unsigned long lref, unsigned long href)
        else
                spll_clk.parent = &fpm_clk;
 
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
+       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 
        /* Turn off all clock gates */
        __raw_writel(0, CCM_PCCR0);
index b010bf9ceaaba1f4d18168fccdc31de2d7d26d2e..18c53a6487fafc7234d37cc494f04ff6c7250c49 100644 (file)
@@ -719,7 +719,6 @@ static void __init to2_adjust_clocks(void)
 int __init mx27_clocks_init(unsigned long fref)
 {
        u32 cscr = __raw_readl(CCM_CSCR);
-       int i;
 
        external_high_reference = fref;
 
@@ -736,8 +735,7 @@ int __init mx27_clocks_init(unsigned long fref)
 
        to2_adjust_clocks();
 
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
+       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 
        /* Turn off all clocks we do not need */
        __raw_writel(0, CCM_PCCR0);
index 6e838b857712733784ceb3f00cff790d4ba80c84..66916f104812a4a9cc6a6d251bdce43ce55bef9d 100644 (file)
@@ -210,11 +210,7 @@ static struct clk_lookup lookups[] = {
 
 int __init mx25_clocks_init(unsigned long fref)
 {
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
-
+       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
        mxc_timer_init(&gpt_clk, MX25_IO_ADDRESS(MX25_GPT1_BASE_ADDR), 54);
 
        return 0;
index 7584b4c6c556d6a23d3d7fa30567d0de4fdbd6c3..f3f41fa4f21bd4541400082519b5b449a8bfa696 100644 (file)
@@ -485,15 +485,13 @@ static struct clk_lookup lookups[] = {
 
 int __init mx35_clocks_init()
 {
-       int i;
        unsigned int ll = 0;
 
 #if defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC)
        ll = (3 << 16);
 #endif
 
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
+       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 
        /* Turn off all clocks except the ones we need to survive, namely:
         * EMI, GPIO1/2/3, GPT, IOMUX, MAX and eventually uart
index 27a318af0d200640215a7ef01c1272119ea69748..b5c39a016db78a6459a4edc8b4f5153db6f45582 100644 (file)
@@ -578,12 +578,10 @@ static struct clk_lookup lookups[] = {
 int __init mx31_clocks_init(unsigned long fref)
 {
        u32 reg;
-       int i;
 
        ckih_rate = fref;
 
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
+       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 
        /* change the csi_clk parent if necessary */
        reg = __raw_readl(MXC_CCM_CCMR);
index ecfa37fef8ade52accc9f14a0839d4f6af9afea0..5c85075d8a56b9b6c40059785dd9a4cd69658632 100644 (file)
@@ -624,7 +624,6 @@ static struct clk_lookup lookups[] = {
 int __init mxc91231_clocks_init(unsigned long fref)
 {
        void __iomem *gpt_base;
-       int i;
 
        ckih_rate = fref;
 
@@ -632,8 +631,7 @@ int __init mxc91231_clocks_init(unsigned long fref)
        sdhc_clk[0].parent = clk_sdhc_parent(&sdhc_clk[0]);
        sdhc_clk[1].parent = clk_sdhc_parent(&sdhc_clk[1]);
 
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
+       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 
        gpt_base = MXC91231_IO_ADDRESS(MXC91231_GPT1_BASE_ADDR);
        mxc_timer_init(&gpt_clk, gpt_base, MXC91231_INT_GPT);
index 49ae38292310c2b1058c433f7e2a16fbe378756f..abba0089a2ae0d6af3ca35a9bf961d9a5a65406e 100644 (file)
@@ -78,11 +78,3 @@ const struct clkops clk_cken_ops = {
        .enable         = clk_cken_enable,
        .disable        = clk_cken_disable,
 };
-
-void clks_register(struct clk_lookup *clks, size_t num)
-{
-       int i;
-
-       for (i = 0; i < num; i++)
-               clkdev_add(&clks[i]);
-}
index 978a3667e90dcd3548c2fc01fcbc82484c724686..d8488742b8075179fd4d66026d79730e00505a21 100644 (file)
@@ -67,7 +67,3 @@ extern void clk_pxa3xx_cken_enable(struct clk *);
 extern void clk_pxa3xx_cken_disable(struct clk *);
 #endif
 
-void clks_register(struct clk_lookup *clks, size_t num);
-int clk_add_alias(const char *alias, const char *alias_name, char *id,
-       struct device *dev);
-
index 91417f035069a0ce40efd7cc9c60d2542962bdd9..96ed13081639598335309b23b992751d27102ea5 100644 (file)
@@ -128,6 +128,6 @@ static struct clk_lookup eseries_clkregs[] = {
 
 void eseries_register_clks(void)
 {
-       clks_register(eseries_clkregs, ARRAY_SIZE(eseries_clkregs));
+       clkdev_add_table(eseries_clkregs, ARRAY_SIZE(eseries_clkregs));
 }
 
index 2c1b0b70d01d0520b6b8facecd88c05884c319d6..0b9ad30bfd51cd659359dfbf2ded2412095033ad 100644 (file)
@@ -349,7 +349,7 @@ static int __init pxa25x_init(void)
 
                reset_status = RCSR;
 
-               clks_register(pxa25x_clkregs, ARRAY_SIZE(pxa25x_clkregs));
+               clkdev_add_table(pxa25x_clkregs, ARRAY_SIZE(pxa25x_clkregs));
 
                if ((ret = pxa_init_dma(IRQ_DMA, 16)))
                        return ret;
@@ -370,7 +370,7 @@ static int __init pxa25x_init(void)
 
        /* Only add HWUART for PXA255/26x; PXA210/250 do not have it. */
        if (cpu_is_pxa255())
-               clks_register(&pxa25x_hwuart_clkreg, 1);
+               clkdev_add(&pxa25x_hwuart_clkreg);
 
        return ret;
 }
index 6a0b73167e03b9bc4529c8e73060117f7fc02190..d783123e2d48e483917f88614dea852d74040504 100644 (file)
@@ -392,7 +392,7 @@ static int __init pxa27x_init(void)
 
                reset_status = RCSR;
 
-               clks_register(pxa27x_clkregs, ARRAY_SIZE(pxa27x_clkregs));
+               clkdev_add_table(pxa27x_clkregs, ARRAY_SIZE(pxa27x_clkregs));
 
                if ((ret = pxa_init_dma(IRQ_DMA, 32)))
                        return ret;
index f4af6e2bef892700b273db56e1b13605a1c22d56..40bb16501d8601789875c03bbef88dd87519c925 100644 (file)
@@ -102,12 +102,12 @@ static int __init pxa300_init(void)
        if (cpu_is_pxa300() || cpu_is_pxa310()) {
                mfp_init_base(io_p2v(MFPR_BASE));
                mfp_init_addr(pxa300_mfp_addr_map);
-               clks_register(ARRAY_AND_SIZE(common_clkregs));
+               clkdev_add_table(ARRAY_AND_SIZE(common_clkregs));
        }
 
        if (cpu_is_pxa310()) {
                mfp_init_addr(pxa310_mfp_addr_map);
-               clks_register(ARRAY_AND_SIZE(pxa310_clkregs));
+               clkdev_add_table(ARRAY_AND_SIZE(pxa310_clkregs));
        }
 
        return 0;
index c7373e74a109dffe6ad923e18c7c7ef951a121e4..8d614ecd8e998d3d663187656dd108ca29405e62 100644 (file)
@@ -90,7 +90,7 @@ static int __init pxa320_init(void)
        if (cpu_is_pxa320()) {
                mfp_init_base(io_p2v(MFPR_BASE));
                mfp_init_addr(pxa320_mfp_addr_map);
-               clks_register(ARRAY_AND_SIZE(pxa320_clkregs));
+               clkdev_add_table(ARRAY_AND_SIZE(pxa320_clkregs));
        }
 
        return 0;
index fcb0721f466947f221c447f235846841204f8bf8..4d7c03e725042e4d735c7b0055df65ce26214bda 100644 (file)
@@ -634,7 +634,7 @@ static int __init pxa3xx_init(void)
                 */
                ASCR &= ~(ASCR_RDH | ASCR_D1S | ASCR_D2S | ASCR_D3S);
 
-               clks_register(pxa3xx_clkregs, ARRAY_SIZE(pxa3xx_clkregs));
+               clkdev_add_table(pxa3xx_clkregs, ARRAY_SIZE(pxa3xx_clkregs));
 
                if ((ret = pxa_init_dma(IRQ_DMA, 32)))
                        return ret;
index 9f293438e020cb124e36cf4b370a5c43b0379c19..90bd4ef71b2cae9b426d0bf5e707c2a441a35e1c 100644 (file)
@@ -346,10 +346,7 @@ static struct clk_lookup lookups[] = {
 
 static int __init clk_init(void)
 {
-       int i;
-
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
+       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
        return 0;
 }
 arch_initcall(clk_init);
index 111f7ea32b384bd6e492d1cb1c0cf9635632c035..c174ed1f3691cc631d7ad5edcc4ab912abab4ec8 100644 (file)
@@ -1276,11 +1276,8 @@ static struct clk_lookup lookups[] = {
 
 static void __init clk_register(void)
 {
-       int i;
-
        /* Register the lookups */
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
+       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 }
 
 /*
index 20b6ebb6783aa7bb8f3a60356b780b66ff784a95..8359a73d0041c0b988cd4ecea50a77ac92f71093 100644 (file)
@@ -85,11 +85,8 @@ static struct clk_lookup lookups[] = {
 
 static int __init clk_init(void)
 {
-       int i;
-
        /* register the clock lookups */
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
+       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
        return 0;
 }
 arch_initcall(clk_init);
index e13be7c444ca83acb774b3865b4055b81f908b0f..9ddb49b1cb719119c2df40c3e807a4c90b36e712 100644 (file)
@@ -851,8 +851,7 @@ void __init versatile_init(void)
 {
        int i;
 
-       for (i = 0; i < ARRAY_SIZE(lookups); i++)
-               clkdev_add(&lookups[i]);
+       clkdev_add_table(lookups, ARRAY_SIZE(lookups));
 
        platform_device_register(&versatile_flash_device);
        platform_device_register(&versatile_i2c_device);
index b785994bab0a64fbe2bf5cf6f2cdd8e67f10306c..2c371ff22e517ad17776902f5af31e8e198d1a66 100644 (file)
@@ -90,12 +90,3 @@ void nuc900_subclk_enable(struct clk *clk, int enable)
 
        __raw_writel(clken, W90X900_VA_CLKPWR + SUBCLK);
 }
-
-
-void clks_register(struct clk_lookup *clks, size_t num)
-{
-       int i;
-
-       for (i = 0; i < num; i++)
-               clkdev_add(&clks[i]);
-}
index f5816a06eed6aa415bffd21b5dbd708266d404dc..c56ddab3d9128acce33ba0d293a3dcfa29bcd08c 100644 (file)
@@ -14,7 +14,6 @@
 
 void nuc900_clk_enable(struct clk *clk, int enable);
 void nuc900_subclk_enable(struct clk *clk, int enable);
-void clks_register(struct clk_lookup *clks, size_t num);
 
 struct clk {
        unsigned long           cken;
index 20dc0c96214dcae4e93bb67910e5c0027eb6cf8f..6f5ca532883f9bf640f73689dc08235eb131772e 100644 (file)
@@ -208,6 +208,6 @@ void __init nuc900_map_io(struct map_desc *mach_desc, int mach_size)
 
 void __init nuc900_init_clocks(void)
 {
-       clks_register(nuc900_clkregs, ARRAY_SIZE(nuc900_clkregs));
+       clkdev_add_table(nuc900_clkregs, ARRAY_SIZE(nuc900_clkregs));
 }
 
index 5d2f19a09e44c7bc02b05bfbe16c420769b29104..e593a2a801c63370efea993d529adf8b8960e0f4 100644 (file)
@@ -1126,9 +1126,8 @@ static int __init clk_init(void)
                        if (ops && ops->set_parent)
                                ops->set_parent(cl->clk, cl->clk->parent);
                }
-
-               clkdev_add(cl);
        }
+       clkdev_add_table(onchip_clks, ARRAY_SIZE(onchip_clks));
        return 0;
 }