Skip to content

Commit 7b6aea3

Browse files
mripardpopcornmix
authored andcommitted
clk: bcm: rpi: Make the PLLB registration function return a clk_hw
The raspberrypi_register_pllb has been returning an integer so far to notify whether the functions has exited successfully or not. However, the OF provider functions in the clock framework require access to the clk_hw structure so that we can expose those clocks to device tree consumers. Since we'll want that for the future clocks, let's return a clk_hw pointer instead of the return code. Cc: Michael Turquette <mturquette@baylibre.com> Cc: linux-clk@vger.kernel.org Reviewed-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
1 parent a542c56 commit 7b6aea3

1 file changed

Lines changed: 22 additions & 18 deletions

File tree

‎drivers/clk/bcm/clk-raspberrypi.c‎

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static const struct clk_ops raspberrypi_firmware_pll_clk_ops = {
190190
.determine_rate = raspberrypi_pll_determine_rate,
191191
};
192192

193-
static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
193+
static struct clk_hw *raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
194194
{
195195
struct raspberrypi_clk_data *data;
196196
struct clk_init_data init = {};
@@ -199,7 +199,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
199199

200200
data = devm_kzalloc(rpi->dev, sizeof(*data), GFP_KERNEL);
201201
if (!data)
202-
return -ENOMEM;
202+
return ERR_PTR(-ENOMEM);
203203
data->rpi = rpi;
204204
data->id = RPI_FIRMWARE_ARM_CLK_ID;
205205

@@ -217,7 +217,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
217217
if (ret) {
218218
dev_err(rpi->dev, "Failed to get %s min freq: %d\n",
219219
init.name, ret);
220-
return ret;
220+
return ERR_PTR(ret);
221221
}
222222

223223
ret = raspberrypi_clock_property(rpi->firmware, data,
@@ -226,13 +226,13 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
226226
if (ret) {
227227
dev_err(rpi->dev, "Failed to get %s max freq: %d\n",
228228
init.name, ret);
229-
return ret;
229+
return ERR_PTR(ret);
230230
}
231231

232232
if (!min_rate || !max_rate) {
233233
dev_err(rpi->dev, "Unexpected frequency range: min %u, max %u\n",
234234
min_rate, max_rate);
235-
return -EINVAL;
235+
return ERR_PTR(-EINVAL);
236236
}
237237

238238
dev_info(rpi->dev, "CPU frequency range: min %u, max %u\n",
@@ -243,7 +243,11 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
243243

244244
data->hw.init = &init;
245245

246-
return devm_clk_hw_register(rpi->dev, &data->hw);
246+
ret = devm_clk_hw_register(rpi->dev, &data->hw);
247+
if (ret)
248+
return ERR_PTR(ret);
249+
250+
return &data->hw;
247251
}
248252

249253
static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
@@ -258,25 +262,25 @@ static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
258262
},
259263
};
260264

261-
static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
265+
static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
262266
{
263267
int ret;
264268

265269
ret = devm_clk_hw_register(rpi->dev, &raspberrypi_clk_pllb_arm.hw);
266270
if (ret) {
267271
dev_err(rpi->dev, "Failed to initialize pllb_arm\n");
268-
return ret;
272+
return ERR_PTR(ret);
269273
}
270274

271275
ret = devm_clk_hw_register_clkdev(rpi->dev,
272276
&raspberrypi_clk_pllb_arm.hw,
273277
NULL, "cpu0");
274278
if (ret) {
275279
dev_err(rpi->dev, "Failed to initialize clkdev\n");
276-
return ret;
280+
return ERR_PTR(ret);
277281
}
278282

279-
return 0;
283+
return &raspberrypi_clk_pllb_arm.hw;
280284
}
281285

282286
static int raspberrypi_clk_probe(struct platform_device *pdev)
@@ -285,7 +289,7 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
285289
struct device *dev = &pdev->dev;
286290
struct rpi_firmware *firmware;
287291
struct raspberrypi_clk *rpi;
288-
int ret;
292+
struct clk_hw *hw;
289293

290294
firmware_node = of_parse_phandle(dev->of_node, "raspberrypi,firmware", 0);
291295
if (!firmware_node) {
@@ -305,15 +309,15 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
305309
rpi->firmware = firmware;
306310
platform_set_drvdata(pdev, rpi);
307311

308-
ret = raspberrypi_register_pllb(rpi);
309-
if (ret) {
310-
dev_err(dev, "Failed to initialize pllb, %d\n", ret);
311-
return ret;
312+
hw = raspberrypi_register_pllb(rpi);
313+
if (IS_ERR(hw)) {
314+
dev_err(dev, "Failed to initialize pllb, %ld\n", PTR_ERR(hw));
315+
return PTR_ERR(hw);
312316
}
313317

314-
ret = raspberrypi_register_pllb_arm(rpi);
315-
if (ret)
316-
return ret;
318+
hw = raspberrypi_register_pllb_arm(rpi);
319+
if (IS_ERR(hw))
320+
return PTR_ERR(hw);
317321

318322
rpi->cpufreq = platform_device_register_data(dev, "raspberrypi-cpufreq",
319323
-1, NULL, 0);

0 commit comments

Comments
 (0)