linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: paul@pwsan.com (Paul Walmsley)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 05/22] OMAP: hwmod: Fix wrong pointer iteration in oh->slaves
Date: Tue, 18 May 2010 20:18:43 -0600	[thread overview]
Message-ID: <20100519021842.19716.89475.stgit@localhost.localdomain> (raw)
In-Reply-To: <20100519021800.19716.8938.stgit@localhost.localdomain>

From: Benoit Cousson <b-cousson@ti.com>

The iteration is currently done on the omap_hwmod_ocp_if pointer
and not on the table pointer that reference them.
It worked most of the time because the structure are contiguous in
memory.

Signed-off-by: Benoit Cousson <b-cousson@ti.com>
Signed-off-by: Paul Walmsley <paul@pwsan.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 6459d07..a280ccc 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -432,7 +432,6 @@ static int _init_main_clk(struct omap_hwmod *oh)
  */
 static int _init_interface_clks(struct omap_hwmod *oh)
 {
-	struct omap_hwmod_ocp_if *os;
 	struct clk *c;
 	int i;
 	int ret = 0;
@@ -440,7 +439,9 @@ static int _init_interface_clks(struct omap_hwmod *oh)
 	if (oh->slaves_cnt == 0)
 		return 0;
 
-	for (i = 0, os = *oh->slaves; i < oh->slaves_cnt; i++, os++) {
+	for (i = 0; i < oh->slaves_cnt; i++) {
+		struct omap_hwmod_ocp_if *os = oh->slaves[i];
+
 		if (!os->clk)
 			continue;
 
@@ -490,7 +491,6 @@ static int _init_opt_clks(struct omap_hwmod *oh)
  */
 static int _enable_clocks(struct omap_hwmod *oh)
 {
-	struct omap_hwmod_ocp_if *os;
 	int i;
 
 	pr_debug("omap_hwmod: %s: enabling clocks\n", oh->name);
@@ -499,7 +499,8 @@ static int _enable_clocks(struct omap_hwmod *oh)
 		clk_enable(oh->_clk);
 
 	if (oh->slaves_cnt > 0) {
-		for (i = 0, os = *oh->slaves; i < oh->slaves_cnt; i++, os++) {
+		for (i = 0; i < oh->slaves_cnt; i++) {
+			struct omap_hwmod_ocp_if *os = oh->slaves[i];
 			struct clk *c = os->_clk;
 
 			if (c && !IS_ERR(c) && (os->flags & OCPIF_SWSUP_IDLE))
@@ -520,7 +521,6 @@ static int _enable_clocks(struct omap_hwmod *oh)
  */
 static int _disable_clocks(struct omap_hwmod *oh)
 {
-	struct omap_hwmod_ocp_if *os;
 	int i;
 
 	pr_debug("omap_hwmod: %s: disabling clocks\n", oh->name);
@@ -529,7 +529,8 @@ static int _disable_clocks(struct omap_hwmod *oh)
 		clk_disable(oh->_clk);
 
 	if (oh->slaves_cnt > 0) {
-		for (i = 0, os = *oh->slaves; i < oh->slaves_cnt; i++, os++) {
+		for (i = 0; i < oh->slaves_cnt; i++) {
+			struct omap_hwmod_ocp_if *os = oh->slaves[i];
 			struct clk *c = os->_clk;
 
 			if (c && !IS_ERR(c) && (os->flags & OCPIF_SWSUP_IDLE))
@@ -551,14 +552,15 @@ static int _disable_clocks(struct omap_hwmod *oh)
  */
 static int _find_mpu_port_index(struct omap_hwmod *oh)
 {
-	struct omap_hwmod_ocp_if *os;
 	int i;
 	int found = 0;
 
 	if (!oh || oh->slaves_cnt == 0)
 		return -EINVAL;
 
-	for (i = 0, os = *oh->slaves; i < oh->slaves_cnt; i++, os++) {
+	for (i = 0; i < oh->slaves_cnt; i++) {
+		struct omap_hwmod_ocp_if *os = oh->slaves[i];
+
 		if (os->user & OCP_USER_MPU) {
 			found = 1;
 			break;
@@ -593,7 +595,7 @@ static void __iomem *_find_mpu_rt_base(struct omap_hwmod *oh, u8 index)
 	if (!oh || oh->slaves_cnt == 0)
 		return NULL;
 
-	os = *oh->slaves + index;
+	os = oh->slaves[index];
 
 	for (i = 0, mem = os->addr; i < os->addr_cnt; i++, mem++) {
 		if (mem->flags & ADDR_TYPE_RT) {
@@ -806,7 +808,7 @@ static int _wait_target_ready(struct omap_hwmod *oh)
 	if (oh->_int_flags & _HWMOD_NO_MPU_PORT)
 		return 0;
 
-	os = *oh->slaves + oh->_mpu_port_index;
+	os = oh->slaves[oh->_mpu_port_index];
 
 	if (oh->flags & HWMOD_NO_IDLEST)
 		return 0;
@@ -1000,7 +1002,6 @@ static int _shutdown(struct omap_hwmod *oh)
  */
 static int _setup(struct omap_hwmod *oh)
 {
-	struct omap_hwmod_ocp_if *os;
 	int i, r;
 
 	if (!oh)
@@ -1008,7 +1009,8 @@ static int _setup(struct omap_hwmod *oh)
 
 	/* Set iclk autoidle mode */
 	if (oh->slaves_cnt > 0) {
-		for (i = 0, os = *oh->slaves; i < oh->slaves_cnt; i++, os++) {
+		for (i = 0; i < oh->slaves_cnt; i++) {
+			struct omap_hwmod_ocp_if *os = oh->slaves[i];
 			struct clk *c = os->_clk;
 
 			if (!c || IS_ERR(c))
@@ -1438,7 +1440,7 @@ int omap_hwmod_count_resources(struct omap_hwmod *oh)
 	ret = oh->mpu_irqs_cnt + oh->sdma_chs_cnt;
 
 	for (i = 0; i < oh->slaves_cnt; i++)
-		ret += (*oh->slaves + i)->addr_cnt;
+		ret += oh->slaves[i]->addr_cnt;
 
 	return ret;
 }
@@ -1479,7 +1481,7 @@ int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res)
 	for (i = 0; i < oh->slaves_cnt; i++) {
 		struct omap_hwmod_ocp_if *os;
 
-		os = *oh->slaves + i;
+		os = oh->slaves[i];
 
 		for (j = 0; j < os->addr_cnt; j++) {
 			(res + r)->start = (os->addr + j)->pa_start;

  parent reply	other threads:[~2010-05-19  2:18 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-19  2:18 [PATCH 00/22] OMAP PRCM/clock/powerdomain/hwmod: remaining patches for 2.6.35 Paul Walmsley
2010-05-19  2:18 ` [PATCH 01/22] OMAP4: hwmod: Replace module & device offsets by absolute clkctrl address Paul Walmsley
2010-05-19  2:18 ` [PATCH 02/22] OMAP: CM: Move MAX_MODULE_READY_TIME to cm.h Paul Walmsley
2010-05-19  2:18 ` [PATCH 03/22] OMAP4: hwmod & CM: Implement the omap4_cm_wait_module_ready function Paul Walmsley
2010-05-19  2:18 ` [PATCH 04/22] OMAP4: hwmod: Replace OCPIF_HAS_IDLEST by HWMOD_NO_IDLEST Paul Walmsley
2010-05-19  2:18 ` Paul Walmsley [this message]
2010-05-19  2:18 ` [PATCH 06/22] OMAP: hwmod: Remove IS_ERR check with omap_clk_get_by_name return value Paul Walmsley
2010-05-19  2:18 ` [PATCH 07/22] OMAP: hwmod: Replace WARN by pr_warning if clock lookup failed Paul Walmsley
2010-05-21 10:00   ` Sergei Shtylyov
2010-05-21 10:16     ` Benoit Cousson
2010-05-19  2:18 ` [PATCH 08/22] OMAP: hwmod: Do not exit the iteration if one clock init failed Paul Walmsley
2010-05-19  2:18 ` [PATCH 09/22] OMAP: hwmod: Rename hwmod name for the MPU Paul Walmsley
2010-05-19  2:18 ` [PATCH 10/22] OMAP: hwmod: Replace WARN by pr_warning for clockdomain check Paul Walmsley
2010-05-21 10:02   ` Sergei Shtylyov
2010-05-21 10:23     ` Sergei Shtylyov
2010-05-21 10:41       ` Benoit Cousson
2010-05-19  2:18 ` [PATCH 11/22] OMAP4: CM: Remove non-functional registers in ES1.0 Paul Walmsley
2010-05-19  2:18 ` [PATCH 12/22] OMAP4: PRM: Remove MPU internal code name and apply PRCM naming convention Paul Walmsley
2010-05-19  2:18 ` [PATCH 13/22] OMAP4: PRCM: Remove duplicate definition of base addresses Paul Walmsley
2010-05-19  2:18 ` [PATCH 14/22] OMAP4: PRCM: Add offset defines for all PRM registers Paul Walmsley
2010-05-19  2:18 ` [PATCH 15/22] OMAP4: PRCM: Add offset defines for all CM registers Paul Walmsley
2010-05-19  2:18 ` [PATCH 16/22] OMAP4 clock: Support clk_set_parent Paul Walmsley
2010-05-19  2:18 ` [PATCH 17/22] OMAP: timers: Fix clock source names for OMAP4 Paul Walmsley
2010-05-19  2:18 ` [PATCH 18/22] OMAP4 powerdomain: Fix pwrsts flags for ALWAYS ON domains Paul Walmsley
2010-05-19  2:19 ` [PATCH 19/22] OMAP3 clock: add support for setting the divider for sys_clkout2 using clk_set_rate Paul Walmsley
2010-05-19  2:19 ` [PATCH 20/22] OMAP4 powerdomain: Support LOWPOWERSTATECHANGE for powerdomains Paul Walmsley
2010-05-19  2:19 ` [PATCH 21/22] OMAP powerdomain, hwmod, omap_device: add some credits Paul Walmsley
2010-05-19  2:19 ` [PATCH 22/22] OMAP2 clock: fix recursive spinlock attempt when CONFIG_CPU_FREQ=y Paul Walmsley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100519021842.19716.89475.stgit@localhost.localdomain \
    --to=paul@pwsan.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).