Skip to contentSkip to conversation

clkdev: don't call __of_clk_get_by_name() unnecessarily from clk_get()

PATCH RESEND In review Bartosz Golaszewski 3 participants 3 messages Jun 25, 2018 – Jun 27, 2018 Arm/clkdev support

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 clkdev: don't call __of_clk_get_by_name() unnecessarily from clk_get()

From: Bartosz Golaszewski <[email protected]>

The way this function is implemented caused some confusion when converting the TI DaVinci platform to using the common clock framework.

Current kernel supports booting DaVinci boards both in device tree as well as legacy, board-file mode. In the latter, we always end up calling clk_get_sys() as of_node is NULL and __of_clk_get_by_name() returns -ENOENT.

It was not obvious at first glance how clk_get(dev, NULL) will work in board-file mode since we always call __of_clk_get_by_name(). Let's make it clearer by checking if of_node is NULL and skipping right to clk_get_sys().

Cc Sekhar Nori <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc David Lechner <[email protected]>
---
 drivers/clk/clkdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clkdev.c +1 -1
index 7513411140b6..f394e8964909 100644
@@ -199,7 +199,7 @@ struct clk *clk_get(struct device *dev, const char *con_id)
 	const char *dev_id = dev ? dev_name(dev) : NULL;
 	struct clk *clk;
 
-	if (dev) {
+	if (dev && dev->of_node) {
 		clk = __of_clk_get_by_name(dev->of_node, dev_id, con_id);
 		if (!IS_ERR(clk) || PTR_ERR(clk) == -EPROBE_DEFER)
 			return clk;
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 15 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

The way this function is implemented caused some confusion when converting the TI DaVinci platform to using the common clock framework.

Current kernel supports booting DaVinci boards both in device tree as well as legacy, board-file mode. In the latter, we always end up calling clk_get_sys() as of_node is NULL and __of_clk_get_by_name() returns -ENOENT.

It was not obvious at first glance how clk_get(dev, NULL) will work in board-file mode since we always call __of_clk_get_by_name(). Let's make it clearer by checking if of_node is NULL and skipping right to clk_get_sys().

Quoted 5 lines
Cc Sekhar Nori <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc David Lechner <[email protected]>

---

Reviewed-by
#2 lore raw
Quoted 16 lines · David Lechner
Quoted 15 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

The way this function is implemented caused some confusion when converting the TI DaVinci platform to using the common clock framework.

Current kernel supports booting DaVinci boards both in device tree as well as legacy, board-file mode. In the latter, we always end up calling clk_get_sys() as of_node is NULL and __of_clk_get_by_name() returns -ENOENT.

It was not obvious at first glance how clk_get(dev, NULL) will work in board-file mode since we always call __of_clk_get_by_name(). Let's make it clearer by checking if of_node is NULL and skipping right to clk_get_sys().

Quoted 7 lines
Quoted 5 lines
Cc Sekhar Nori <[email protected]>
Cc Kevin Hilman <[email protected]>
Cc David Lechner <[email protected]>

---

I think Russell previously said that the patch looks good to him. So you can probably just add it to his patch tracker.

http://www.arm.linux.org.uk/developer/patches/add.php

FWIW, you can also add:

Thanks,
Sekhar