From patchwork Fri Dec 18 14:18:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 58708 Delivered-To: patch@linaro.org Received: by 10.112.89.199 with SMTP id bq7csp1061917lbb; Fri, 18 Dec 2015 06:29:26 -0800 (PST) X-Received: by 10.66.155.197 with SMTP id vy5mr5577879pab.109.1450448966131; Fri, 18 Dec 2015 06:29:26 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id rz7si2075470pab.124.2015.12.18.06.29.23; Fri, 18 Dec 2015 06:29:26 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933161AbbLRO3V (ORCPT + 29 others); Fri, 18 Dec 2015 09:29:21 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:36607 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932582AbbLROTa (ORCPT ); Fri, 18 Dec 2015 09:19:30 -0500 Received: by mail-wm0-f51.google.com with SMTP id p187so65517060wmp.1 for ; Fri, 18 Dec 2015 06:19:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cyZL6LoTvfjfnIAmyFlfjt8g2IhkiN4UtWJdnXLRJAs=; b=YBVv0dtd2UBs7HDxw6EbxfNChXDW3GCEMdRRsjXP+A00lSfVbsX6WHJI+WgUUuu7rE so0XLNqajJqsRMrOVtS7buSL1sw9AYOYDV5iQc3rMRzbTEv/yjmojA6t7sMsMBY5o/ue PPEoccyqQ8tMyKM5BTJbZ0j8lKmrWpF4q3Ts0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cyZL6LoTvfjfnIAmyFlfjt8g2IhkiN4UtWJdnXLRJAs=; b=iJbyRs2PoXUSsz8rnXaQgXPx+fwQt5Fdk90gr5WdApOWWFiQrxyHGJzzc09LpgOE5D IxN4HVSulITSdcraNLtrbYvmlOaTZGI2+hZwwZhoWYunwfpPmGyqp6zSubCvLHIRueXu LowtPhRF6S+nT/wqNlRgnYwEfB5osMIDI/1fXLks5tS6TbH7b+9B04xdiziTMDy1wsEE AxDWaoQvyAWB6d2cR4u+6vO8+hweXtvpt4xbx/3rsB8LPvVsVcU69b8g4iBfAOqpWo+c 2AY0Mi/N2Q8M83jexm5eLXGKcuEpcfm4lDLGc01owamEeYq2sWke1994hXBn1bZJVmao r4pQ== X-Gm-Message-State: ALoCoQmVT/DXz38awNRvpSsVNEIFBk7X9GdsuajIVv9GFXU29Rc51/KWzi/L1mJ+Ybvp5m988yvt5G6joZPlUYHuwu+/yT1U9A== X-Received: by 10.194.133.233 with SMTP id pf9mr4352702wjb.71.1450448369265; Fri, 18 Dec 2015 06:19:29 -0800 (PST) Received: from localhost.localdomain ([78.210.255.2]) by smtp.gmail.com with ESMTPSA id ql10sm15010027wjc.23.2015.12.18.06.19.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 18 Dec 2015 06:19:28 -0800 (PST) From: Daniel Lezcano To: tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, mingo@kernel.org, Yoshinori Sato , uclinux-h8-devel@lists.sourceforge.jp (moderated list:H8/300 ARCHITECTURE) Subject: [PATCH 47/69] clocksource/drivers/h8300_timer8: Retrieve the clock rate at init time Date: Fri, 18 Dec 2015 15:18:00 +0100 Message-Id: <1450448302-27429-47-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1450448302-27429-1-git-send-email-daniel.lezcano@linaro.org> References: <5672CB9E.7090707@linaro.org> <1450448302-27429-1-git-send-email-daniel.lezcano@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current code retrieves the rate value when the timer is enabled which occurs each time a timer is re-armed. Except if the clock frequency has changed magically I don't see why this should be done each time. Retrieve the clock rate value at init time only. Signed-off-by: Daniel Lezcano --- drivers/clocksource/h8300_timer8.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/drivers/clocksource/h8300_timer8.c b/drivers/clocksource/h8300_timer8.c index 24d91b1..187c416 100644 --- a/drivers/clocksource/h8300_timer8.c +++ b/drivers/clocksource/h8300_timer8.c @@ -34,7 +34,6 @@ struct timer8_priv { unsigned long flags; unsigned int rate; unsigned int tcora; - struct clk *pclk; }; static unsigned long timer8_get_counter(struct timer8_priv *p) @@ -92,7 +91,6 @@ static void timer8_set_next(struct timer8_priv *p, unsigned long delta) static int timer8_enable(struct timer8_priv *p) { - p->rate = clk_get_rate(p->pclk) / SCALE; ctrl_outw(0xffff, p->mapbase + TCORA); ctrl_outw(0x0000, p->mapbase + _8TCNT); ctrl_outw(0x0c02, p->mapbase + _8TCR); @@ -102,16 +100,15 @@ static int timer8_enable(struct timer8_priv *p) static int timer8_start(struct timer8_priv *p) { - int ret = 0; + int ret; - if (!(p->flags & FLAG_STARTED)) - ret = timer8_enable(p); + if ((p->flags & FLAG_STARTED)) + return 0; - if (ret) - goto out; - p->flags |= FLAG_STARTED; + ret = timer8_enable(p); + if (!ret) + p->flags |= FLAG_STARTED; - out: return ret; } @@ -217,7 +214,12 @@ static void __init h8300_8timer_init(struct device_node *node) } timer8_priv.mapbase = (unsigned long)base; - timer8_priv.pclk = clk; + + rate = clk_get_rate(clk) / SCALE; + if (!rate) { + pr_err("Failed to get rate for the clocksource\n"); + goto unmap_reg; + } ret = request_irq(irq, timer8_interrupt, IRQF_TIMER, timer8_priv.ced.name, &timer8_priv); @@ -225,10 +227,10 @@ static void __init h8300_8timer_init(struct device_node *node) pr_err("failed to request irq %d for clockevent\n", irq); goto unmap_reg; } - rate = clk_get_rate(clk) / SCALE; + clockevents_config_and_register(&timer8_priv.ced, rate, 1, 0x0000ffff); - return; + return; unmap_reg: iounmap(base); free_clk: