From patchwork Thu Jul 12 19:22:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rob Herring \(Arm\)" X-Patchwork-Id: 141833 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1886993ljj; Thu, 12 Jul 2018 12:22:27 -0700 (PDT) X-Google-Smtp-Source: AAOMgpczXl5OT5TGbbSsHrbFtOChl1umYwb1Hzrf7UUnL0A06WCCjNz6r1uLcmDErDcoMWxV1gQj X-Received: by 2002:aa7:818b:: with SMTP id g11-v6mr3739200pfi.50.1531423347068; Thu, 12 Jul 2018 12:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531423347; cv=none; d=google.com; s=arc-20160816; b=MUJZX81mZEUXyd1xJR46egJE8npxNrDye+AIdE9XFBue4ruu2kdtFrJlIStRFouA9L GygPvLdBcNWVXD6uzhE6k/Uc8+6s2lED41mSNmwyELML4vJoyDDirQ7spz+ikePL9Cv0 aUnhxN8zhRQ1qXAlyfF3xvciyJClAxjIHdaUPCvsAql8Dn1+nQejlkRu3JNFY5D7/fkw 3rM+vS6f1/Lpq4eK+raagnNN84B/WWaNfPm7RT4XYJEiTdCGJd+U2/if18u36s4Datk1 JzY28b3NAKKkOjTpv1DjkGJrL22MZSdKC5bGFeDFTgndxHSXY3kJ39D8iAj19heCYW7D 92sA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=U7J0kGsuiDbHMVnoebD9kqlOIofyAKviGregL8cjp8c=; b=pxM5kxEctqh8YAmiOqIZC4hoc1uslJmSDFoBJMUCBJ0azIeFZTbfRqH77JeAL92uVK JVQHNjU/78Sutc9a5ljI3Z3ZSmAbjnOawja3Dv7xno9qzK0Cwhr8PMtqgAM9D1RUS40o IbYumbftw54Wa9m1ZIKfjUUWsOsasOrhwQ3iEjXJUZSacFZduFgIKmI5mjPDuJ95aez9 PJBP3bGF2j9f7/kBfvuMg6H/jeYmKLGf8sYELpxa5pKaICeIf1NJrXYBsF4h0MEWwDS0 8k8WczIAxPvEnKc/EjKoUc03L41SRS4gMtWFk8RU9MKvZUDVE58Q2CIyAHHn32ptrjxU K1lg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n18-v6si20704605pgg.225.2018.07.12.12.22.26; Thu, 12 Jul 2018 12:22:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726589AbeGLTdU (ORCPT + 5 others); Thu, 12 Jul 2018 15:33:20 -0400 Received: from mail-yw0-f195.google.com ([209.85.161.195]:33209 "EHLO mail-yw0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726583AbeGLTdU (ORCPT ); Thu, 12 Jul 2018 15:33:20 -0400 Received: by mail-yw0-f195.google.com with SMTP id c135-v6so10871279ywa.0 for ; Thu, 12 Jul 2018 12:22:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=OpQf3YgXgJYFELlKXdFCaJwBCiqFER7ld5GYYs5KizU=; b=WUvS1HDcDPoXP+Iq9Za6FyDvavyiuAkPNeFpzeBCTbiB43PEC4nqx9nF+ySu51QwCM 0YBsqSxtClw7YM3zWIeikND1O+wrg8FasjcTIv6I4ap90FHtOyQyxdCYdIjBYDLOdkUC 0KfzlWHJ0+2xqjTBT7AgRB6BZdi/qnIdnIBQ/n8ntCyGDsUi21dlUzuO1R1Gxsl1uLXL obTLsmQLuP3YbPyGhjRiKcZ9Twg6oTx0D+nr5xHpNgDe0a2no8zEEQjQml/uKwr7b7vm sPOg8PYNEMY6RBJhkkmQDRzK2TYTY04MXdVIwswjBK+wy64ws4afxiny4VOKgvttosHi IPag== X-Gm-Message-State: AOUpUlHP5oAgZeT91JvfTzgsrLz6NbNe25EyZHL/NbhoWqetp7QzT1B5 Sh4XtDHZh3/1ZOvK7MKSJM9jvH0= X-Received: by 2002:a0d:f7c3:: with SMTP id h186-v6mr197610ywf.272.1531423345558; Thu, 12 Jul 2018 12:22:25 -0700 (PDT) Received: from localhost.localdomain (24-223-123-72.static.usa-companies.net. [24.223.123.72]) by smtp.googlemail.com with ESMTPSA id x7-v6sm9565587ywd.43.2018.07.12.12.22.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Jul 2018 12:22:24 -0700 (PDT) From: Rob Herring To: Linus Walleij Cc: Jean-Christophe Plagniol-Villard , Nicolas Ferre , Alexandre Belloni , linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org Subject: [PATCH] pinctrl: at91: fix deferred probing support Date: Thu, 12 Jul 2018 13:22:22 -0600 Message-Id: <20180712192222.32481-1-robh@kernel.org> X-Mailer: git-send-email 2.17.1 Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org AT91 pinctrl deferred probing support is broken if the GPIO devices haven't probed first and set gpio_banks to non-zero. The later condition that only some GPIO devices haven't probed can't actually happen as either all the GPIO devices have probed first or none of them have. Plus the pinctrl driver has already returned -EINVAL, so it's not on the deferred list to retry probing. Fix this by consolidating the checking that all GPIO devices are probed. Cc: Jean-Christophe Plagniol-Villard Cc: Linus Walleij Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: linux-arm-kernel@lists.infradead.org Cc: linux-gpio@vger.kernel.org Signed-off-by: Rob Herring Acked-by: Ludovic Desroches --- This is a result of trying to remove of_platform_default_populate from at91 code and relying on the DT core handling populating devices. That changed the probe order and broke booting. Compile tested only. Rob drivers/pinctrl/pinctrl-at91.c | 36 ++++++++++++---------------------- 1 file changed, 13 insertions(+), 23 deletions(-) -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 50f0ec42c637..167838901b75 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -1162,7 +1162,7 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, struct at91_pinctrl *info) { int ret = 0; - int i, j; + int i, j, ngpio_chips_enabled = 0; uint32_t *tmp; struct device_node *np = pdev->dev.of_node; struct device_node *child; @@ -1175,10 +1175,17 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, of_match_device(at91_pinctrl_of_match, &pdev->dev)->data; at91_pinctrl_child_count(info, np); - if (gpio_banks < 1) { - dev_err(&pdev->dev, "you need to specify at least one gpio-controller\n"); - return -EINVAL; - } + /* + * We need all the GPIO drivers to probe FIRST, or we will not be able + * to obtain references to the struct gpio_chip * for them, and we + * need this to proceed. + */ + for (i = 0; i < MAX_GPIO_BANKS; i++) + if (gpio_chips[i]) + ngpio_chips_enabled++; + + if (ngpio_chips_enabled < info->nactive_banks) + return -EPROBE_DEFER; ret = at91_pinctrl_mux_mask(info, np); if (ret) @@ -1234,7 +1241,7 @@ static int at91_pinctrl_probe(struct platform_device *pdev) { struct at91_pinctrl *info; struct pinctrl_pin_desc *pdesc; - int ret, i, j, k, ngpio_chips_enabled = 0; + int ret, i, j, k; info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); if (!info) @@ -1244,23 +1251,6 @@ static int at91_pinctrl_probe(struct platform_device *pdev) if (ret) return ret; - /* - * We need all the GPIO drivers to probe FIRST, or we will not be able - * to obtain references to the struct gpio_chip * for them, and we - * need this to proceed. - */ - for (i = 0; i < gpio_banks; i++) - if (gpio_chips[i]) - ngpio_chips_enabled++; - - if (ngpio_chips_enabled < info->nactive_banks) { - dev_warn(&pdev->dev, - "All GPIO chips are not registered yet (%d/%d)\n", - ngpio_chips_enabled, info->nactive_banks); - devm_kfree(&pdev->dev, info); - return -EPROBE_DEFER; - } - at91_pinctrl_desc.name = dev_name(&pdev->dev); at91_pinctrl_desc.npins = gpio_banks * MAX_NB_GPIO_PER_BANK; at91_pinctrl_desc.pins = pdesc =