Skip to content

Commit e0f21e6

Browse files
AxelLingregkh
authored andcommitted
memory: tegra{20,30}-mc: Fix reading incorrect register in mc_readl()
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>
1 parent 0a18b05 commit e0f21e6

2 files changed

Lines changed: 10 additions & 22 deletions

File tree

‎drivers/memory/tegra20-mc.c‎

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,18 @@ static inline u32 mc_readl(struct tegra20_mc *mc, u32 offs)
5757

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

6363
return val;
6464
}
6565

6666
static inline void mc_writel(struct tegra20_mc *mc, u32 val, u32 offs)
6767
{
68-
if (offs < 0x24) {
68+
if (offs < 0x24)
6969
writel(val, mc->regs[0] + offs);
70-
return;
71-
}
72-
if (offs < 0x400) {
70+
else if (offs < 0x400)
7371
writel(val, mc->regs[1] + offs - 0x3c);
74-
return;
75-
}
7672
}
7773

7874
static const char * const tegra20_mc_client[] = {

‎drivers/memory/tegra30-mc.c‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -95,34 +95,26 @@ static inline u32 mc_readl(struct tegra30_mc *mc, u32 offs)
9595

9696
if (offs < 0x10)
9797
val = readl(mc->regs[0] + offs);
98-
if (offs < 0x1f0)
98+
else if (offs < 0x1f0)
9999
val = readl(mc->regs[1] + offs - 0x3c);
100-
if (offs < 0x228)
100+
else if (offs < 0x228)
101101
val = readl(mc->regs[2] + offs - 0x200);
102-
if (offs < 0x400)
102+
else if (offs < 0x400)
103103
val = readl(mc->regs[3] + offs - 0x284);
104104

105105
return val;
106106
}
107107

108108
static inline void mc_writel(struct tegra30_mc *mc, u32 val, u32 offs)
109109
{
110-
if (offs < 0x10) {
110+
if (offs < 0x10)
111111
writel(val, mc->regs[0] + offs);
112-
return;
113-
}
114-
if (offs < 0x1f0) {
112+
else if (offs < 0x1f0)
115113
writel(val, mc->regs[1] + offs - 0x3c);
116-
return;
117-
}
118-
if (offs < 0x228) {
114+
else if (offs < 0x228)
119115
writel(val, mc->regs[2] + offs - 0x200);
120-
return;
121-
}
122-
if (offs < 0x400) {
116+
else if (offs < 0x400)
123117
writel(val, mc->regs[3] + offs - 0x284);
124-
return;
125-
}
126118
}
127119

128120
static const char * const tegra30_mc_client[] = {

0 commit comments

Comments
 (0)