mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 3/7] PWM: core: adopt Linux prototype for struct pwm_ops::apply
Date: Mon, 15 Apr 2024 07:35:56 +0200	[thread overview]
Message-ID: <20240415053600.370622-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240415053600.370622-1-a.fatoum@pengutronix.de>

In Linux, a pwm_chip can have more one pwm_device, one for each channel.
Therefore, pwm_apply takes a pwm_device as argument to identify, which
channel is the one being operated on.

In barebox, there's a 1:1 relationship between the two, but let's add
pwm_device as extra, so far unused, parameter to make porting kernel
code slightly easier.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/pwm/core.c      | 2 +-
 drivers/pwm/pwm-atmel.c | 4 +++-
 drivers/pwm/pwm-imx.c   | 4 +++-
 drivers/pwm/pwm-mxs.c   | 4 +++-
 drivers/pwm/pwm-stm32.c | 4 +++-
 drivers/pwm/pxa_pwm.c   | 4 +++-
 include/pwm.h           | 3 ++-
 7 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index ab7e55b00079..706c4515e9a8 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -326,7 +326,7 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state)
 	if (state->duty_ns > state->period_ns)
 		goto err;
 
-	ret = chip->ops->apply(chip, state);
+	ret = chip->ops->apply(chip, pwm, state);
 err:
 	if (ret == 0)
 		chip->state = *state;
diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
index 52b5926097b5..331a6e97124f 100644
--- a/drivers/pwm/pwm-atmel.c
+++ b/drivers/pwm/pwm-atmel.c
@@ -286,7 +286,9 @@ static void atmel_pwm_disable(struct pwm_chip *chip, bool disable_clk)
 		clk_disable(atmel_pwm->clk);
 }
 
-static int atmel_pwm_apply(struct pwm_chip *chip, const struct pwm_state *state)
+static int atmel_pwm_apply(struct pwm_chip *chip,
+			   struct pwm_device *pwm,
+			   const struct pwm_state *state)
 {
 	struct atmel_pwm_chip *atmel_pwm = to_atmel_pwm_chip(chip);
 	struct pwm_state cstate;
diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
index 0b79b0831a5c..f5e3cbcd7c80 100644
--- a/drivers/pwm/pwm-imx.c
+++ b/drivers/pwm/pwm-imx.c
@@ -191,7 +191,9 @@ static void imx_pwm_set_enable_v2(struct pwm_chip *chip, bool enable)
 		imx_pwm_clk_disable_v2(imx);
 }
 
-static int imx_pwm_apply(struct pwm_chip *chip, const struct pwm_state *state)
+static int imx_pwm_apply(struct pwm_chip *chip,
+			 struct pwm_device *pwm,
+			 const struct pwm_state *state)
 {
 	struct imx_chip *imx = to_imx_chip(chip);
 	bool enabled;
diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c
index e94fcf538488..18279bf287b4 100644
--- a/drivers/pwm/pwm-mxs.c
+++ b/drivers/pwm/pwm-mxs.c
@@ -44,7 +44,9 @@ struct mxs_pwm {
 
 #define to_mxs_pwm_chip(_chip) container_of(_chip, struct mxs_pwm_chip, chip)
 
-static int mxs_pwm_apply(struct pwm_chip *chip, const struct pwm_state *state)
+static int mxs_pwm_apply(struct pwm_chip *chip,
+			 struct pwm_device *pwm,
+			 const struct pwm_state *state)
 {
 	struct mxs_pwm_chip *mxs = to_mxs_pwm_chip(chip);
 	int div = 0;
diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
index 7c7a8e2ce68e..218a270c022d 100644
--- a/drivers/pwm/pwm-stm32.c
+++ b/drivers/pwm/pwm-stm32.c
@@ -198,7 +198,9 @@ static void stm32_pwm_disable(struct stm32_pwm *priv, unsigned ch)
 	clk_disable(priv->clk);
 }
 
-static int stm32_pwm_apply(struct pwm_chip *chip, const struct pwm_state *state)
+static int stm32_pwm_apply(struct pwm_chip *chip,
+			   struct pwm_device *pwm,
+			   const struct pwm_state *state)
 {
 	bool enabled;
 	struct stm32_pwm *priv = to_stm32_pwm_dev(chip);
diff --git a/drivers/pwm/pxa_pwm.c b/drivers/pwm/pxa_pwm.c
index 69ff7dfb7736..09f36c92dda2 100644
--- a/drivers/pwm/pxa_pwm.c
+++ b/drivers/pwm/pxa_pwm.c
@@ -77,7 +77,9 @@ static void pxa_pwm_disable(struct pxa_pwm_chip *pxa_pwm)
  * duty_ns      = 10^9 * (PRESCALE + 1) * DC / PWM_CLK_RATE
  * PWM_CLK_RATE = 13 MHz
  */
-static int pxa_pwm_apply(struct pwm_chip *chip, const struct pwm_state *state)
+static int pxa_pwm_apply(struct pwm_chip *chip,
+			 struct pwm_device *pwm,
+			 const struct pwm_state *state)
 {
 	unsigned long long c;
 	unsigned long period_cycles, prescale, pv, dc;
diff --git a/include/pwm.h b/include/pwm.h
index 5157fee7d43d..876a242289d7 100644
--- a/include/pwm.h
+++ b/include/pwm.h
@@ -123,7 +123,8 @@ int pwm_apply_state(struct pwm_device *pwm, const struct pwm_state *state);
 struct pwm_ops {
 	int (*request)(struct pwm_chip *chip);
 	void (*free)(struct pwm_chip *chip);
-	int (*apply)(struct pwm_chip *chip, const struct pwm_state *state);
+	int (*apply)(struct pwm_chip *chip, struct pwm_device *pwm,
+		     const struct pwm_state *state);
 };
 
 /**
-- 
2.39.2




  parent reply	other threads:[~2024-04-15  5:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-15  5:35 [PATCH 0/7] PWM: rockchip: add driver support Ahmad Fatoum
2024-04-15  5:35 ` [PATCH 1/7] PWM: core: check that struct pwm_chip::devname is set Ahmad Fatoum
2024-04-15  5:35 ` [PATCH 2/7] PWM: core: add struct pwm_chip::dev Ahmad Fatoum
2024-04-15  5:35 ` Ahmad Fatoum [this message]
2024-04-15  5:35 ` [PATCH 4/7] PWM: align struct pwm_state member names with Linux Ahmad Fatoum
2024-04-15  5:35 ` [PATCH 5/7] PWM: core: add definition for PWM_POLARITY_INVERSED Ahmad Fatoum
2024-04-15  5:35 ` [PATCH 6/7] PWM: rockchip: add driver support Ahmad Fatoum
2024-04-15  5:36 ` [PATCH 7/7] ARM: dts: rk356x: add aliases for PWM controllers Ahmad Fatoum
2024-04-16 10:11 ` [PATCH 0/7] PWM: rockchip: add driver support Sascha Hauer

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=20240415053600.370622-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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