From patchwork Wed Jun 15 18:22:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9179095 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7141860776 for ; Wed, 15 Jun 2016 18:24:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6497526490 for ; Wed, 15 Jun 2016 18:24:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58FC927E5A; Wed, 15 Jun 2016 18:24:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0660A26490 for ; Wed, 15 Jun 2016 18:24:50 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bDFT1-0006Tb-Uj; Wed, 15 Jun 2016 18:23:07 +0000 Received: from mx1.redhat.com ([209.132.183.28]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bDFSy-0006Qy-2N for linux-arm-kernel@lists.infradead.org; Wed, 15 Jun 2016 18:23:05 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0C5D876F; Wed, 15 Jun 2016 18:22:41 +0000 (UTC) Received: from shalem.localdomain.com (vpn1-7-65.ams2.redhat.com [10.36.7.65]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u5FIMbfv024682; Wed, 15 Jun 2016 14:22:38 -0400 From: Hans de Goede To: Linus Walleij Subject: [PATCH] Revert "gpio: bail out silently on NULL descriptors" Date: Wed, 15 Jun 2016 20:22:34 +0200 Message-Id: <1466014954-17956-1-git-send-email-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 15 Jun 2016 18:22:41 +0000 (UTC) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160615_112304_383609_68AD4B8C X-CRM114-Status: GOOD ( 15.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hans de Goede , Maxime Ripard , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This reverts commit 54d77198fdfb("gpio: bail out silently on NULL descriptors"). This commit causes the following code to fail: gpio_desc = devm_gpiod_get_optional(dev, ...); gpio_irq = gpiod_to_irq(gpio_desc); if (gpio_irq >= 0) { ret = devm_request_irq(dev, gpio_irq, ...); And now ret is an error causing the probe function in question to bail. The problem here is that gpiod_to_irq now returns 0 for a NULL gpio_desc while 0 is a valid irq-nr. Also see: commit 4c37ce8608a8("gpio: make gpiod_to_irq() return negative for NO_IRQ") which specifically avoids returning 0. Signed-off-by: Hans de Goede --- drivers/gpio/gpiolib.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 24f60d2..6c33a07 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1367,13 +1367,10 @@ done: /* * This descriptor validation needs to be inserted verbatim into each * function taking a descriptor, so we need to use a preprocessor - * macro to avoid endless duplication. If the desc is NULL it is an - * optional GPIO and calls should just bail out. + * macro to avoid endless duplication. */ #define VALIDATE_DESC(desc) do { \ - if (!desc) \ - return 0; \ - if (!desc->gdev) { \ + if (!desc || !desc->gdev) { \ pr_warn("%s: invalid GPIO\n", __func__); \ return -EINVAL; \ } \ @@ -1384,9 +1381,7 @@ done: } } while (0) #define VALIDATE_DESC_VOID(desc) do { \ - if (!desc) \ - return; \ - if (!desc->gdev) { \ + if (!desc || !desc->gdev) { \ pr_warn("%s: invalid GPIO\n", __func__); \ return; \ } \