[PATCH 1/4] clk: clk-gpio: Turn into driver

Sascha Hauer s.hauer at pengutronix.de
Wed Mar 22 01:32:42 PDT 2023


A comment states OF_CLK_DECLARE can't be used for the clk-gpio driver
as it needs to be registered after the GPIO controllers. If that's the
case there is no point in calling of_clk_init() directly from an
initcall. We can better register it as a regular driver which also
makes deep probe work.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/clk/clk-gpio.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/clk-gpio.c b/drivers/clk/clk-gpio.c
index 6ac2e820fa..8cc0c5fc97 100644
--- a/drivers/clk/clk-gpio.c
+++ b/drivers/clk/clk-gpio.c
@@ -50,8 +50,9 @@ static struct clk_ops clk_gpio_ops = {
 	.is_enabled = clk_gpio_is_enabled,
 };
 
-static int of_gpio_clk_setup(struct device_node *node)
+static int of_gpio_clk_probe(struct device *dev)
 {
+	struct device_node *node = dev->device_node;
 	struct clk_gpio *clk_gpio;
 	enum of_gpio_flags of_flags;
 	unsigned long flags;
@@ -105,16 +106,15 @@ no_parent:
 	return ret;
 }
 
-/* Can't use OF_CLK_DECLARE due to need to run after GPIOcontrollers have
- * registrered */
-
 static const struct of_device_id clk_gpio_device_id[] = {
-	{ .compatible = "gpio-gate-clock", .data = of_gpio_clk_setup, },
+	{ .compatible = "gpio-gate-clock", },
 	{}
 };
 
-static int clk_gpio_init(void)
-{
-	return of_clk_init(NULL, clk_gpio_device_id);
-}
-coredevice_initcall(clk_gpio_init);
+static struct driver gpio_gate_clock_driver = {
+	.probe = of_gpio_clk_probe,
+	.name = "gpio-gate-clock",
+	.of_compatible = DRV_OF_COMPAT(clk_gpio_device_id),
+};
+
+core_platform_driver(gpio_gate_clock_driver);
-- 
2.30.2




More information about the barebox mailing list