aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap2/omap_hwmod.c
diff options
context:
space:
mode:
authorPaul Walmsley <paul@pwsan.com>2011-07-09 21:14:06 -0400
committerPaul Walmsley <paul@pwsan.com>2011-07-09 21:14:06 -0400
commit212738a4499d278254ed6fdb400e3b4be4cb1de2 (patch)
treecaa57aa80c343a20eaa7a5e32b7205132b561669 /arch/arm/mach-omap2/omap_hwmod.c
parentded11383fc14a7483cf30700ffc253caf37c9933 (diff)
omap_hwmod: use a terminator record with omap_hwmod_mpu_irqs arrays
Previously, struct omap_hwmod_mpu_irqs arrays were unterminated; and users of these arrays used the ARRAY_SIZE() macro to determine the length of the array. However, ARRAY_SIZE() only works when the array is in the same scope as the macro user. So far this hasn't been a problem. However, to reduce duplicated data, a subsequent patch will move common data to a separate, shared file. When this is done, ARRAY_SIZE() will no longer be usable. This patch removes ARRAY_SIZE() usage for struct omap_hwmod_mpu_irqs arrays and uses a sentinel value (irq == -1) as the array terminator instead. Signed-off-by: Paul Walmsley <paul@pwsan.com>
Diffstat (limited to 'arch/arm/mach-omap2/omap_hwmod.c')
-rw-r--r--arch/arm/mach-omap2/omap_hwmod.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 77094d75367f..21e3eb8e83c1 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -679,6 +679,29 @@ static void _disable_optional_clocks(struct omap_hwmod *oh)
679} 679}
680 680
681/** 681/**
682 * _count_mpu_irqs - count the number of MPU IRQ lines associated with @oh
683 * @oh: struct omap_hwmod *oh
684 *
685 * Count and return the number of MPU IRQs associated with the hwmod
686 * @oh. Used to allocate struct resource data. Returns 0 if @oh is
687 * NULL.
688 */
689static int _count_mpu_irqs(struct omap_hwmod *oh)
690{
691 struct omap_hwmod_irq_info *ohii;
692 int i = 0;
693
694 if (!oh || !oh->mpu_irqs)
695 return 0;
696
697 do {
698 ohii = &oh->mpu_irqs[i++];
699 } while (ohii->irq != -1);
700
701 return i;
702}
703
704/**
682 * _count_ocp_if_addr_spaces - count the number of address space entries for @oh 705 * _count_ocp_if_addr_spaces - count the number of address space entries for @oh
683 * @oh: struct omap_hwmod *oh 706 * @oh: struct omap_hwmod *oh
684 * 707 *
@@ -1964,7 +1987,7 @@ int omap_hwmod_count_resources(struct omap_hwmod *oh)
1964{ 1987{
1965 int ret, i; 1988 int ret, i;
1966 1989
1967 ret = oh->mpu_irqs_cnt + oh->sdma_reqs_cnt; 1990 ret = _count_mpu_irqs(oh) + oh->sdma_reqs_cnt;
1968 1991
1969 for (i = 0; i < oh->slaves_cnt; i++) 1992 for (i = 0; i < oh->slaves_cnt; i++)
1970 ret += _count_ocp_if_addr_spaces(oh->slaves[i]); 1993 ret += _count_ocp_if_addr_spaces(oh->slaves[i]);
@@ -1984,12 +2007,13 @@ int omap_hwmod_count_resources(struct omap_hwmod *oh)
1984 */ 2007 */
1985int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res) 2008int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res)
1986{ 2009{
1987 int i, j; 2010 int i, j, mpu_irqs_cnt;
1988 int r = 0; 2011 int r = 0;
1989 2012
1990 /* For each IRQ, DMA, memory area, fill in array.*/ 2013 /* For each IRQ, DMA, memory area, fill in array.*/
1991 2014
1992 for (i = 0; i < oh->mpu_irqs_cnt; i++) { 2015 mpu_irqs_cnt = _count_mpu_irqs(oh);
2016 for (i = 0; i < mpu_irqs_cnt; i++) {
1993 (res + r)->name = (oh->mpu_irqs + i)->name; 2017 (res + r)->name = (oh->mpu_irqs + i)->name;
1994 (res + r)->start = (oh->mpu_irqs + i)->irq; 2018 (res + r)->start = (oh->mpu_irqs + i)->irq;
1995 (res + r)->end = (oh->mpu_irqs + i)->irq; 2019 (res + r)->end = (oh->mpu_irqs + i)->irq;