From patchwork Mon Nov 9 10:06:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 56205 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp91521lbb; Mon, 9 Nov 2015 02:09:36 -0800 (PST) X-Received: by 10.68.65.6 with SMTP id t6mr19799684pbs.90.1447063776115; Mon, 09 Nov 2015 02:09:36 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qd3si20243988pab.208.2015.11.09.02.09.35; Mon, 09 Nov 2015 02:09:36 -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.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753226AbbKIKJe (ORCPT + 28 others); Mon, 9 Nov 2015 05:09:34 -0500 Received: from mail-wi0-f170.google.com ([209.85.212.170]:38228 "EHLO mail-wi0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751185AbbKIKHZ (ORCPT ); Mon, 9 Nov 2015 05:07:25 -0500 Received: by wicli17 with SMTP id li17so12069867wic.1 for ; Mon, 09 Nov 2015 02:07:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cyZL6LoTvfjfnIAmyFlfjt8g2IhkiN4UtWJdnXLRJAs=; b=KYfCeOdzXx7OTJHjV8YpR0kpjWBxY8AVv8YXogceznOtnEhR/HLsldi/Vu/VmgTP5B nRbbFY9ef9DQKChr9BhK+gbHvKqtd1k0Q3wJV8PTruodNilY2gl3C7umsFHTWqsUFweH PoO7aUKGDUW+QpannZ0QTayo7NFp1jRknt0GYlRO2VF+yFTzeffD3mpCVJGM3+0cOKpc Uv33G6gEd83GIZKFgQG0nvTud3P1HqBUTLu3lrUXegrMD01O9oLUQtwXtJukGOIgu9QC Ge3FaWQl6MV/MNy8vEmw9CRW9D/4MViOTYOUwRfpKDUY+Afb2tPn0knZe/m9zQ6cV8s1 rGsw== 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=PtS/3rp89VjZj0Kh8iaaJaHS6TO26YG9efnhoNkuTM113R1jImDSR1Eix6L/u0dpR9 80UfXwaNBHhNy5TR89svpX1R0LyqdTLp5/JKzApbXwEbKwAh/UJatpK2g1Wc1583f2+A MEN5Ul25u29/MyKNqYJ1e1KbJh+SsnXLuVEL+vIcIGE6fSj4j3PphG3tUgnHmTaxvCd7 19+QfQvFNxXOHwhFg+PzNY0fyv20EHel2qyoq00wGlpaoM/zroTYKqVfd0c16+XKB2TW cOqTqEmEIhZwWQJVm93LQh7pfnTilJiuVacwSGfF3eiR/qY8F6d57hEDr6gN9N9Y+Zax OHgA== X-Gm-Message-State: ALoCoQmY3ZcKdYmUGxOSt+TIDljhcn3zyfHzJ827L+ID6+JVcsv596p/3MifpLEdRFU34t2Zca0S X-Received: by 10.194.116.100 with SMTP id jv4mr27842600wjb.67.1447063644666; Mon, 09 Nov 2015 02:07:24 -0800 (PST) Received: from localhost.localdomain (sju31-1-78-210-255-2.fbx.proxad.net. [78.210.255.2]) by smtp.gmail.com with ESMTPSA id t126sm13384201wmd.23.2015.11.09.02.07.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 09 Nov 2015 02:07:24 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org Cc: ysato@users.sourceforge.jp, tglx@linutronix.de, linux-kernel@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp (moderated list:H8/300 ARCHITECTURE) Subject: [PATCH 10/15] clocksource/drivers/h8300_timer8: Retrieve the clock rate at init time Date: Mon, 9 Nov 2015 11:06:48 +0100 Message-Id: <1447063614-4662-10-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447063614-4662-1-git-send-email-daniel.lezcano@linaro.org> References: <1447063614-4662-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: