Skip to content

Commit

Permalink
memory: tegra{20,30}-mc: Fix reading incorrect register in mc_readl()
Browse files Browse the repository at this point in the history
The code reading the register does not match the code writing to the register,
fix it.

Also fix the coding style in mc_writel() for better readability.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
Acked-by: Stephen Warren <swarren@nvidia.com>
Tested-by: Stephen Warren <swarren@nvidia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Axel Lin authored and Greg Kroah-Hartman committed Sep 26, 2012
1 parent 0a18b05 commit e0f21e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 22 deletions.
10 changes: 3 additions & 7 deletions drivers/memory/tegra20-mc.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,18 @@ static inline u32 mc_readl(struct tegra20_mc *mc, u32 offs)

if (offs < 0x24)
val = readl(mc->regs[0] + offs);
if (offs < 0x400)
else if (offs < 0x400)
val = readl(mc->regs[1] + offs - 0x3c);

return val;
}

static inline void mc_writel(struct tegra20_mc *mc, u32 val, u32 offs)
{
if (offs < 0x24) {
if (offs < 0x24)
writel(val, mc->regs[0] + offs);
return;
}
if (offs < 0x400) {
else if (offs < 0x400)
writel(val, mc->regs[1] + offs - 0x3c);
return;
}
}

static const char * const tegra20_mc_client[] = {
Expand Down
22 changes: 7 additions & 15 deletions drivers/memory/tegra30-mc.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,34 +95,26 @@ static inline u32 mc_readl(struct tegra30_mc *mc, u32 offs)

if (offs < 0x10)
val = readl(mc->regs[0] + offs);
if (offs < 0x1f0)
else if (offs < 0x1f0)
val = readl(mc->regs[1] + offs - 0x3c);
if (offs < 0x228)
else if (offs < 0x228)
val = readl(mc->regs[2] + offs - 0x200);
if (offs < 0x400)
else if (offs < 0x400)
val = readl(mc->regs[3] + offs - 0x284);

return val;
}

static inline void mc_writel(struct tegra30_mc *mc, u32 val, u32 offs)
{
if (offs < 0x10) {
if (offs < 0x10)
writel(val, mc->regs[0] + offs);
return;
}
if (offs < 0x1f0) {
else if (offs < 0x1f0)
writel(val, mc->regs[1] + offs - 0x3c);
return;
}
if (offs < 0x228) {
else if (offs < 0x228)
writel(val, mc->regs[2] + offs - 0x200);
return;
}
if (offs < 0x400) {
else if (offs < 0x400)
writel(val, mc->regs[3] + offs - 0x284);
return;
}
}

static const char * const tegra30_mc_client[] = {
Expand Down

0 comments on commit e0f21e6

Please sign in to comment.