Re: [PATCH v2 2/5] clk: mediatek: Refactor pll registration to pass device

Nicolas Frattaroli
2025-10-10T20:11:45Z

On Thursday, 9 October 2025 10:18:42 Central European Summer Time Chen-Yu Tsai wrote:
> On Thu, Oct 9, 2025 at 4:09 PM AngeloGioacchino Del Regno
> <angelogioacchino.delregno@collabora.com> wrote:
> >
> > Il 08/10/25 18:05, Nicolas Frattaroli ha scritto:
> > > As it stands, mtk_clk_register_plls takes a struct device_node pointer
> > > as its first argument. This is a tragic happenstance, as it's trivial to
> > > get the device_node from a struct device, but the opposite not so much.
> > > The struct device is a much more useful thing to have passed down.
> > >
> > > Refactor mtk_clk_register_plls to take a struct device pointer instead
> > > of a struct device_node pointer, and fix up all users of this function.
> > >
> > > Signed-off-by: Nicolas Frattaroli <nicolas.frattaroli@collabora.com>
> > > ---
> > > drivers/clk/mediatek/clk-mt2701.c | 2 +-
> > > drivers/clk/mediatek/clk-mt2712-apmixedsys.c | 2 +-
> > > drivers/clk/mediatek/clk-mt6735-apmixedsys.c | 4 ++--
> > > drivers/clk/mediatek/clk-mt6765.c | 2 +-
> > > drivers/clk/mediatek/clk-mt6779.c | 2 +-
> > > drivers/clk/mediatek/clk-mt6797.c | 2 +-
> > > drivers/clk/mediatek/clk-mt7622-apmixedsys.c | 2 +-
> > > drivers/clk/mediatek/clk-mt7629.c | 2 +-
> > > drivers/clk/mediatek/clk-mt7981-apmixed.c | 2 +-
> > > drivers/clk/mediatek/clk-mt7986-apmixed.c | 2 +-
> > > drivers/clk/mediatek/clk-mt7988-apmixed.c | 2 +-
> > > drivers/clk/mediatek/clk-mt8135-apmixedsys.c | 3 ++-
> > > drivers/clk/mediatek/clk-mt8167-apmixedsys.c | 2 +-
> > > drivers/clk/mediatek/clk-mt8183-apmixedsys.c | 2 +-
> > > drivers/clk/mediatek/clk-mt8188-apmixedsys.c | 2 +-
> > > drivers/clk/mediatek/clk-mt8195-apusys_pll.c | 3 ++-
> > > drivers/clk/mediatek/clk-mt8196-apmixedsys.c | 3 ++-
> > > drivers/clk/mediatek/clk-mt8196-mcu.c | 2 +-
> > > drivers/clk/mediatek/clk-mt8196-mfg.c | 2 +-
> > > drivers/clk/mediatek/clk-mt8196-vlpckgen.c | 2 +-
> > > drivers/clk/mediatek/clk-mt8365-apmixedsys.c | 2 +-
> > > drivers/clk/mediatek/clk-mt8516-apmixedsys.c | 2 +-
> > > drivers/clk/mediatek/clk-pll.c | 7 ++++---
> > > drivers/clk/mediatek/clk-pll.h | 6 +++---
> > > 24 files changed, 33 insertions(+), 29 deletions(-)
> > >
> >
> > ..snip..
> >
> > > diff --git a/drivers/clk/mediatek/clk-pll.h b/drivers/clk/mediatek/clk-pll.h
> > > index d71c150ce83e4bb2fe78290c2d5570a90084246d..0e2b94b9cd4b56adceee3b04e9ab24c2526471da 100644
> > > --- a/drivers/clk/mediatek/clk-pll.h
> > > +++ b/drivers/clk/mediatek/clk-pll.h
> > > @@ -78,9 +78,9 @@ struct mtk_clk_pll {
> > > const struct mtk_pll_data *data;
> > > };
> > >
> >
> > There's a forward declaration of struct device_node in this header: with this
> > change, that becomes unused.
> >
> > Please change that to a forward declaration of struct device instead.
> >
> > While at it, I'd appreciate if you could either:
> > A. Remove the forward declaration for `struct clk_hw_onecell_data` and for
> > `struct clk_ops` (as both come from clk-provider.h - which this already
> > includes);
> > ...or...
> > B. Remove the inclusion of clk-provider.h and keep the forward declarations.
>
> Prefer (B) since no APIs from clk-provider.h are referenced in the header.
> It is up to the implementation to directly include any and all headers it
> needs.

drivers/clk/mediatek/clk-pll.h:67:16: error: field has incomplete type 'struct clk_hw'
67 | struct clk_hw hw;
| ^
drivers/clk/mediatek/clk-pll.h:67:9: note: forward declaration of 'struct clk_hw'
67 | struct clk_hw hw;
| ^

The compiler needs to know the complete type here, as it's not a
pointer but a member proper, which is needed for the container_of
macro to work.

In other words, clk-provider.h is needed.

Kind regards,
Nicolas Frattaroli

>
> ChenYu
>
> > After which:
> >
> > Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> >
> > > -int mtk_clk_register_plls(struct device_node *node,
> > > - const struct mtk_pll_data *plls, int num_plls,
> > > - struct clk_hw_onecell_data *clk_data);
> > > +int mtk_clk_register_plls(struct device *dev, const struct mtk_pll_data *plls,
> > > + int num_plls, struct clk_hw_onecell_data *clk_data);
> > > +
> > > void mtk_clk_unregister_plls(const struct mtk_pll_data *plls, int num_plls,
> > > struct clk_hw_onecell_data *clk_data);
> > >
> > >
> >
> >
>