diff options
| author | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-11-23 10:21:37 +0300 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-11-23 10:21:37 +0300 |
| commit | 03c1136af504bbc2cabda76af6b27fd5f7cf8a7d (patch) | |
| tree | 6c53a0f635b4339571050006191a950e3f5db93c /drivers/hwmon/pwm-fan.c | |
| parent | 0d79a48440f559ac939d1be2089757c5e4ab16c7 (diff) | |
| parent | 418baf2c28f3473039f2f7377760bd8f6897ae18 (diff) | |
| download | linux-03c1136af504bbc2cabda76af6b27fd5f7cf8a7d.tar.xz | |
Merge 5.10-rc5 into staging-testing
We want the staging/IIO fixes in here as well.
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/hwmon/pwm-fan.c')
| -rw-r--r-- | drivers/hwmon/pwm-fan.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index bdba2143021a..1f63807c0399 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -54,16 +54,18 @@ static irqreturn_t pulse_handler(int irq, void *dev_id) static void sample_timer(struct timer_list *t) { struct pwm_fan_ctx *ctx = from_timer(ctx, t, rpm_timer); + unsigned int delta = ktime_ms_delta(ktime_get(), ctx->sample_start); int pulses; - u64 tmp; - pulses = atomic_read(&ctx->pulses); - atomic_sub(pulses, &ctx->pulses); - tmp = (u64)pulses * ktime_ms_delta(ktime_get(), ctx->sample_start) * 60; - do_div(tmp, ctx->pulses_per_revolution * 1000); - ctx->rpm = tmp; + if (delta) { + pulses = atomic_read(&ctx->pulses); + atomic_sub(pulses, &ctx->pulses); + ctx->rpm = (unsigned int)(pulses * 1000 * 60) / + (ctx->pulses_per_revolution * delta); + + ctx->sample_start = ktime_get(); + } - ctx->sample_start = ktime_get(); mod_timer(&ctx->rpm_timer, jiffies + HZ); } |
