iwlwifi: Rename 9560 to 9260 and add new PCI IDs for it
[cascardo/linux.git] / drivers / pwm / pwm-omap-dmtimer.c
index 54641e4..b7e6ecb 100644 (file)
@@ -49,11 +49,7 @@ to_pwm_omap_dmtimer_chip(struct pwm_chip *chip)
 
 static u32 pwm_omap_dmtimer_get_clock_cycles(unsigned long clk_rate, int ns)
 {
-       u64 c = (u64)clk_rate * ns;
-
-       do_div(c, NSEC_PER_SEC);
-
-       return c;
+       return DIV_ROUND_CLOSEST_ULL((u64)clk_rate * ns, NSEC_PER_SEC);
 }
 
 static void pwm_omap_dmtimer_start(struct pwm_omap_dmtimer_chip *omap)
@@ -106,7 +102,8 @@ static int pwm_omap_dmtimer_config(struct pwm_chip *chip,
        unsigned long clk_rate;
        bool timer_active;
 
-       dev_dbg(chip->dev, "duty cycle: %d, period %d\n", duty_ns, period_ns);
+       dev_dbg(chip->dev, "requested duty cycle: %d ns, period: %d ns\n",
+               duty_ns, period_ns);
 
        mutex_lock(&omap->mutex);
        if (duty_ns == pwm_get_duty_cycle(pwm) &&
@@ -170,6 +167,12 @@ static int pwm_omap_dmtimer_config(struct pwm_chip *chip,
                duty_cycles = period_cycles - 1;
        }
 
+       dev_dbg(chip->dev, "effective duty cycle: %lld ns, period: %lld ns\n",
+               DIV_ROUND_CLOSEST_ULL((u64)NSEC_PER_SEC * duty_cycles,
+                                     clk_rate),
+               DIV_ROUND_CLOSEST_ULL((u64)NSEC_PER_SEC * period_cycles,
+                                     clk_rate));
+
        load_value = (DM_TIMER_MAX - period_cycles) + 1;
        match_value = load_value + duty_cycles - 1;