Skip to content

Commit

Permalink
OMAP: hwmod: Fix wrong pointer iteration in oh->slaves
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Benoit Cousson authored and Paul Walmsley committed May 20, 2010
1 parent 33f7ec8 commit 682fdc9
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions arch/arm/mach-omap2/omap_hwmod.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,16 @@ 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;

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;

Expand Down Expand Up @@ -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);
Expand All @@ -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))
Expand All @@ -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);
Expand All @@ -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))
Expand All @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1000,15 +1002,15 @@ 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)
return -EINVAL;

/* 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))
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 682fdc9

Please sign in to comment.