Re: [PATCH v5 8/8] clk: fixed-rate: Convert into a module platform driver

Stephen Boyd
2018-10-18T20:25:18Z

Quoting Ricardo Ribalda Delgado (2018-10-18 13:02:01)
> Hi Alan
>
>
> On Thu, Oct 18, 2018 at 9:21 PM Alan Tull <atull@kernel.org> wrote:
> >
> > On Tue, Jul 5, 2016 at 11:45 AM Ricardo Ribalda Delgado
> > <ricardo.ribalda@gmail.com> wrote:
> >
> > I've stumbled across a of_node_get/put imbalance that happens when the
> > fixed rate clock is added and deleted using device tree. The cause is
> > that this driver calls of_clk_add_provider() when probed, but doesn't
> > call of_clk_del_provider() when removed.
> >
> > It looks like a lot of clock drivers share that issue:
> >
> > $ cd drivers/clk/
> > $ git grep -l of_clk_add_provider * | xargs grep -L of_clk_del_provider | wc -l
> > 131
> >
> > It should be a one line fix, but for many files.
> >
> > I'm not a clock subsystem expert, so please let me know whether I'm
> > missing something here.
>
> Not an expert either, but I believe that the affected drivers are much
> less. We have to consider only the drivers that can be removed
>
> git grep -l of_clk_add_provider | xargs grep -l platform_driver |
> xargs grep -l remove | xargs grep -L of_clk_del_provider
> drivers/clk/clk-fixed-factor.c
> drivers/clk/clk-fixed-rate.c
> drivers/clk/davinci/psc.c
> drivers/clk/ti/adpll.c
> drivers/gpu/drm/mediatek/mtk_mt8173_hdmi_phy.c
>
>
> Also there is something else that I do not undersand:
> of_clk_add_hw_provider() is the same as of_clk_add_provider() ?

The difference is the hw provider API deals with struct clk_hw and the
other API deals with struct clk pointers. The preference is to use the
clk_hw based APIs.