From patchwork Wed Apr 11 08:34:08 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 7733 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 94E1923E12 for ; Wed, 11 Apr 2012 08:34:40 +0000 (UTC) Received: from mail-iy0-f180.google.com (mail-iy0-f180.google.com [209.85.210.180]) by fiordland.canonical.com (Postfix) with ESMTP id 30AD5A18174 for ; Wed, 11 Apr 2012 08:34:40 +0000 (UTC) Received: by iage36 with SMTP id e36so1346168iag.11 for ; Wed, 11 Apr 2012 01:34:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf:from:to:cc :subject:date:message-id:x-mailer:mime-version:content-type :x-gm-message-state; bh=zZZwSEjgr8un3dQ26UaI3xkEg8H/8bQvZDeZApmR0TU=; b=n+Z+/J2lj8s+PsKSp4D1HEW4DbhrNwGxBqFoV2Ve/+6bal5KSmtS7RGUxikLvdT9RU hbdCCvO4Sc66147ChmdxvKH17bzr9sohoH9bbNOj0JOdzF6qV43y/pGt+hBWk05wrHnf zHYgWqxkwvghz75o9DhlSjfldamm8L3FMtcN67idIEPIg2rP71OI7xrAslsZ6u311Ylm sMCo+nTlJ/jqgK2ex0E+R8fQrFUe89LJ2Lq/XJdZtOGMG1IDcgTxKUMUyN0p0X0y4vQE WOfEG3Xp/EXHd2Bx2/EPndVwHAl9HdmWS416agQocA9XDPeI60U7d/jACKGvpxScDacC gYRg== Received: by 10.42.155.9 with SMTP id s9mr8622238icw.51.1334133279583; Wed, 11 Apr 2012 01:34:39 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.231.164.217 with SMTP id f25csp56409iby; Wed, 11 Apr 2012 01:34:38 -0700 (PDT) Received: by 10.14.96.198 with SMTP id r46mr1800274eef.80.1334133277365; Wed, 11 Apr 2012 01:34:37 -0700 (PDT) Received: from eu1sys200aog104.obsmtp.com (eu1sys200aog104.obsmtp.com. [207.126.144.117]) by mx.google.com with SMTP id a2si480042eeg.98.2012.04.11.01.34.23 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 11 Apr 2012 01:34:37 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.117 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.117; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.117 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) smtp.mail=linus.walleij@stericsson.com Received: from beta.dmz-ap.st.com ([138.198.100.35]) (using TLSv1) by eu1sys200aob104.postini.com ([207.126.147.11]) with SMTP ID DSNKT4VCDJat7VtBcc7Nf/JlPRGjsqp3C8na@postini.com; Wed, 11 Apr 2012 08:34:36 UTC Received: from zeta.dmz-ap.st.com (ns6.st.com [138.198.234.13]) by beta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 42EEEF8; Wed, 11 Apr 2012 08:25:52 +0000 (GMT) Received: from relay1.stm.gmessaging.net (unknown [10.230.100.17]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id DF6F08D8; Wed, 11 Apr 2012 08:34:14 +0000 (GMT) Received: from exdcvycastm004.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm004", Issuer "exdcvycastm004" (not verified)) by relay1.stm.gmessaging.net (Postfix) with ESMTPS id 432B824C2F3; Wed, 11 Apr 2012 10:34:09 +0200 (CEST) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.2) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 11 Apr 2012 10:34:13 +0200 From: Linus Walleij To: , Cc: Stephen Warren , Shawn Guo , Thomas Abraham , Dong Aisheng , Rajendra Nayak , Haojian Zhuang , Linus Walleij , Mark Brown , Arnd Bergmann Subject: [PATCH v2] pinctrl: implement pinctrl deferred probing Date: Wed, 11 Apr 2012 10:34:08 +0200 Message-ID: <1334133248-1452-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.9.2 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmaiAbkSbRfFbDrUhYQhNiiMMhS4zdVDj0IntZggBrhxXVnMu04Me7LLxd3j4UsmrOcMU5Z From: Linus Walleij If drivers try to obtain pinctrl handles for a pin controller that has not yet registered to the subsystem, we need to be able to back out and retry with deferred probing. So let's return -EPROBE_DEFER whenever this location fails. Also downgrade the errors to info, maybe we will even set them to debug once the deferred probing is commonplace. Cc: Mark Brown Cc: Arnd Bergmann Signed-off-by: Linus Walleij --- Documentation/pinctrl.txt | 5 +++++ drivers/pinctrl/core.c | 9 ++++++--- drivers/pinctrl/devicetree.c | 6 +++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/Documentation/pinctrl.txt b/Documentation/pinctrl.txt index eb46b1c..4431c3e7 100644 --- a/Documentation/pinctrl.txt +++ b/Documentation/pinctrl.txt @@ -1043,6 +1043,11 @@ quickly poking some registers. The pins are allocated for your device when you issue the pinctrl_get() call, after this you should be able to see this in the debugfs listing of all pins. +NOTE: the pinctrl system will return -EPROBE_DEFER if it cannot find the +requested pinctrl handles, for example if the pinctrl driver has not yet +registered. Thus make sure that the error path in your driver gracefully +cleans up and is ready to retry the probing later in the startup process. + System pin control hogging ========================== diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 7ff8690..59027ab 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -518,11 +518,14 @@ static int add_setting(struct pinctrl *p, struct pinctrl_map const *map) setting->pctldev = get_pinctrl_dev_from_devname(map->ctrl_dev_name); if (setting->pctldev == NULL) { - dev_err(p->dev, "unknown pinctrl device %s in map entry", + dev_info(p->dev, "unknown pinctrl device %s in map entry, deferring probe", map->ctrl_dev_name); kfree(setting); - /* Eventually, this should trigger deferred probe */ - return -ENODEV; + /* + * OK let us guess that the driver is not there yet, and + * let's defer obtaining this pinctrl handle to later... + */ + return -EPROBE_DEFER; } switch (map->type) { diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c index 5ef2feb..fcb1de4 100644 --- a/drivers/pinctrl/devicetree.c +++ b/drivers/pinctrl/devicetree.c @@ -121,11 +121,11 @@ static int dt_to_map_one_config(struct pinctrl *p, const char *statename, for (;;) { np_pctldev = of_get_next_parent(np_pctldev); if (!np_pctldev || of_node_is_root(np_pctldev)) { - dev_err(p->dev, "could not find pctldev for node %s\n", + dev_info(p->dev, "could not find pctldev for node %s, deferring probe\n", np_config->full_name); of_node_put(np_pctldev); - /* FIXME: This should trigger deferrered probe */ - return -ENODEV; + /* OK let's just assume this will appear later then */ + return -EPROBE_DEFER; } pctldev = find_pinctrl_by_of_node(np_pctldev); if (pctldev)