diff mbox series

[RFC/RFT,02/14] clk: core: introduce clk_hw_set_parent()

Message ID 20190620150013.13462-3-narmstrong@baylibre.com (mailing list archive)
State Superseded
Headers show
Series arm64: g12a: add support for DVFS | expand

Commit Message

Neil Armstrong June 20, 2019, 3 p.m. UTC
Introduce the clk_hw_set_parent() provider call to change parent of
a clock by using the clk_hw pointers.

This eases the clock reparenting from clock rate notifiers and
implementing DVFS with simpler code avoiding the boilerplates
functions as __clk_lookup(clk_hw_get_name()) then clk_set_parent().

Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
 drivers/clk/clk.c            | 5 +++++
 include/linux/clk-provider.h | 1 +
 2 files changed, 6 insertions(+)

Comments

Stephen Boyd June 25, 2019, 8:32 p.m. UTC | #1
Quoting Neil Armstrong (2019-06-20 08:00:01)
> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
> index aa51756fd4d6..3e98f7dec626 100644
> --- a/drivers/clk/clk.c
> +++ b/drivers/clk/clk.c
> @@ -2490,6 +2490,11 @@ static int clk_core_set_parent_nolock(struct clk_core *core,
>         return ret;
>  }
>  
> +int clk_hw_set_parent(struct clk_hw *hw, struct clk_hw *parent)
> +{
> +       return clk_core_set_parent_nolock(hw->core, parent->core);
> +}

Will this be used from a module? Maybe it needs an EXPORT_SYMBOL_GPL().

> +
>  /**
>   * clk_set_parent - switch the parent of a mux clk
>   * @clk: the mux clk whose input we are switching
Neil Armstrong June 26, 2019, 8:22 a.m. UTC | #2
On 25/06/2019 22:32, Stephen Boyd wrote:
> Quoting Neil Armstrong (2019-06-20 08:00:01)
>> diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
>> index aa51756fd4d6..3e98f7dec626 100644
>> --- a/drivers/clk/clk.c
>> +++ b/drivers/clk/clk.c
>> @@ -2490,6 +2490,11 @@ static int clk_core_set_parent_nolock(struct clk_core *core,
>>         return ret;
>>  }
>>  
>> +int clk_hw_set_parent(struct clk_hw *hw, struct clk_hw *parent)
>> +{
>> +       return clk_core_set_parent_nolock(hw->core, parent->core);
>> +}
> 
> Will this be used from a module? Maybe it needs an EXPORT_SYMBOL_GPL().

Probably since it's in clk-provider.h

Will add.

> 
>> +
>>  /**
>>   * clk_set_parent - switch the parent of a mux clk
>>   * @clk: the mux clk whose input we are switching
diff mbox series

Patch

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index aa51756fd4d6..3e98f7dec626 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -2490,6 +2490,11 @@  static int clk_core_set_parent_nolock(struct clk_core *core,
 	return ret;
 }
 
+int clk_hw_set_parent(struct clk_hw *hw, struct clk_hw *parent)
+{
+	return clk_core_set_parent_nolock(hw->core, parent->core);
+}
+
 /**
  * clk_set_parent - switch the parent of a mux clk
  * @clk: the mux clk whose input we are switching
diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
index bb6118f79784..8a453380f9a4 100644
--- a/include/linux/clk-provider.h
+++ b/include/linux/clk-provider.h
@@ -812,6 +812,7 @@  unsigned int clk_hw_get_num_parents(const struct clk_hw *hw);
 struct clk_hw *clk_hw_get_parent(const struct clk_hw *hw);
 struct clk_hw *clk_hw_get_parent_by_index(const struct clk_hw *hw,
 					  unsigned int index);
+int clk_hw_set_parent(struct clk_hw *hw, struct clk_hw *new_parent);
 unsigned int __clk_get_enable_count(struct clk *clk);
 unsigned long clk_hw_get_rate(const struct clk_hw *hw);
 unsigned long __clk_get_flags(struct clk *clk);