From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 904E7C43462 for ; Fri, 21 May 2021 12:05:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 734F7613D6 for ; Fri, 21 May 2021 12:05:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234068AbhEUMHJ (ORCPT ); Fri, 21 May 2021 08:07:09 -0400 Received: from mga18.intel.com ([134.134.136.126]:17519 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229507AbhEUMHH (ORCPT ); Fri, 21 May 2021 08:07:07 -0400 IronPort-SDR: uBklas3PM9l57jdxKDTbyjcLj+tnLq3CJQHGya7DZ7+AplbceUfCPEbvd5cNa5C9szZDZ+R2p6 XYztJLVwCh/Q== X-IronPort-AV: E=McAfee;i="6200,9189,9990"; a="188866420" X-IronPort-AV: E=Sophos;i="5.82,319,1613462400"; d="scan'208";a="188866420" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2021 05:05:44 -0700 IronPort-SDR: skltu30wB3m4YBEmmxugcZS/7efbrFzfmy7vEJWDiA5Ulgds4Dh/57hl0FKBNHSYjOP8j45TdU cNmQBuSDYeMA== X-IronPort-AV: E=Sophos;i="5.82,319,1613462400"; d="scan'208";a="545366534" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 May 2021 05:05:39 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1lk3uJ-00Dhdw-St; Fri, 21 May 2021 15:05:35 +0300 Date: Fri, 21 May 2021 15:05:35 +0300 From: Andy Shevchenko To: Daniel Scally Cc: "Rafael J . Wysocki" , Wolfram Sang , Lee Jones , Hans de Goede , Maximilian Luz , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, platform-driver-x86@vger.kernel.org, devel@acpica.org, Len Brown , Mika Westerberg , Russell King , Linus Walleij , Bartosz Golaszewski , Mark Gross , Robert Moore , Erik Kaneda , laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: Re: [PATCH v4 6/8] gpiolib: acpi: Add acpi_gpio_get_io_resource() Message-ID: References: <20210520140928.3252671-1-djrscally@gmail.com> <20210520140928.3252671-7-djrscally@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210520140928.3252671-7-djrscally@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org On Thu, May 20, 2021 at 03:09:26PM +0100, Daniel Scally wrote: > Add a function to verify that a given acpi_resource represents an IO > type GPIO resource, and return it if so. Reviewed-by: Andy Shevchenko > Signed-off-by: Daniel Scally > --- > Changes since v3: > - Patch introduced > > drivers/gpio/gpiolib-acpi.c | 23 +++++++++++++++++++++++ > include/linux/acpi.h | 7 +++++++ > 2 files changed, 30 insertions(+) > > diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c > index 684ddb35d83b..9887bb684575 100644 > --- a/drivers/gpio/gpiolib-acpi.c > +++ b/drivers/gpio/gpiolib-acpi.c > @@ -196,6 +196,29 @@ bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, > } > EXPORT_SYMBOL_GPL(acpi_gpio_get_irq_resource); > > +/** > + * acpi_gpio_get_io_resource - Fetch details of an ACPI resource if it is a GPIO > + * I/O resource or return False if not. > + * @ares: Pointer to the ACPI resource to fetch > + * @agpio: Pointer to a &struct acpi_resource_gpio to store the output pointer > + */ > +bool acpi_gpio_get_io_resource(struct acpi_resource *ares, > + struct acpi_resource_gpio **agpio) > +{ > + struct acpi_resource_gpio *gpio; > + > + if (ares->type != ACPI_RESOURCE_TYPE_GPIO) > + return false; > + > + gpio = &ares->data.gpio; > + if (gpio->connection_type != ACPI_RESOURCE_GPIO_TYPE_IO) > + return false; > + > + *agpio = gpio; > + return true; > +} > +EXPORT_SYMBOL_GPL(acpi_gpio_get_io_resource); > + > static void acpi_gpiochip_request_irq(struct acpi_gpio_chip *acpi_gpio, > struct acpi_gpio_event *event) > { > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index 170b9bebdb2b..e8ba7063c000 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -1098,6 +1098,8 @@ void __acpi_handle_debug(struct _ddebug *descriptor, acpi_handle handle, const c > #if defined(CONFIG_ACPI) && defined(CONFIG_GPIOLIB) > bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, > struct acpi_resource_gpio **agpio); > +bool acpi_gpio_get_io_resource(struct acpi_resource *ares, > + struct acpi_resource_gpio **agpio); > 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, > @@ -1105,6 +1107,11 @@ static inline bool acpi_gpio_get_irq_resource(struct acpi_resource *ares, > { > return false; > } > +static inline bool acpi_gpio_get_io_resource(struct acpi_resource *ares, > + struct acpi_resource_gpio **agpio) > +{ > + return false; > +} > static inline int acpi_dev_gpio_irq_get_by(struct acpi_device *adev, > const char *name, int index) > { > -- > 2.25.1 > -- With Best Regards, Andy Shevchenko