diff options
author | Tomasz Figa <tomasz.figa@gmail.com> | 2014-01-11 16:39:01 -0500 |
---|---|---|
committer | Chris Ball <chris@printf.net> | 2014-03-03 10:21:32 -0500 |
commit | 8880a4a526340335403696f30daf4e05a413f3bd (patch) | |
tree | 7f83dbbb7f54132ae75d30bda5359ef3808f9107 /drivers/mmc | |
parent | d9c3f5df539a8a74cc830b35838670fe0541fed1 (diff) |
mmc: sdhci-s3c: Use shifts to divide by powers of two
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 <tomasz.figa@gmail.com>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Jaehoon Chung <jh80.chung@samsung.com>
Acked-by; Jaehoon Chung <jh80.chung@samsung.com>
Signed-off-by: Chris Ball <chris@printf.net>
Diffstat (limited to 'drivers/mmc')
-rw-r--r-- | drivers/mmc/host/sdhci-s3c.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c index 6debda952155..52770d58cc47 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, | |||
144 | { | 144 | { |
145 | unsigned long rate; | 145 | unsigned long rate; |
146 | struct clk *clksrc = ourhost->clk_bus[src]; | 146 | struct clk *clksrc = ourhost->clk_bus[src]; |
147 | int div; | 147 | int shift; |
148 | 148 | ||
149 | if (!clksrc) | 149 | if (!clksrc) |
150 | return UINT_MAX; | 150 | return UINT_MAX; |
@@ -160,15 +160,15 @@ static unsigned int sdhci_s3c_consider_clock(struct sdhci_s3c *ourhost, | |||
160 | 160 | ||
161 | rate = clk_get_rate(clksrc); | 161 | rate = clk_get_rate(clksrc); |
162 | 162 | ||
163 | for (div = 1; div < 256; div *= 2) { | 163 | for (shift = 0; shift < 8; ++shift) { |
164 | if ((rate / div) <= wanted) | 164 | if ((rate >> shift) <= wanted) |
165 | break; | 165 | break; |
166 | } | 166 | } |
167 | 167 | ||
168 | dev_dbg(&ourhost->pdev->dev, "clk %d: rate %ld, want %d, got %ld\n", | 168 | dev_dbg(&ourhost->pdev->dev, "clk %d: rate %ld, want %d, got %ld\n", |
169 | src, rate, wanted, rate / div); | 169 | src, rate, wanted, rate >> shift); |
170 | 170 | ||
171 | return wanted - (rate / div); | 171 | return wanted - (rate >> shift); |
172 | } | 172 | } |
173 | 173 | ||
174 | /** | 174 | /** |