Hi Angelo,
On Mon, Dec 26, 2022 at 03:07:10PM +0800, Chen-Yu Tsai wrote:
> On Fri, Dec 23, 2022 at 5:43 PM AngeloGioacchino Del Regno
> <angelogioacchino.delregno@collabora.com> wrote:
> >
> > Take a pointer to a struct device in mtk_clk_register_cpumuxes() and
> > propagate the same to mtk_clk_register_cpumux() => clk_hw_register().
> > Even though runtime pm is unlikely to be used with CPU muxes, this
> > helps with code consistency and possibly opens to commonization of
> > some mtk_clk_register_(x) functions.
> >
> > Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
>
> Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
>
> As with the gates patch, could we make the |struct device *| parameter the
> first one? Also for this case I think we could even drop the
> |struct device_node *| parameter.
Reviewed-by: Markus Schneider-Pargmann <msp@baylibre.com>
clk_hw_register and others are using the device pointer as first
parameter as well. So I think it makes sense to do it the same way as
ChenYu suggested.
Best,
Markus
@@ -59,7 +59,7 @@ static const struct clk_ops clk_cpumux_ops = {
static struct clk_hw *
mtk_clk_register_cpumux(const struct mtk_composite *mux,
- struct regmap *regmap)
+ struct regmap *regmap, struct device *dev)
{
struct mtk_clk_cpumux *cpumux;
int ret;
@@ -81,7 +81,7 @@ mtk_clk_register_cpumux(const struct mtk_composite *mux,
cpumux->regmap = regmap;
cpumux->hw.init = &init;
- ret = clk_hw_register(NULL, &cpumux->hw);
+ ret = clk_hw_register(dev, &cpumux->hw);
if (ret) {
kfree(cpumux);
return ERR_PTR(ret);
@@ -104,7 +104,8 @@ static void mtk_clk_unregister_cpumux(struct clk_hw *hw)
int mtk_clk_register_cpumuxes(struct device_node *node,
const struct mtk_composite *clks, int num,
- struct clk_hw_onecell_data *clk_data)
+ struct clk_hw_onecell_data *clk_data,
+ struct device *dev)
{
int i;
struct clk_hw *hw;
@@ -125,7 +126,7 @@ int mtk_clk_register_cpumuxes(struct device_node *node,
continue;
}
- hw = mtk_clk_register_cpumux(mux, regmap);
+ hw = mtk_clk_register_cpumux(mux, regmap, dev);
if (IS_ERR(hw)) {
pr_err("Failed to register clk %s: %pe\n", mux->name,
hw);
@@ -13,7 +13,8 @@ struct mtk_composite;
int mtk_clk_register_cpumuxes(struct device_node *node,
const struct mtk_composite *clks, int num,
- struct clk_hw_onecell_data *clk_data);
+ struct clk_hw_onecell_data *clk_data,
+ struct device *dev);
void mtk_clk_unregister_cpumuxes(const struct mtk_composite *clks, int num,
struct clk_hw_onecell_data *clk_data);
@@ -770,7 +770,7 @@ static void __init mtk_infrasys_init_early(struct device_node *node)
infra_clk_data);
mtk_clk_register_cpumuxes(node, cpu_muxes, ARRAY_SIZE(cpu_muxes),
- infra_clk_data);
+ infra_clk_data, NULL);
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get,
infra_clk_data);
@@ -106,7 +106,8 @@ static int clk_mt6795_infracfg_probe(struct platform_device *pdev)
if (ret)
goto free_clk_data;
- ret = mtk_clk_register_cpumuxes(node, cpu_muxes, ARRAY_SIZE(cpu_muxes), clk_data);
+ ret = mtk_clk_register_cpumuxes(node, cpu_muxes, ARRAY_SIZE(cpu_muxes),
+ clk_data, &pdev->dev);
if (ret)
goto unregister_gates;
@@ -674,7 +674,7 @@ static int mtk_infrasys_init(struct platform_device *pdev)
clk_data, &pdev->dev);
mtk_clk_register_cpumuxes(node, infra_muxes, ARRAY_SIZE(infra_muxes),
- clk_data);
+ clk_data, &pdev->dev);
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get,
clk_data);
@@ -609,7 +609,7 @@ static int mtk_infrasys_init(struct platform_device *pdev)
clk_data, &pdev->dev);
mtk_clk_register_cpumuxes(node, infra_muxes, ARRAY_SIZE(infra_muxes),
- clk_data);
+ clk_data, &pdev->dev);
return of_clk_add_hw_provider(node, of_clk_hw_onecell_get,
clk_data);
@@ -893,7 +893,7 @@ static void __init mtk_infrasys_init(struct device_node *node)
mtk_clk_register_factors(infra_divs, ARRAY_SIZE(infra_divs), clk_data);
mtk_clk_register_cpumuxes(node, cpu_muxes, ARRAY_SIZE(cpu_muxes),
- clk_data);
+ clk_data, NULL);
r = of_clk_add_hw_provider(node, of_clk_hw_onecell_get, clk_data);
if (r)