From patchwork Tue Jun 6 15:59:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9769219 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 227EA6034B for ; Tue, 6 Jun 2017 16:02:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CA3222B1F for ; Tue, 6 Jun 2017 16:02:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2156628415; Tue, 6 Jun 2017 16:02:24 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable 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 AA50222B1F for ; Tue, 6 Jun 2017 16:02:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751524AbdFFQAy (ORCPT ); Tue, 6 Jun 2017 12:00:54 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:35834 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751435AbdFFQAu (ORCPT ); Tue, 6 Jun 2017 12:00:50 -0400 Received: by mail-lf0-f68.google.com with SMTP id v20so9203641lfa.2; Tue, 06 Jun 2017 09:00:49 -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=l0sxWPxMQsEKMRa2e7vbQQAxBQTTCXESMi4a2vNeTVg=; b=BT1v/8HOSEZSRByoD2g+nioy3kUZd67BRMKruzgP3q1FFnPAhqS8Fpic3wyQZLyQ+X uADy3eCFac/3qDpImOEtfRH65v/dIYlZcdXCI5zV74xWXkhCMZrbTJYNeOCm8yoh59IN 1PukxFbQPCjEoRzIiTDfzxI5Fm1D43UaGUzx7at2XQgCCgzbtFxH1hDiE89ZW0GV7xTT wzYO7xy8wYw6zQI2i7F/fhWIEFaCfyAutNSoTP5EhSR67bxR45L0e8OFywn57tHWlfyZ v4PVIjgSNhVVPEOPnixcKcLfHL8vyeQot0GuXEhG3uTHRjddyav+NBk8CEOrN/MNdlnp YZ5g== 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=l0sxWPxMQsEKMRa2e7vbQQAxBQTTCXESMi4a2vNeTVg=; b=JLagsOOvvED2Y8/C/iPw1K4vDCPDDwRoyXnleMfojYp3g7bOQimIhEQFqp+HCLXdf0 lFlKNNFRMSZLmKAI95WoSmyiTQeqoLoY6hGnTFte2oKnbl6VJZC6PL0MROa2dPjMPF+c K569/wkZ7yEiH3+F67W8nbQ9Jco6M2PcCWZRm+rTGV8RmEakY9XsRIdLhcy1nbDiVMmP +W414eon/aHjOWRZ73Z6C6HsbO3qptQFmBZK/q8TPZ1suNtNWjIrzAr3fCKRLWUwLVa6 S/BJSvWy3+pcyd8ovGhQ/sQ0ZZuF87i0MSKNJhSMLkjKsFpWwHb5kwjKiEk4vUxur4By v3Jw== X-Gm-Message-State: AODbwcCydzDL+HgBLiudyZ06UJF+vHO80l+Vt8FLwkNPq7zxf6pPBBEm ayMZeH9BVeXSUw== X-Received: by 10.25.227.15 with SMTP id a15mr7933750lfh.22.1496764848290; Tue, 06 Jun 2017 09:00:48 -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 r80sm7619012lff.63.2017.06.06.09.00.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Jun 2017 09:00:46 -0700 (PDT) Received: from johan by xi.terra with local (Exim 4.89) (envelope-from ) id 1dIGuU-00071E-TT; Tue, 06 Jun 2017 18:00:46 +0200 From: Johan Hovold To: Greg Kroah-Hartman Cc: Linus Walleij , Peter Chen , Rob Herring , Arnd Bergmann , Sricharan R , Zhang Rui , Eduardo Valentin , linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-usb@vger.kernel.org, Johan Hovold Subject: [PATCH v2 4/7] driver core: fix automatic pinctrl management Date: Tue, 6 Jun 2017 17:59:01 +0200 Message-Id: <20170606155904.26819-5-johan@kernel.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170606155904.26819-1-johan@kernel.org> References: <20170606155904.26819-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") Acked-by: Linus Walleij Signed-off-by: Johan Hovold --- 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;