Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3514890pxf; Mon, 15 Mar 2021 11:14:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNwRz3H+QKZRuW5Lzf75D+fgzQLvsuN6yLWaUckeAvls8SPMNNwNlI1jfLsS2wLsg3SQs+ X-Received: by 2002:aa7:c857:: with SMTP id g23mr31982190edt.86.1615832078291; Mon, 15 Mar 2021 11:14:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832078; cv=none; d=google.com; s=arc-20160816; b=Los3/M4tYFFmODoIxEJCh8ovl9Ov1l2lfRhA9ldtTfE/RTYk3Zz0hwm3B3g0WVirdo ue/MS6IK6HQfygLmk1JfVUm/FR4AUc+y4pF04HonOgNd5dXACmdBkbN1ACJFav8O11UB FFI0kcGhEav1klfxqvESd5ERhrTqhuwXrcrtAT8jALG7Wvt6BEwCg/t81EmX2VZfuc03 fkOg4e11fuzHwDSVh0cAXtUtRPRc1WLc9qAaZDUEJzeo3C2efafz7V9sZHvRlTCywA3c EEx5mEwSn/BvKIE4W/FBre+5ZQagWEU51srUWeKvb6ogdkoA7rJbO5QKI4bx24vmYmBc 9NAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=osrmfDwqY60JWzzXTu+fn3C4MNamsfKC7ny+lCcTwNs=; b=pa2PzHgTTZayCwlV1HBMNVNFp+raNxJy98JhjCftK+xlMEzGjhANbHi5fp7Jxnofh+ vd7HN7xGSsuXEcdirW79RdZt/0J8zIPIR2iyk5QLPZJq5xRfLCEcEQXGjWISozZd4OI4 xS30q6goXVqmMPzdOOyj5fZPPm8lSqRgnmOXk27nYhQseqXoXoScsDCPE0ne/IqmbcvU vJuGjIDnCBZscfj1KJibQr2ZZnfOAYFx822PLuBAFeJHQXsgN5wzxhN5pjfEcFxyQGHT PHJ5s0cHDULRg16/DwtAdBKa8if4jnl96JkylGPe0FZZBjnnLwoLWiHs+W7pITCntyur 945g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rhHlTOJ+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v22si11190341edc.137.2021.03.15.11.14.16; Mon, 15 Mar 2021 11:14:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rhHlTOJ+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236525AbhCOONL (ORCPT + 99 others); Mon, 15 Mar 2021 10:13:11 -0400 Received: from mail.kernel.org ([198.145.29.99]:37820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232559AbhCON7D (ORCPT ); Mon, 15 Mar 2021 09:59:03 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6224F64EEF; Mon, 15 Mar 2021 13:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816730; bh=ARJ3dRydyS1Ffdu3I1F0lWkWNccCt51wguNDYPItEfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rhHlTOJ+jS+o3E1gBfFBUWChNrWMDDkpcIATCmH+B1I3fWyltP2MAKKDWIHfDtCcw SPfky+EFgW6r+sSWAIf/6qXWWvCUghKOcs8To1RibYTA3qWzGCZkqmMhQ83pBwKuQg oDDUdUi9359ny5HtiIpt7Yw6EQIocYBugDX30zzE= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andy Shevchenko , Mika Westerberg , Linus Walleij Subject: [PATCH 5.10 080/290] gpiolib: acpi: Allow to find GpioInt() resource by name and index Date: Mon, 15 Mar 2021 14:52:53 +0100 Message-Id: <20210315135544.620625395@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135541.921894249@linuxfoundation.org> References: <20210315135541.921894249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Andy Shevchenko commit 809390219fb9c2421239afe5c9eb862d73978ba0 upstream. Currently only search by index is supported. However, in some cases we might need to pass the quirks to the acpi_dev_gpio_irq_get(). For this, split out acpi_dev_gpio_irq_get_by() and replace acpi_dev_gpio_irq_get() by calling above with NULL for name parameter. Fixes: ba8c90c61847 ("gpio: pca953x: Override IRQ for one of the expanders on Galileo Gen 2") Depends-on: 0ea683931adb ("gpio: dwapb: Convert driver to using the GPIO-lib-based IRQ-chip") Signed-off-by: Andy Shevchenko Acked-by: Mika Westerberg Acked-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpiolib-acpi.c | 12 ++++++++---- include/linux/acpi.h | 10 ++++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -916,8 +916,9 @@ struct gpio_desc *acpi_node_get_gpiod(st } /** - * acpi_dev_gpio_irq_get() - Find GpioInt and translate it to Linux IRQ number + * acpi_dev_gpio_irq_get_by() - Find GpioInt and translate it to Linux IRQ number * @adev: pointer to a ACPI device to get IRQ from + * @name: optional name of GpioInt resource * @index: index of GpioInt resource (starting from %0) * * If the device has one or more GpioInt resources, this function can be @@ -927,9 +928,12 @@ struct gpio_desc *acpi_node_get_gpiod(st * The function is idempotent, though each time it runs it will configure GPIO * pin direction according to the flags in GpioInt resource. * + * The function takes optional @name parameter. If the resource has a property + * name, then only those will be taken into account. + * * Return: Linux IRQ number (> %0) on success, negative errno on failure. */ -int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) +int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index) { int idx, i; unsigned int irq_flags; @@ -939,7 +943,7 @@ int acpi_dev_gpio_irq_get(struct acpi_de struct acpi_gpio_info info; struct gpio_desc *desc; - desc = acpi_get_gpiod_by_index(adev, NULL, i, &info); + desc = acpi_get_gpiod_by_index(adev, name, i, &info); /* Ignore -EPROBE_DEFER, it only matters if idx matches */ if (IS_ERR(desc) && PTR_ERR(desc) != -EPROBE_DEFER) @@ -976,7 +980,7 @@ int acpi_dev_gpio_irq_get(struct acpi_de } return -ENOENT; } -EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get); +EXPORT_SYMBOL_GPL(acpi_dev_gpio_irq_get_by); static acpi_status acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address, --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -1072,19 +1072,25 @@ void __acpi_handle_debug(struct _ddebug #if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB) bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio); -int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index); +int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, const char *name, int index); #else static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, struct acpi_resource_gpio **agpio) { return false; } -static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) +static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, + const char *name, int index) { return -ENXIO; } #endif +static inline int acpi_dev_gpio_irq_get(struct acpi_device *adev, int index) +{ + return acpi_dev_gpio_irq_get_by(adev, NULL, index); +} + /* Device properties */ #ifdef CONFIG_ACPI