FAILED: patch "[PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle" failed to apply to 4.4-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 4.4-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 9017dc4fbd59c09463019ce494cfe36d654495a8 Mon Sep 17 00:00:00 2001
From: Paul Cercueil <[email protected]>
Date: Wed, 27 May 2020 13:52:23 +0200
Subject: [PATCH] pwm: jz4740: Enhance precision in calculation of duty cycle
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Calculating the hardware value for the duty from the hardware value of the period resulted in a precision loss versus calculating it from the clock rate directly.
(Also remove a cast that doesn't really need to be here)
drivers/pwm/pwm-jz4740.c +3 -3
@@ -158,11 +158,11 @@ static int jz4740_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,/* Calculate period value */ tmp = (unsigned long long )rate * state->period;do_div (tmp,NSEC_PER_SEC ); - period = (unsigned long )tmp; + period = tmp;/* Calculate duty value */ - tmp = (unsigned long long )period * state->duty_cycle; -do_div (tmp, state->period); + tmp = (unsigned long long )rate * state->duty_cycle; +do_div (tmp,NSEC_PER_SEC ); duty = period - tmp;if (duty >= period)