summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2024-04-15 07:35:55 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2024-04-16 12:10:05 +0200
commit66cc09c044abc08ce5d55b793f770883c2b205ab (patch)
tree7113932833071993f29cd740af541652d4678d13
parent9c2ce11137522e61cb922ceaa54219fc38ae7146 (diff)
downloadbarebox-66cc09c044abc08ce5d55b793f770883c2b205ab.tar.gz
barebox-66cc09c044abc08ce5d55b793f770883c2b205ab.tar.xz
PWM: core: add struct pwm_chip::dev
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> Link: https://lore.barebox.org/20240415053600.370622-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--drivers/pwm/core.c6
-rw-r--r--drivers/pwm/pwm-atmel.c3
-rw-r--r--drivers/pwm/pwm-imx.c3
-rw-r--r--drivers/pwm/pwm-mxs.c3
-rw-r--r--drivers/pwm/pwm-stm32.c3
-rw-r--r--drivers/pwm/pxa_pwm.c3
-rw-r--r--include/pwm.h4
7 files changed, 16 insertions, 9 deletions
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 976357e606..ab7e55b000 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 d5e70600ee..52b5926097 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 c9db4aef34..0b79b0831a 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 6b89ac192a..e94fcf5384 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 5c2029ab6a..7c7a8e2ce6 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 0ed69d999f..69ff7dfb77 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 4d403fe174..5157fee7d4 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 */