From patchwork Sun Nov 8 22:36:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 56176 Delivered-To: patch@linaro.org Received: by 10.112.1.169 with SMTP id 9csp162302lbn; Sun, 8 Nov 2015 14:39:06 -0800 (PST) X-Received: by 10.67.5.2 with SMTP id ci2mr23912414pad.47.1447022343103; Sun, 08 Nov 2015 14:39:03 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qu10si17945119pbb.181.2015.11.08.14.39.02; Sun, 08 Nov 2015 14:39:03 -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 S1752404AbbKHWin (ORCPT + 28 others); Sun, 8 Nov 2015 17:38:43 -0500 Received: from mail-wi0-f171.google.com ([209.85.212.171]:34703 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751807AbbKHWhs (ORCPT ); Sun, 8 Nov 2015 17:37:48 -0500 Received: by wikq8 with SMTP id q8so58085462wik.1 for ; Sun, 08 Nov 2015 14:37:47 -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=uZO43NhYQ5BM2z5mPp+iB0e3u4R41yRtSd1KTFlZOZU=; b=HaPX8H/EksjRjnvfe7S0PVgSFLqNF+toH5rCG77hjJUW4IkmqN5TAEX8r82RJat4j0 FuPgfAWWFta2xOVDFygbSUgkuVPzSiOO84ibLQspV5//kHlyQGkKsP6QRIbdgid2cbpg xl2d+AB71WBWTazWBtYMOArC+SlBuyBPKDwuvTGjFNLlavBQR5NCW8zfrYpZXFXJADxs d5vvMdmPf2daRAMQTBZaWf3Oh8TpkIw1U+jk12sbQAQ9BX1P24Ju6+8Fx2SouHkcULGI kfqXMpXPXgkd1aLMpRECAcsJpBvfdCqrWWuTvuOVzDP0vE+hjFET5KY4m+JBWMVFM9IP FaHQ== 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=uZO43NhYQ5BM2z5mPp+iB0e3u4R41yRtSd1KTFlZOZU=; b=GTt+4dCu4nuszIJ71D013BUtnH35K0MOSBQ7C3xiiXo1SJH4ankivVqdnplrqq8lue 95jk/A0nXfkMOF1naFMu3fewqnkFZxf37h5gw3dBDOHbRBcNSsbsGH5d2p72+ZSlu9YH MBwivnIgT3hfA9ZA5SQBdR1NWf3Yb9bm492V51kWu/HapDR3P0X7X0zzgBeAQbgEy2Vm bg8uFsAaUIlDCmjVB5XtQe1sqscmnoWEHrljDy6F8IEdDz8vy8dh45NUkdajbQOI+A4P vivLPPLtJVI8fcBadEhk/Qjz46K6YPqksIlShUrYy9cgrAp7r1lBYIkXiE4r3XtpfwuD sZ9Q== X-Gm-Message-State: ALoCoQlwShSFd62jvq4rYfORRnzdAp4f2qCt/g3eBucZZzx908l2pzQImV87mbjXbPtsvqWFAimq X-Received: by 10.194.6.40 with SMTP id x8mr25210666wjx.50.1447022267599; Sun, 08 Nov 2015 14:37:47 -0800 (PST) Received: from localhost.localdomain ([78.210.255.2]) by smtp.gmail.com with ESMTPSA id n17sm10912746wmg.17.2015.11.08.14.37.46 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 08 Nov 2015 14:37:47 -0800 (PST) From: Daniel Lezcano To: daniel.lezcano@linaro.org, ysato@users.sourceforge.jp Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp (moderated list:H8/300 ARCHITECTURE) Subject: [RFC PATCH 10/10] clocksource/drivers/h8300_timer8: Retrieve the clock rate at init time Date: Sun, 8 Nov 2015 23:36:39 +0100 Message-Id: <1447022199-4648-10-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1447022199-4648-1-git-send-email-daniel.lezcano@linaro.org> References: <1447022199-4648-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 cf0feee..020f109 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; writew(0xffff, p->mapbase + TCORA); writew(0x0000, p->mapbase + _8TCNT); writew(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: