From patchwork Tue May 30 16:25:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9754859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A4BA1602BF for ; Tue, 30 May 2017 16:27:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9725726538 for ; Tue, 30 May 2017 16:27:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A50827165; Tue, 30 May 2017 16:27:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6B3D826538 for ; Tue, 30 May 2017 16:27:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750946AbdE3Q1D (ORCPT ); Tue, 30 May 2017 12:27:03 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:33650 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751067AbdE3Q1B (ORCPT ); Tue, 30 May 2017 12:27:01 -0400 Received: by mail-lf0-f66.google.com with SMTP id m18so9326562lfj.0; Tue, 30 May 2017 09:26:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=oblG/d28iS8mXpL4oqTtiMaBXvELcplyESdpQgkJSe8=; b=H623CMfMJ0Xr6d4UqyUoOWe3heiHgtp/gaX1PylqovxAfJIIqsd6Pm2dLl/QrjVw/G om81Owur0AnrZ+NwmAFh7oP1m2b8OOPwXz7d6XdxRysaLqQTy4SsPoVC0BAvrSWi8Ce+ 1F8IL8lPKaXMHB1DPy/GGQDP/22mjkn4SIx6WcGsPGGszshNRnerTaP98GbJMQmeQvSD vapVlkD+GHRTCjSopEkfxtUCLv9qmPzXaC1LkpWmNQAT8/KQRwBbwqlqPDws/WCgpjBs BajiVGrjTcHYq8ocV2Kp3yGsM7qvUofItJaJUp5X00qghrG2ZZLor2rdQMU/Edv7zGMj Am1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=oblG/d28iS8mXpL4oqTtiMaBXvELcplyESdpQgkJSe8=; b=SQv1W25cM8Ers95KNqxKDI/dKV8UMtouzK5zOBLCjLLHCvj50H/ci6YSRKm04k3hn2 9P/B8engoUz5N6UIeFo6HnE1ZxGEGgcO6wCIpP/UBTp2GLWNvKUFyrqzuFt5uQvrObAn gtXv1BU1XeSg/0oapmUn07Ui4MrVy0jQqVifZ7JHk+QVqorpRwNc05EYY2leJ8uzIoV7 ZqiNLhgmvoMbsUeZHqtaLEdbZBpbXCeMKfC90SczVvsLX53tTU2tHiZeSQ7r0Oz2Ndns +ljp2PhXZhP8twXgeno8xS/vn/WG5ZOHCK7CAPwmKsDqYd0Yi/ufK3Rq30poWh6pMtRS yihg== X-Gm-Message-State: AODbwcBY8Ra1VNdW1SJpqGZWxu7NBvA0uW1qpuwoV8ouAapVW/nx+Su/ dTW+b+/0JQ33Yw== X-Received: by 10.25.201.21 with SMTP id z21mr5991967lff.35.1496161609022; Tue, 30 May 2017 09:26:49 -0700 (PDT) Received: from xi.terra (c-42c8e255.07-184-6d6c6d4.cust.bredbandsbolaget.se. [85.226.200.66]) by smtp.gmail.com with ESMTPSA id x78sm2824647lfd.41.2017.05.30.09.26.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 May 2017 09:26:47 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1dFjyr-0006p3-Au; Tue, 30 May 2017 18:26:49 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Linus Walleij , Peter Chen , Rob Herring , Arnd Bergmann , Sricharan R , Zhang Rui , Eduardo Valentin , linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 4/7] driver core: fix automatic pinctrl management Date: Tue, 30 May 2017 18:25:51 +0200 Message-Id: <20170530162554.26159-5-johan@kernel.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170530162554.26159-1-johan@kernel.org> References: <20170530162554.26159-1-johan@kernel.org> Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit ab78029ecc34 ("drivers/pinctrl: grab default handles from device core") added automatic pin-control management to driver core by looking up and setting any default pinctrl state found in device tree while a device is being probed. This obviously runs into problems as soon as device-tree nodes are reused for child devices which are later also probed as pins would already have been claimed by the ancestor device. For example if a USB host controller claims a pin, its root hub would consequently fail to probe when its device-tree node is set to the node of the controller: pinctrl-single 48002030.pinmux: pin PIN204 already requested by 48064800.ehci; cannot claim for usb1 pinctrl-single 48002030.pinmux: pin-204 (usb1) status -22 pinctrl-single 48002030.pinmux: could not request pin 204 (PIN204) from group usb_dbg_pins on device pinctrl-single usb usb1: Error applying setting, reverse things back usb: probe of usb1 failed with error -22 Fix this by checking the new of_node_reused flag and skipping automatic pinctrl configuration during probe if set. Note that the flag is checked in driver core rather than in pinctrl (e.g. in pinctrl_dt_to_map()) which would specifically have prevented intentional use of a parent's pinctrl properties by a child device (should such a need ever arise). Fixes: ab78029ecc34 ("drivers/pinctrl: grab default handles from device core") Signed-off-by: Johan Hovold Acked-by: Linus Walleij --- drivers/base/pinctrl.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/base/pinctrl.c b/drivers/base/pinctrl.c index 5917b4b5fb99..eb929dd6ef1e 100644 --- a/drivers/base/pinctrl.c +++ b/drivers/base/pinctrl.c @@ -23,6 +23,9 @@ int pinctrl_bind_pins(struct device *dev) { int ret; + if (dev->of_node_reused) + return 0; + dev->pins = devm_kzalloc(dev, sizeof(*(dev->pins)), GFP_KERNEL); if (!dev->pins) return -ENOMEM;