[PATCH v2 10/12] pwm: register dependency parser for firmware nodes

From: Tomeu Vizoso
Date: Wed Jul 01 2015 - 05:45:28 EST


So others can find out what depends on pwm controllers, as specified
in bindings/pwm/pwm.txt.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@xxxxxxxxxxxxx>
---

Changes in v2: None

drivers/pwm/core.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)

diff --git a/drivers/pwm/core.c b/drivers/pwm/core.c
index 3a7769f..81b4fc0 100644
--- a/drivers/pwm/core.c
+++ b/drivers/pwm/core.c
@@ -917,11 +917,39 @@ static const struct file_operations pwm_debugfs_ops = {
.release = seq_release,
};

+static void pwm_get_dependencies(struct fwnode_handle *fwnode,
+ struct list_head *deps)
+{
+ struct device_node *np;
+ struct of_phandle_args pspec;
+ int count, i, ret;
+
+ np = to_of_node(fwnode);
+ if (!np)
+ return;
+
+ count = of_count_phandle_with_args(np, "pwms",
+ "#pwm-cells");
+ for (i = 0; i < count; i++) {
+ ret = of_parse_phandle_with_args(np, "pwms",
+ "#pwm-cells", i,
+ &pspec);
+ if (ret || !pspec.np)
+ continue;
+
+ fwnode_add_dependency(&pspec.np->fwnode, deps);
+
+ of_node_put(pspec.np);
+ }
+}
+
static int __init pwm_debugfs_init(void)
{
debugfs_create_file("pwm", S_IFREG | S_IRUGO, NULL, NULL,
&pwm_debugfs_ops);

+ fwnode_add_dependency_parser(pwm_get_dependencies);
+
return 0;
}

--
2.4.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/