Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp125208imm; Tue, 3 Jul 2018 15:19:15 -0700 (PDT) X-Google-Smtp-Source: ADUXVKL8/vO0cu2axRbeuuM7JKRNQ6s8lpg5yc5Ah58h2ayyKA/NzliXnj5WfL4Cl1xREKP72MPC X-Received: by 2002:a63:be4a:: with SMTP id g10-v6mr26760128pgo.378.1530656355729; Tue, 03 Jul 2018 15:19:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530656355; cv=none; d=google.com; s=arc-20160816; b=lDcwc53hqGe0A4bHfldaL2dbubDWTEQYExmONqd1w6UfE4A607iesHHjgGNE4Z1VqS Y6JJI3Huw5SzqzaUpA8kF2x0Tda3MYtLhV1K9YXCx/TKC10b9xG01ICWKZSBOS3qYGLd LF73j6w39QX8FSgo/sGXDo7RrCD9ntH6EX0gWn/hehkIW8pg+8VV0my7IuXlN4gahXPw 3efoB0YeTSLgb1ZPe/CdqJRfBbcKAN84LNkwKau+bjUtRhWG2oevSdVKYYZv0Ra+s+6t qqa/vZdY2//RVLJRlPoT2I/KwRESOl9I6pZKx3wjVPpOWxmoRNTTJ3wDx4NYz2dnXTVb nUQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=qxLqNB1YdTc2r3mDCuIA3X1Wf7BQI0n+qf7F0U4V/hA=; b=QMRJxHDaDXGkqzRAG5Tx8FcY/XjiEyKwoO7Ih168Yim5KNLv4ZGfjdmXeIINKRKFYc sdohTwr6893RMl7I4DsySMwaVdLAnt8918DwC3Zm1tCDbLL+u7ZzweSqivPfP3yb5JS1 nAk0i9T4+2Xq5ueDckTiQtj7ev2Z/qij6pDj0w5wN3/0vrYCM6rLs72ZSXfXN07yGVLG APTYXmCZ49vdNXUMAecBnOMYoePajSF21Cpek2lh0I4+QMPJnrFQHsgg2gLKAHmtMqqh EwzM8egajq3mPxx9lwqEcqMsVPYkLf44pHUAOdOeKXcltfMmmlPMZZCLTn2eLCksVwMk lasw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KgWlBYyk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v10-v6si1911147plo.326.2018.07.03.15.19.00; Tue, 03 Jul 2018 15:19:15 -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=@gmail.com header.s=20161025 header.b=KgWlBYyk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753410AbeGCWSM (ORCPT + 99 others); Tue, 3 Jul 2018 18:18:12 -0400 Received: from mail-lf0-f68.google.com ([209.85.215.68]:45136 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753183AbeGCWSK (ORCPT ); Tue, 3 Jul 2018 18:18:10 -0400 Received: by mail-lf0-f68.google.com with SMTP id m13-v6so2805739lfb.12; Tue, 03 Jul 2018 15:18:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qxLqNB1YdTc2r3mDCuIA3X1Wf7BQI0n+qf7F0U4V/hA=; b=KgWlBYykK4cJ3TaFXbVExFU2aPryn1y9EflVCEG6xQcrYpU37e41GW316zCGQy3lOr hzYFRN3MtHEWbjRe6UMLck4/V63JQUVhJ+0UbxqDpNdsZpaaFwzMQmE2aWfjw+Udp9fB inO2Ei8smsIeHx/Fq7Qa3ZF4oN6MoPD84Cirsbu9A/E0Hbcw4oVOT3tAldWoyaUwm/HX AARjYL9kXKqY2I/1DSg7zN4rrt0daX31Ex7jWnpcEj9Pgl29YKgmGuI8BFOdCMBM+Ymp F6ghj16f6SgMSHpPRGS0xMMLe/9VvVKtm7eRBiZfJU7TAQLWLeTaWgqPS0PnzHPHMD1x hNAw== 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:in-reply-to :references; bh=qxLqNB1YdTc2r3mDCuIA3X1Wf7BQI0n+qf7F0U4V/hA=; b=ClvFQ9J2dgjhN/iqoof1GL9qzCtJJlPvQIEtKzojXN5LIZFKsI3eCAOdfkgY8wVNTv t8olSZq87sN/xwXC8L0XVhTvuxXCStAIinnHk4WuBfeMzLa07QOFjOxqIqzaBeX4z82H E7M/xMxdMtjtEzfDsQ+nN/jvpsQKXALUOIwkoUHQOLH5xsC0rlIyhW1dhqwiRe694ezX 0bzbcnHe6+E8y3j9nVavfKKvFkq7dcwsBW5HnPe/m5kifEMmyRKzsxFQl/jYWcia+J8E FaanJLztv2hJO35grHVIbKOYm9iK6SiuN6yOjffjQ4djeS2WYTZAmlF2p6EJZjQUMq48 l+VA== X-Gm-Message-State: APt69E2dbUlHc1M53qoO1E6ANDeC1nvLHhZGmYycMa3676PqhnrqeVnJ 5GELuA3dLZNDidZx2Mh4fr4= X-Received: by 2002:a19:4344:: with SMTP id m4-v6mr11276008lfj.111.1530656289174; Tue, 03 Jul 2018 15:18:09 -0700 (PDT) Received: from z50.lan (93-181-165-181.internetia.net.pl. [93.181.165.181]) by smtp.gmail.com with ESMTPSA id p88-v6sm328253ljp.90.2018.07.03.15.18.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 03 Jul 2018 15:18:08 -0700 (PDT) From: Janusz Krzysztofik To: Linus Walleij Cc: Boris Brezillon , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Andy Shevchenko , Janusz Krzysztofik Subject: [PATCH v2] gpiolib: Defer on non-DT find_chip_by_name() failure Date: Wed, 4 Jul 2018 00:18:19 +0200 Message-Id: <20180703221819.1825-1-jmkrzyszt@gmail.com> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180703172635.32508-1-jmkrzyszt@gmail.com> References: <20180703172635.32508-1-jmkrzyszt@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Avoid replication of error code conversion in non-DT GPIO consumers' code by returning -EPROBE_DEFER from gpiod_find() in case a chip identified by its label in a registered lookup table is not ready. See https://lkml.org/lkml/2018/5/30/176 for example case. Suggested-by: Boris Brezillon Signed-off-by: Janusz Krzysztofik Reviewed-by: Boris Brezillon --- Changelog v2: fix typo (latar -> later) - thanks Boris and Andy for catching this I'm not sure if adding both Suggested-by: and Reviewed-by: heades both with the same person name is in line with good practices, please remove one if not. Thanks, Janusz drivers/gpio/gpiolib.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index e11a3bb03820..01295c03b315 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -3639,9 +3639,16 @@ static struct gpio_desc *gpiod_find(struct device *dev, const char *con_id, chip = find_chip_by_name(p->chip_label); if (!chip) { - dev_err(dev, "cannot find GPIO chip %s\n", - p->chip_label); - return ERR_PTR(-ENODEV); + /* + * As the lookup table indicates a chip with + * p->chip_label should exist, assume it may + * still appear later and let the interested + * consumer be probed again or let the Deferred + * Probe infrastructure handle the error. + */ + dev_warn(dev, "cannot find GPIO chip %s, deferring\n", + p->chip_label); + return ERR_PTR(-EPROBE_DEFER); } if (chip->ngpio <= p->chip_hwnum) { -- 2.16.4