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
7 The raspberrypi_register_pllb has been returning an integer so far to
8 notify whether the functions has exited successfully or not.
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
14 Since we'll want that for the future clocks, let's return a clk_hw pointer
15 instead of the return code.
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>
22 drivers/clk/bcm/clk-raspberrypi.c | 40 +++++++++++++++++--------------
23 1 file changed, 22 insertions(+), 18 deletions(-)
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,
31 -static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
32 +static struct clk_hw *raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
34 struct raspberrypi_clk_data *data;
35 struct clk_init_data init = {};
36 @@ -199,7 +199,7 @@ static int raspberrypi_register_pllb(str
38 data = devm_kzalloc(rpi->dev, sizeof(*data), GFP_KERNEL);
41 + return ERR_PTR(-ENOMEM);
43 data->id = RPI_FIRMWARE_ARM_CLK_ID;
45 @@ -217,7 +217,7 @@ static int raspberrypi_register_pllb(str
47 dev_err(rpi->dev, "Failed to get %s min freq: %d\n",
50 + return ERR_PTR(ret);
53 ret = raspberrypi_clock_property(rpi->firmware, data,
54 @@ -226,13 +226,13 @@ static int raspberrypi_register_pllb(str
56 dev_err(rpi->dev, "Failed to get %s max freq: %d\n",
59 + return ERR_PTR(ret);
62 if (!min_rate || !max_rate) {
63 dev_err(rpi->dev, "Unexpected frequency range: min %u, max %u\n",
66 + return ERR_PTR(-EINVAL);
69 dev_info(rpi->dev, "CPU frequency range: min %u, max %u\n",
70 @@ -243,7 +243,11 @@ static int raspberrypi_register_pllb(str
72 data->hw.init = &init;
74 - return devm_clk_hw_register(rpi->dev, &data->hw);
75 + ret = devm_clk_hw_register(rpi->dev, &data->hw);
77 + return ERR_PTR(ret);
82 static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
83 @@ -258,14 +262,14 @@ static struct clk_fixed_factor raspberry
87 -static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
88 +static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
92 ret = devm_clk_hw_register(rpi->dev, &raspberrypi_clk_pllb_arm.hw);
94 dev_err(rpi->dev, "Failed to initialize pllb_arm\n");
96 + return ERR_PTR(ret);
99 ret = devm_clk_hw_register_clkdev(rpi->dev,
100 @@ -273,10 +277,10 @@ static int raspberrypi_register_pllb_arm
103 dev_err(rpi->dev, "Failed to initialize clkdev\n");
105 + return ERR_PTR(ret);
109 + return &raspberrypi_clk_pllb_arm.hw;
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;
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);
126 - ret = raspberrypi_register_pllb(rpi);
128 - dev_err(dev, "Failed to initialize pllb, %d\n", ret);
130 + hw = raspberrypi_register_pllb(rpi);
132 + dev_err(dev, "Failed to initialize pllb, %ld\n", PTR_ERR(hw));
133 + return PTR_ERR(hw);
136 - ret = raspberrypi_register_pllb_arm(rpi);
139 + hw = raspberrypi_register_pllb_arm(rpi);
141 + return PTR_ERR(hw);
143 rpi->cpufreq = platform_device_register_data(dev, "raspberrypi-cpufreq",