From patchwork Mon Jun 3 09:36:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Paul Walmsley X-Patchwork-Id: 2651911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork1.kernel.org (Postfix) with ESMTP id 57F4E40077 for ; Mon, 3 Jun 2013 10:32:07 +0000 (UTC) Received: from merlin.infradead.org ([205.233.59.134]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjRJ0-000272-CF; Mon, 03 Jun 2013 09:43:59 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjRCc-00025E-Te; Mon, 03 Jun 2013 09:37:22 +0000 Received: from utopia.booyaka.com ([74.50.51.50]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UjRCa-00023a-Il for linux-arm-kernel@lists.infradead.org; Mon, 03 Jun 2013 09:37:21 +0000 Received: (qmail 7664 invoked by uid 1019); 3 Jun 2013 09:36:56 -0000 Date: Mon, 3 Jun 2013 09:36:56 +0000 (UTC) From: Paul Walmsley To: Jean-Philippe Francois Subject: Re: [PATCH v2 1/1] ARM : omap3 : fix wrong container_of in clock36xx.c In-Reply-To: <1369903827-2025-1-git-send-email-jp.francois@cynove.com> Message-ID: References: <1369903827-2025-1-git-send-email-jp.francois@cynove.com> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130603_053720_710259_3B5C4D70 X-CRM114-Status: GOOD ( 12.26 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: tony@atomide.com, linux-omap@vger.kernel.org, mturquette@linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 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 On Thu, 30 May 2013, Jean-Philippe Francois wrote: > omap36xx_pwrdn_clk_enable_with_hsdiv_restore expects the parent hw of the clock > to be a clk_hw_omap. However, looking at cclock3xxx_data.c, all concerned clock > have parent defined as clk_divider. Instead of using container_of to eventually get > to the register and directly mess with the divider, change freq via clk_set_rate, > and let the clock framework toggle the divider value. > Tested with 3.9 on dm3730. > > Signed-off-by: Jean-Philippe Fran??ois Queued for 3.10-rc fixes with Mike's ack, after fixing the checkpatch.pl errors listed below. Please don't forget to run scripts/checkpatch.pl on future patches -- Documentation/SubmittingPatches has more info about this. ERROR: space required before the open parenthesis '(' #59: FILE: arch/arm/mach-omap2/clock36xx.c:52: + if(ret) ERROR: space required before the open parenthesis '(' #62: FILE: arch/arm/mach-omap2/clock36xx.c:55: + if(ret) WARNING: please, no spaces at the start of a line #67: FILE: arch/arm/mach-omap2/clock36xx.c:60: + badfreq :$ ERROR: space prohibited before that ':' (ctx:WxE) #67: FILE: arch/arm/mach-omap2/clock36xx.c:60: + badfreq : ^ Updated patch follows. - Paul From: Jean-Philippe Francois Date: Thu, 30 May 2013 10:50:27 +0200 Subject: [PATCH] ARM: omap3: clock: fix wrong container_of in clock36xx.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit omap36xx_pwrdn_clk_enable_with_hsdiv_restore expects the parent hw of the clock to be a clk_hw_omap. However, looking at cclock3xxx_data.c, all concerned clock have parent defined as clk_divider. Instead of using container_of to eventually get to the register and directly mess with the divider, change freq via clk_set_rate, and let the clock framework toggle the divider value. Tested with 3.9 on dm3730. Signed-off-by: Jean-Philippe François Acked-by: Mike Turquette Signed-off-by: Paul Walmsley --- arch/arm/mach-omap2/clock36xx.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/arch/arm/mach-omap2/clock36xx.c b/arch/arm/mach-omap2/clock36xx.c index 8f3bf4e..7f69fbb 100644 --- a/arch/arm/mach-omap2/clock36xx.c +++ b/arch/arm/mach-omap2/clock36xx.c @@ -39,30 +39,25 @@ */ int omap36xx_pwrdn_clk_enable_with_hsdiv_restore(struct clk_hw *clk) { - struct clk_hw_omap *parent; - struct clk_hw *parent_hw; - u32 dummy_v, orig_v, clksel_shift; int ret; /* Clear PWRDN bit of HSDIVIDER */ ret = omap2_dflt_clk_enable(clk); - parent_hw = __clk_get_hw(__clk_get_parent(clk->clk)); - parent = to_clk_hw_omap(parent_hw); - - /* Restore the dividers */ + /* kick parent's clksel register after toggling PWRDN bit */ if (!ret) { - clksel_shift = __ffs(parent->clksel_mask); - orig_v = __raw_readl(parent->clksel_reg); - dummy_v = orig_v; - - /* Write any other value different from the Read value */ - dummy_v ^= (1 << clksel_shift); - __raw_writel(dummy_v, parent->clksel_reg); - - /* Write the original divider */ - __raw_writel(orig_v, parent->clksel_reg); + struct clk *parent = clk_get_parent(clk->clk); + unsigned long parent_rate = clk_get_rate(parent); + ret = clk_set_rate(parent, parent_rate/2); + if (ret) + goto badfreq; + ret = clk_set_rate(parent, parent_rate); + if (ret) + goto badfreq; } + return ret; +badfreq: + omap2_dflt_clk_disable(clk); return ret; }