atmel_pwm: set up only one PWM clock when allocating a clock
authorHans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
Thu, 24 Jul 2008 04:28:55 +0000 (21:28 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 24 Jul 2008 17:47:25 +0000 (10:47 -0700)
This patch will only setup one clock, if free, and return this clock to the
caller.  The previous solution would setup both clocks with the same prescaler
and divider and return PWM_CPR_CLKB, thus taking both clocks in the same call
without the caller knowing.

Signed-off-by: Hans-Christian Egtvedt <hans-christian.egtvedt@atmel.com>
Cc: David Brownell <david-b@pacbell.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/misc/atmel_pwm.c

index 5b5a14d..6aa5294 100644 (file)
@@ -211,8 +211,7 @@ int pwm_clk_alloc(unsigned prescale, unsigned div)
        if ((mr & 0xffff) == 0) {
                mr |= val;
                ret = PWM_CPR_CLKA;
-       }
-       if ((mr & (0xffff << 16)) == 0) {
+       } else if ((mr & (0xffff << 16)) == 0) {
                mr |= val << 16;
                ret = PWM_CPR_CLKB;
        }