]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
pwm: tegra: Use DIV_ROUND_CLOSEST_ULL() instead of local implementation
authorLaxman Dewangan <ldewangan@nvidia.com>
Fri, 7 Apr 2017 09:33:59 +0000 (15:03 +0530)
committerThierry Reding <thierry.reding@gmail.com>
Wed, 12 Apr 2017 14:08:00 +0000 (16:08 +0200)
Use macro DIV_ROUND_CLOSEST_ULL() for 64-bit division to closest one
instead of implementing the same locally. This increase readability.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
drivers/pwm/pwm-tegra.c

index e4647840cd6e3129fb94da036e30470714852f14..0a688dabd6705d1da27c80309ddbeaed253995b9 100644 (file)
@@ -85,8 +85,7 @@ static int tegra_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
         * nearest integer during division.
         */
        c *= (1 << PWM_DUTY_WIDTH);
-       c += period_ns / 2;
-       do_div(c, period_ns);
+       c = DIV_ROUND_CLOSEST_ULL(c, period_ns);
 
        val = (u32)c << PWM_DUTY_SHIFT;