From patchwork Fri Sep 18 13:22:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Leizhen \(ThunderTown\)" X-Patchwork-Id: 313189 Delivered-To: patch@linaro.org Received: by 2002:a92:5ad1:0:0:0:0:0 with SMTP id b78csp1333254ilg; Fri, 18 Sep 2020 06:23:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzc0ux6IrjzKG2XW3QPLTDn3GjCxaXnaxkqWjWcLj3OYNfloGg1XT3OC4FIEWvbTjoOIK06 X-Received: by 2002:a05:6402:17fc:: with SMTP id t28mr38561054edy.244.1600435395170; Fri, 18 Sep 2020 06:23:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600435395; cv=none; d=google.com; s=arc-20160816; b=uwUbi3jZq55uqls39ECDTXtdtL00VXuPmcBPezmDjhRQYt1f/Lo5fhQZbLzowWmzBc S7uwuacR8ZZLRbf1YNiLBwbeINz2vJhhEsi+7FpaDO+EjHxLy1qqsxCJ/fXNxzmbVcHU qyNc/T6iMggal+igrgF+7wG2lRTbbKaI+hl/dm5tp82uF16YOxGl87zmBgXIu89Pmitd iAPTT1S66qbS7V+j582KK0Fa5YVdUdD6XF0Wd15KbXxQvM83OyDTb0P+wDXQ5H0KGbTL an0JVBN/dRGei220Xa0SCo/58rlq9M5AoQD7b+fb1aQFZuA2EP01ldPIktBIrvHU8tH3 0flw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Wm2ja0ywcREULPypt/DxvBVz7jxDFM+ZjJ9C1LJ9Paw=; b=fINU68yMKvEeZBq4Btr7xEMGyxYSoPI1O2lOJ8Uxa3psrgCQJMJIkMdH33CCnxaMMX 0F86gDy7FMb1UC9ZL10j38EoKxQEE6Y9tYFo0XMXgoV9AHK6z0lXWZUXDA2Tnae57vBi Js49Y9Zn6rNwohhVxIBG6zAI6zcNsArQdMM1I033rQy1jL/X9FUGK7/VuN+aN+NFnDu/ I0z7PGUdeskn8/cmgCki6i0VelTpMPwyNnnUxTfCrZhB+AhKnszZ8lt9RiGq8YF+8SEa sGnDRGvnkJ2Mt1p/3LXM4YbmMeCOEY2t/JmislBSKYg9Y06bNYAGvZFwPjwwgE1+09tV WapA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si2160452ejn.61.2020.09.18.06.23.15; Fri, 18 Sep 2020 06:23:15 -0700 (PDT) Received-SPF: pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of devicetree-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726683AbgIRNXM (ORCPT + 6 others); Fri, 18 Sep 2020 09:23:12 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:13306 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726121AbgIRNXL (ORCPT ); Fri, 18 Sep 2020 09:23:11 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 7661B4A67D1F7224016B; Fri, 18 Sep 2020 21:23:08 +0800 (CST) Received: from thunder-town.china.huawei.com (10.174.177.253) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Fri, 18 Sep 2020 21:22:58 +0800 From: Zhen Lei To: Rob Herring , devicetree , Daniel Lezcano , Thomas Gleixner , Haojian Zhuang , linux-kernel CC: Zhen Lei , Libin , Kefeng Wang , Jianguo Chen Subject: [PATCH v3 1/9] clocksource: sp804: cleanup clk_get_sys() Date: Fri, 18 Sep 2020 21:22:29 +0800 Message-ID: <20200918132237.3552-2-thunder.leizhen@huawei.com> X-Mailer: git-send-email 2.26.0.windows.1 In-Reply-To: <20200918132237.3552-1-thunder.leizhen@huawei.com> References: <20200918132237.3552-1-thunder.leizhen@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.174.177.253] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org From: Kefeng Wang Move the clk_get_sys() part into sp804_get_clock_rate(), cleanup the same code. Signed-off-by: Kefeng Wang Signed-off-by: Zhen Lei --- drivers/clocksource/timer-sp804.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) -- 1.8.3 diff --git a/drivers/clocksource/timer-sp804.c b/drivers/clocksource/timer-sp804.c index 5cd0abf9b3965fe..bec2d372e0df018 100644 --- a/drivers/clocksource/timer-sp804.c +++ b/drivers/clocksource/timer-sp804.c @@ -22,11 +22,18 @@ #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: %s clock not found: %ld\n", name, PTR_ERR(clk)); + return PTR_ERR(clk); + } + err = clk_prepare(clk); if (err) { pr_err("sp804: clock failed to prepare: %d\n", err); @@ -72,16 +79,7 @@ int __init __sp804_clocksource_and_sched_clock_init(void __iomem *base, { 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 PTR_ERR(clk); - } - } - - rate = sp804_get_clock_rate(clk); + rate = sp804_get_clock_rate(clk, name); if (rate < 0) return -EINVAL; @@ -173,15 +171,7 @@ int __init __sp804_clockevents_init(void __iomem *base, unsigned int irq, struct 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 PTR_ERR(clk); - } - - rate = sp804_get_clock_rate(clk); + rate = sp804_get_clock_rate(clk, name); if (rate < 0) return -EINVAL;