clk: don't call __of_clk_get_by_name() unnecessarily from clk_get()
PATCH 1/1 clk: 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().
--- drivers/clk/clkdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/clkdev.c +1 -1
@@ -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.16.1
Quoted 29 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()asof_nodeis 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 ifof_nodeis NULL and skipping right toclk_get_sys().Cc Sekhar Nori <[email protected]>Cc Kevin Hilman <[email protected]>Cc David Lechner <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/clk/clkdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/clk/clkdev.c +0
-0
drivers/clk/clkdev.c struct clk *clk_get(struct device *dev, const char *con_id) · line 205
Quoted 8 lines
drivers/clk/clkdev.c +1
-1@@ -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;
Shouldn't you be sending this to the linux-clk mailing list and cc'ing the clock maintainers?
FWIW, it seems pretty clear to me that if we are using a board file then we should expect clk_get_sys() to be called because there is no device tree.
Russell King - ARM Linux
maintainerQuoted 24 lines · David Lechner
Quoted 23 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()asof_nodeis 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 ifof_nodeis NULL and skipping right toclk_get_sys().Cc Sekhar Nori <[email protected]>Cc Kevin Hilman <[email protected]>Cc David Lechner <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/clk/clkdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 16 lines
drivers/clk/clkdev.c struct clk *clk_get(struct device *dev, const char *con_id) · line 205
Quoted 13 lines
drivers/clk/clkdev.c +1
-1@@ -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;Shouldn't you be sending this to the linux-clk mailing list and cc'ing the clock maintainers?
No, I'm the maintainer for clkdev, as per MAINTAINERS.
Quoted 3 lines
FWIW, it seems pretty clear to me that if we are using a board file then we should expect
clk_get_sys()to be called because there is no device tree.
clk_get() pre-dates DT, and using it has no bearing on whether DT is in use or not. The above change looks correct to me - if the struct device is not a DT device, then we shouldn't be trying to look up the clock in DT.
Signature · 3 lines
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/ FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up
Quoted 42 lines · Russell King - ARM Linux
Quoted 24 lines · David Lechner
Quoted 23 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()asof_nodeis 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 ifof_nodeis NULL and skipping right toclk_get_sys().Cc Sekhar Nori <[email protected]>Cc Kevin Hilman <[email protected]>Cc David Lechner <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/clk/clkdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 16 lines
drivers/clk/clkdev.c struct clk *clk_get(struct device *dev, const char *con_id) · line 205
Quoted 13 lines
drivers/clk/clkdev.c +1
-1@@ -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;Shouldn't you be sending this to the linux-clk mailing list and cc'ing the clock maintainers?
Quoted 1 line
No, I'm the maintainer for clkdev, as per
MAINTAINERS.
Oops, I guess I should have looked before I said something.
Quoted 10 lines
Quoted 4 lines
FWIW, it seems pretty clear to me that if we are using a board file then we should expect
clk_get_sys()to be called because there is no device tree.
clk_get()pre-dates DT, and using it has no bearing on whether DT is in use or not. The above change looks correct to me - if the struct device is not a DT device, then we shouldn't be trying to look up the clock in DT.
Looks fine to me too.
2018-02-12 22:00 GMT+01:00 Russell King - ARM Linux <[email protected]>:
Quoted 53 lines · David Lechner
Quoted 24 lines · Bartosz Golaszewski
Quoted 23 lines
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()asof_nodeis 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 ifof_nodeis NULL and skipping right toclk_get_sys().Cc Sekhar Nori <[email protected]>Cc Kevin Hilman <[email protected]>Cc David Lechner <[email protected]>Signed-off-by Bartosz Golaszewski <[email protected]>--- drivers/clk/clkdev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)Quoted 16 lines
drivers/clk/clkdev.c struct clk *clk_get(struct device *dev, const char *con_id) · line 205
Quoted 13 lines
drivers/clk/clkdev.c +1
-1@@ -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;Shouldn't you be sending this to the linux-clk mailing list and cc'ing the clock maintainers?
No, I'm the maintainer for clkdev, as per
MAINTAINERS.Quoted 3 lines
FWIW, it seems pretty clear to me that if we are using a board file then we should expect
clk_get_sys()to be called because there is no device tree.
clk_get()pre-dates DT, and using it has no bearing on whether DT is in use or not. The above change looks correct to me - if the struct device is not a DT device, then we shouldn't be trying to look up the clock in DT.
Quoted 4 lines
--
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 8.8Mbps down 630kbps up According to speedtest.net: 8.21Mbps down 510kbps up
Hi Russell,
can you pick this patch up for 4.17?
Thanks in advance,
Bartosz