Linux PWM subsystem development
 help / color / mirror / Atom feed
From: Nicolas Ferre <nicolas.ferre@microchip.com>
To: "Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Alexandre Belloni" <alexandre.belloni@bootlin.com>,
	"Claudiu Beznea" <claudiu.beznea@tuxon.dev>
Cc: <linux-pwm@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 2/2] pwm: atmel-tcb: Simplify checking the companion output
Date: Wed, 10 Jul 2024 16:17:47 +0200	[thread overview]
Message-ID: <6db1de1b-cf0c-4acc-91dd-41dddfa36227@microchip.com> (raw)
In-Reply-To: <20240709101806.52394-4-u.kleine-koenig@baylibre.com>

On 09/07/2024 at 12:18, Uwe Kleine-König wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> The two outputs provided by the supported hardware share some settings,
> so access to the other PWM is required when one of them is configured.
> 
> Instead of an explicit if to deterimine the other PWM just use
> hwpwm ^ 1. Further atcbpwm is never NULL, so drop the corresponding
> check.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>

Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>
Thanks. Best regards,
   Nicolas

> ---
>   drivers/pwm/pwm-atmel-tcb.c | 11 +++--------
>   1 file changed, 3 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/pwm/pwm-atmel-tcb.c b/drivers/pwm/pwm-atmel-tcb.c
> index aca11493239a..2feee3744b50 100644
> --- a/drivers/pwm/pwm-atmel-tcb.c
> +++ b/drivers/pwm/pwm-atmel-tcb.c
> @@ -260,7 +260,8 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>   {
>          struct atmel_tcb_pwm_chip *tcbpwmc = to_tcb_chip(chip);
>          struct atmel_tcb_pwm_device *tcbpwm = &tcbpwmc->pwms[pwm->hwpwm];
> -       struct atmel_tcb_pwm_device *atcbpwm = NULL;
> +       /* companion PWM sharing register values period and div */
> +       struct atmel_tcb_pwm_device *atcbpwm = &tcbpwmc->pwms[pwm->hwpwm ^ 1];
>          int i = 0;
>          int slowclk = 0;
>          unsigned period;
> @@ -305,11 +306,6 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>          duty = div_u64(duty_ns, min);
>          period = div_u64(period_ns, min);
> 
> -       if (pwm->hwpwm == 0)
> -               atcbpwm = &tcbpwmc->pwms[1];
> -       else
> -               atcbpwm = &tcbpwmc->pwms[0];
> -
>          /*
>           * PWM devices provided by the TCB driver are grouped by 2.
>           * PWM devices in a given group must be configured with the
> @@ -318,8 +314,7 @@ static int atmel_tcb_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm,
>           * We're checking the period value of the second PWM device
>           * in this group before applying the new config.
>           */
> -       if ((atcbpwm && atcbpwm->duty > 0 &&
> -                       atcbpwm->duty != atcbpwm->period) &&
> +       if ((atcbpwm->duty > 0 && atcbpwm->duty != atcbpwm->period) &&
>                  (atcbpwm->div != i || atcbpwm->period != period)) {
>                  dev_err(pwmchip_parent(chip),
>                          "failed to configure period_ns: PWM group already configured with a different value\n");
> --
> 2.43.0
> 


  reply	other threads:[~2024-07-10 14:17 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-09 10:18 [PATCH 1/2] pwm: atmel-tcb: Fix race condition and convert to guards Uwe Kleine-König
2024-07-09 10:18 ` [PATCH 2/2] pwm: atmel-tcb: Simplify checking the companion output Uwe Kleine-König
2024-07-10 14:17   ` Nicolas Ferre [this message]
2024-07-10 15:58     ` Uwe Kleine-König
2024-07-10 14:17 ` [PATCH 1/2] pwm: atmel-tcb: Fix race condition and convert to guards Nicolas Ferre
2024-07-10 15:31   ` Uwe Kleine-König
2024-07-10 16:13     ` Nicolas Ferre

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=6db1de1b-cf0c-4acc-91dd-41dddfa36227@microchip.com \
    --to=nicolas.ferre@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=u.kleine-koenig@baylibre.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