diff options
author | Alvaro Fernando García <alvarofernandogarcia@gmail.com> | 2023-08-03 21:35:38 -0300 |
---|---|---|
committer | Kever Yang <kever.yang@rock-chips.com> | 2023-08-12 10:18:12 +0800 |
commit | 8300cebcd60476443d8a630b56f715eae5af911b (patch) | |
tree | 95406561257f941757afce05b0632905e9b9af4b /drivers | |
parent | bb38db086c6c7eade690d83aa0d96af8c993b991 (diff) | |
download | u-boot-8300cebcd60476443d8a630b56f715eae5af911b.tar.gz u-boot-8300cebcd60476443d8a630b56f715eae5af911b.tar.bz2 u-boot-8300cebcd60476443d8a630b56f715eae5af911b.zip |
video: avoid build failure on veyron board
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>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/video/pwm_backlight.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/video/pwm_backlight.c b/drivers/video/pwm_backlight.c index 46c16a8f44..aa0e292866 100644 --- a/drivers/video/pwm_backlight.c +++ b/drivers/video/pwm_backlight.c @@ -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 { |