From patchwork Tue Jul 1 20:46:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mike Turquette X-Patchwork-Id: 4462101 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 57BFE9F26C for ; Tue, 1 Jul 2014 20:49:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6E34820364 for ; Tue, 1 Jul 2014 20:49:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 78D46202F8 for ; Tue, 1 Jul 2014 20:49:11 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1X24xb-0004UM-Pq; Tue, 01 Jul 2014 20:47:27 +0000 Received: from mail-pa0-f52.google.com ([209.85.220.52]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1X24xZ-0004Ql-5O for linux-arm-kernel@lists.infradead.org; Tue, 01 Jul 2014 20:47:26 +0000 Received: by mail-pa0-f52.google.com with SMTP id eu11so11236165pac.11 for ; Tue, 01 Jul 2014 13:47:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:content-type:mime-version :content-transfer-encoding:to:from:in-reply-to:cc:references :message-id:user-agent:subject:date; bh=vCU0SUj9ROTA6Az2Srq5XvoL3cMy44pfNyKDsNwBoWA=; b=Jc7tCjqspwQIM/hKL6COxmjVGht3tc9KPhQoPr14HhXNhBZgZmlYTeaHSyhpvNQziM Dvw9QDTgYFP3pzuNwh77aPE/UvoKSlntmTPmwChYiGRaFjwBHbi1CPPQCa+DSe76UXtB LtzIqxxGQbgdrGDPTUvxCgiMlWiAowvE4639MQSlvalUyfB14oiK6N8qnZhMqTwkZg+A epGNTnms2CFc2tGOkyp1FuGwBLr7VUDbcl7TVylOjBe3ujpB2UeWVedkyR+9ucKoQ5Yq 2oQ2MB+wgWhE/IAs4HBLX8u31qgts7m5Dzn0hJsvBj3Fv8bHYaTpV017t//Mw5XSu5S7 NM6Q== X-Gm-Message-State: ALoCoQnrLSeGnrEoZQFW6rTgnnE1KtxOz8BAx4PkYGHkiJQ3+2K2sW480LWOBy45r6NXvDvlpc7x X-Received: by 10.68.97.129 with SMTP id ea1mr64538902pbb.73.1404247623788; Tue, 01 Jul 2014 13:47:03 -0700 (PDT) Received: from localhost ([2601:9:5900:1fe:ca60:ff:fe0a:8a36]) by mx.google.com with ESMTPSA id ee5sm34022777pbc.47.2014.07.01.13.47.02 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 01 Jul 2014 13:47:02 -0700 (PDT) MIME-Version: 1.0 To: =?utf-8?q?Heiko_St=C3=BCbner?= , From: Mike Turquette In-Reply-To: <3089033.Y3HT2Lq8qX@diego> References: <1808429.dNxms7FR7U@diego> <3089033.Y3HT2Lq8qX@diego> Message-ID: <20140701204650.32686.12713@quantum> User-Agent: alot/0.3.5 Subject: Re: [PATCH v4 02/13] clk: composite: allow read-only clocks Date: Tue, 01 Jul 2014 13:46:50 -0700 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140701_134725_229571_B6572F46 X-CRM114-Status: GOOD ( 16.27 ) X-Spam-Score: -0.7 (/) Cc: Max Schwarz , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 > --- > 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 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 --- 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) {