pinctrl: mxs: warn if functions are not grouped by name
authorUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Tue, 21 Oct 2014 09:40:45 +0000 (11:40 +0200)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 30 Oct 2014 14:52:39 +0000 (15:52 +0100)
The mxs pinctrl driver cannot handle when functions are not grouped by
name (which IMO is a bug). This happens for example if a
imx28-somemachine.dts provides a function that has the same name as a
function defined in imx28.dtsi.

The proper way to fix that would be to check for duplicates in the loops
(which increases parsing time) or parse the groups first and sort the
resulting array.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/pinctrl/freescale/pinctrl-mxs.c

index f98c6bb0f76974cea03e55e127be9fb107423ad3..646d5c244af11df315259660c5047c4f239ad6ff 100644 (file)
@@ -445,6 +445,31 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev,
                if (of_property_read_u32(child, "reg", &val))
                        continue;
                if (strcmp(fn, child->name)) {
+                       struct device_node *child2;
+
+                       /*
+                        * This reference is dropped by
+                        * of_get_next_child(np, * child)
+                        */
+                       of_node_get(child);
+
+                       /*
+                        * The logic parsing the functions from dt currently
+                        * doesn't handle if functions with the same name are
+                        * not grouped together. Only the first contiguous
+                        * cluster is usable for each function name. This is a
+                        * bug that is not trivial to fix, but at least warn
+                        * about it.
+                        */
+                       for (child2 = of_get_next_child(np, child);
+                            child2 != NULL;
+                            child2 = of_get_next_child(np, child2)) {
+                               if (!strcmp(child2->name, fn))
+                                       dev_warn(&pdev->dev,
+                                                "function nodes must be grouped by name (failed for: %s)",
+                                                fn);
+                       }
+
                        f = &soc->functions[idxf++];
                        f->name = fn = child->name;
                }