From patchwork Thu Jun 7 16:51:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 926436 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="DPuhr1oN"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 411s5K73kmz9s1B for ; Fri, 8 Jun 2018 02:51:49 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932830AbeFGQvs (ORCPT ); Thu, 7 Jun 2018 12:51:48 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:41087 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932400AbeFGQvr (ORCPT ); Thu, 7 Jun 2018 12:51:47 -0400 Received: by mail-qk0-f193.google.com with SMTP id w23-v6so6977201qkb.8; Thu, 07 Jun 2018 09:51:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=okbSeXdRujaBBOEBntb5RCi4lbmBCAGl/IhIxb/YzW4=; b=DPuhr1oNU/CXMHNC/+gZ2zt2UIbzhuCbViasRvqZb0hGzd4QamG6b4jeB+9Qaw6Eou lwfL+uMrZ/5EMfa/E1p5c5FYQFCAiykTK9Z8aySD7oi6QX4hGUU0M7stTVhmp0QriV2/ Bqz5nHSC7HmQpuRlpN8sgPZ1WqJKdMJx/Y1XoV28A8kJkiQ2w2KGwOLafwuxNTDB6F9b 1+7zPviM8VzuTVFMuOcDN6Ogcor9RAaGY7RbtIWvxxwyKmfIm1+j1MSOZzKDRQ7a5vD4 AR6oU+J4hCLCYsl+6mAvSx/LKG38eFwP/Kkgwb7ZbBjBxEywk2HTy5MKcaqIwOI06Amh kp0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=okbSeXdRujaBBOEBntb5RCi4lbmBCAGl/IhIxb/YzW4=; b=LqMLacnRSNJzLXI3htQsbVB6FKvCnHLRl9RF3lsWrlmSaOKFuhwRs1RU5E9ggn4E1E cKyLpWScH8+pGOgVOkSQjEl7CYxi2xq5FAVMEuUQhYxxO57/QARp0Ptdx0QaF4e+tpca NmTMk3pAgQ+/hHLWo/o7ZstXjZz+6fcKohaE2tHsO4XdX/Pax3EZR3abjl1fiu2DGhBe M09e63iVuhhYBYeG0yHxqzEK2BeyYZuXJjXz5q8h9oFmChFgxF3NWPDa9mTk6EBIeulp JfjEjzuq5VayXGyA1+PU/pEg77hXhrwWiglgvLCn5RwuBE5otpc9zQ63Wuh8YguKJD+I aufw== X-Gm-Message-State: APt69E2Gu78XF0OiIwv39qu536LqJbw9hRvbE+Z3kO2NvdAgvHZv27sx b2fDFIWyQppbKmTLjyEc7bo= X-Google-Smtp-Source: ADUXVKIj4MC8vFK4vPF8N5OfFmjnCpMXl9DwQzPrmpUNn+WgPLFBqhUQleWYHUR5yCKi1Df7auY3qw== X-Received: by 2002:a37:4249:: with SMTP id p70-v6mr2158677qka.297.1528390306596; Thu, 07 Jun 2018 09:51:46 -0700 (PDT) Received: from localhost.localdomain ([2804:14c:482:b34:5548:7abc:2ac1:82cb]) by smtp.gmail.com with ESMTPSA id s15-v6sm26672417qtc.81.2018.06.07.09.51.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 07 Jun 2018 09:51:45 -0700 (PDT) From: Fabio Estevam To: linus.walleij@linaro.org Cc: rf@opensource.cirrus.com, linux-gpio@vger.kernel.org, slongerbeam@gmail.com, shawnguo@kernel.org, kernel@pengutronix.de, linux-imx@nxp.com, mika.penttila@nextfour.com, Fabio Estevam , stable@vger.kernel.org Subject: [PATCH] pinctrl: devicetree: Fix pctldev pointer overwrite Date: Thu, 7 Jun 2018 13:51:33 -0300 Message-Id: <1528390293-8022-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org From: Fabio Estevam Commit b89405b6102f ("pinctrl: devicetree: Fix dt_to_map_one_config handling of hogs") causes the pinctrl hog pins to not get initialized on i.MX platforms leaving them with the IOMUX settings untouched. This causes several regressions on i.MX such as: - OV5640 camera driver can not be probed anymore on imx6qdl-sabresd because the camera clock pin is in a pinctrl_hog group and since its pinctrl initialization is skipped, the camera clock is kept in GPIO functionality instead of CLK_CKO function. - Audio stopped working on imx6qdl-wandboard and imx53-qsb for the same reason. Richard Fitzgerald explains the problem: "I see the bug. If the hog node isn't a 1st level child of the pinctrl parent node it will go around the for(;;) loop again but on the first pass I overwrite pctldev with the result of get_pinctrl_dev_from_of_node() so it doesn't point to the pinctrl driver any more." Fix the issue by stashing the original pctldev so it doesn't get overwritten. Fixes: b89405b6102f ("pinctrl: devicetree: Fix dt_to_map_one_config handling of hogs") Cc: Reported-by: Mika Penttilä Reported-by: Steve Longerbeam Suggested-by: Richard Fitzgerald Signed-off-by: Fabio Estevam Reviewed-by: Richard Fitzgerald --- drivers/pinctrl/devicetree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c index b601039..c4aa411 100644 --- a/drivers/pinctrl/devicetree.c +++ b/drivers/pinctrl/devicetree.c @@ -101,10 +101,11 @@ struct pinctrl_dev *of_pinctrl_get(struct device_node *np) } static int dt_to_map_one_config(struct pinctrl *p, - struct pinctrl_dev *pctldev, + struct pinctrl_dev *hog_pctldev, const char *statename, struct device_node *np_config) { + struct pinctrl_dev *pctldev = NULL; struct device_node *np_pctldev; const struct pinctrl_ops *ops; int ret; @@ -123,8 +124,10 @@ static int dt_to_map_one_config(struct pinctrl *p, return -EPROBE_DEFER; } /* If we're creating a hog we can use the passed pctldev */ - if (pctldev && (np_pctldev == p->dev->of_node)) + if (hog_pctldev && (np_pctldev == p->dev->of_node)) { + pctldev = hog_pctldev; break; + } pctldev = get_pinctrl_dev_from_of_node(np_pctldev); if (pctldev) break;