From patchwork Sat May 28 09:33:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kefeng Wang X-Patchwork-Id: 68790 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp508675qge; Sat, 28 May 2016 02:36:28 -0700 (PDT) X-Received: by 10.66.229.33 with SMTP id sn1mr29185478pac.49.1464428188446; Sat, 28 May 2016 02:36:28 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xs2si34972718pab.43.2016.05.28.02.36.28; Sat, 28 May 2016 02:36:28 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752574AbcE1Jf3 (ORCPT + 30 others); Sat, 28 May 2016 05:35:29 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:37430 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751231AbcE1Jf1 (ORCPT ); Sat, 28 May 2016 05:35:27 -0400 Received: from 172.24.1.47 (EHLO SZXEML423-HUB.china.huawei.com) ([172.24.1.47]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CCH96853; Sat, 28 May 2016 17:35:13 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by SZXEML423-HUB.china.huawei.com (10.82.67.154) with Microsoft SMTP Server id 14.3.235.1; Sat, 28 May 2016 17:35:00 +0800 From: Kefeng Wang To: Thomas Gleixner , Daniel Lezcano , Rob Herring CC: , , , , Sudeep Holla , Arnd Bergmann , Subject: [PATCH 1/4] clocksource: sp804: cleanup clk_get_sys() Date: Sat, 28 May 2016 17:33:50 +0800 Message-ID: <1464428033-52106-2-git-send-email-wangkefeng.wang@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1464428033-52106-1-git-send-email-wangkefeng.wang@huawei.com> References: <1464428033-52106-1-git-send-email-wangkefeng.wang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020205.57496652.00A2, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 714d7ea93a5db976eba2fbb87f6707ac Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move the clk_get_sys() part into sp804_get_clock_rate(), cleanup the same code. Signed-off-by: Kefeng Wang --- drivers/clocksource/timer-sp804.c | 34 +++++++++++----------------------- 1 file changed, 11 insertions(+), 23 deletions(-) -- 1.7.12.4 diff --git a/drivers/clocksource/timer-sp804.c b/drivers/clocksource/timer-sp804.c index 5f45b9a..362e5d0 100644 --- a/drivers/clocksource/timer-sp804.c +++ b/drivers/clocksource/timer-sp804.c @@ -34,11 +34,19 @@ #include "timer-sp.h" -static long __init sp804_get_clock_rate(struct clk *clk) +static long __init sp804_get_clock_rate(struct clk *clk, const char *name) { long rate; int err; + if (!clk) { + clk = clk_get_sys("sp804", name); + if (IS_ERR(clk)) { + pr_err("sp804: clock not found: %ld\n", PTR_ERR(clk)); + return PTR_ERR(clk); + } + } + err = clk_prepare(clk); if (err) { pr_err("sp804: clock failed to prepare: %d\n", err); @@ -82,18 +90,7 @@ void __init __sp804_clocksource_and_sched_clock_init(void __iomem *base, struct clk *clk, int use_sched_clock) { - long rate; - - if (!clk) { - clk = clk_get_sys("sp804", name); - if (IS_ERR(clk)) { - pr_err("sp804: clock not found: %d\n", - (int)PTR_ERR(clk)); - return; - } - } - - rate = sp804_get_clock_rate(clk); + long rate = sp804_get_clock_rate(clk, name); if (rate < 0) return; @@ -189,17 +186,8 @@ static struct irqaction sp804_timer_irq = { void __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struct clk *clk, const char *name) { struct clock_event_device *evt = &sp804_clockevent; - long rate; - - if (!clk) - clk = clk_get_sys("sp804", name); - if (IS_ERR(clk)) { - pr_err("sp804: %s clock not found: %d\n", name, - (int)PTR_ERR(clk)); - return; - } + long rate = sp804_get_clock_rate(clk, name); - rate = sp804_get_clock_rate(clk); if (rate < 0) return;