From patchwork Sat Jan 11 21:39:01 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomasz Figa X-Patchwork-Id: 3470461 Return-Path: X-Original-To: patchwork-linux-samsung-soc@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 F2E339F39C for ; Sat, 11 Jan 2014 21:39:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2925C20123 for ; Sat, 11 Jan 2014 21:39:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BAF620127 for ; Sat, 11 Jan 2014 21:39:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751016AbaAKVjX (ORCPT ); Sat, 11 Jan 2014 16:39:23 -0500 Received: from mail-ee0-f53.google.com ([74.125.83.53]:48082 "EHLO mail-ee0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750940AbaAKVjW (ORCPT ); Sat, 11 Jan 2014 16:39:22 -0500 Received: by mail-ee0-f53.google.com with SMTP id b57so2508724eek.12 for ; Sat, 11 Jan 2014 13:39:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=i8Mi/BLXukF3WGKwAzoKRXtnagRA2qcQ7zf36+hZuFg=; b=a96G8ECpq/zFkGJFyUxaxQqRKVmVyZC2DjPCTqn7YjNuluYfYmGTphD0Iq0T1w94lI P4RGI3jrtcs/UTAdHRbxo2BsVr/Oq8dBYLfbcXmg+Xg/xqivjgpuuwaYdHjIOCXY3F4Q mU62ysU6KIFxj3SZ2aafgqIQxQ2wOl9UIiOkvjzwcODstlM0cK0GRJmYrvSqQmMU77dn 2Q8npmq+FiJn1OKVadk7jrX6cWtiVsItw4q9rUl2xq3H0zWhzP81yVlrTwEix6KoaEWX wxJJpwrHNJM8eDXsEOBHCjGv/GlWaHAOcT8In9wm+lrk1XhPEq9wUaFZr6yWEyGGeiCJ eDXQ== X-Received: by 10.15.42.133 with SMTP id u5mr17726700eev.47.1389476360750; Sat, 11 Jan 2014 13:39:20 -0800 (PST) Received: from flatron.tomeq (87-207-52-162.dynamic.chello.pl. [87.207.52.162]) by mx.google.com with ESMTPSA id p45sm26014591eeg.1.2014.01.11.13.39.19 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Jan 2014 13:39:20 -0800 (PST) From: Tomasz Figa To: linux-mmc@vger.kernel.org Cc: linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ben Dooks , Chris Ball , Jaehoon Chung , Seungwon Jeon , Marek Szyprowski , Tomasz Figa Subject: [PATCH 1/6] mmc: sdhci-s3c: Use shifts to divide by powers of two Date: Sat, 11 Jan 2014 22:39:01 +0100 Message-Id: <1389476346-20396-2-git-send-email-tomasz.figa@gmail.com> X-Mailer: git-send-email 1.8.5.2 In-Reply-To: <1389476346-20396-1-git-send-email-tomasz.figa@gmail.com> References: <1389476346-20396-1-git-send-email-tomasz.figa@gmail.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 Current implementation of sdhci_s3c_consider_clock() is highly inefficient due to multiple integer divisions by variable performed in a loop. Since only divisors that are powers of two are considered, this patch replaces them with respective shifts, removing all the integer divisions. Signed-off-by: Tomasz Figa --- drivers/mmc/host/sdhci-s3c.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index 6debda9..52770d5 100644 --- a/drivers/mmc/host/sdhci-s3c.c +++ b/drivers/mmc/host/sdhci-s3c.c @@ -144,7 +144,7 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost, { unsigned long rate; struct clk *clksrc = ourhost->clk_bus[src]; - int div; + int shift; if (!clksrc) return UINT_MAX; @@ -160,15 +160,15 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost, rate = clk_get_rate(clksrc); - for (div = 1; div < 256; div *= 2) { - if ((rate / div) <= wanted) + for (shift = 0; shift < 8; ++shift) { + if ((rate >> shift) <= wanted) break; } dev_dbg(&ourhost->pdev->dev, "clk %d: rate %ld, want %d, got %ld\n", - src, rate, wanted, rate / div); + src, rate, wanted, rate >> shift); - return wanted - (rate / div); + return wanted - (rate >> shift); } /**