diff mbox series

[2/2] clk: bcm: rpi: Do not call devm_of_clk_add_hw_provider with a NULL dev->of_node

Message ID 20210423171335.262316-3-tudor.ambarus@microchip.com (mailing list archive)
State Changes Requested, archived
Headers show
Series clk: Do not register provider with a NULL dev->of_node | expand

Commit Message

Tudor Ambarus April 23, 2021, 5:13 p.m. UTC
devm_of_clk_add_hw_provider() expects, as the "_of_" string indicates,
a non NULL dev->of_node, otherwise it will return -ENODEV.
Since this driver can be probed either through the old-fashioned
platform device registration or through a DT node that is a child of the
firmware node, call devm_of_clk_add_hw_provider() only when the DT node
is present.

Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Fixes: 6579c8d97ad7 ("clk: Mark fwnodes when their clock provider is added")
Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
---
 drivers/clk/bcm/clk-raspberrypi.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/drivers/clk/bcm/clk-raspberrypi.c b/drivers/clk/bcm/clk-raspberrypi.c
index dd3b71eafabf..84a4e14babff 100644
--- a/drivers/clk/bcm/clk-raspberrypi.c
+++ b/drivers/clk/bcm/clk-raspberrypi.c
@@ -337,10 +337,12 @@  static int raspberrypi_clk_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
-					  clk_data);
-	if (ret)
-		return ret;
+	if (dev->of_node) {
+		ret = devm_of_clk_add_hw_provider(dev, of_clk_hw_onecell_get,
+						  clk_data);
+		if (ret)
+			return ret;
+	}
 
 	rpi->cpufreq = platform_device_register_data(dev, "raspberrypi-cpufreq",
 						     -1, NULL, 0);