mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sean Young <sean@mess.org>
To: "Maíra Canal" <maira.canal@usp.br>
Cc: mchehab@kernel.org, thierry.reding@gmail.com,
	u.kleine-koenig@pengutronix.de, lee.jones@linaro.org,
	linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pwm@vger.kernel.org
Subject: Re: [PATCH] media: rc: pwm-ir-tx: Switch to atomic PWM API
Date: Sat, 23 Oct 2021 18:50:56 +0100	[thread overview]
Message-ID: <20211023175056.GA26584@gofer.mess.org> (raw)
In-Reply-To: <YXRE5i9xXpwSjicO@fedora>

Hi Maíra,

Your patch looks good, just some very minor nits.

On Sat, Oct 23, 2021 at 02:22:46PM -0300, Maíra Canal wrote:
> Remove legacy PWM interface (pwm_config, pwm_enable, pwm_disable) and
> replace it for the atomic PWM API.
> 
> Signed-off-by: Maíra Canal <maira.canal@usp.br>
> ---
>  drivers/media/rc/pwm-ir-tx.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/media/rc/pwm-ir-tx.c b/drivers/media/rc/pwm-ir-tx.c
> index 4bc28d2c9cc9..dfaa6125991e 100644
> --- a/drivers/media/rc/pwm-ir-tx.c
> +++ b/drivers/media/rc/pwm-ir-tx.c
> @@ -53,6 +53,7 @@ static int pwm_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
>  {
>  	struct pwm_ir *pwm_ir = dev->priv;
>  	struct pwm_device *pwm = pwm_ir->pwm;
> +	struct pwm_state state;
>  	int i, duty, period;
>  	ktime_t edge;
>  	long delta;
> @@ -60,15 +61,19 @@ static int pwm_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
>  	period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier);
>  	duty = DIV_ROUND_CLOSEST(pwm_ir->duty_cycle * period, 100);
>  
> -	pwm_config(pwm, duty, period);
> +	pwm_init_state(pwm, &state);
> +
> +	state.duty_cycle = duty;
> +	state.period = period;

There is no reason to have the period and duty local variables any more;
the result of DIV_ROUND_CLOSEST(..) can be assigned directly.

>  	edge = ktime_get();
>  
>  	for (i = 0; i < count; i++) {
>  		if (i % 2) // space
> -			pwm_disable(pwm);
> +			state.enabled = false;
>  		else
> -			pwm_enable(pwm);
> +			state.enabled = true;

This could be simply:
		state.enabled = (i % 2) == 0;

> +		pwm_apply_state(pwm, &state);
>  
>  		edge = ktime_add_us(edge, txbuf[i]);
>  		delta = ktime_us_delta(edge, ktime_get());
> @@ -76,7 +81,8 @@ static int pwm_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
>  			usleep_range(delta, delta + 10);
>  	}
>  
> -	pwm_disable(pwm);
> +	state.enabled = false;
> +	pwm_apply_state(pwm, &state);
>  
>  	return count;
>  }
> -- 
> 2.31.1

Thanks
Sean

      reply	other threads:[~2021-10-23 17:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-23 17:22 Maíra Canal
2021-10-23 17:50 ` Sean Young [this message]

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=20211023175056.GA26584@gofer.mess.org \
    --to=sean@mess.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-pwm@vger.kernel.org \
    --cc=maira.canal@usp.br \
    --cc=mchehab@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®