633cf1878251f61e6549cef8470170191810601d
[openwrt/staging/dangole.git] /
1 From 5272bad5ff927362e5d12da82eb819a8d1444da6 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Fri, 7 Feb 2020 16:30:01 +0100
4 Subject: [PATCH] clk: bcm: rpi: Make the PLLB registration function
5 return a clk_hw
6
7 The raspberrypi_register_pllb has been returning an integer so far to
8 notify whether the functions has exited successfully or not.
9
10 However, the OF provider functions in the clock framework require access to
11 the clk_hw structure so that we can expose those clocks to device tree
12 consumers.
13
14 Since we'll want that for the future clocks, let's return a clk_hw pointer
15 instead of the return code.
16
17 Cc: Michael Turquette <mturquette@baylibre.com>
18 Cc: linux-clk@vger.kernel.org
19 Reviewed-by: Stephen Boyd <sboyd@kernel.org>
20 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
21 ---
22 drivers/clk/bcm/clk-raspberrypi.c | 40 +++++++++++++++++--------------
23 1 file changed, 22 insertions(+), 18 deletions(-)
24
25 --- a/drivers/clk/bcm/clk-raspberrypi.c
26 +++ b/drivers/clk/bcm/clk-raspberrypi.c
27 @@ -190,7 +190,7 @@ static const struct clk_ops raspberrypi_
28 .determine_rate = raspberrypi_pll_determine_rate,
29 };
30
31 -static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
32 +static struct clk_hw *raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
33 {
34 struct raspberrypi_clk_data *data;
35 struct clk_init_data init = {};
36 @@ -199,7 +199,7 @@ static int raspberrypi_register_pllb(str
37
38 data = devm_kzalloc(rpi->dev, sizeof(*data), GFP_KERNEL);
39 if (!data)
40 - return -ENOMEM;
41 + return ERR_PTR(-ENOMEM);
42 data->rpi = rpi;
43 data->id = RPI_FIRMWARE_ARM_CLK_ID;
44
45 @@ -217,7 +217,7 @@ static int raspberrypi_register_pllb(str
46 if (ret) {
47 dev_err(rpi->dev, "Failed to get %s min freq: %d\n",
48 init.name, ret);
49 - return ret;
50 + return ERR_PTR(ret);
51 }
52
53 ret = raspberrypi_clock_property(rpi->firmware, data,
54 @@ -226,13 +226,13 @@ static int raspberrypi_register_pllb(str
55 if (ret) {
56 dev_err(rpi->dev, "Failed to get %s max freq: %d\n",
57 init.name, ret);
58 - return ret;
59 + return ERR_PTR(ret);
60 }
61
62 if (!min_rate || !max_rate) {
63 dev_err(rpi->dev, "Unexpected frequency range: min %u, max %u\n",
64 min_rate, max_rate);
65 - return -EINVAL;
66 + return ERR_PTR(-EINVAL);
67 }
68
69 dev_info(rpi->dev, "CPU frequency range: min %u, max %u\n",
70 @@ -243,7 +243,11 @@ static int raspberrypi_register_pllb(str
71
72 data->hw.init = &init;
73
74 - return devm_clk_hw_register(rpi->dev, &data->hw);
75 + ret = devm_clk_hw_register(rpi->dev, &data->hw);
76 + if (ret)
77 + return ERR_PTR(ret);
78 +
79 + return &data->hw;
80 }
81
82 static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
83 @@ -258,14 +262,14 @@ static struct clk_fixed_factor raspberry
84 },
85 };
86
87 -static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
88 +static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
89 {
90 int ret;
91
92 ret = devm_clk_hw_register(rpi->dev, &raspberrypi_clk_pllb_arm.hw);
93 if (ret) {
94 dev_err(rpi->dev, "Failed to initialize pllb_arm\n");
95 - return ret;
96 + return ERR_PTR(ret);
97 }
98
99 ret = devm_clk_hw_register_clkdev(rpi->dev,
100 @@ -273,10 +277,10 @@ static int raspberrypi_register_pllb_arm
101 NULL, "cpu0");
102 if (ret) {
103 dev_err(rpi->dev, "Failed to initialize clkdev\n");
104 - return ret;
105 + return ERR_PTR(ret);
106 }
107
108 - return 0;
109 + return &raspberrypi_clk_pllb_arm.hw;
110 }
111
112 static int raspberrypi_clk_probe(struct platform_device *pdev)
113 @@ -285,7 +289,7 @@ static int raspberrypi_clk_probe(struct
114 struct device *dev = &pdev->dev;
115 struct rpi_firmware *firmware;
116 struct raspberrypi_clk *rpi;
117 - int ret;
118 + struct clk_hw *hw;
119
120 firmware_node = of_parse_phandle(dev->of_node, "raspberrypi,firmware", 0);
121 if (!firmware_node) {
122 @@ -305,15 +309,15 @@ static int raspberrypi_clk_probe(struct
123 rpi->firmware = firmware;
124 platform_set_drvdata(pdev, rpi);
125
126 - ret = raspberrypi_register_pllb(rpi);
127 - if (ret) {
128 - dev_err(dev, "Failed to initialize pllb, %d\n", ret);
129 - return ret;
130 + hw = raspberrypi_register_pllb(rpi);
131 + if (IS_ERR(hw)) {
132 + dev_err(dev, "Failed to initialize pllb, %ld\n", PTR_ERR(hw));
133 + return PTR_ERR(hw);
134 }
135
136 - ret = raspberrypi_register_pllb_arm(rpi);
137 - if (ret)
138 - return ret;
139 + hw = raspberrypi_register_pllb_arm(rpi);
140 + if (IS_ERR(hw))
141 + return PTR_ERR(hw);
142
143 rpi->cpufreq = platform_device_register_data(dev, "raspberrypi-cpufreq",
144 -1, NULL, 0);