pwm: atmel-tcb: fix max time computation for slow clk source
authorBoris BREZILLON <b.brezillon@overkiz.com>
Wed, 18 Sep 2013 15:06:21 +0000 (17:06 +0200)
committerThierry Reding <thierry.reding@gmail.com>
Thu, 19 Sep 2013 12:04:32 +0000 (14:04 +0200)
Use the the tcb counter width to compute the maximum time that can be
represented using the slow clock source instead of the static 16 bit width.

Signed-off-by: Boris BREZILLON <b.brezillon@overkiz.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-atmel-tcb.c

index 026696970d7797924fdba501b9c06283c27bc7c4..f3dcd02390f1b5da7d9cf43d3b053d3e6840bc0f 100644 (file)
@@ -307,7 +307,7 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
                i = slowclk;
                rate = 32768;
                min = div_u64(NSEC_PER_SEC, rate);
-               max = min << 16;
+               max = min << tc->tcb_config->counter_width;
 
                /* If period is too big return ERANGE error */
                if (max < period_ns)