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 2/7] PWM: core: add struct pwm_chip::dev
Date: Mon, 15 Apr 2024 07:35:55 +0200	[thread overview]
Message-ID: <20240415053600.370622-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20240415053600.370622-1-a.fatoum@pengutronix.de>

For compatibility with Linux, let's add a dev member into struct pwm_chip
instead of passing it as argument to pwmchip_add

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

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 976357e6062f..ab7e55b00079 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -91,7 +91,7 @@ static int set_enable(struct param_d *p, void *priv)
  * register a new pwm. pwm->devname must be initialized, usually
  * from dev_name(dev) from the hardware driver.
  */
-int pwmchip_add(struct pwm_chip *chip, struct device *dev)
+int pwmchip_add(struct pwm_chip *chip)
 {
 	struct pwm_device *pwm;
 	struct param_d *p;
@@ -105,11 +105,11 @@ int pwmchip_add(struct pwm_chip *chip, struct device *dev)
 
 	pwm = xzalloc(sizeof(*pwm));
 	pwm->chip = chip;
-	pwm->hwdev = dev;
+	pwm->hwdev = chip->dev;
 
 	dev_set_name(&pwm->dev, chip->devname);
 	pwm->dev.id = DEVICE_ID_SINGLE;
-	pwm->dev.parent = dev;
+	pwm->dev.parent = chip->dev;
 
 	ret = register_device(&pwm->dev);
 	if (ret)
diff --git a/drivers/pwm/pwm-atmel.c b/drivers/pwm/pwm-atmel.c
index d5e70600ee59..52b5926097b5 100644
--- a/drivers/pwm/pwm-atmel.c
+++ b/drivers/pwm/pwm-atmel.c
@@ -453,7 +453,8 @@ static int atmel_pwm_probe(struct device *dev)
 
 		chip->ops = &atmel_pwm_ops;
 		chip->id = i;
-		ret = pwmchip_add(chip, dev);
+		chip->dev = dev;
+		ret = pwmchip_add(chip);
 		if (ret) {
 			dev_err(dev, "failed to add pwm chip %d\n", ret);
 			return ret;
diff --git a/drivers/pwm/pwm-imx.c b/drivers/pwm/pwm-imx.c
index c9db4aef3443..0b79b0831a5c 100644
--- a/drivers/pwm/pwm-imx.c
+++ b/drivers/pwm/pwm-imx.c
@@ -267,6 +267,7 @@ static int imx_pwm_probe(struct device *dev)
 		return PTR_ERR(iores);
 	imx->mmio_base = IOMEM(iores->start);
 
+	imx->chip.dev = dev;
 	imx->chip.ops = &imx_pwm_ops;
 	if (dev->of_node) {
 		imx->chip.devname = of_alias_get(dev->of_node);
@@ -280,7 +281,7 @@ static int imx_pwm_probe(struct device *dev)
 	imx->config = data->config;
 	imx->set_enable = data->set_enable;
 
-	return pwmchip_add(&imx->chip, dev);;
+	return pwmchip_add(&imx->chip);
 }
 
 static struct driver imx_pwm_driver = {
diff --git a/drivers/pwm/pwm-mxs.c b/drivers/pwm/pwm-mxs.c
index 6b89ac192ad9..e94fcf538488 100644
--- a/drivers/pwm/pwm-mxs.c
+++ b/drivers/pwm/pwm-mxs.c
@@ -130,9 +130,10 @@ static int mxs_pwm_probe(struct device *dev)
 		mxspwm->chip.ops = &mxs_pwm_ops;
 		mxspwm->chip.devname = basprintf("pwm%d", i);
 		mxspwm->chip.id = i;
+		mxspwm->chip.dev = dev;
 		mxspwm->mxs = mxs;
 
-		ret = pwmchip_add(&mxspwm->chip, dev);
+		ret = pwmchip_add(&mxspwm->chip);
 		if (ret < 0) {
 			dev_err(dev, "failed to add pwm chip %d\n", ret);
 			return ret;
diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c
index 5c2029ab6ad6..7c7a8e2ce68e 100644
--- a/drivers/pwm/pwm-stm32.c
+++ b/drivers/pwm/pwm-stm32.c
@@ -377,8 +377,9 @@ static int stm32_pwm_probe(struct device *dev)
 
 		chip->ops = &stm32pwm_ops;
 		chip->id = i;
+		chip->dev = dev;
 
-		ret = pwmchip_add(chip, dev);
+		ret = pwmchip_add(chip);
 		if (ret < 0) {
 			dev_err(dev, "failed to add pwm chip %d\n", ret);
 			return ret;
diff --git a/drivers/pwm/pxa_pwm.c b/drivers/pwm/pxa_pwm.c
index 0ed69d999f02..69ff7dfb7736 100644
--- a/drivers/pwm/pxa_pwm.c
+++ b/drivers/pwm/pxa_pwm.c
@@ -141,9 +141,10 @@ static int pxa_pwm_probe(struct device *dev)
 		return PTR_ERR(iores);
 	chip->iobase = IOMEM(iores->start);
 	chip->id = dev->id;
+	chip->chip.dev = dev;
 	dev->priv = chip;
 
-	return pwmchip_add(&chip->chip, dev);
+	return pwmchip_add(&chip->chip);
 }
 
 static struct driver pxa_pwm_driver = {
diff --git a/include/pwm.h b/include/pwm.h
index 4d403fe1746c..5157fee7d43d 100644
--- a/include/pwm.h
+++ b/include/pwm.h
@@ -128,12 +128,14 @@ struct pwm_ops {
 
 /**
  * struct pwm_chip - abstract a PWM
+ * @dev: device providing the PWMs
  * @id: The id of this pwm
  * @devname: unique identifier for this pwm
  * @ops: The callbacks for this PWM
  * @state: current state of the PWM
  */
 struct pwm_chip {
+	struct device		*dev;
 	int			id;
 	const char		*devname;
 	const struct pwm_ops	*ops;
@@ -141,7 +143,7 @@ struct pwm_chip {
 	struct pwm_state	state;
 };
 
-int pwmchip_add(struct pwm_chip *chip, struct device *dev);
+int pwmchip_add(struct pwm_chip *chip);
 int pwmchip_remove(struct pwm_chip *chip);
 
 #endif /* __PWM_H */
-- 
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 ` Ahmad Fatoum [this message]
2024-04-15  5:35 ` [PATCH 3/7] PWM: core: adopt Linux prototype for struct pwm_ops::apply Ahmad Fatoum
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-3-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