From patchwork Wed Mar 19 18:19:32 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Emilio_L=C3=B3pez?= X-Patchwork-Id: 3860101 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 50A919F369 for ; Wed, 19 Mar 2014 18:23:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6F4D3201BF for ; Wed, 19 Mar 2014 18:23:16 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 85E92200BE for ; Wed, 19 Mar 2014 18:23:15 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WQL7P-0002Yh-Pz; Wed, 19 Mar 2014 18:21:36 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WQL70-0003fr-23; Wed, 19 Mar 2014 18:21:10 +0000 Received: from yotta.elopez.com.ar ([2a00:1768:1004:d00d:c0de:4:f00d:cafe]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WQL6V-0003cJ-Ro for linux-arm-kernel@lists.infradead.org; Wed, 19 Mar 2014 18:20:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=elopez.com.ar; s=mail; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=J4orzPcRM9dtkTbnKThzT59JaQD7p4raZD7j2YpCNzg=; b=jQTQFm4Xl6DY7UIaoiTQk6SF4aIuFAWX55HciKFhR0XmIMEW+IFTyMULV3OHiFm7luu5vVoYfYL9PRVpXivLzjHh0jqtbpoypBKQAcYofSKHtt5oNB+7t1xpTTU5A404tYZEF3BCHFVsdXzWjiBvaXt9UJeMGT7vlP9OCA1gh53Qw/Qk7pZVXR9gHIxZMVaExeauD0QWdrW+i8p2gHpdRMWx0LznsnwBi2Qo0kdV2402cHZOJD58p07DJtZzGVkOjSoqzNKNCBn3cvSgr6XunPsKXxIBmDtaVVHV9M7OQgZIA+b0n+NRcHuM0r3xlUVLLrn7nmz6lvwp6Jjpdt2prQ==; Received: from 201-212-135-39.cab.prima.net.ar ([201.212.135.39] helo=desktop.lan) by yotta.elopez.com.ar with esmtpsa (TLS1.2:RSA_AES_128_CBC_SHA256:128) (Exim 4.82) id 1WQL6A-0006ra-9z; Wed, 19 Mar 2014 15:20:18 -0300 From: =?UTF-8?q?Emilio=20L=C3=B3pez?= To: Mike Turquette , Maxime Ripard Subject: [PATCH 3/4] clk: sunxi: fix some calculations Date: Wed, 19 Mar 2014 15:19:32 -0300 Message-Id: <1395253173-30437-4-git-send-email-emilio@elopez.com.ar> X-Mailer: git-send-email 1.9.0 In-Reply-To: <1395253173-30437-1-git-send-email-emilio@elopez.com.ar> References: <1395253173-30437-1-git-send-email-emilio@elopez.com.ar> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140319_142040_192276_19D89F62 X-CRM114-Status: UNSURE ( 8.28 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.0 (--) Cc: =?UTF-8?q?Emilio=20L=C3=B3pez?= , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some divisor calculations were misrounded, causing higher than requested rates on some clocks. Fix them up using DIV_ROUND_UP, and replace one homebrew instance of it as well with the right macro. Reported-by: Boris BREZILLON Signed-off-by: Emilio López --- drivers/clk/sunxi/clk-sunxi.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/clk/sunxi/clk-sunxi.c b/drivers/clk/sunxi/clk-sunxi.c index a393df1..0393f85 100644 --- a/drivers/clk/sunxi/clk-sunxi.c +++ b/drivers/clk/sunxi/clk-sunxi.c @@ -326,7 +326,7 @@ static void sun4i_get_apb1_factors(u32 *freq, u32 parent_rate, if (parent_rate < *freq) *freq = parent_rate; - parent_rate = (parent_rate + (*freq - 1)) / *freq; + parent_rate = DIV_ROUND_UP(parent_rate, *freq); /* Invalid rate! */ if (parent_rate > 32) @@ -371,7 +371,7 @@ static void sun4i_get_mod0_factors(u32 *freq, u32 parent_rate, if (*freq > parent_rate) *freq = parent_rate; - div = parent_rate / *freq; + div = DIV_ROUND_UP(parent_rate, *freq); if (div < 16) calcp = 0; @@ -412,7 +412,7 @@ static void sun7i_a20_get_out_factors(u32 *freq, u32 parent_rate, if (*freq > parent_rate) *freq = parent_rate; - div = parent_rate / *freq; + div = DIV_ROUND_UP(parent_rate, *freq); if (div < 32) calcp = 0;