Re: [PATCH RFC 1/2] clk: provide devm_clk_get_optional_enabled_with_rate()

Stephen Boyd
2024-08-03T01:04:24Z

Quoting Bartosz Golaszewski (2024-08-01 08:58:49)
> diff --git a/drivers/clk/clk-devres.c b/drivers/clk/clk-devres.c
> index 90e6078fb6e1..34e800525e21 100644
> --- a/drivers/clk/clk-devres.c
> +++ b/drivers/clk/clk-devres.c
> @@ -99,6 +99,34 @@ struct clk *devm_clk_get_optional_enabled(struct device *dev, const char *id)
> }
> EXPORT_SYMBOL_GPL(devm_clk_get_optional_enabled);
>
> +struct clk *devm_clk_get_optional_enabled_with_rate(struct device *dev,
> + const char *id,
> + unsigned long rate)
> +{
> + struct clk *clk;
> + int ret;
> +
> + clk = __devm_clk_get(dev, id, clk_get_optional, NULL,
> + clk_disable_unprepare);
> + if (IS_ERR(clk))
> + return ERR_CAST(clk);
> +
> + ret = clk_set_rate(clk, rate);
> + if (ret)
> + goto out_put_clk;
> +
> + ret = clk_prepare_enable(clk);
> + if (ret)
> + goto out_put_clk;
> +
> + return clk;
> +
> +out_put_clk:
> + devm_clk_put(dev, clk);
> + return ERR_PTR(ret);
> +}
> +EXPORT_SYMBOL(devm_clk_get_optional_enabled_with_rate);

GPL