Skip to content

Commit

Permalink
Merge branches 'clk-init-allocation', 'clk-unused' and 'clk-register-…
Browse files Browse the repository at this point in the history
…dt-node-better' into clk-next

 - Let clk_ops::init() return an error code
 - Add a clk_ops::terminate() callback to undo clk_ops::init()

* clk-init-allocation:
  clk: add terminate callback to clk_ops
  clk: let init callback return an error code
  clk: actually call the clock init before any other callback of the clock

* clk-unused:
  clk: bm1800: Remove set but not used variable 'fref'

* clk-register-dt-node-better:
  clk: Use parent node pointer during registration if necessary
  • Loading branch information
Stephen Boyd committed Jan 31, 2020
3 parents f873744 + 59ef4da + 9011f92 commit 28db9a8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
3 changes: 1 addition & 2 deletions drivers/clk/clk-bm1880.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,10 @@ static struct bm1880_composite_clock bm1880_composite_clks[] = {
static unsigned long bm1880_pll_rate_calc(u32 regval, unsigned long parent_rate)
{
u64 numerator;
u32 fbdiv, fref, refdiv;
u32 fbdiv, refdiv;
u32 postdiv1, postdiv2, denominator;

fbdiv = (regval >> 16) & 0xfff;
fref = parent_rate;
refdiv = regval & 0x1f;
postdiv1 = (regval >> 8) & 0x7;
postdiv2 = (regval >> 12) & 0x7;
Expand Down
27 changes: 25 additions & 2 deletions drivers/clk/clk.c
Original file line number Diff line number Diff line change
Expand Up @@ -3728,6 +3728,28 @@ __clk_register(struct device *dev, struct device_node *np, struct clk_hw *hw)
return ERR_PTR(ret);
}

/**
* 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
Expand All @@ -3743,7 +3765,7 @@ __clk_register(struct device *dev, struct device_node *np, struct clk_hw *hw)
*/
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);

Expand All @@ -3759,7 +3781,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);

Expand Down

0 comments on commit 28db9a8

Please sign in to comment.