Skip to content

Commit 980bcaf

Browse files
committed
clk: renesas: rza1: Remove struct rz_cpg
The register block base pointer as stored in the reg member of the rz_cpg structure is only used during initialization. Hence move it to a local variable, and pass it as a parameter to rz_cpg_register_clock(). After this, the data member is the only remaining member of the rz_cpg structure, so the whole structure can be replaced by the data member. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Reviewed-by: Wolfram Sang <wsa+renesas@sang-engineering.com> Link: https://lore.kernel.org/r/2380285576edaa4ad3dc5eca7e0ca418f068c6ef.1654694831.git.geert+renesas@glider.be
1 parent 4448779 commit 980bcaf

1 file changed

Lines changed: 15 additions & 18 deletions

File tree

drivers/clk/renesas/clk-rz.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@
1515
#include <linux/of_address.h>
1616
#include <linux/slab.h>
1717

18-
struct rz_cpg {
19-
struct clk_onecell_data data;
20-
void __iomem *reg;
21-
};
22-
2318
#define CPG_FRQCR 0x10
2419
#define CPG_FRQCR2 0x14
2520

@@ -49,7 +44,8 @@ static u16 __init rz_cpg_read_mode_pins(void)
4944
}
5045

5146
static struct clk * __init
52-
rz_cpg_register_clock(struct device_node *np, struct rz_cpg *cpg, const char *name)
47+
rz_cpg_register_clock(struct device_node *np, void __iomem *base,
48+
const char *name)
5349
{
5450
u32 val;
5551
unsigned mult;
@@ -65,17 +61,17 @@ rz_cpg_register_clock(struct device_node *np, struct rz_cpg *cpg, const char *na
6561
}
6662

6763
/* If mapping regs failed, skip non-pll clocks. System will boot anyhow */
68-
if (!cpg->reg)
64+
if (!base)
6965
return ERR_PTR(-ENXIO);
7066

7167
/* FIXME:"i" and "g" are variable clocks with non-integer dividers (e.g. 2/3)
7268
* and the constraint that always g <= i. To get the rz platform started,
7369
* let them run at fixed current speed and implement the details later.
7470
*/
7571
if (strcmp(name, "i") == 0)
76-
val = (readl(cpg->reg + CPG_FRQCR) >> 8) & 3;
72+
val = (readl(base + CPG_FRQCR) >> 8) & 3;
7773
else if (strcmp(name, "g") == 0)
78-
val = readl(cpg->reg + CPG_FRQCR2) & 3;
74+
val = readl(base + CPG_FRQCR2) & 3;
7975
else
8076
return ERR_PTR(-EINVAL);
8177

@@ -85,39 +81,40 @@ rz_cpg_register_clock(struct device_node *np, struct rz_cpg *cpg, const char *na
8581

8682
static void __init rz_cpg_clocks_init(struct device_node *np)
8783
{
88-
struct rz_cpg *cpg;
84+
struct clk_onecell_data *data;
8985
struct clk **clks;
86+
void __iomem *base;
9087
unsigned i;
9188
int num_clks;
9289

9390
num_clks = of_property_count_strings(np, "clock-output-names");
9491
if (WARN(num_clks <= 0, "can't count CPG clocks\n"))
9592
return;
9693

97-
cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
94+
data = kzalloc(sizeof(*data), GFP_KERNEL);
9895
clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL);
99-
BUG_ON(!cpg || !clks);
96+
BUG_ON(!data || !clks);
10097

101-
cpg->data.clks = clks;
102-
cpg->data.clk_num = num_clks;
98+
data->clks = clks;
99+
data->clk_num = num_clks;
103100

104-
cpg->reg = of_iomap(np, 0);
101+
base = of_iomap(np, 0);
105102

106103
for (i = 0; i < num_clks; ++i) {
107104
const char *name;
108105
struct clk *clk;
109106

110107
of_property_read_string_index(np, "clock-output-names", i, &name);
111108

112-
clk = rz_cpg_register_clock(np, cpg, name);
109+
clk = rz_cpg_register_clock(np, base, name);
113110
if (IS_ERR(clk))
114111
pr_err("%s: failed to register %pOFn %s clock (%ld)\n",
115112
__func__, np, name, PTR_ERR(clk));
116113
else
117-
cpg->data.clks[i] = clk;
114+
data->clks[i] = clk;
118115
}
119116

120-
of_clk_add_provider(np, of_clk_src_onecell_get, &cpg->data);
117+
of_clk_add_provider(np, of_clk_src_onecell_get, data);
121118

122119
cpg_mstp_add_clk_domain(np);
123120
}

0 commit comments

Comments
 (0)