Re: [PATCH v6 19/37] clk: scmi: port driver to the new scmi_clk_proto_ops interface

From: Cristian Marussi
Date: Wed Mar 10 2021 - 09:20:22 EST


Hi Stephen,

any chance you could have a look at this and, possibly, ack ?

The rationale for the change in the SCMI layer interface is in the
series cover-letter here:

https://lore.kernel.org/lkml/20210202221555.41167-1-cristian.marussi@xxxxxxx/

Thanks

Cristian

On Tue, Feb 02, 2021 at 10:15:37PM +0000, Cristian Marussi wrote:
> Port driver to the new SCMI Clock interface based on protocol handles
> and common devm_get_ops().
>
> Cc: Michael Turquette <mturquette@xxxxxxxxxxxx>
> Cc: Stephen Boyd <sboyd@xxxxxxxxxx>
> Signed-off-by: Cristian Marussi <cristian.marussi@xxxxxxx>
> ---
> v4 --> v5
> - using renamed devm_get/put_protocol
> ---
> drivers/clk/clk-scmi.c | 27 +++++++++++++++++----------
> 1 file changed, 17 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/clk/clk-scmi.c b/drivers/clk/clk-scmi.c
> index c754dfbb73fd..f3da3042d09c 100644
> --- a/drivers/clk/clk-scmi.c
> +++ b/drivers/clk/clk-scmi.c
> @@ -2,7 +2,7 @@
> /*
> * System Control and Power Interface (SCMI) Protocol based clock driver
> *
> - * Copyright (C) 2018 ARM Ltd.
> + * Copyright (C) 2018-2020 ARM Ltd.
> */
>
> #include <linux/clk-provider.h>
> @@ -13,11 +13,13 @@
> #include <linux/scmi_protocol.h>
> #include <asm/div64.h>
>
> +static const struct scmi_clk_proto_ops *clk_ops;
> +
> struct scmi_clk {
> u32 id;
> struct clk_hw hw;
> const struct scmi_clock_info *info;
> - const struct scmi_handle *handle;
> + const struct scmi_protocol_handle *ph;
> };
>
> #define to_scmi_clk(clk) container_of(clk, struct scmi_clk, hw)
> @@ -29,7 +31,7 @@ static unsigned long scmi_clk_recalc_rate(struct clk_hw *hw,
> u64 rate;
> struct scmi_clk *clk = to_scmi_clk(hw);
>
> - ret = clk->handle->clk_ops->rate_get(clk->handle, clk->id, &rate);
> + ret = clk_ops->rate_get(clk->ph, clk->id, &rate);
> if (ret)
> return 0;
> return rate;
> @@ -69,21 +71,21 @@ static int scmi_clk_set_rate(struct clk_hw *hw, unsigned long rate,
> {
> struct scmi_clk *clk = to_scmi_clk(hw);
>
> - return clk->handle->clk_ops->rate_set(clk->handle, clk->id, rate);
> + return clk_ops->rate_set(clk->ph, clk->id, rate);
> }
>
> static int scmi_clk_enable(struct clk_hw *hw)
> {
> struct scmi_clk *clk = to_scmi_clk(hw);
>
> - return clk->handle->clk_ops->enable(clk->handle, clk->id);
> + return clk_ops->enable(clk->ph, clk->id);
> }
>
> static void scmi_clk_disable(struct clk_hw *hw)
> {
> struct scmi_clk *clk = to_scmi_clk(hw);
>
> - clk->handle->clk_ops->disable(clk->handle, clk->id);
> + clk_ops->disable(clk->ph, clk->id);
> }
>
> static const struct clk_ops scmi_clk_ops = {
> @@ -142,11 +144,16 @@ static int scmi_clocks_probe(struct scmi_device *sdev)
> struct device *dev = &sdev->dev;
> struct device_node *np = dev->of_node;
> const struct scmi_handle *handle = sdev->handle;
> + struct scmi_protocol_handle *ph;
>
> - if (!handle || !handle->clk_ops)
> + if (!handle)
> return -ENODEV;
>
> - count = handle->clk_ops->count_get(handle);
> + clk_ops = handle->devm_get_protocol(sdev, SCMI_PROTOCOL_CLOCK, &ph);
> + if (IS_ERR(clk_ops))
> + return PTR_ERR(clk_ops);
> +
> + count = clk_ops->count_get(ph);
> if (count < 0) {
> dev_err(dev, "%pOFn: invalid clock output count\n", np);
> return -EINVAL;
> @@ -167,14 +174,14 @@ static int scmi_clocks_probe(struct scmi_device *sdev)
> if (!sclk)
> return -ENOMEM;
>
> - sclk->info = handle->clk_ops->info_get(handle, idx);
> + sclk->info = clk_ops->info_get(ph, idx);
> if (!sclk->info) {
> dev_dbg(dev, "invalid clock info for idx %d\n", idx);
> continue;
> }
>
> sclk->id = idx;
> - sclk->handle = handle;
> + sclk->ph = ph;
>
> err = scmi_clk_ops_init(dev, sclk);
> if (err) {
> --
> 2.17.1
>