From: Stephen Boyd <sboyd@kernel.org>
To: Chen-Yu Tsai <wenst@chromium.org>,
Michael Turquette <mturquette@baylibre.com>
Cc: Chen-Yu Tsai <wenst@chromium.org>,
Chun-Jie Chen <chun-jie.chen@mediatek.com>,
Miles Chen <miles.chen@mediatek.com>,
Rex-BC Chen <rex-bc.chen@mediatek.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
linux-clk@vger.kernel.org, linux-mediatek@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/5] clk: mediatek: Switch to clk_hw provider APIs
Date: Thu, 19 May 2022 17:37:34 -0700 [thread overview]
Message-ID: <20220520003736.94F74C385B8@smtp.kernel.org> (raw)
In-Reply-To: <20220519071610.423372-5-wenst@chromium.org>
Quoting Chen-Yu Tsai (2022-05-19 00:16:09)
> As part of the effort to improve the MediaTek clk drivers, the next step
> is to switch from the old 'struct clk' clk prodivder APIs to the new
> 'struct clk_hw' ones.
>
> In a previous patch, 'struct clk_onecell_data' was replaced with
> 'struct clk_hw_onecell_data', with (struct clk_hw *)->clk and
> __clk_get_hw() bridging the new data structures and old code.
>
> Now switch from the old 'clk_(un)?register*()' APIs to the new
> 'clk_hw_(un)?register*()' ones. This is done with the coccinelle script
> below.
>
> Unfortunately this also leaves clk-mt8173.c with a compile error that
> would need a coccinelle script longer than the actual diff to fix. This
> last part is fixed up by hand.
>
> // Fix prototypes
> @@
> identifier F =~ "^mtk_clk_register_";
> @@
> - struct clk *
> + struct clk_hw *
> F(...);
>
> // Fix calls to mtk_clk_register_<singular>
> @ reg @
> identifier F =~ "^mtk_clk_register_";
> identifier FS =~ "^mtk_clk_register_[a-z_]*s";
> identifier I;
> expression clk_data;
> expression E;
> @@
> FS(...) {
> ...
> - struct clk *I;
> + struct clk_hw *hw;
> ...
> for (...;...;...) {
> ...
> (
> - I
> + hw
> =
> - clk_register_fixed_rate(
> + clk_hw_register_fixed_rate(
> ...
> );
> |
> - I
> + hw
> =
> - clk_register_fixed_factor(
> + clk_hw_register_fixed_factor(
> ...
> );
> |
> - I
> + hw
> =
> - clk_register_divider(
> + clk_hw_register_divider(
> ...
> );
> |
> - I
> + hw
> =
> F(...);
> )
> ...
> if (
> - IS_ERR(I)
> + IS_ERR(hw)
> ) {
> pr_err(...,
> - I
> + hw
> ,...);
> ...
> }
>
> - clk_data->hws[E] = __clk_get_hw(I);
> + clk_data->hws[E] = hw;
> }
> ...
> }
>
> @ depends on reg @
> identifier reg.I;
> @@
> return PTR_ERR(
> - I
> + hw
> );
>
> // Fix mtk_clk_register_composite to return clk_hw instead of clk
> @@
> identifier I, R;
> expression E;
> @@
> - struct clk *
> + struct clk_hw *
> mtk_clk_register_composite(...) {
> ...
> - struct clk *I;
> + struct clk_hw *hw;
> ...
> - I = clk_register_composite(
> + hw = clk_hw_register_composite(
> ...);
> if (IS_ERR(
> - I
> + hw
> )) {
> ...
> R = PTR_ERR(
> - I
> + hw
> );
> ...
> }
>
> return
> - I
> + hw
> ;
> ...
> }
>
> // Fix other mtk_clk_register_<singular> to return clk_hw instead of clk
> @@
> identifier F =~ "^mtk_clk_register_";
> identifier I, D, C;
> expression E;
> @@
> - struct clk *
> + struct clk_hw *
> F(...) {
> ...
> - struct clk *I;
> + int ret;
> ...
> - I = clk_register(D, E);
> + ret = clk_hw_register(D, E);
> ...
> (
> - if (IS_ERR(I))
> + if (ret) {
> kfree(C);
> + return ERR_PTR(ret);
> + }
> |
> - if (IS_ERR(I))
> + if (ret)
> {
> kfree(C);
> - return I;
> + return ERR_PTR(ret);
> }
> )
>
> - return I;
> + return E;
> }
>
> // Fix mtk_clk_unregister_<singular> to take clk_hw instead of clk
> @@
> identifier F =~ "^mtk_clk_unregister_";
> identifier I, I2;
> @@
> static void F(
> - struct clk *I
> + struct clk_hw *I2
> )
> {
> ...
> - struct clk_hw *I2;
> ...
> - I2 = __clk_get_hw(I);
> ...
> (
> - clk_unregister(I);
> + clk_hw_unregister(I2);
> |
> - clk_unregister_composite(I);
> + clk_hw_unregister_composite(I2);
> )
> ...
> }
>
> // Fix calls to mtk_clk_unregister_*()
> @@
> identifier F =~ "^mtk_clk_unregister_";
> expression I;
> expression E;
> @@
> - F(I->hws[E]->clk);
> + F(I->hws[E]);
>
> Signed-off-by: Chen-Yu Tsai <wenst@chromium.org>
> Reviewed-by: Miles Chen <miles.chen@mediatek.com>
> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> Tested-by: Miles Chen <miles.chen@mediatek.com>
> ---
Applied to clk-next
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-05-20 0:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-19 7:16 [PATCH v3 0/5] clk: mediatek: Move to struct clk_hw provider APIs Chen-Yu Tsai
2022-05-19 7:16 ` [PATCH v3 1/5] clk: mediatek: Make mtk_clk_register_composite() static Chen-Yu Tsai
2022-05-20 0:36 ` Stephen Boyd
2022-05-19 7:16 ` [PATCH v3 2/5] clk: mediatek: apmixed: Drop error message from clk_register() failure Chen-Yu Tsai
2022-05-20 0:37 ` Stephen Boyd
2022-05-19 7:16 ` [PATCH v3 4/5] clk: mediatek: Switch to clk_hw provider APIs Chen-Yu Tsai
2022-05-20 0:37 ` Stephen Boyd [this message]
2022-05-19 7:16 ` [PATCH v3 5/5] clk: mediatek: mt8173: " Chen-Yu Tsai
2022-05-20 0:37 ` Stephen Boyd
[not found] ` <20220519071610.423372-4-wenst@chromium.org>
2022-05-20 0:37 ` [PATCH v3 3/5] clk: mediatek: Replace 'struct clk' with 'struct clk_hw' Stephen Boyd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220520003736.94F74C385B8@smtp.kernel.org \
--to=sboyd@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chun-jie.chen@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=miles.chen@mediatek.com \
--cc=mturquette@baylibre.com \
--cc=rex-bc.chen@mediatek.com \
--cc=wenst@chromium.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).