From: Thierry Reding <thierry.reding@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: "Bartlomiej Zolnierkiewicz" <b.zolnierkie@samsung.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Lee Jones" <lee.jones@linaro.org>,
"Guru Das Srinagesh" <gurus@codeaurora.org>,
linux-pwm@vger.kernel.org, linux-fbdev@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] pwm: iqs620a: Use 64-bit division
Date: Mon, 15 Jun 2020 16:16:06 +0200 [thread overview]
Message-ID: <20200615141606.2814208-3-thierry.reding@gmail.com> (raw)
In-Reply-To: <20200615141606.2814208-1-thierry.reding@gmail.com>
The PWM framework is going to change the PWM period and duty cycles to
be 64-bit unsigned integers. To avoid build errors on platforms that do
not natively support 64-bit division, use explicity 64-bit division.
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
---
drivers/pwm/pwm-iqs620a.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/pwm/pwm-iqs620a.c b/drivers/pwm/pwm-iqs620a.c
index 674f0e238ba0..b2bb27eff623 100644
--- a/drivers/pwm/pwm-iqs620a.c
+++ b/drivers/pwm/pwm-iqs620a.c
@@ -46,7 +46,8 @@ static int iqs620_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
{
struct iqs620_pwm_private *iqs620_pwm;
struct iqs62x_core *iqs62x;
- int duty_scale, ret;
+ u64 duty_scale;
+ int ret;
if (state->polarity != PWM_POLARITY_NORMAL)
return -ENOTSUPP;
@@ -69,7 +70,7 @@ static int iqs620_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
* For lower duty cycles (e.g. 0), the PWM output is simply disabled to
* allow an external pull-down resistor to hold the GPIO3/LTX pin low.
*/
- duty_scale = state->duty_cycle * 256 / IQS620_PWM_PERIOD_NS;
+ duty_scale = div_u64(state->duty_cycle * 256, IQS620_PWM_PERIOD_NS);
mutex_lock(&iqs620_pwm->lock);
@@ -81,7 +82,7 @@ static int iqs620_pwm_apply(struct pwm_chip *chip, struct pwm_device *pwm,
}
if (duty_scale) {
- u8 duty_val = min(duty_scale - 1, 0xFF);
+ u8 duty_val = min_t(u64, duty_scale - 1, 0xff);
ret = regmap_write(iqs62x->regmap, IQS620_PWM_DUTY_CYCLE,
duty_val);
--
2.24.1
next prev parent reply other threads:[~2020-06-15 14:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-15 14:16 [PATCH 0/2] pwm: Miscellaneous fixes for 64-bit support Thierry Reding
2020-06-15 14:16 ` [PATCH 1/2] video: ssd1307fb: Print PWM period using 64-bit format specifier Thierry Reding
2020-06-15 15:18 ` Uwe Kleine-König
2020-06-15 17:19 ` kernel test robot
2020-06-15 17:25 ` kernel test robot
2020-06-17 7:18 ` Geert Uytterhoeven
2020-06-17 17:30 ` Uwe Kleine-König
2020-06-18 20:05 ` Guru Das Srinagesh
2020-06-19 6:46 ` Geert Uytterhoeven
2020-06-15 14:16 ` Thierry Reding [this message]
2020-06-15 15:16 ` [PATCH 2/2] pwm: iqs620a: Use 64-bit division Uwe Kleine-König
2020-06-16 7:06 ` Lee Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200615141606.2814208-3-thierry.reding@gmail.com \
--to=thierry.reding@gmail.com \
--cc=b.zolnierkie@samsung.com \
--cc=gurus@codeaurora.org \
--cc=lee.jones@linaro.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=u.kleine-koenig@pengutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).