summaryrefslogtreecommitdiff
path: root/arch/arm/plat-s3c24xx
diff options
context:
space:
mode:
authorHeiko Stuebner <heiko@sntech.de>2011-10-14 15:08:56 +0900
committerKukjin Kim <kgene.kim@samsung.com>2011-10-14 15:15:52 +0900
commitf9f7c7503f7002deffe4cb8409ccada075a52522 (patch)
tree6613230fdc583300e66be800d9debd0b38890052 /arch/arm/plat-s3c24xx
parent5f33bd76f5c4df45cd5b2e4132c6451dac8afee9 (diff)
downloadlinux-3.10-f9f7c7503f7002deffe4cb8409ccada075a52522.tar.gz
linux-3.10-f9f7c7503f7002deffe4cb8409ccada075a52522.tar.bz2
linux-3.10-f9f7c7503f7002deffe4cb8409ccada075a52522.zip
ARM: S3C2443: handle unset armdiv values gracefully
The armdiv array may contain unset divider values. Check the relevant value to prevent division by zero errors. Also check for set nr_armdiv and armdivmask before meddling with clkdiv0. Signed-off-by: Heiko Stuebner <heiko@sntech.de> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'arch/arm/plat-s3c24xx')
-rw-r--r--arch/arm/plat-s3c24xx/s3c2443-clock.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/arch/arm/plat-s3c24xx/s3c2443-clock.c b/arch/arm/plat-s3c24xx/s3c2443-clock.c
index fea3d5c0252..31f97f1bb36 100644
--- a/arch/arm/plat-s3c24xx/s3c2443-clock.c
+++ b/arch/arm/plat-s3c24xx/s3c2443-clock.c
@@ -179,11 +179,16 @@ static unsigned long s3c2443_armclk_roundrate(struct clk *clk,
unsigned div;
int ptr;
+ if (!nr_armdiv)
+ return -EINVAL;
+
for (ptr = 0; ptr < nr_armdiv; ptr++) {
div = armdiv[ptr];
- calc = parent / div;
- if (calc <= rate && div < best)
- best = div;
+ if (div) {
+ calc = parent / div;
+ if (calc <= rate && div < best)
+ best = div;
+ }
}
return parent / best;
@@ -195,6 +200,9 @@ static unsigned long s3c2443_armclk_getrate(struct clk *clk)
unsigned long clkcon0;
int val;
+ if (!nr_armdiv || !armdivmask)
+ return -EINVAL;
+
clkcon0 = __raw_readl(S3C2443_CLKDIV0);
clkcon0 &= armdivmask;
val = clkcon0 >> S3C2443_CLKDIV0_ARMDIV_SHIFT;
@@ -211,12 +219,17 @@ static int s3c2443_armclk_setrate(struct clk *clk, unsigned long rate)
int ptr;
int val = -1;
+ if (!nr_armdiv || !armdivmask)
+ return -EINVAL;
+
for (ptr = 0; ptr < nr_armdiv; ptr++) {
div = armdiv[ptr];
- calc = parent / div;
- if (calc <= rate && div < best) {
- best = div;
- val = ptr;
+ if (div) {
+ calc = parent / div;
+ if (calc <= rate && div < best) {
+ best = div;
+ val = ptr;
+ }
}
}