Add qcom_find_src_cfg(), a helper that maps P_something (src) to the register value (cfg). Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@xxxxxxxxxx> --- drivers/clk/qcom/common.c | 12 ++++++++++++ drivers/clk/qcom/common.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c index 75f09e6e057e..63097b5b2f54 100644 --- a/drivers/clk/qcom/common.c +++ b/drivers/clk/qcom/common.c @@ -81,6 +81,18 @@ int qcom_find_cfg_index(struct clk_hw *hw, const struct parent_map *map, u8 cfg) } EXPORT_SYMBOL_GPL(qcom_find_cfg_index); +int qcom_find_src_cfg(struct clk_hw *hw, const struct parent_map *map, u8 src) +{ + int i, num_parents = clk_hw_get_num_parents(hw); + + for (i = 0; i < num_parents; i++) + if (src == map[i].src) + return map[i].cfg; + + return -ENOENT; +} +EXPORT_SYMBOL_GPL(qcom_find_src_cfg); + struct regmap * qcom_cc_map(struct platform_device *pdev, const struct qcom_cc_desc *desc) { diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h index 9c8f7b798d9f..1d02c7d61477 100644 --- a/drivers/clk/qcom/common.h +++ b/drivers/clk/qcom/common.h @@ -51,6 +51,8 @@ extern int qcom_find_src_index(struct clk_hw *hw, const struct parent_map *map, u8 src); extern int qcom_find_cfg_index(struct clk_hw *hw, const struct parent_map *map, u8 cfg); +extern int qcom_find_src_cfg(struct clk_hw *hw, const struct parent_map *map, + u8 src); extern int qcom_cc_register_board_clk(struct device *dev, const char *path, const char *name, unsigned long rate); -- 2.39.2