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 Acked-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Reviewed-by: Stephen Boyd <sboyd@kernel.org> Tested-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Signed-off-by: Maxime Ripard <maxime@cerno.tech> Link: https://lore.kernel.org/r/97218559db643e62fdd2b5e3046a2a05b8c2e769.1592210452.git-series.maxime@cerno.tech Signed-off-by: Stephen Boyd <sboyd@kernel.org>
This commit is contained in:
parent
3ea59ace7c
commit
23e114b6b7
|
@ -186,7 +186,7 @@ static const struct clk_ops raspberrypi_firmware_pll_clk_ops = {
|
|||
.determine_rate = raspberrypi_pll_determine_rate,
|
||||
};
|
||||
|
||||
static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
|
||||
static struct clk_hw *raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
|
||||
{
|
||||
struct raspberrypi_clk_data *data;
|
||||
struct clk_init_data init = {};
|
||||
|
@ -195,7 +195,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
|
|||
|
||||
data = devm_kzalloc(rpi->dev, sizeof(*data), GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
return ERR_PTR(-ENOMEM);
|
||||
data->rpi = rpi;
|
||||
data->id = RPI_FIRMWARE_ARM_CLK_ID;
|
||||
|
||||
|
@ -213,7 +213,7 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
|
|||
if (ret) {
|
||||
dev_err(rpi->dev, "Failed to get %s min freq: %d\n",
|
||||
init.name, ret);
|
||||
return ret;
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
ret = raspberrypi_clock_property(rpi->firmware, data,
|
||||
|
@ -222,13 +222,13 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
|
|||
if (ret) {
|
||||
dev_err(rpi->dev, "Failed to get %s max freq: %d\n",
|
||||
init.name, ret);
|
||||
return ret;
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
if (!min_rate || !max_rate) {
|
||||
dev_err(rpi->dev, "Unexpected frequency range: min %u, max %u\n",
|
||||
min_rate, max_rate);
|
||||
return -EINVAL;
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
dev_info(rpi->dev, "CPU frequency range: min %u, max %u\n",
|
||||
|
@ -237,12 +237,14 @@ static int raspberrypi_register_pllb(struct raspberrypi_clk *rpi)
|
|||
data->hw.init = &init;
|
||||
|
||||
ret = devm_clk_hw_register(rpi->dev, &data->hw);
|
||||
if (!ret)
|
||||
clk_hw_set_rate_range(&data->hw,
|
||||
min_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE,
|
||||
max_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE);
|
||||
if (ret)
|
||||
return ERR_PTR(ret);
|
||||
|
||||
return ret;
|
||||
clk_hw_set_rate_range(&data->hw,
|
||||
min_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE,
|
||||
max_rate * RPI_FIRMWARE_PLLB_ARM_DIV_RATE);
|
||||
|
||||
return &data->hw;
|
||||
}
|
||||
|
||||
static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
|
||||
|
@ -257,14 +259,14 @@ static struct clk_fixed_factor raspberrypi_clk_pllb_arm = {
|
|||
},
|
||||
};
|
||||
|
||||
static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
|
||||
static struct clk_hw *raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = devm_clk_hw_register(rpi->dev, &raspberrypi_clk_pllb_arm.hw);
|
||||
if (ret) {
|
||||
dev_err(rpi->dev, "Failed to initialize pllb_arm\n");
|
||||
return ret;
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
ret = devm_clk_hw_register_clkdev(rpi->dev,
|
||||
|
@ -272,10 +274,10 @@ static int raspberrypi_register_pllb_arm(struct raspberrypi_clk *rpi)
|
|||
NULL, "cpu0");
|
||||
if (ret) {
|
||||
dev_err(rpi->dev, "Failed to initialize clkdev\n");
|
||||
return ret;
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return &raspberrypi_clk_pllb_arm.hw;
|
||||
}
|
||||
|
||||
static int raspberrypi_clk_probe(struct platform_device *pdev)
|
||||
|
@ -284,7 +286,7 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
|
|||
struct device *dev = &pdev->dev;
|
||||
struct rpi_firmware *firmware;
|
||||
struct raspberrypi_clk *rpi;
|
||||
int ret;
|
||||
struct clk_hw *hw;
|
||||
|
||||
/*
|
||||
* We can be probed either through the an old-fashioned
|
||||
|
@ -314,15 +316,15 @@ static int raspberrypi_clk_probe(struct platform_device *pdev)
|
|||
rpi->firmware = firmware;
|
||||
platform_set_drvdata(pdev, rpi);
|
||||
|
||||
ret = raspberrypi_register_pllb(rpi);
|
||||
if (ret) {
|
||||
dev_err(dev, "Failed to initialize pllb, %d\n", ret);
|
||||
return ret;
|
||||
hw = raspberrypi_register_pllb(rpi);
|
||||
if (IS_ERR(hw)) {
|
||||
dev_err(dev, "Failed to initialize pllb, %ld\n", PTR_ERR(hw));
|
||||
return PTR_ERR(hw);
|
||||
}
|
||||
|
||||
ret = raspberrypi_register_pllb_arm(rpi);
|
||||
if (ret)
|
||||
return ret;
|
||||
hw = raspberrypi_register_pllb_arm(rpi);
|
||||
if (IS_ERR(hw))
|
||||
return PTR_ERR(hw);
|
||||
|
||||
rpi->cpufreq = platform_device_register_data(dev, "raspberrypi-cpufreq",
|
||||
-1, NULL, 0);
|
||||
|
|
Loading…
Reference in a new issue