Re: [PATCH V2] clk: scmi: add is_prepared hook

From: Cristian Marussi
Date: Fri Jul 26 2024 - 10:12:56 EST


On Fri, Jul 26, 2024 at 07:14:14PM +0530, Dhruva Gole wrote:
> On Jul 26, 2024 at 21:10:07 +0800, Peng Fan (OSS) wrote:
> > From: Peng Fan <peng.fan@xxxxxxx>
> >
> > Some clks maybe default enabled by hardware, so add is_prepared hook
> > for non-atomic clk_ops to get the status of the clk. Then when disabling
> > unused clks, those unused clks but default hardware on clks could be
> > in off state to save power.
> >
> > Signed-off-by: Peng Fan <peng.fan@xxxxxxx>
> > ---
> >
> > V2:
> > Provider helper __scmi_clk_is_enabled for atomic and non-atomic usage
> > Move is_prepared hook out of SCMI_CLK_STATE_CTRL_SUPPORTED
> >
> > drivers/clk/clk-scmi.c | 16 ++++++++++++++--
> > 1 file changed, 14 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c
> > index d86a02563f6c..15510c2ff21c 100644
> > --- a/drivers/clk/clk-scmi.c
> > +++ b/drivers/clk/clk-scmi.c
> > @@ -156,13 +156,13 @@ static void scmi_clk_atomic_disable(struct clk_hw *hw)
> > scmi_proto_clk_ops->disable(clk->ph, clk->id, ATOMIC);
> > }
> >
> > -static int scmi_clk_atomic_is_enabled(struct clk_hw *hw)
> > +static int __scmi_clk_is_enabled(struct clk_hw *hw, bool atomic)
>
> I think we can combine other atomic/non atomic in the same way no?
> Let me know if I should send a follow up patch based on this to make
> __scmi_clk_enable(hw,atomic) and __scmi_clk_disable(hw,atomic)

I dont think that it is worth unifying also the disable/enable atomic and
non_atomic versions because if you look at their implementations they are
indeed already wrappers around the state_get()....this new is_prepared/is_enabled
were more 'thick' and so there was a lot of duplicated code.

Thanks
Cristian