Content-Type: multipart/mixed; boundary="===============4293690753354932500==" MIME-Version: 1.0 From: MaĆ­ra Canal To: kbuild-all@lists.01.org Subject: [PATCH v4] media: rc: pwm-ir-tx: Switch to atomic PWM API Date: Wed, 27 Oct 2021 12:34:30 -0300 Message-ID: List-Id: --===============4293690753354932500== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Remove legacy PWM interface (pwm_config, pwm_enable, pwm_disable) and replace it for the atomic PWM API. Signed-off-by: Ma=C3=ADra Canal Reported-by: kernel test robot --- V1 -> V2: Assign variables directly and simplify conditional statement V2 -> V3: Fix declaration of undeclared variables V3 -> V4: Fix DIV_ROUND_CLOSEST error with u64 variables --- drivers/media/rc/pwm-ir-tx.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/media/rc/pwm-ir-tx.c b/drivers/media/rc/pwm-ir-tx.c index 4bc28d2c9cc9..105a9c24f1e3 100644 --- a/drivers/media/rc/pwm-ir-tx.c +++ b/drivers/media/rc/pwm-ir-tx.c @@ -53,22 +53,21 @@ static int pwm_ir_tx(struct rc_dev *dev, unsigned int *= txbuf, { struct pwm_ir *pwm_ir =3D dev->priv; struct pwm_device *pwm =3D pwm_ir->pwm; - int i, duty, period; + struct pwm_state state; + int i; ktime_t edge; long delta; = - period =3D DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier); - duty =3D DIV_ROUND_CLOSEST(pwm_ir->duty_cycle * period, 100); + pwm_init_state(pwm, &state); = - pwm_config(pwm, duty, period); + state.period =3D DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier); + pwm_set_relative_duty_cycle(&state, pwm_ir->duty_cycle, 100); = edge =3D ktime_get(); = for (i =3D 0; i < count; i++) { - if (i % 2) // space - pwm_disable(pwm); - else - pwm_enable(pwm); + state.enabled =3D !(i % 2); + pwm_apply_state(pwm, &state); = edge =3D ktime_add_us(edge, txbuf[i]); delta =3D ktime_us_delta(edge, ktime_get()); @@ -76,7 +75,8 @@ static int pwm_ir_tx(struct rc_dev *dev, unsigned int *tx= buf, usleep_range(delta, delta + 10); } = - pwm_disable(pwm); + state.enabled =3D false; + pwm_apply_state(pwm, &state); = return count; } -- = 2.31.1 --===============4293690753354932500==--