From b4b58f5834a023dab67201db9a626bef07bb200c Mon Sep 17 00:00:00 2001 From: Chandra Shekhar Date: Wed, 8 Oct 2008 10:01:39 +0300 Subject: ARM: OMAP: Allocate McBSP devices dynamically Based on Chandra's earlier patches in linux-omap tree. Note that omap1_mcbsp_check and omap2_mcbsp_check are no longer needed as there's now omap_mcbsp_check_valid_id() defined. Also some functions can now be marked __init. Signed-off-by: Chandra Shekhar Signed-off-by: Tony Lindgren --- arch/arm/mach-omap2/mcbsp.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'arch/arm/mach-omap2') diff --git a/arch/arm/mach-omap2/mcbsp.c b/arch/arm/mach-omap2/mcbsp.c index 709db03b9999..73f2279ef2ea 100644 --- a/arch/arm/mach-omap2/mcbsp.c +++ b/arch/arm/mach-omap2/mcbsp.c @@ -28,7 +28,7 @@ struct mcbsp_internal_clk { int n_childs; }; -#if defined(CONFIG_ARCH_OMAP24XX) || defined(CONFIG_ARCH_OMAP34XX) +#if defined(CONFIG_ARCH_OMAP24XX) static void omap_mcbsp_clk_init(struct mcbsp_internal_clk *mclk) { const char *clk_names[] = { "mcbsp_ick", "mcbsp_fck" }; @@ -117,18 +117,8 @@ static void omap2_mcbsp_request(unsigned int id) omap2_mcbsp2_mux_setup(); } -static int omap2_mcbsp_check(unsigned int id) -{ - if (id > OMAP_MAX_MCBSP_COUNT - 1) { - printk(KERN_ERR "OMAP-McBSP: McBSP%d doesn't exist\n", id + 1); - return -ENODEV; - } - return 0; -} - static struct omap_mcbsp_ops omap2_mcbsp_ops = { .request = omap2_mcbsp_request, - .check = omap2_mcbsp_check, }; #ifdef CONFIG_ARCH_OMAP24XX @@ -185,7 +175,7 @@ static struct omap_mcbsp_platform_data omap34xx_mcbsp_pdata[] = { #define OMAP34XX_MCBSP_PDATA_SZ 0 #endif -int __init omap2_mcbsp_init(void) +static int __init omap2_mcbsp_init(void) { int i; @@ -195,14 +185,20 @@ int __init omap2_mcbsp_init(void) clk_register(&omap_mcbsp_clks[i].clk); } + if (cpu_is_omap24xx()) + omap_mcbsp_count = OMAP24XX_MCBSP_PDATA_SZ; + if (cpu_is_omap34xx()) + omap_mcbsp_count = OMAP34XX_MCBSP_PDATA_SZ; + + mcbsp_ptr = kzalloc(omap_mcbsp_count * sizeof(struct omap_mcbsp *), + GFP_KERNEL); + if (!mcbsp_ptr) + return -ENOMEM; + if (cpu_is_omap24xx()) omap_mcbsp_register_board_cfg(omap24xx_mcbsp_pdata, OMAP24XX_MCBSP_PDATA_SZ); - if (cpu_is_omap34xx()) - omap_mcbsp_register_board_cfg(omap34xx_mcbsp_pdata, - OMAP34XX_MCBSP_PDATA_SZ); - return omap_mcbsp_init(); } arch_initcall(omap2_mcbsp_init); -- cgit v1.2.3