public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Boyd <sboyd@kernel.org>
To: David Yang <mmyangfl@gmail.com>
Cc: David Yang <mmyangfl@gmail.com>,
	Michael Turquette <mturquette@baylibre.com>,
	linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 2/5] clk: hisilicon: Extract common functions
Date: Tue, 21 Mar 2023 10:34:28 -0700	[thread overview]
Message-ID: <c087fa09f92838b4e1a2a3e7139b7106.sboyd@kernel.org> (raw)
In-Reply-To: <20230320204042.980708-3-mmyangfl@gmail.com>

Quoting David Yang (2023-03-20 13:40:35)
> To be reused with other Hi3798 series SoCs.
> 
> Signed-off-by: David Yang <mmyangfl@gmail.com>
> ---

Please squash this patch in

---8<---
diff --git a/drivers/clk/hisilicon/crg-hi3798.c b/drivers/clk/hisilicon/crg-hi3798.c
index 3a8d70b7c8ec..0d6886bca3ba 100644
--- a/drivers/clk/hisilicon/crg-hi3798.c
+++ b/drivers/clk/hisilicon/crg-hi3798.c
@@ -203,8 +203,9 @@ struct hi3798_clks {
 	int complex_clks_nums;
 };
 
-static struct hisi_clock_data *hi3798_clk_register(
-		struct platform_device *pdev, const struct hi3798_clks *clks)
+static struct hisi_clock_data *
+hi3798_clk_register(struct platform_device *pdev,
+		    const struct hi3798_clks *clks)
 {
 	struct hisi_clock_data *clk_data;
 	int ret;
@@ -257,8 +258,8 @@ static struct hisi_clock_data *hi3798_clk_register(
 	return ERR_PTR(ret);
 }
 
-static void hi3798_clk_unregister(
-		struct platform_device *pdev, const struct hi3798_clks *clks)
+static void hi3798_clk_unregister(struct platform_device *pdev,
+				  const struct hi3798_clks *clks)
 {
 	struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
 
@@ -276,8 +277,9 @@ static void hi3798_clk_unregister(
 
 #define HI3798_SYSCTRL_NR_CLKS 16
 
-static struct hisi_clock_data *hi3798_sysctrl_clk_register(
-		struct platform_device *pdev, const struct hi3798_clks *clks)
+static struct hisi_clock_data *
+hi3798_sysctrl_clk_register(struct platform_device *pdev,
+			    const struct hi3798_clks *clks)
 {
 	struct hisi_clock_data *clk_data;
 	int ret;
@@ -302,8 +304,8 @@ static struct hisi_clock_data *hi3798_sysctrl_clk_register(
 	return ERR_PTR(ret);
 }
 
-static void hi3798_sysctrl_clk_unregister(
-		struct platform_device *pdev, const struct hi3798_clks *clks)
+static void hi3798_sysctrl_clk_unregister(struct platform_device *pdev,
+					  const struct hi3798_clks *clks)
 {
 	struct hisi_crg_dev *crg = platform_get_drvdata(pdev);
 
@@ -623,8 +625,8 @@ static const struct hi3798_clks hi3798cv200_crg_clks = {
 	.phase_clks_nums = ARRAY_SIZE(hi3798mv100_phase_clks),
 };
 
-static struct hisi_clock_data *hi3798cv200_clk_register(
-				struct platform_device *pdev)
+static struct hisi_clock_data *
+hi3798cv200_clk_register(struct platform_device *pdev)
 {
 	return hi3798_clk_register(pdev, &hi3798cv200_crg_clks);
 }
@@ -653,8 +655,8 @@ static const struct hi3798_clks hi3798cv200_sysctrl_clks = {
 	.gate_clks_nums = ARRAY_SIZE(hi3798cv200_sysctrl_gate_clks),
 };
 
-static struct hisi_clock_data *hi3798cv200_sysctrl_clk_register(
-					struct platform_device *pdev)
+static struct hisi_clock_data *
+hi3798cv200_sysctrl_clk_register(struct platform_device *pdev)
 {
 	return hi3798_sysctrl_clk_register(pdev, &hi3798cv200_sysctrl_clks);
 }



> diff --git a/drivers/clk/hisilicon/crg-hi3798.c b/drivers/clk/hisilicon/crg-hi3798.c
> index 7e9507de2..2f8f14e73 100644
> --- a/drivers/clk/hisilicon/crg-hi3798.c
> +++ b/drivers/clk/hisilicon/crg-hi3798.c
> @@ -59,6 +59,119 @@ static const struct hisi_fixed_rate_clock hi3798_fixed_rate_clks[] = {
>         { HI3798_FIXED_250M, "250m", NULL, 0, 250000000, },
>  };
>  
> +struct hi3798_clks {
> +       const struct hisi_gate_clock *gate_clks;
> +       int gate_clks_nums;
> +       const struct hisi_mux_clock *mux_clks;
> +       int mux_clks_nums;
> +       const struct hisi_phase_clock *phase_clks;
> +       int phase_clks_nums;
> +};
> +
> +static struct hisi_clock_data *hi3798_clk_register(
> +               struct platform_device *pdev, const struct hi3798_clks *clks)
> +{
> +       struct hisi_clock_data *clk_data;
> +       int ret;
> +
> +       clk_data = hisi_clk_alloc(pdev, HI3798_CRG_NR_CLKS);
> +       if (!clk_data)
> +               return ERR_PTR(-ENOMEM);
> +
> +       /* hisi_phase_clock is resource managed */
> +       ret = hisi_clk_register_phase(&pdev->dev, clks->phase_clks,
> +                                     clks->phase_clks_nums, clk_data);
> +       if (ret)
> +               return ERR_PTR(ret);
> +
> +       ret = hisi_clk_register_fixed_rate(hi3798_fixed_rate_clks,
> +                                          ARRAY_SIZE(hi3798_fixed_rate_clks),
> +                                          clk_data);
> +       if (ret)
> +               return ERR_PTR(ret);
> +
> +       ret = hisi_clk_register_mux(clks->mux_clks, clks->mux_clks_nums, clk_data);
> +       if (ret)
> +               goto unregister_fixed_rate;
> +
> +       ret = hisi_clk_register_gate(clks->gate_clks, clks->gate_clks_nums, clk_data);

Please make a follow-up patch that passes the pdev->dev pointer to these
registration functions so they can use devm APIs.

> +       if (ret)
> +               goto unregister_mux;
> +
> +       ret = of_clk_add_provider(pdev->dev.of_node,

Please make a follow-up patch that migrates this to
devm_of_clk_add_hw_provider.

> +                       of_clk_src_onecell_get, &clk_data->clk_data);
> +       if (ret)
> +               goto unregister_gate;
> +

  reply	other threads:[~2023-03-21 17:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-20 20:40 [PATCH v5 0/5] Add CRG driver for Hi3798MV100 SoC David Yang
2023-03-20 20:40 ` [PATCH v5 1/5] clk: hisilicon: Rename Hi3798CV200 to Hi3798 David Yang
2023-03-20 20:40 ` [PATCH v5 2/5] clk: hisilicon: Extract common functions David Yang
2023-03-21 17:34   ` Stephen Boyd [this message]
2023-03-20 20:40 ` [PATCH v5 3/5] clk: hisilicon: Add complex clock for Hi3798 David Yang
2023-03-21 17:31   ` Stephen Boyd
2023-03-20 20:40 ` [PATCH v5 4/5] dt-bindings: clock: Add Hi3798MV100 CRG David Yang
2023-03-20 20:40 ` [PATCH v5 5/5] clk: hisilicon: Add CRG driver for Hi3798MV100 SoC David Yang

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=c087fa09f92838b4e1a2a3e7139b7106.sboyd@kernel.org \
    --to=sboyd@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mmyangfl@gmail.com \
    --cc=mturquette@baylibre.com \
    /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