From patchwork Fri Mar 10 20:58:46 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: 737576 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 3vg03z3GvYz9s7r for ; Sat, 11 Mar 2017 07:58:55 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932372AbdCJU6y (ORCPT ); Fri, 10 Mar 2017 15:58:54 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40734 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755049AbdCJU6x (ORCPT ); Fri, 10 Mar 2017 15:58:53 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (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 9CA3E85547; Fri, 10 Mar 2017 20:58:53 +0000 (UTC) Received: from dhcp-45-79.space.revspace.nl.com (ovpn-116-90.ams2.redhat.com [10.36.116.90]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2AKwm8o020641; Fri, 10 Mar 2017 15:58:52 -0500 From: Hans de Goede To: Linus Walleij , Alexandre Courbot Cc: Andy Shevchenko , linux-gpio@vger.kernel.org, Hans de Goede Subject: [PATCH 2/2] gpio: acpi: acpi_dev_gpio_irq_get: ignore the status of unselected irqs Date: Fri, 10 Mar 2017 21:58:46 +0100 Message-Id: <20170310205846.16530-3-hdegoede@redhat.com> In-Reply-To: <20170310205846.16530-1-hdegoede@redhat.com> References: <20170310205846.16530-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Fri, 10 Mar 2017 20:58:53 +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 the gpioint matching index 0 or 1 has a valid descriptor. Before this commit acpi_dev_gpio_irq_get would exit on the first gpioint with an invalid descriptor it would encounter, this commit modifies it to only care if the gpioint with the requested index has a valid descriptor. Signed-off-by: Hans de Goede --- drivers/gpio/gpiolib-acpi.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c index 86fabdd..11bd1a6 100644 --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -746,21 +746,27 @@ struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode, int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) { unsigned int irq_flags; - int idx, i; + int idx, i, irq, ret; for (i = 0, idx = 0; idx <= index; i++) { struct acpi_gpio_info info; - struct gpio_desc *desc; + struct acpi_gpio_lookup lookup; - desc = acpi_get_gpiod_by_index(adev, NULL, i, &info); - if (IS_ERR(desc)) - return PTR_ERR(desc); + memset(&lookup, 0, sizeof(lookup)); + lookup.index = index; + lookup.adev = adev; + ret = acpi_gpio_resource_lookup(&lookup, &info); + if (!lookup.found) + return ret; if (info.gpioint && idx++ == index) { - int irq = gpiod_to_irq(desc); + struct gpio_desc *desc = lookup.desc; char label[32]; - int ret; + if (!desc) + return ret; + + irq = gpiod_to_irq(desc); if (irq < 0) return irq;