diff options
author | Stephen Boyd <sboyd@kernel.org> | 2020-01-04 23:08:57 -0800 |
---|---|---|
committer | Stephen Boyd <sboyd@kernel.org> | 2020-01-04 23:08:57 -0800 |
commit | e7ce74bc0e97794d69330547aea4bbb0ff0be2bc (patch) | |
tree | 3173155a75f46a28e70459aeeca752efc374bd2d /drivers/clk | |
parent | dd3d06622138e913fa2a0b9a21c0aae231eb45b7 (diff) | |
parent | 9011f92622e5ef2d075f45e5fa818776d4feb8c0 (diff) | |
download | linux-e7ce74bc0e97794d69330547aea4bbb0ff0be2bc.tar.gz linux-e7ce74bc0e97794d69330547aea4bbb0ff0be2bc.tar.bz2 linux-e7ce74bc0e97794d69330547aea4bbb0ff0be2bc.zip |
Merge branch 'clk-register-dt-node-better' into clk-qcom
* clk-register-dt-node-better:
clk: Use parent node pointer during registration if necessary
Diffstat (limited to 'drivers/clk')
-rw-r--r-- | drivers/clk/clk.c | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b68e200829f2..897874acb893 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -3720,6 +3720,28 @@ fail_out: } /** + * dev_or_parent_of_node() - Get device node of @dev or @dev's parent + * @dev: Device to get device node of + * + * Return: device node pointer of @dev, or the device node pointer of + * @dev->parent if dev doesn't have a device node, or NULL if neither + * @dev or @dev->parent have a device node. + */ +static struct device_node *dev_or_parent_of_node(struct device *dev) +{ + struct device_node *np; + + if (!dev) + return NULL; + + np = dev_of_node(dev); + if (!np) + np = dev_of_node(dev->parent); + + return np; +} + +/** * clk_register - allocate a new clock, register it and return an opaque cookie * @dev: device that is registering this clock * @hw: link to hardware-specific clock data @@ -3734,7 +3756,7 @@ fail_out: */ struct clk *clk_register(struct device *dev, struct clk_hw *hw) { - return __clk_register(dev, dev_of_node(dev), hw); + return __clk_register(dev, dev_or_parent_of_node(dev), hw); } EXPORT_SYMBOL_GPL(clk_register); @@ -3750,7 +3772,8 @@ EXPORT_SYMBOL_GPL(clk_register); */ int clk_hw_register(struct device *dev, struct clk_hw *hw) { - return PTR_ERR_OR_ZERO(__clk_register(dev, dev_of_node(dev), hw)); + return PTR_ERR_OR_ZERO(__clk_register(dev, dev_or_parent_of_node(dev), + hw)); } EXPORT_SYMBOL_GPL(clk_hw_register); |