mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Subject: [PATCH 5/6] PWM: Allow multiple PWMs per device node
Date: Fri, 12 Jun 2015 11:53:40 +0200	[thread overview]
Message-ID: <1434102821-10555-5-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1434102821-10555-1-git-send-email-s.hauer@pengutronix.de>

Matching a device node is enough since a device node may have
multiple PWMs. Check for a id aswell.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/pwm/core.c | 7 ++++---
 include/pwm.h      | 2 ++
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index cc33dec..3605201 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -181,12 +181,13 @@ struct pwm_device *pwm_request(const char *devname)
 }
 EXPORT_SYMBOL_GPL(pwm_request);
 
-static struct pwm_device *of_node_to_pwm_device(struct device_node *np)
+static struct pwm_device *of_node_to_pwm_device(struct device_node *np, int id)
 {
 	struct pwm_device *pwm;
 
 	list_for_each_entry(pwm, &pwm_list, node) {
-		if (pwm->hwdev && pwm->hwdev->device_node == np)
+		if (pwm->hwdev && pwm->hwdev->device_node == np &&
+				pwm->chip->id == id)
 			return pwm;
 	}
 
@@ -210,7 +211,7 @@ struct pwm_device *of_pwm_request(struct device_node *np, const char *con_id)
 		return ERR_PTR(ret);
 	}
 
-	pwm = of_node_to_pwm_device(args.np);
+	pwm = of_node_to_pwm_device(args.np, args.args[0]);
 	if (IS_ERR(pwm)) {
 		pr_debug("%s(): PWM chip not found\n", __func__);
 		return pwm;
diff --git a/include/pwm.h b/include/pwm.h
index 59d86d4..911c760 100644
--- a/include/pwm.h
+++ b/include/pwm.h
@@ -57,12 +57,14 @@ struct pwm_ops {
 
 /**
  * struct pwm_chip - abstract a PWM
+ * @id: The id of this pwm
  * @devname: unique identifier for this pwm
  * @ops: The callbacks for this PWM
  * @duty_ns: The duty cycle of the PWM, in nano-seconds
  * @period_ns: The period of the PWM, in nano-seconds
  */
 struct pwm_chip {
+	int			id;
 	const char		*devname;
 	struct pwm_ops		*ops;
 	int			duty_ns;
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2015-06-12  9:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-12  9:53 [PATCH 1/6] video: stmfb: Add device tree support Sascha Hauer
2015-06-12  9:53 ` [PATCH 2/6] video: Add backlight support Sascha Hauer
2015-06-12  9:53 ` [PATCH 3/6] video: Add PWM " Sascha Hauer
2015-06-12  9:58   ` Marc Kleine-Budde
2015-06-12  9:53 ` [PATCH 4/6] ARM: i.MX28: Add PWM clk support Sascha Hauer
2015-06-12  9:53 ` Sascha Hauer [this message]
2015-06-12  9:53 ` [PATCH 6/6] PWM: Add MXS PWM 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=1434102821-10555-5-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