From: Guru Das Srinagesh <gurus@codeaurora.org>
To: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
Cc: Thierry Reding <thierry.reding@gmail.com>,
Lee Jones <lee.jones@linaro.org>,
linux-pwm@vger.kernel.org, kernel@pengutronix.de
Subject: Re: [PATCH] pwm: soften potential loss of precision in compat code
Date: Thu, 11 Mar 2021 13:06:39 -0800 [thread overview]
Message-ID: <20210311210639.GA29363@codeaurora.org> (raw)
In-Reply-To: <20210308092322.24502-1-u.kleine-koenig@pengutronix.de>
On Mon, Mar 08, 2021 at 10:23:22AM +0100, Uwe Kleine-König wrote:
> if (state->period != pwm->state.period ||
> state->duty_cycle != pwm->state.duty_cycle) {
> + int duty_cycle, period;
> +
> + if (state->period < INT_MAX)
> + period = state->period;
> + else
> + period = INT_MAX;
Using a MIN() macro here might improve readability:
period = MIN(state->period, INT_MAX);
> +
> + if (state->duty_cycle < INT_MAX)
> + duty_cycle = state->duty_cycle;
> + else
> + duty_cycle = INT_MAX;
Same here.
> +
> err = chip->ops->config(pwm->chip, pwm,
> - state->duty_cycle,
> - state->period);
> + duty_cycle, period);
> if (err)
> return err;
>
> --
> 2.30.1
>
next prev parent reply other threads:[~2021-03-11 21:07 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-08 9:23 [PATCH] pwm: soften potential loss of precision in compat code Uwe Kleine-König
2021-03-11 21:06 ` Guru Das Srinagesh [this message]
2021-03-12 7:12 ` Uwe Kleine-König
2021-03-15 1:53 ` Guru Das Srinagesh
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=20210311210639.GA29363@codeaurora.org \
--to=gurus@codeaurora.org \
--cc=kernel@pengutronix.de \
--cc=lee.jones@linaro.org \
--cc=linux-pwm@vger.kernel.org \
--cc=thierry.reding@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.