summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-06-12 11:48:17 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-06-12 12:00:41 +0200
commit605621a3c85387e7bd896ce3fa7b2c974a0a8601 (patch)
treec8a6ca90380facc35aec1d4f0aa341ba008b2d5a
parentcd616c464228f54f4b5371dd6308a35ef0249cfd (diff)
downloadbarebox-605621a3c85387e7bd896ce3fa7b2c974a0a8601.tar.gz
PWM: Allow multiple PWMs per device node
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>
-rw-r--r--drivers/pwm/core.c7
-rw-r--r--include/pwm.h2
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;