Skip to content

Commit 5f4081d

Browse files
jbrun3tbebarino
authored andcommitted
clk: add a clk_hw helpers to get the clock device or device_node
Add helpers to get the device or device_node associated with clk_hw. This can be used by clock drivers to access various device related functionality such as devres, dev_ prints, etc ... Signed-off-by: Jerome Brunet <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Brian Masney <[email protected]> Signed-off-by: Stephen Boyd <[email protected]>
1 parent 19272b3 commit 5f4081d

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

drivers/clk/clk.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,18 @@ const char *clk_hw_get_name(const struct clk_hw *hw)
365365
}
366366
EXPORT_SYMBOL_GPL(clk_hw_get_name);
367367

368+
struct device *clk_hw_get_dev(const struct clk_hw *hw)
369+
{
370+
return hw->core->dev;
371+
}
372+
EXPORT_SYMBOL_GPL(clk_hw_get_dev);
373+
374+
struct device_node *clk_hw_get_of_node(const struct clk_hw *hw)
375+
{
376+
return hw->core->of_node;
377+
}
378+
EXPORT_SYMBOL_GPL(clk_hw_get_of_node);
379+
368380
struct clk_hw *__clk_get_hw(struct clk *clk)
369381
{
370382
return !clk ? NULL : clk->core->hw;

include/linux/clk-provider.h

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,6 +1360,32 @@ void clk_hw_unregister(struct clk_hw *hw);
13601360
/* helper functions */
13611361
const char *__clk_get_name(const struct clk *clk);
13621362
const char *clk_hw_get_name(const struct clk_hw *hw);
1363+
1364+
/**
1365+
* clk_hw_get_dev() - get device from an hardware clock.
1366+
* @hw: the clk_hw pointer to get the struct device from
1367+
*
1368+
* This is a helper to get the struct device associated with a hardware
1369+
* clock. Some clock controllers, such as the one registered with
1370+
* CLK_OF_DECLARE(), may have not provided a device pointer while
1371+
* registering the clock.
1372+
*
1373+
* Return: the struct device associated with the clock, or NULL if there
1374+
* is none.
1375+
*/
1376+
struct device *clk_hw_get_dev(const struct clk_hw *hw);
1377+
1378+
/**
1379+
* clk_hw_get_of_node() - get device_node from a hardware clock.
1380+
* @hw: the clk_hw pointer to get the struct device_node from
1381+
*
1382+
* This is a helper to get the struct device_node associated with a
1383+
* hardware clock.
1384+
*
1385+
* Return: the struct device_node associated with the clock, or NULL
1386+
* if there is none.
1387+
*/
1388+
struct device_node *clk_hw_get_of_node(const struct clk_hw *hw);
13631389
#ifdef CONFIG_COMMON_CLK
13641390
struct clk_hw *__clk_get_hw(struct clk *clk);
13651391
#else

0 commit comments

Comments
 (0)