From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: Fabrice Gasnier <fabrice.gasnier@st.com>, linux-pwm@vger.kernel.org
Subject: Re: [PATCH 1/3] pwm: stm32: Remove clutter from ternary operator
Date: Wed, 16 Oct 2019 10:26:12 +0200 [thread overview]
Message-ID: <20191016082612.fwpig3pup6bor5cn@pengutronix.de> (raw)
In-Reply-To: <20191016073842.1300297-2-thierry.reding@gmail.com>
On Wed, Oct 16, 2019 at 09:38:40AM +0200, Thierry Reding wrote:
> Remove usage of the ternary operator to assign values for register
> fields. This removes clutter and improves readability.
>
> Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
> ---
> drivers/pwm/pwm-stm32.c | 18 +++++++++++++-----
> 1 file changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
> index 9430b4cd383f..b12fb11b7a55 100644
> --- a/drivers/pwm/pwm-stm32.c
> +++ b/drivers/pwm/pwm-stm32.c
> @@ -493,11 +493,19 @@ static const struct pwm_ops stm32pwm_ops = {
> static int stm32_pwm_set_breakinput(struct stm32_pwm *priv,
> int index, int level, int filter)
> {
> - u32 bke = (index == 0) ? TIM_BDTR_BKE : TIM_BDTR_BK2E;
> - int shift = (index == 0) ? TIM_BDTR_BKF_SHIFT : TIM_BDTR_BK2F_SHIFT;
> - u32 mask = (index == 0) ? TIM_BDTR_BKE | TIM_BDTR_BKP | TIM_BDTR_BKF
> - : TIM_BDTR_BK2E | TIM_BDTR_BK2P | TIM_BDTR_BK2F;
> - u32 bdtr = bke;
> + u32 bke, shift, mask, bdtr;
> +
> + if (index == 0) {
> + bke = TIM_BDTR_BKE;
> + shift = TIM_BDTR_BKF_SHIFT;
> + mask = TIM_BDTR_BKE | TIM_BDTR_BKP | TIM_BDTR_BKF;
> + } else {
> + bke = TIM_BDTR_BK2E;
> + shift = TIM_BDTR_BK2F_SHIFT;
> + mask = TIM_BDTR_BK2E | TIM_BDTR_BK2P | TIM_BDTR_BK2F;
> + }
> +
> + bdtr = bke;
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Is index always in {0, 1}? Maybe a comment or a check about that would
be helpful. (-> separate patch I think).
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-König |
Industrial Linux Solutions | http://www.pengutronix.de/ |
next prev parent reply other threads:[~2019-10-16 8:26 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-16 7:38 [PATCH 0/3] pwm: stm32: Minor cleanups Thierry Reding
2019-10-16 7:38 ` [PATCH 1/3] pwm: stm32: Remove clutter from ternary operator Thierry Reding
2019-10-16 8:26 ` Uwe Kleine-König [this message]
2019-10-16 9:30 ` Thierry Reding
2019-10-16 7:38 ` [PATCH 2/3] pwm: stm32: Remove confusing bitmask Thierry Reding
2019-10-16 8:31 ` Uwe Kleine-König
2019-10-16 9:50 ` Thierry Reding
2019-10-16 10:20 ` Fabrice Gasnier
2019-10-16 10:52 ` Uwe Kleine-König
2019-10-16 7:38 ` [PATCH 3/3] pwm: stm32: Pass breakinput instead of its values Thierry Reding
2019-10-16 8:33 ` [PATCH 0/3] pwm: stm32: Minor cleanups Uwe Kleine-König
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=20191016082612.fwpig3pup6bor5cn@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--cc=fabrice.gasnier@st.com \
--cc=linux-pwm@vger.kernel.org \
--cc=thierry.reding@gmail.com \
/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