From patchwork Mon Mar 13 22:04:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 738455 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vhsNB4p8lz9ryv for ; Tue, 14 Mar 2017 09:04:26 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753012AbdCMWE0 (ORCPT ); Mon, 13 Mar 2017 18:04:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57330 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750846AbdCMWEZ (ORCPT ); Mon, 13 Mar 2017 18:04:25 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (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 51A283B721; Mon, 13 Mar 2017 22:04:25 +0000 (UTC) Received: from shalem.localdomain.com (ovpn-116-138.ams2.redhat.com [10.36.116.138]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DM4NSH028581; Mon, 13 Mar 2017 18:04:24 -0400 From: Hans de Goede To: Linus Walleij , Alexandre Courbot Cc: Hans de Goede , Andy Shevchenko , linux-gpio@vger.kernel.org Subject: [PATCH v2] gpio: acpi: Ignore -EPROBE_DEFER for unselected gpioints Date: Mon, 13 Mar 2017 23:04:21 +0100 Message-Id: <20170313220421.27314-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 13 Mar 2017 22:04:25 +0000 (UTC) Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org When acpi_dev_gpio_irq_get gets called with an index of say 2, it should not care if acpi_get_gpiod for index 0 or 1 returns -EPROBE_DEFER. This allows drivers which request a gpioint with index > 0 to function if there is no gpiochip driver (loaded) for gpioints with a lower index. Signed-off-by: Hans de Goede Signed-off-by: Andy Shevchenko Acked-by: Mika Westerberg --- drivers/gpio/gpiolib-acpi.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 9b37a36..8cd3f66 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -653,20 +653,24 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) { int idx, i; unsigned int irq_flags; - int ret = -ENOENT; for (i = 0, idx = 0; idx <= index; i++) { struct acpi_gpio_info info; struct gpio_desc *desc; desc = acpi_get_gpiod_by_index(adev, NULL, i, &info); - if (IS_ERR(desc)) { - ret = PTR_ERR(desc); - break; - } + + /* Ignore -EPROBE_DEFER, it only matters if idx matches */ + if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) + return PTR_ERR(desc); + if (info.gpioint && idx++ == index) { - int irq = gpiod_to_irq(desc); + int irq; + + if (IS_ERR(desc)) + return PTR_ERR(desc); + irq = gpiod_to_irq(desc); if (irq < 0) return irq; @@ -682,7 +686,7 @@ int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) } } - return ret; + return -ENOENT; } EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get);