Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp361686yba; Wed, 24 Apr 2019 02:31:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqwM3jNqWmyl87qIWzgjTIp08btJzqS7NjZINxgHoTI8MpQdDoxsHWwHmuyebE+4fHMK7wyw X-Received: by 2002:a65:64c8:: with SMTP id t8mr13053361pgv.248.1556098294777; Wed, 24 Apr 2019 02:31:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556098294; cv=none; d=google.com; s=arc-20160816; b=gV8z/nRSf6iZ6qBuKHK2RKzvdQ4/vvbexA/4xDopHSD5miV2TQe7tCyPJ/zzPhJ4OM TdG65MW09BfKyBpBIZfMrTnpStQkqIjdjR3SfggQZwmDjrCNv9h1lbYWsYmDRytoQ6ln MXGios1gzrRPy5eXa6N+dm1lPcLEekwPfxz7crZlYa2+Gzgb2hfBg2/4Sw5IsB4+lOkz WHopw2NjrhvAt4ixXc7GMbQZBK51KCDnsMZ8J7TqKL3QN4wcAs2c5PP6j4fHWDZNqzWP DkVDOoBRaIkdA/4wUFbinqMPYTFqE7fN3wkcFJHa+PommtwBLN4/0Hl4uFZs5DyseoOW mN0w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:to:subject:dkim-signature; bh=2o5IGPIQ5p1cWC32IDoQF85xBOwkYPMDHu6k/f7altE=; b=qOWrVJhPUbObnI8uH2LOqLg6myxgjMBKktd1C3QyOw+o92vA+qFausaQzPG29ySIq6 hIkdRMrWbr8lwHIzMhZPuYmDHWRYlsDouhGVK5lsWeXMGBedwFz8chg6kmBnf8LMAtEE fTf+4Uj+NLrgP1ngXqTFdGq9lh9KEcfue9GSAj40oeUSPtjLRqxdZNXI/2vDf5JRcLRa LiVt/MFRAXeLme46Y+P7QHY3SMwP3xl9lEm6RUJcZjfO+L6t3JqLG8nb1HBFoSR4Tp0+ Qmyor+CeXK/1xYSVqrV/tcdkQMz77mo2IBnSE6RfIgI0JC59NL7zOoj9n4YAx3fqWAb1 cdpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=FAaJNQW3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h2si19876178pfk.277.2019.04.24.02.31.17; Wed, 24 Apr 2019 02:31:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=FAaJNQW3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728971AbfDXJaQ (ORCPT + 99 others); Wed, 24 Apr 2019 05:30:16 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:23692 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726176AbfDXJaP (ORCPT ); Wed, 24 Apr 2019 05:30:15 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x3O9S2xl016196; Wed, 24 Apr 2019 11:29:50 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=subject : to : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=STMicroelectronics; bh=2o5IGPIQ5p1cWC32IDoQF85xBOwkYPMDHu6k/f7altE=; b=FAaJNQW32HeoS4ZvT3oGug14CS4FmZMpfdnCFjhMPEh8nIy3sOj32YHDvja4H4R37lWU BmMmv+VnVofzrdK3HRsO97u2TYC5MBKp82GX514qcLaRuGzdbT+4NJXdqhN/Jr3Zazd0 l89Vz3yMguA4lbKl3/3qhe95hdNR3gvbc5Yh9Lf8X0Y4PQWoMkJdCgLb3oOhOSEPaKtE x39y79eN3XT8kwdcv8rcU4eFV7Bv29MnYf/8QTGNVWECO2Fwd8OiGY2RSpj3Kd6kR0Pl xCKmi6kiv4JgxnzGNerJcGnpNqEyRu71LeCMCNhO1SReKz23+MJ4x912U1JUsRygA9FE bQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2ryrj65yrq-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 24 Apr 2019 11:29:50 +0200 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 19A323A; Wed, 24 Apr 2019 09:29:50 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag3node2.st.com [10.75.127.8]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id E89E7157D; Wed, 24 Apr 2019 09:29:49 +0000 (GMT) Received: from [10.48.0.204] (10.75.127.47) by SFHDAG3NODE2.st.com (10.75.127.8) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Wed, 24 Apr 2019 11:29:49 +0200 Subject: Re: [PATCH] pinctrl: stm32: check irq controller availability at probe To: Fabien Dessenne , Linus Walleij , Maxime Coquelin , Benjamin Gaignard , , , , References: <1556093324-1008-1-git-send-email-fabien.dessenne@st.com> From: Alexandre Torgue Message-ID: <8d65f99f-0874-8012-5e44-3e579cb1f878@st.com> Date: Wed, 24 Apr 2019 11:29:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1556093324-1008-1-git-send-email-fabien.dessenne@st.com> Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG7NODE3.st.com (10.75.127.21) To SFHDAG3NODE2.st.com (10.75.127.8) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-04-23_02:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/24/19 10:08 AM, Fabien Dessenne wrote: > It is not guaranteed that the IRQ controller driver is probed before > the pin controller driver gets probed. > Considering this, check for the irq domain availability during probe > and return EPROBE_DEFER if needed. > > Signed-off-by: Fabien Dessenne > --- Acked-by: Alexandre TORGUE > drivers/pinctrl/stm32/pinctrl-stm32.c | 37 +++++++++++++++++++++++++---------- > 1 file changed, 27 insertions(+), 10 deletions(-) > > diff --git a/drivers/pinctrl/stm32/pinctrl-stm32.c b/drivers/pinctrl/stm32/pinctrl-stm32.c > index 0aebc31..2317ccf 100644 > --- a/drivers/pinctrl/stm32/pinctrl-stm32.c > +++ b/drivers/pinctrl/stm32/pinctrl-stm32.c > @@ -1122,23 +1122,35 @@ static int stm32_gpiolib_register_bank(struct stm32_pinctrl *pctl, > return 0; > } > > +static struct irq_domain *stm32_pctrl_get_irq_domain(struct device_node *np) > +{ > + struct device_node *parent; > + struct irq_domain *domain; > + > + if (!of_find_property(np, "interrupt-parent", NULL)) > + return NULL; > + > + parent = of_irq_find_parent(np); > + if (!parent) > + return ERR_PTR(-ENXIO); > + > + domain = irq_find_host(parent); > + if (!domain) > + /* domain not registered yet */ > + return ERR_PTR(-EPROBE_DEFER); > + > + return domain; > +} > + > static int stm32_pctrl_dt_setup_irq(struct platform_device *pdev, > struct stm32_pinctrl *pctl) > { > - struct device_node *np = pdev->dev.of_node, *parent; > + struct device_node *np = pdev->dev.of_node; > struct device *dev = &pdev->dev; > struct regmap *rm; > int offset, ret, i; > int mask, mask_width; > > - parent = of_irq_find_parent(np); > - if (!parent) > - return -ENXIO; > - > - pctl->domain = irq_find_host(parent); > - if (!pctl->domain) > - return -ENXIO; > - > pctl->regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); > if (IS_ERR(pctl->regmap)) > return PTR_ERR(pctl->regmap); > @@ -1264,6 +1276,11 @@ int stm32_pctl_probe(struct platform_device *pdev) > > platform_set_drvdata(pdev, pctl); > > + /* check for IRQ controller (may require deferred probe) */ > + pctl->domain = stm32_pctrl_get_irq_domain(np); > + if (IS_ERR(pctl->domain)) > + return PTR_ERR(pctl->domain); > + > /* hwspinlock is optional */ > hwlock_id = of_hwspin_lock_get_id(pdev->dev.of_node, 0); > if (hwlock_id < 0) { > @@ -1294,7 +1311,7 @@ int stm32_pctl_probe(struct platform_device *pdev) > return -EINVAL; > } > > - if (of_find_property(np, "interrupt-parent", NULL)) { > + if (pctl->domain) { > ret = stm32_pctrl_dt_setup_irq(pdev, pctl); > if (ret) > return ret; >