From patchwork Tue Oct 21 09:40:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 401408 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 845F114007F for ; Tue, 21 Oct 2014 20:40:56 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752915AbaJUJk4 (ORCPT ); Tue, 21 Oct 2014 05:40:56 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:47059 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751283AbaJUJkz (ORCPT ); Tue, 21 Oct 2014 05:40:55 -0400 Received: from dude.hi.pengutronix.de ([2001:67c:670:100:1d::7]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1XgVvs-0003fJ-Gj; Tue, 21 Oct 2014 11:40:48 +0200 Received: from ukl by dude.hi.pengutronix.de with local (Exim 4.84) (envelope-from ) id 1XgVvr-0007Sm-SD; Tue, 21 Oct 2014 11:40:47 +0200 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= To: Shawn Guo , Linus Walleij Cc: linux-gpio@vger.kernel.org, kernel@pengutronix.de Subject: [PATCH] pinctrl: mxs: warn if functions are not grouped by name Date: Tue, 21 Oct 2014 11:40:45 +0200 Message-Id: <1413884445-28347-1-git-send-email-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 2.1.1 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-gpio@vger.kernel.org Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org 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 Acked-by: Shawn Guo --- I tried to fix that, but it made my machine fail to boot without any output and I currently don't have access to an i.MX28 with a working debug UART, so I cannot use earlyprintk without effort. I wrote this patch because I debugged this issue the second time now. I admit that a fix would be better, but a warning is better as the status quo. If someone is interested in a proper fix I can provide my broken patch, maybe someone spots my error. The current issue was with mac0 on an i.MX28 and I expected the fec driver to fail to bind, but ethernet works just fine (relying on the pinmuxing done by the bootloader). Also something not catched is if for two functions with the same name, the reg property is identical. This somehow breaks, too. Didn't debug this one. Best regards Uwe --- drivers/pinctrl/freescale/pinctrl-mxs.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/pinctrl/freescale/pinctrl-mxs.c b/drivers/pinctrl/freescale/pinctrl-mxs.c index f98c6bb0f769..646d5c244af1 100644 --- a/drivers/pinctrl/freescale/pinctrl-mxs.c +++ b/drivers/pinctrl/freescale/pinctrl-mxs.c @@ -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; }