[PATCH v2 15/31] clk: mediatek: Implement mtk_clk_unregister_fixed_clks() API

Chen-Yu Tsai posted 31 patches 2 years, 7 months ago
There is a newer version of this series
[PATCH v2 15/31] clk: mediatek: Implement mtk_clk_unregister_fixed_clks() API
Posted by Chen-Yu Tsai 2 years, 7 months ago
mtk_clk_register_fixed_clks(), as the name suggests, is used to register
a given list of fixed rate clks. However it is lacking a counterpart
unregister API.

Implement said unregister API so that the various clock platform drivers
can utilize it to do proper unregistration, cleanup and removal.

In the header file, the register function's declaration is also
reformatted to fit code style guidelines.

Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Miles Chen <miles.chen@mediatek.com>
---
 drivers/clk/mediatek/clk-mtk.c | 20 ++++++++++++++++++++
 drivers/clk/mediatek/clk-mtk.h |  6 ++++--
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index 0c5db3c71fdd..7c0d5706eed7 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -80,6 +80,26 @@ void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks,
 }
 EXPORT_SYMBOL_GPL(mtk_clk_register_fixed_clks);
 
+void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *clks, int num,
+				   struct clk_onecell_data *clk_data)
+{
+	int i;
+
+	if (!clk_data)
+		return;
+
+	for (i = num; i > 0; i--) {
+		const struct mtk_fixed_clk *rc = &clks[i - 1];
+
+		if (IS_ERR_OR_NULL(clk_data->clks[rc->id]))
+			continue;
+
+		clk_unregister_fixed_rate(clk_data->clks[rc->id]);
+		clk_data->clks[rc->id] = ERR_PTR(-ENOENT);
+	}
+}
+EXPORT_SYMBOL_GPL(mtk_clk_unregister_fixed_clks);
+
 void mtk_clk_register_factors(const struct mtk_fixed_factor *clks,
 		int num, struct clk_onecell_data *clk_data)
 {
diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h
index 168220f85489..cc7f920eabb4 100644
--- a/drivers/clk/mediatek/clk-mtk.h
+++ b/drivers/clk/mediatek/clk-mtk.h
@@ -34,8 +34,10 @@ struct mtk_fixed_clk {
 		.rate = _rate,				\
 	}
 
-void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks,
-		int num, struct clk_onecell_data *clk_data);
+void mtk_clk_register_fixed_clks(const struct mtk_fixed_clk *clks, int num,
+				 struct clk_onecell_data *clk_data);
+void mtk_clk_unregister_fixed_clks(const struct mtk_fixed_clk *clks, int num,
+				   struct clk_onecell_data *clk_data);
 
 struct mtk_fixed_factor {
 	int id;
-- 
2.35.0.rc2.247.g8bbb082509-goog

Re: [PATCH v2 15/31] clk: mediatek: Implement mtk_clk_unregister_fixed_clks() API
Posted by AngeloGioacchino Del Regno 2 years, 7 months ago
Il 02/02/22 14:48, Chen-Yu Tsai ha scritto:
> mtk_clk_register_fixed_clks(), as the name suggests, is used to register
> a given list of fixed rate clks. However it is lacking a counterpart
> unregister API.
> 
> Implement said unregister API so that the various clock platform drivers
> can utilize it to do proper unregistration, cleanup and removal.
> 
> In the header file, the register function's declaration is also
> reformatted to fit code style guidelines.
> 
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
> Reviewed-by: Miles Chen <miles.chen@mediatek.com>

Hello Chen-Yu,

I like this entire series, but I had to manually apply this patch (and some of
the other ones)...

Especially for the ones that will be touching MT8195 clock drivers, can you
please rebase over series [1] by Chun-Jie?

[1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=603955

Thanks,
Angelo

Re: [PATCH v2 15/31] clk: mediatek: Implement mtk_clk_unregister_fixed_clks() API
Posted by Chen-Yu Tsai 2 years, 7 months ago
Hi,

On Thu, Feb 3, 2022 at 5:47 PM AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com> wrote:
>
> Il 02/02/22 14:48, Chen-Yu Tsai ha scritto:
> > mtk_clk_register_fixed_clks(), as the name suggests, is used to register
> > a given list of fixed rate clks. However it is lacking a counterpart
> > unregister API.
> >
> > Implement said unregister API so that the various clock platform drivers
> > can utilize it to do proper unregistration, cleanup and removal.
> >
> > In the header file, the register function's declaration is also
> > reformatted to fit code style guidelines.
> >
> > Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
> > Reviewed-by: Miles Chen <miles.chen@mediatek.com>
>
> Hello Chen-Yu,
>
> I like this entire series, but I had to manually apply this patch (and some of
> the other ones)...

This was based on linux-next, which already has a couple clk patches queued
up.

> Especially for the ones that will be touching MT8195 clock drivers, can you
> please rebase over series [1] by Chun-Jie?

I think this series supersedes the first patch in that series? As for the
other two, I think the discussion about the bindings is ongoing, which
might affect the third patch as well?

ChenYu

> [1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=603955
>
> Thanks,
> Angelo
>
Re: [PATCH v2 15/31] clk: mediatek: Implement mtk_clk_unregister_fixed_clks() API
Posted by AngeloGioacchino Del Regno 2 years, 7 months ago
Il 08/02/22 04:50, Chen-Yu Tsai ha scritto:
> Hi,
> 
> On Thu, Feb 3, 2022 at 5:47 PM AngeloGioacchino Del Regno
> <angelogioacchino.delregno@collabora.com> wrote:
>>
>> Il 02/02/22 14:48, Chen-Yu Tsai ha scritto:
>>> mtk_clk_register_fixed_clks(), as the name suggests, is used to register
>>> a given list of fixed rate clks. However it is lacking a counterpart
>>> unregister API.
>>>
>>> Implement said unregister API so that the various clock platform drivers
>>> can utilize it to do proper unregistration, cleanup and removal.
>>>
>>> In the header file, the register function's declaration is also
>>> reformatted to fit code style guidelines.
>>>
>>> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
>>> Reviewed-by: Miles Chen <miles.chen@mediatek.com>
>>
>> Hello Chen-Yu,
>>
>> I like this entire series, but I had to manually apply this patch (and some of
>> the other ones)...
> 
> This was based on linux-next, which already has a couple clk patches queued
> up.
> 
>> Especially for the ones that will be touching MT8195 clock drivers, can you
>> please rebase over series [1] by Chun-Jie?
> 
> I think this series supersedes the first patch in that series? As for the
> other two, I think the discussion about the bindings is ongoing, which
> might affect the third patch as well?

You're right about that - besides, the mentioned series will take a bit of time to
get merged in and this cleanup should not be waiting for all that time, as it's
very, very nice...
In any case, I don't think that the third patch from that series will be affected,
as it's a double-definition instance: the vppsys{0,1} are really defined in mmsys
and they're simply moving it around... The committer forgot to add the two
properties (the ones that he removed from mt8195-clock) to mediatek,mmsys.yaml,
I'll send a reply over that thread.

Anyway, yes, this series definitely supersedes patch 1 in that series, so,
I'm sorry for the noise, and:

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>

> 
> ChenYu
> 
>> [1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=603955
>>
>> Thanks,
>> Angelo
>>