From patchwork Wed Dec 12 19:53:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 13516 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 8B8CA23E27 for ; Wed, 12 Dec 2012 19:54:09 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 1C0B2A181D8 for ; Wed, 12 Dec 2012 19:54:09 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id c10so2673991ieb.11 for ; Wed, 12 Dec 2012 11:54:08 -0800 (PST) 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=Ls1t4upHSrQ+fMMtcJtF3tLZQlrKWT1HrKOUAiFhO14=; b=Eox09mD+i4fIxInz8Fv5Ryp/aqkGMn5gH70OhSIV0SKReNzwKf/QgYnqLen/Stm0sa V4bbePG1xqGlUUapvJRVoifYKSj1FwL0a/7hvCcmbxLfuPqrA3PrwrMhn35DX6pp0Cug eR5kEC2KvG0ukF4IUcf36BC5MLKPA5ZtjUX2iAQtPvkAfMsJgu60FQvr982/DEXP+o/Z RXHt3xumdRe7F6gXDqicWMc/OFXnAQJMXFAKQcXdFFMq+Nz5Mqs49eOhMQopA14R5BRA tYCuyaJvAF+NR8pndKc141rqy3qa2oE0VpExQWCAfbh+DhFYCoj3147K0a1XBkNKVcJa b/ow== Received: by 10.42.32.200 with SMTP id f8mr1803794icd.18.1355342048555; Wed, 12 Dec 2012 11:54:08 -0800 (PST) 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.50.67.148 with SMTP id n20csp221684igt; Wed, 12 Dec 2012 11:54:07 -0800 (PST) Received: by 10.14.223.135 with SMTP id v7mr5551945eep.41.1355342047423; Wed, 12 Dec 2012 11:54:07 -0800 (PST) Received: from eu1sys200aog105.obsmtp.com (eu1sys200aog105.obsmtp.com [207.126.144.119]) by mx.google.com with SMTP id q6si65784262eep.0.2012.12.12.11.53.59 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Dec 2012 11:54:07 -0800 (PST) Received-SPF: neutral (google.com: 207.126.144.119 is neither permitted nor denied by best guess record for domain of linus.walleij@stericsson.com) client-ip=207.126.144.119; Authentication-Results: mx.google.com; spf=neutral (google.com: 207.126.144.119 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-us.st.com ([167.4.1.35]) (using TLSv1) by eu1sys200aob105.postini.com ([207.126.147.11]) with SMTP ID DSNKUMjg17fECqi5cosCH83e+xIA1NENcPCc@postini.com; Wed, 12 Dec 2012 19:54:07 UTC Received: from zeta.dmz-us.st.com (ns4.st.com [167.4.16.71]) by beta.dmz-us.st.com (STMicroelectronics) with ESMTP id 41E8859; Wed, 12 Dec 2012 19:53:15 +0000 (GMT) Received: from relay2.stm.gmessaging.net (unknown [10.230.100.18]) by zeta.dmz-us.st.com (STMicroelectronics) with ESMTP id E9C5349; Wed, 12 Dec 2012 14:43:37 +0000 (GMT) Received: from exdcvycastm003.EQ1STM.local (alteon-source-exch [10.230.100.61]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client CN "exdcvycastm003", Issuer "exdcvycastm003" (not verified)) by relay2.stm.gmessaging.net (Postfix) with ESMTPS id 1FC7BA8072; Wed, 12 Dec 2012 20:53:45 +0100 (CET) Received: from steludxu4075.lud.stericsson.com (10.230.100.153) by smtp.stericsson.com (10.230.100.1) with Microsoft SMTP Server (TLS) id 8.3.83.0; Wed, 12 Dec 2012 20:53:52 +0100 From: Linus Walleij To: , Cc: Stephen Warren , Anmar Oueja , Linus Walleij Subject: [PATCH 2/2 v2] pinctrl: skip deferral of hogs Date: Wed, 12 Dec 2012 20:53:47 +0100 Message-ID: <1355342027-2287-1-git-send-email-linus.walleij@stericsson.com> X-Mailer: git-send-email 1.7.11.3 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQnbiTDHqLubwjvo41P1/iIn20AT1W25TBB7MHVw74Q2ztweSUvMxJx+O6LmCloMSMz1BpZz From: Linus Walleij Up until now, as hogs were always taken at the end of the pin control device registration, it didn't cause any problem. But when starting to hog pins from the device core it will cause deferral of the pin controller device itself since the default pin fetch is done *before* the device probes, so let's fix this annoyance (which is also aesthetically ugly). Also take some care to make sure that if any one map entry results in a deferral rather than a failure, then that deferral will take precedence. Signed-off-by: Linus Walleij --- ChangeLog v1->v2: - Make deferral take precedence. --- drivers/pinctrl/core.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index 59f5a96..5b4885c 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c @@ -609,13 +609,16 @@ 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_info(p->dev, "unknown pinctrl device %s in map entry, deferring probe", - map->ctrl_dev_name); kfree(setting); + /* Do not defer probing of hogs (circular loop) */ + if (!strcmp(map->ctrl_dev_name, map->dev_name)) + return -ENODEV; /* * OK let us guess that the driver is not there yet, and * let's defer obtaining this pinctrl handle to later... */ + dev_info(p->dev, "unknown pinctrl device %s in map entry, deferring probe", + map->ctrl_dev_name); return -EPROBE_DEFER; } @@ -694,11 +697,29 @@ static struct pinctrl *create_pinctrl(struct device *dev) continue; ret = add_setting(p, map); - if (ret < 0) { + /* + * At this point the adding of a setting may: + * + * - Defer, if the pinctrl device is not yet available + * - Fail, if the pinctrl device is not yet available, + * AND the setting is a hog. We cannot defer that, since + * the hog will kick in immediately after the device + * is registered. + * + * If the error returned was not -EPROBE_DEFER then we + * accumulate the errors to see if we end up with + * an -EPROBE_DEFER later, as that is the worst case. + */ + if (ret == -EPROBE_DEFER) { pinctrl_put_locked(p, false); return ERR_PTR(ret); } } + if (ret < 0) { + /* If some other error than deferral occured, return here */ + pinctrl_put_locked(p, false); + return ERR_PTR(ret); + } /* Add the pinctrl handle to the global list */ list_add_tail(&p->node, &pinctrl_list);