From patchwork Tue Apr 5 01:51:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 65036 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp195809lbc; Mon, 4 Apr 2016 18:53:31 -0700 (PDT) X-Received: by 10.67.7.37 with SMTP id cz5mr11928434pad.18.1459821210894; Mon, 04 Apr 2016 18:53:30 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id yk10si4109676pac.24.2016.04.04.18.53.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Apr 2016 18:53:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org 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 1anGA5-0007dK-Qu; Tue, 05 Apr 2016 01:52:09 +0000 Received: from conuserg-12.nifty.com ([210.131.2.79]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1anGA0-0007Wh-8K for linux-arm-kernel@lists.infradead.org; Tue, 05 Apr 2016 01:52:07 +0000 Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id u351p6f6010253; Tue, 5 Apr 2016 10:51:09 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com u351p6f6010253 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1459821071; bh=UwBoRhALPeWj3ZjMBY+lFGw7ixCTor699j38hlub/tE=; h=From:To:Cc:Subject:Date:From; b=oqS8RNYy4b5zlP3OWseNVa3SgHk2Y2NS1LwFz71MKj/IO/TPcMCO3xfG5HmYtPohq 8hhM1r435M0V+mGAcOgdMM2H13pG5ibd6Rt18hc4EiegFG6pfDgbfvfZaxFVFHUVd6 3kFiZI23T/ytobBOSttmo+jg1ibFBZ+Bj9jYRzgl0fz97nqIzTplRwIziHEErH9y0f ol50+4zqmjE6FvuM9DJ8QgMZhSO0EANc0cClYm23rmZ/ohdCn1W9UzO3+9AT9nExps 0sB35GG4Rha3za7BJ/YOBOvATmobVGVQ2IUAmO1ETBqQNaL0OBkVnWLi8CjHlzABkL I/9v+sW3kcoNA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-clk@vger.kernel.org Subject: [PATCH v2] clk: let clk_disable() return immediately if clk is NULL or error Date: Tue, 5 Apr 2016 10:51:23 +0900 Message-Id: <1459821083-28116-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160404_185204_854322_87DCDBBC X-CRM114-Status: GOOD ( 14.69 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mips@linux-mips.org, Rich Felker , linux-sh@vger.kernel.org, Michael Turquette , Masahiro Yamada , Greg Ungerer , Russell King , Yoshinori Sato , Magnus Damm , Geert Uytterhoeven , Wan ZongShun , Steven Miao , adi-buildroot-devel@lists.sourceforge.net, Haojian Zhuang , linux-m68k@lists.linux-m68k.org, Simon Horman , linux-arm-kernel@lists.infradead.org, John Crispin , Eric Miao , Ryan Mallon , Stephen Boyd , linux-kernel@vger.kernel.org, Ralf Baechle , linux-renesas-soc@vger.kernel.org, Hartley Sweeten MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org The clk_disable() in the common clock framework (drivers/clk/clk.c) returns immediately if a given clk is NULL or an error pointer. It allows clock consumers to call clk_disable() without IS_ERR_OR_NULL checking if drivers are only used with the common clock framework. Unfortunately, NULL/error checking is missing from some of non-common clk_disable() implementations. This prevents us from completely dropping NULL/error checking from callers. Let's make it tree-wide consistent by adding IS_ERR_OR_NULL(clk) to all callees. Signed-off-by: Masahiro Yamada Acked-by: Greg Ungerer Acked-by: Wan Zongshun --- Stephen, This patch has been unapplied for a long time. Please let me know if there is something wrong with this patch. Thanks, Changes in v2: - Rebase on Linux 4.6-rc1 arch/arm/mach-ep93xx/clock.c | 2 +- arch/arm/mach-mmp/clock.c | 3 +++ arch/arm/mach-sa1100/clock.c | 15 ++++++++------- arch/arm/mach-w90x900/clock.c | 3 +++ arch/blackfin/mach-bf609/clock.c | 3 +++ arch/m68k/coldfire/clk.c | 4 ++++ arch/mips/bcm63xx/clk.c | 3 +++ arch/mips/lantiq/clk.c | 3 +++ drivers/sh/clk/core.c | 2 +- 9 files changed, 29 insertions(+), 9 deletions(-) -- 1.9.1 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c index 39ef3b6..4e11f7d 100644 --- a/arch/arm/mach-ep93xx/clock.c +++ b/arch/arm/mach-ep93xx/clock.c @@ -293,7 +293,7 @@ void clk_disable(struct clk *clk) { unsigned long flags; - if (!clk) + if (IS_ERR_OR_NULL(clk)) return; spin_lock_irqsave(&clk_lock, flags); diff --git a/arch/arm/mach-mmp/clock.c b/arch/arm/mach-mmp/clock.c index ac6633d..39ad3896 100644 --- a/arch/arm/mach-mmp/clock.c +++ b/arch/arm/mach-mmp/clock.c @@ -67,6 +67,9 @@ void clk_disable(struct clk *clk) { unsigned long flags; + if (IS_ERR_OR_NULL(clk)) + return; + WARN_ON(clk->enabled == 0); spin_lock_irqsave(&clocks_lock, flags); diff --git a/arch/arm/mach-sa1100/clock.c b/arch/arm/mach-sa1100/clock.c index cbf53bb..ea103fd 100644 --- a/arch/arm/mach-sa1100/clock.c +++ b/arch/arm/mach-sa1100/clock.c @@ -85,13 +85,14 @@ void clk_disable(struct clk *clk) { unsigned long flags; - if (clk) { - WARN_ON(clk->enabled == 0); - spin_lock_irqsave(&clocks_lock, flags); - if (--clk->enabled == 0) - clk->ops->disable(clk); - spin_unlock_irqrestore(&clocks_lock, flags); - } + if (IS_ERR_OR_NULL(clk)) + return; + + WARN_ON(clk->enabled == 0); + spin_lock_irqsave(&clocks_lock, flags); + if (--clk->enabled == 0) + clk->ops->disable(clk); + spin_unlock_irqrestore(&clocks_lock, flags); } EXPORT_SYMBOL(clk_disable); diff --git a/arch/arm/mach-w90x900/clock.c b/arch/arm/mach-w90x900/clock.c index 2c371ff..90ec250 100644 --- a/arch/arm/mach-w90x900/clock.c +++ b/arch/arm/mach-w90x900/clock.c @@ -46,6 +46,9 @@ void clk_disable(struct clk *clk) { unsigned long flags; + if (IS_ERR_OR_NULL(clk)) + return; + WARN_ON(clk->enabled == 0); spin_lock_irqsave(&clocks_lock, flags); diff --git a/arch/blackfin/mach-bf609/clock.c b/arch/blackfin/mach-bf609/clock.c index 3783058..fed8015 100644 --- a/arch/blackfin/mach-bf609/clock.c +++ b/arch/blackfin/mach-bf609/clock.c @@ -97,6 +97,9 @@ EXPORT_SYMBOL(clk_enable); void clk_disable(struct clk *clk) { + if (IS_ERR_OR_NULL(clk)) + return; + if (clk->ops && clk->ops->disable) clk->ops->disable(clk); } diff --git a/arch/m68k/coldfire/clk.c b/arch/m68k/coldfire/clk.c index fddfdcc..eb0e8c1 100644 --- a/arch/m68k/coldfire/clk.c +++ b/arch/m68k/coldfire/clk.c @@ -101,6 +101,10 @@ EXPORT_SYMBOL(clk_enable); void clk_disable(struct clk *clk) { unsigned long flags; + + if (IS_ERR_OR_NULL(clk)) + return; + spin_lock_irqsave(&clk_lock, flags); if ((--clk->enabled == 0) && clk->clk_ops) clk->clk_ops->disable(clk); diff --git a/arch/mips/bcm63xx/clk.c b/arch/mips/bcm63xx/clk.c index 6375652..d6a39bf 100644 --- a/arch/mips/bcm63xx/clk.c +++ b/arch/mips/bcm63xx/clk.c @@ -326,6 +326,9 @@ EXPORT_SYMBOL(clk_enable); void clk_disable(struct clk *clk) { + if (IS_ERR_OR_NULL(clk)) + return; + mutex_lock(&clocks_mutex); clk_disable_unlocked(clk); mutex_unlock(&clocks_mutex); diff --git a/arch/mips/lantiq/clk.c b/arch/mips/lantiq/clk.c index a0706fd..c8d87b1 100644 --- a/arch/mips/lantiq/clk.c +++ b/arch/mips/lantiq/clk.c @@ -130,6 +130,9 @@ EXPORT_SYMBOL(clk_enable); void clk_disable(struct clk *clk) { + if (IS_ERR_OR_NULL(clk)) + return; + if (unlikely(!clk_good(clk))) return; diff --git a/drivers/sh/clk/core.c b/drivers/sh/clk/core.c index 92863e3..9978fa4 100644 --- a/drivers/sh/clk/core.c +++ b/drivers/sh/clk/core.c @@ -252,7 +252,7 @@ void clk_disable(struct clk *clk) { unsigned long flags; - if (!clk) + if (IS_ERR_OR_NULL(clk)) return; spin_lock_irqsave(&clock_lock, flags);