From patchwork Tue Apr 10 08:04: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: 7699 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 52F6F23E49 for ; Tue, 10 Apr 2012 08:04:42 +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 ED643A181B6 for ; Tue, 10 Apr 2012 08:04:41 +0000 (UTC) Received: by iage36 with SMTP id e36so9854175iag.11 for ; Tue, 10 Apr 2012 01:04:41 -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=k2dG+o/wKpOAIRROghSJx+R+0K0lCCIu7eopf+qRFKk=; b=Oe5MGXzWCJQZt0TY483QGQTTh+Qw63mZAvd10LzXW7uakHjvpM9G6UsnbpHF1nqJpg zKv7+fdPDHo6Son8TNjBK2OW4dAtr/PbnsZbJijR2Az3lPcwd42vEBYMBqh3SvwVBhbs qqajeaUv9FJhc4TzgPL4G82Uo2MKBES+EVvg4MRulAmQ98CSLcuF6c4DKPCCX2rS45v1 Byr6O2D+aALma3JKnALOwAIZlj25Py00qEBmJoBjFRkp69dLAPGqVDKzK49SOpVaICxo J04HdjBG/C7Iy2RwLsGZmg0Mg3Z89qVIipThk+sJK53wzSJTohYEL8e1XEHjHKUCM/VS 7q4w== Received: by 10.50.51.197 with SMTP id m5mr1356537igo.38.1334045081287; Tue, 10 Apr 2012 01:04:41 -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 f25csp9322iby; Tue, 10 Apr 2012 01:04:40 -0700 (PDT) Received: by 10.14.28.132 with SMTP id g4mr1202607eea.96.1334045079759; Tue, 10 Apr 2012 01:04:39 -0700 (PDT) Received: from eu1sys200aog116.obsmtp.com (eu1sys200aog116.obsmtp.com. [207.126.144.141]) by mx.google.com with SMTP id q1si5526689eem.56.2012.04.10.01.04.25 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 Apr 2012 01:04:39 -0700 (PDT) Received-SPF: neutral (google.com: 207.126.144.141 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.141; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.141 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 eu1sys200aob116.postini.com ([207.126.147.11]) with SMTP ID DSNKT4Ppha07glOtktBYeZeQgjM2VANaPoUw@postini.com; Tue, 10 Apr 2012 08:04:38 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 42036D9; Tue, 10 Apr 2012 07:55:52 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-ap.st.com (STMicroelectronics) with ESMTP id 8A442168E; Tue, 10 Apr 2012 08:04:15 +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 relay2.stm.gmessaging.net (Postfix) with ESMTPS id 398A1A8072; Tue, 10 Apr 2012 10:04:11 +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; Tue, 10 Apr 2012 10:04:14 +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] pinctrl: implement pinctrl deferred probing Date: Tue, 10 Apr 2012 10:04:08 +0200 Message-ID: <1334045048-15566-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: ALoCoQkYUOdRlqkey7EUb7oFHnPCNOS2SHsfMAJsJvGnY8hjinYMJAUfJkuD/d+GESbn7sEvX2GA 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. Cc: Mark Brown Cc: Arnd Bergmann Signed-off-by: Linus Walleij --- Documentation/pinctrl.txt | 5 +++++ drivers/pinctrl/core.c | 7 +++++-- drivers/pinctrl/devicetree.c | 4 ++-- 3 files changed, 12 insertions(+), 4 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..3ae00ab 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -521,8 +521,11 @@ static int add_setting(struct pinctrl *p, struct pinctrl_map const *map) dev_err(p->dev, "unknown pinctrl device %s in map entry", 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..8833538 100644 --- a/drivers/pinctrl/devicetree.c +++ b/drivers/pinctrl/devicetree.c @@ -124,8 +124,8 @@ static int dt_to_map_one_config(struct pinctrl *p, const char *statename, dev_err(p->dev, "could not find pctldev for node %s\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)