From patchwork Wed Aug 24 17:26:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 74625 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp429530qga; Wed, 24 Aug 2016 10:31:20 -0700 (PDT) X-Received: by 10.66.132.11 with SMTP id oq11mr7866465pab.4.1472059880365; Wed, 24 Aug 2016 10:31:20 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id i6si10521192pax.186.2016.08.24.10.31.20 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 24 Aug 2016 10:31:20 -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.85_2 #1 (Red Hat Linux)) id 1bcbzB-0003kQ-BX; Wed, 24 Aug 2016 17:29:09 +0000 Received: from conuserg-12.nifty.com ([210.131.2.79]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bcbyH-0003Yc-FQ for linux-arm-kernel@lists.infradead.org; Wed, 24 Aug 2016 17:28:14 +0000 Received: from grover.sesame (FL1-119-242-215-193.osk.mesh.ad.jp [119.242.215.193]) (authenticated) by conuserg-12.nifty.com with ESMTP id u7OHR1nU023395; Thu, 25 Aug 2016 02:27:04 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com u7OHR1nU023395 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1472059625; bh=4Yy85OpQGJ8YZusk7u04eMv9UZ4mwlBvVpR4E8GCCk4=; h=From:To:Cc:Subject:Date:From; b=N7aZcYhf4B5YOVvSMleMje187W7ZRInAEFsdWlzuF9qzjbnmXDv7WNPUrulQ5Th3+ AGzFrJnjPq29cOYGuaZg7KyTf6fMJ8f0Bpas00hpzyjHcXb8Urt3wb8YuaS5n43ju/ oKDXSGSoDC6KIgJFJg0PF2oM5LfRmcaznSdDZxN3d9nQmjgav5F+G2WSugHR+HuxO4 9TBDGKrcq8V7ATyg3iSW/hhP6jIyFQVw+GpHY5dGEIRbC1ocORWtBr+vp0rv5K45c7 K/CGKuDLozL8nbxh2EDgZANSojFiwtobSe42zf3mEI5jf69RT2Am7Opa+fEiMVC5Ud A6POT6GPd8Ckw== X-Nifty-SrcIP: [119.242.215.193] From: Masahiro Yamada To: linux-clk@vger.kernel.org Subject: [PATCH v3] clk: let clk_disable() return immediately if clk is NULL Date: Thu, 25 Aug 2016 02:26:53 +0900 Message-Id: <1472059613-30551-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-20160824_102813_925475_299E783A X-CRM114-Status: GOOD ( 10.26 ) 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_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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, Florian Fainelli , Eric Miao , Wan ZongShun , Steven Miao , Russell King , Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, Haojian Zhuang , adi-buildroot-devel@lists.sourceforge.net, Masahiro Yamada , linux-m68k@lists.linux-m68k.org, bcm-kernel-feedback-list@broadcom.com, Ralf Baechle , Geert Uytterhoeven , Greg Ungerer , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Many of clk_disable() implementations just return for NULL pointer, but this check is missing from some. Let's make it tree-wide consistent. It will allow clock consumers to call clk_disable() without NULL pointer check. Signed-off-by: Masahiro Yamada Acked-by: Greg Ungerer Acked-by: Wan Zongshun --- I came back after a long pause. You can see the discussion about the previous version: https://www.linux-mips.org/archives/linux-mips/2016-04/msg00063.html Changes in v3: - Return only when clk is NULL. Do not take care of error pointer. Changes in v2: - Rebase on Linux 4.6-rc1 arch/arm/mach-mmp/clock.c | 3 +++ 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 +++ 5 files changed, 16 insertions(+) -- 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-mmp/clock.c b/arch/arm/mach-mmp/clock.c index ac6633d..28fe64c 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 (!clk) + return; + WARN_ON(clk->enabled == 0); spin_lock_irqsave(&clocks_lock, flags); diff --git a/arch/arm/mach-w90x900/clock.c b/arch/arm/mach-w90x900/clock.c index 2c371ff..ac6fd1a 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 (!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..392a59b 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 (!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..1e3c7e9 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 (!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..b49fc9c 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 (!clk) + return; + mutex_lock(&clocks_mutex); clk_disable_unlocked(clk); mutex_unlock(&clocks_mutex);