]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
video: avoid build failure on veyron board
authorAlvaro Fernando García <alvarofernandogarcia@gmail.com>
Fri, 4 Aug 2023 00:35:38 +0000 (21:35 -0300)
committerKever Yang <kever.yang@rock-chips.com>
Sat, 12 Aug 2023 02:18:12 +0000 (10:18 +0800)
533ad9dc avoided an overflow but causes compilation
failure on 32bit boards (eg. veyron speedy)

this commit uses div_u64 which has a fallback codepath
for 32bit platforms

Signed-off-by: Alvaro Fernando García <alvarofernandogarcia@gmail.com>
Tested-by: Simon Glass <sjg@chromium.org> # chromebook_jerry
Reviewed-by: Kever Yang <kever.yang@rock-chips.com>
drivers/video/pwm_backlight.c

index 46c16a8f447bdcefd8a231a959348b7a648ff23b..aa0e2928666a0c2d7189d0fdcf9347d53ddade4b 100644 (file)
@@ -14,6 +14,7 @@
 #include <pwm.h>
 #include <asm/gpio.h>
 #include <linux/delay.h>
+#include <linux/math64.h>
 #include <power/regulator.h>
 
 /**
@@ -59,12 +60,14 @@ struct pwm_backlight_priv {
 
 static int set_pwm(struct pwm_backlight_priv *priv)
 {
+       u64 width;
        uint duty_cycle;
        int ret;
 
        if (priv->period_ns) {
-               duty_cycle = (u64)priv->period_ns * (priv->cur_level - priv->min_level) /
-                       (priv->max_level - priv->min_level);
+               width = priv->period_ns * (priv->cur_level - priv->min_level);
+               duty_cycle = div_u64(width,
+                                    (priv->max_level - priv->min_level));
                ret = pwm_set_config(priv->pwm, priv->channel, priv->period_ns,
                                     duty_cycle);
        } else {