lkml.org 
[lkml]   [2021]   [Sep]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 2/2] pwm: renesas-tpu: don't allow no duty if duty_ns is given
Date
From: Duc Nguyen <duc.nguyen.ub@renesas.com>

We have special code if duty_ns is 0. But if non-zero is given, then the
calculation should not result in zero duty.

Signed-off-by: Duc Nguyen <duc.nguyen.ub@renesas.com>
[wsa: split and reworded commit message]
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
drivers/pwm/pwm-renesas-tpu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pwm/pwm-renesas-tpu.c b/drivers/pwm/pwm-renesas-tpu.c
index 754440194650..bb51156e4bda 100644
--- a/drivers/pwm/pwm-renesas-tpu.c
+++ b/drivers/pwm/pwm-renesas-tpu.c
@@ -275,7 +275,7 @@ static int tpu_pwm_config(struct pwm_chip *chip, struct pwm_device *_pwm,
if (duty_ns) {
duty = clk_rate / prescalers[prescaler]
/ (NSEC_PER_SEC / duty_ns);
- if (duty > period)
+ if (duty > period || duty == 0)
return -EINVAL;
} else {
duty = 0;
--
2.30.2
\
 
 \ /
  Last update: 2021-09-15 08:56    [W:0.067 / U:0.188 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site