Skip to content

Commit 55ae8a1

Browse files
committed
Merge tag 'tegra-for-5.5-clk-core-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux into clk-hw-parent-index
Pull clk framework change from Thierry Reding: Contains a single core API addition that allows clock providers to query the parent index for a given struct clk_hw. This is used to implement suspend/resume support on Tegra SoCs. * tag 'tegra-for-5.5-clk-core-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux: clk: Add API to get index of the clock parent
2 parents 54ecb8f + d9b86cc commit 55ae8a1

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

drivers/clk/clk.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1674,6 +1674,24 @@ static int clk_fetch_parent_index(struct clk_core *core,
16741674
return i;
16751675
}
16761676

1677+
/**
1678+
* clk_hw_get_parent_index - return the index of the parent clock
1679+
* @hw: clk_hw associated with the clk being consumed
1680+
*
1681+
* Fetches and returns the index of parent clock. Returns -EINVAL if the given
1682+
* clock does not have a current parent.
1683+
*/
1684+
int clk_hw_get_parent_index(struct clk_hw *hw)
1685+
{
1686+
struct clk_hw *parent = clk_hw_get_parent(hw);
1687+
1688+
if (WARN_ON(parent == NULL))
1689+
return -EINVAL;
1690+
1691+
return clk_fetch_parent_index(hw->core, parent->core);
1692+
}
1693+
EXPORT_SYMBOL_GPL(clk_hw_get_parent_index);
1694+
16771695
/*
16781696
* Update the orphan status of @core and all its children.
16791697
*/

include/linux/clk-provider.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ unsigned int clk_hw_get_num_parents(const struct clk_hw *hw);
818818
struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw);
819819
struct clk_hw *clk_hw_get_parent_by_index(const struct clk_hw *hw,
820820
unsigned int index);
821+
int clk_hw_get_parent_index(struct clk_hw *hw);
821822
int clk_hw_set_parent(struct clk_hw *hw, struct clk_hw *new_parent);
822823
unsigned int __clk_get_enable_count(struct clk *clk);
823824
unsigned long clk_hw_get_rate(const struct clk_hw *hw);

0 commit comments

Comments
 (0)