All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] media: rc: pwm-ir-tx: Switch to atomic PWM API
@ 2021-10-24 10:33 Maíra Canal
  2021-10-25  6:08 ` Uwe Kleine-König
  2021-10-27  6:07   ` kernel test robot
  0 siblings, 2 replies; 13+ messages in thread
From: Maíra Canal @ 2021-10-24 10:33 UTC (permalink / raw)
  To: sean, mchehab, thierry.reding, u.kleine-koenig, lee.jones
  Cc: linux-media, linux-kernel, linux-pwm

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>
---
V1 -> V2: Assign variables directly and simplify conditional statement
V2 -> V3: Fix declaration of undeclared variable
---
 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..e1f348a962e8 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 = dev->priv;
 	struct pwm_device *pwm = pwm_ir->pwm;
-	int i, duty, period;
+	struct pwm_state state;
+	int i;
 	ktime_t edge;
 	long delta;
 
-	period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier);
-	duty = DIV_ROUND_CLOSEST(pwm_ir->duty_cycle * period, 100);
+	pwm_init_state(pwm, &state);
 
-	pwm_config(pwm, duty, period);
+	state.period = DIV_ROUND_CLOSEST(NSEC_PER_SEC, pwm_ir->carrier);
+	state.duty_cycle = DIV_ROUND_CLOSEST(pwm_ir->duty_cycle * state.period, 100);
 
 	edge = ktime_get();
 
 	for (i = 0; i < count; i++) {
-		if (i % 2) // space
-			pwm_disable(pwm);
-		else
-			pwm_enable(pwm);
+		state.enabled = !(i % 2);
+		pwm_apply_state(pwm, &state);
 
 		edge = ktime_add_us(edge, txbuf[i]);
 		delta = ktime_us_delta(edge, ktime_get());
@@ -76,7 +75,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


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-10-27 12:49 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-24 10:33 [PATCH v3] media: rc: pwm-ir-tx: Switch to atomic PWM API Maíra Canal
2021-10-25  6:08 ` Uwe Kleine-König
2021-10-27  6:07 ` kernel test robot
2021-10-27  6:07   ` kernel test robot
2021-10-27  6:15   ` Uwe Kleine-König
2021-10-27  6:15     ` Uwe Kleine-König
2021-10-27  7:32     ` Sean Young
2021-10-27  7:32       ` Sean Young
2021-10-27 12:38       ` Maíra Canal
2021-10-27 12:43         ` Maíra Canal
2021-10-27 12:43           ` Maíra Canal
2021-10-27 12:48           ` Sean Young
2021-10-27 12:48             ` Sean Young

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.