From: "Maíra Canal" <maira.canal@usp.br> To: sean@mess.org, u.kleine-koenig@pengutronix.de, lkp@intel.com, mchehab@kernel.org, thierry.reding@gmail.com, lee.jones@linaro.org Cc: llvm@lists.linux.dev, kbuild-all@lists.01.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org Subject: [PATCH v4] media: rc: pwm-ir-tx: Switch to atomic PWM API Date: Wed, 27 Oct 2021 12:34:30 -0300 [thread overview] Message-ID: <YXlxhpZWf2mxJaMi@fedora> (raw) 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> Reported-by: kernel test robot <lkp@intel.com> --- 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 = 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); + pwm_set_relative_duty_cycle(&state, pwm_ir->duty_cycle, 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
WARNING: multiple messages have this Message-ID (diff)
From: Maíra Canal <maira.canal@usp.br> 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 [thread overview] Message-ID: <YXlxhpZWf2mxJaMi@fedora> (raw) [-- Attachment #1: Type: text/plain, Size: 1820 bytes --] 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> Reported-by: kernel test robot <lkp@intel.com> --- 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 = 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); + pwm_set_relative_duty_cycle(&state, pwm_ir->duty_cycle, 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
next reply other threads:[~2021-10-27 15:34 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-27 15:34 Maíra Canal [this message] 2021-10-27 15:34 ` [PATCH v4] media: rc: pwm-ir-tx: Switch to atomic PWM API Maíra Canal 2021-10-28 6:45 ` Uwe Kleine-König 2021-10-28 6:45 ` Uwe Kleine-König 2021-10-28 9:14 ` Sean Young 2021-10-28 9:14 ` Sean Young 2021-10-28 11:15 ` Uwe Kleine-König 2021-10-28 11:15 ` Uwe Kleine-König 2021-10-28 12:26 ` Sean Young 2021-10-28 12:26 ` Sean Young 2021-10-28 18:05 ` Uwe Kleine-König 2021-10-28 18:05 ` Uwe Kleine-König 2021-10-29 7:16 ` Sean Young 2021-10-29 7:16 ` Sean Young 2021-10-29 11:06 ` Uwe Kleine-König 2021-10-29 11:06 ` Uwe Kleine-König 2021-10-29 11:54 ` Sean Young 2021-10-29 11:54 ` Sean Young 2021-10-29 12:08 ` Maíra Canal 2021-10-29 12:08 ` Maíra Canal 2021-10-29 15:18 ` Uwe Kleine-König 2021-10-29 15:18 ` Uwe Kleine-König 2021-10-30 9:21 ` Sean Young 2021-10-30 9:21 ` Sean Young 2021-10-31 10:39 ` Sean Young 2021-10-31 17:40 ` 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=YXlxhpZWf2mxJaMi@fedora \ --to=maira.canal@usp.br \ --cc=kbuild-all@lists.01.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=lkp@intel.com \ --cc=llvm@lists.linux.dev \ --cc=mchehab@kernel.org \ --cc=sean@mess.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.