From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/5] PWM: Use a separate device for PWMs
Date: Thu, 13 Feb 2014 11:00:17 +0100 [thread overview]
Message-ID: <1392285621-17485-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1392285621-17485-1-git-send-email-s.hauer@pengutronix.de>
Instead of directly using the hardware devicet for PWMs register
a logical PWM device so that the user operates on pwmx devices rather
than pxa-pwmx.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/pwm/core.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index f769cfe..f2b062e 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -26,7 +26,8 @@ struct pwm_device {
#define FLAG_REQUESTED 0
#define FLAG_ENABLED 1
struct list_head node;
- struct device_d *dev;
+ struct device_d *hwdev;
+ struct device_d dev;
unsigned int duty_ns;
unsigned int period_ns;
@@ -79,27 +80,36 @@ int pwmchip_add(struct pwm_chip *chip, struct device_d *dev)
{
struct pwm_device *pwm;
struct param_d *p;
+ int ret;
if (_find_pwm(chip->devname))
return -EBUSY;
pwm = xzalloc(sizeof(*pwm));
pwm->chip = chip;
- pwm->dev = dev;
+ pwm->hwdev = dev;
+
+ strcpy(pwm->dev.name, chip->devname);
+ pwm->dev.id = DEVICE_ID_SINGLE;
+ pwm->dev.parent = dev;
+
+ ret = register_device(&pwm->dev);
+ if (ret)
+ return ret;
list_add_tail(&pwm->node, &pwm_list);
- p = dev_add_param_int(dev, "duty_ns", set_duty_period_ns,
+ p = dev_add_param_int(&pwm->dev, "duty_ns", set_duty_period_ns,
NULL, &pwm->chip->duty_ns, "%u", pwm);
if (IS_ERR(p))
return PTR_ERR(p);
- p = dev_add_param_int(dev, "period_ns", set_duty_period_ns,
+ p = dev_add_param_int(&pwm->dev, "period_ns", set_duty_period_ns,
NULL, &pwm->chip->period_ns, "%u", pwm);
if (IS_ERR(p))
return PTR_ERR(p);
- p = dev_add_param_bool(dev, "enable", set_enable,
+ p = dev_add_param_bool(&pwm->dev, "enable", set_enable,
NULL, &pwm->p_enable, pwm);
if (IS_ERR(p))
return PTR_ERR(p);
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-02-13 10:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-13 10:00 PWM patches Sascha Hauer
2014-02-13 10:00 ` Sascha Hauer [this message]
2014-02-13 10:00 ` [PATCH 2/5] PWM: pxa: use pwmx as devname Sascha Hauer
2014-02-13 10:00 ` [PATCH 3/5] ARM: i.MX6: Add PWM clk lookups Sascha Hauer
2014-02-13 10:00 ` [PATCH 4/5] ARM: dts: i.MX6: Add pwm aliases Sascha Hauer
2014-02-13 10:00 ` [PATCH 5/5] PWM: Add i.MX PWM driver 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=1392285621-17485-2-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@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