From patchwork Mon May 31 09:09:54 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aurelien Jarno X-Patchwork-Id: 103253 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4V9gDdS022306 for ; Mon, 31 May 2010 09:42:13 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756736Ab0EaJmM (ORCPT ); Mon, 31 May 2010 05:42:12 -0400 Received: from hall.aurel32.net ([88.191.82.174]:53762 "EHLO hall.aurel32.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756608Ab0EaJmM (ORCPT ); Mon, 31 May 2010 05:42:12 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Mon, 31 May 2010 09:42:13 +0000 (UTC) X-Greylist: delayed 1923 seconds by postgrey-1.27 at vger.kernel.org; Mon, 31 May 2010 05:42:12 EDT Received: from [2a01:e35:2e80:2fb0:21e:8cff:feb0:693b] (helo=volta.aurel32.net) by hall.aurel32.net with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1OJ10Z-0003fh-T4; Mon, 31 May 2010 11:10:07 +0200 Received: from aurel32 by volta.aurel32.net with local (Exim 4.71) (envelope-from ) id 1OJ10U-000389-LF; Mon, 31 May 2010 11:10:02 +0200 From: Aurelien Jarno To: Paul Mundt Cc: linux-sh@vger.kernel.org, Aurelien Jarno Subject: [PATCH] sh_tmu: compute mult and shift before registration Date: Mon, 31 May 2010 11:09:54 +0200 Message-Id: <1275296994-12005-1-git-send-email-aurelien@aurel32.net> X-Mailer: git-send-email 1.7.1 Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 8e44e14..e9e35aa 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c @@ -199,16 +199,8 @@ static cycle_t sh_tmu_clocksource_read(struct clocksource *cs) static int sh_tmu_clocksource_enable(struct clocksource *cs) { struct sh_tmu_priv *p = cs_to_sh_tmu(cs); - int ret; - - ret = sh_tmu_enable(p); - if (ret) - return ret; - /* TODO: calculate good shift from rate and counter bit width */ - cs->shift = 10; - cs->mult = clocksource_hz2mult(p->rate, cs->shift); - return 0; + return sh_tmu_enable(p); } static void sh_tmu_clocksource_disable(struct clocksource *cs) @@ -228,6 +220,10 @@ static int sh_tmu_register_clocksource(struct sh_tmu_priv *p, cs->disable = sh_tmu_clocksource_disable; cs->mask = CLOCKSOURCE_MASK(32); cs->flags = CLOCK_SOURCE_IS_CONTINUOUS; + /* TODO: calculate good shift from rate and counter bit width */ + cs->shift = 10; + /* channel will be configured at parent clock / 4 */ + cs->mult = clocksource_hz2mult(clk_get_rate(p->clk) / 4, cs->shift); dev_info(&p->pdev->dev, "used as clock source\n"); clocksource_register(cs); return 0;