public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
From: mturquette@linaro.org (Mike Turquette)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v4 02/13] clk: composite: allow read-only clocks
Date: Tue, 01 Jul 2014 13:46:50 -0700	[thread overview]
Message-ID: <20140701204650.32686.12713@quantum> (raw)
In-Reply-To: <3089033.Y3HT2Lq8qX@diego>

Quoting Heiko St?bner (2014-06-22 13:43:35)
> This allows readl-only composite clocks by making mux_ops->set_parent and
> divider_ops->round_rate/set_rate optional.
> 
> Signed-off-by: Heiko Stuebner <heiko@sntech.de>
> ---
>  drivers/clk/clk-composite.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
> index 0a4cd21..046d3f6 100644
> --- a/drivers/clk/clk-composite.c
> +++ b/drivers/clk/clk-composite.c
> @@ -210,7 +210,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
>         clk_composite_ops = &composite->ops;
>  
>         if (mux_hw && mux_ops) {
> -               if (!mux_ops->get_parent || !mux_ops->set_parent) {
> +               if (!mux_ops->get_parent) {
>                         clk = ERR_PTR(-EINVAL);
>                         goto err;
>                 }
> @@ -218,7 +218,8 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
>                 composite->mux_hw = mux_hw;
>                 composite->mux_ops = mux_ops;
>                 clk_composite_ops->get_parent = clk_composite_get_parent;
> -               clk_composite_ops->set_parent = clk_composite_set_parent;
> +               if (mux_ops->set_parent)
> +                       clk_composite_ops->set_parent = clk_composite_set_parent;
>                 if (mux_ops->determine_rate)
>                         clk_composite_ops->determine_rate = clk_composite_determine_rate;
>         }
> @@ -235,10 +236,6 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
>                         if (rate_ops->set_rate) {
>                                 clk_composite_ops->set_rate = clk_composite_set_rate;
>                         }
> -               } else {
> -                       WARN(rate_ops->set_rate,
> -                               "%s: missing round_rate op is required\n",
> -                               __func__);

Getting rid of this WARN isn't such a great solution. How about rolling
in the following cleanup?



>From 03a08d7e746aedc6ce99228d629752f241383e7f Mon Sep 17 00:00:00 2001
From: Mike Turquette <mturquette@linaro.org>
Date: Tue, 1 Jul 2014 12:11:38 -0700
Subject: [PATCH] clk: composite: improve rate_hw sanity check logic

The function pointer population and sanity checking logic got a bit ugly
with the advent of the .determine_rate callback. Clean it up.

Signed-off-by: Mike Turquette <mturquette@linaro.org>
---
 drivers/clk/clk-composite.c | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
index faf7c32..bdf4f2b 100644
--- a/drivers/clk/clk-composite.c
+++ b/drivers/clk/clk-composite.c
@@ -226,21 +226,27 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
 			clk = ERR_PTR(-EINVAL);
 			goto err;
 		}
+		clk_composite_ops->recalc_rate = clk_composite_recalc_rate;
 
-		/* .round_rate is a prerequisite for .set_rate */
-		if (rate_ops->round_rate) {
-			clk_composite_ops->round_rate = clk_composite_round_rate;
-			if (rate_ops->set_rate) {
-				clk_composite_ops->set_rate = clk_composite_set_rate;
-			}
+		if (rate_ops->determine_rate)
+			clk_composite_ops->determine_rate =
+				clk_composite_determine_rate;
+		else if (rate_ops->round_rate)
+			clk_composite_ops->round_rate =
+				clk_composite_round_rate;
+
+		/* .set_rate requires either .round_rate or .determine_rate */
+		if (rate_ops->set_rate) {
+			if (rate_ops->determine_rate || rate_ops->round_rate)
+				clk_composite_ops->set_rate =
+					clk_composite_set_rate;
+			else
+				WARN(1, "%s: missing round_rate op is required\n",
+						__func__);
 		}
 
 		composite->rate_hw = rate_hw;
 		composite->rate_ops = rate_ops;
-		clk_composite_ops->recalc_rate = clk_composite_recalc_rate;
-		if (rate_ops->determine_rate ||
-		    (rate_ops->round_rate && clk_composite_ops->set_parent))
-			clk_composite_ops->determine_rate = clk_composite_determine_rate;
 	}
 
 	if (gate_hw && gate_ops) {
-- 
1.8.3.2

  reply	other threads:[~2014-07-01 20:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-22 20:41 [PATCH v4 00/13] Clock support for rk3066,rk3188 and rk3288 Heiko Stübner
2014-06-22 20:43 ` [PATCH v4 01/13] clk: composite: support determine_rate using rate_ops->round_rate + mux_ops->set_parent Heiko Stübner
2014-06-25  7:57   ` Gabriel Fernandez
2014-06-30 22:00     ` [PATCH v4.1 " Heiko Stübner
2014-07-01  9:30     ` [PATCH v4.2 " Heiko Stübner
2014-06-22 20:43 ` [PATCH v4 02/13] clk: composite: allow read-only clocks Heiko Stübner
2014-07-01 20:46   ` Mike Turquette [this message]
2014-06-22 20:44 ` [PATCH v4 03/13] clk: rockchip: add basic infrastructure for clock branches Heiko Stübner
2014-07-01 18:45   ` Mike Turquette
2014-06-22 20:44 ` [PATCH v4 04/13] clk: rockchip: add clock type for pll clocks and pll used on rk3066 Heiko Stübner
2014-06-22 20:45 ` [PATCH v4 05/13] clk: rockchip: add reset controller Heiko Stübner
2014-06-22 20:46 ` [PATCH v4 06/13] dt-bindings: add documentation for rk3188 clock and reset unit Heiko Stübner
2014-06-22 20:47 ` [PATCH v4 07/13] clk: rockchip: add clock driver for rk3188 and rk3066 clocks Heiko Stübner
2014-06-22 20:47 ` [PATCH v4 08/13] ARM: rockchip: Select ARCH_HAS_RESET_CONTROLLER Heiko Stübner
2014-06-22 20:48 ` [PATCH v4 09/13] ARM: dts: rockchip: add cru nodes and update device clocks to use it Heiko Stübner
2014-06-22 20:48 ` [PATCH v4 10/13] ARM: dts: rockchip: move oscillator input clock into main dtsi Heiko Stübner
2014-06-22 20:49 ` [PATCH v4 11/13] arm: dts: rockchip: remove obsolete clock gate definitions Heiko Stübner
2014-06-22 20:49 ` [PATCH v4 12/13] clk: rockchip: add clock controller for rk3288 Heiko Stübner
2014-06-22 20:50 ` [PATCH v4 13/13] dt-bindings: add documentation for rk3288 cru Heiko Stübner
2014-06-29 17:41 ` [PATCH v4 00/13] Clock support for rk3066,rk3188 and rk3288 Max Schwarz

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=20140701204650.32686.12713@quantum \
    --to=mturquette@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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