From: paul@pwsan.com (Paul Walmsley)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 03/12] ARM: OMAP2+: hwmod: consolidate finding the MPU port index and storing it
Date: Wed, 07 Mar 2012 19:38:25 -0700 [thread overview]
Message-ID: <20120308023824.8205.11522.stgit@dusk> (raw)
In-Reply-To: <20120308023614.8205.78768.stgit@dusk>
An IP block's MPU interface port only needs to be found once. The result
can be cached to speed further lookups. This patch consolidates these
two steps into a single function.
Signed-off-by: Paul Walmsley <paul@pwsan.com>
Cc: Beno?t Cousson <b-cousson@ti.com>
---
arch/arm/mach-omap2/omap_hwmod.c | 39 +++++++++++++++-----------------------
1 files changed, 15 insertions(+), 24 deletions(-)
diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 96a03d7..3c733a8 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1044,37 +1044,34 @@ static int _get_addr_space_by_name(struct omap_hwmod *oh, const char *name,
}
/**
- * _find_mpu_port_index - find hwmod OCP slave port ID intended for MPU use
+ * _save_mpu_port_index - find and save the index to @oh's MPU port
* @oh: struct omap_hwmod *
*
- * Returns the array index of the OCP slave port that the MPU
- * addresses the device on, or -EINVAL upon error or not found.
+ * Determines the array index of the OCP slave port that the MPU uses
+ * to address the device, and saves it into the struct omap_hwmod.
+ * Intended to be called during hwmod registration only. No return
+ * value.
*/
-static int __init _find_mpu_port_index(struct omap_hwmod *oh)
+static void __init _save_mpu_port_index(struct omap_hwmod *oh)
{
- struct omap_hwmod_ocp_if *os;
+ struct omap_hwmod_ocp_if *os = NULL;
int i = 0;
- int found = 0;
if (!oh)
- return -EINVAL;
+ return;
+
+ oh->_int_flags |= _HWMOD_NO_MPU_PORT;
while (i < oh->slaves_cnt) {
os = _fetch_next_ocp_if(NULL, oh->slaves, &i);
if (os->user & OCP_USER_MPU) {
- found = 1;
+ oh->_mpu_port_index = i - 1;
+ oh->_int_flags &= ~_HWMOD_NO_MPU_PORT;
break;
}
}
- if (found)
- pr_debug("omap_hwmod: %s: MPU OCP slave port ID %d\n",
- oh->name, i - 1);
- else
- pr_debug("omap_hwmod: %s: no MPU OCP slave port found\n",
- oh->name);
-
- return (found) ? (i - 1) : -EINVAL;
+ return;
}
/**
@@ -1112,7 +1109,7 @@ static struct omap_hwmod_addr_space * __init _find_mpu_rt_addr_space(struct omap
int found = 0, i = 0;
os = _find_mpu_rt_port(oh);
- if (!os->addr)
+ if (!os || !os->addr)
return NULL;
do {
@@ -2175,8 +2172,6 @@ static int __init _setup(struct omap_hwmod *oh, void *n)
*/
static int __init _register(struct omap_hwmod *oh)
{
- int ms_id;
-
if (!oh || !oh->name || !oh->class || !oh->class->name ||
(oh->_state != _HWMOD_STATE_UNKNOWN))
return -EINVAL;
@@ -2186,11 +2181,7 @@ static int __init _register(struct omap_hwmod *oh)
if (_lookup(oh->name))
return -EEXIST;
- ms_id = _find_mpu_port_index(oh);
- if (!IS_ERR_VALUE(ms_id))
- oh->_mpu_port_index = ms_id;
- else
- oh->_int_flags |= _HWMOD_NO_MPU_PORT;
+ _save_mpu_port_index(oh);
list_add_tail(&oh->node, &omap_hwmod_list);
next prev parent reply other threads:[~2012-03-08 2:38 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-08 2:38 [PATCH 00/12] ARM: OMAP2+: hwmod: remove link arrays Paul Walmsley
2012-03-08 2:38 ` [PATCH 01/12] ARM: OMAP2+: hwmod: add _find_mpu_rt_port() Paul Walmsley
2012-03-08 2:38 ` [PATCH 02/12] ARM: OMAP2+: hwmod: add function to iterate over struct omap_hwmod_ocp_if Paul Walmsley
2012-03-08 2:38 ` Paul Walmsley [this message]
2012-03-08 2:38 ` [PATCH 04/12] ARM: OMAP2+: hwmod: add support for link registration Paul Walmsley
2012-03-08 2:38 ` [PATCH 06/12] ARM: OMAP: hwmod: remove code support for direct hwmod registration Paul Walmsley
2012-03-08 2:38 ` [PATCH 08/12] ARM: OMAP2xxx: hwmod data: share common hwmods between OMAP2420 and OMAP2430 Paul Walmsley
2012-03-08 2:38 ` [PATCH 09/12] ARM: OMAP2xxx: hwmod data: share common interface data Paul Walmsley
2012-03-08 2:38 ` [PATCH 10/12] ARM: OMAP3: hwmod data: fix IVA interface clock Paul Walmsley
2012-03-08 2:38 ` [PATCH 11/12] ARM: OMAP3: hwmod data: add IVA hard reset lines, main clock, clockdomain Paul Walmsley
2012-03-08 2:38 ` [PATCH 12/12] ARM: OMAP2xxx: hwmod data: start to fix the IVA1, IVA2 and DSP Paul Walmsley
2012-04-19 9:18 ` Paul Walmsley
2012-04-19 9:28 ` Russell King - ARM Linux
2012-04-19 9:33 ` Paul Walmsley
2012-04-19 9:38 ` Paul Walmsley
2012-03-08 2:55 ` [PATCH 00/12] ARM: OMAP2+: hwmod: remove link arrays Paul Walmsley
2012-03-09 4:27 ` 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=20120308023824.8205.11522.stgit@dusk \
--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).