Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1092928pxj; Fri, 4 Jun 2021 06:02:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0hLW+5lJ1nt6VdG+jnlrxJLT9UKRGm6559KURUJIFcvkabfJ2SgUNJCJvtFqvXzBCFX5Q X-Received: by 2002:a17:906:180a:: with SMTP id v10mr4056366eje.22.1622811770053; Fri, 04 Jun 2021 06:02:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622811770; cv=none; d=google.com; s=arc-20160816; b=lgmrClLGb7hD4MJeWWNtQR78KG/2EaBmuMUqo0Wkd2KAND6G9cXr8dZnHVfMVXw6yJ wsWLLv3eJ4HMargpHKrdv+s2YlsoyQaxQ4KWHcEPbSeIvZDORrmbwokJhlHq3+KxpTH4 /rOjL0zpwzgkb4qgTCNlpN1/gE79K03NOdSSbTM/4LvvRtIWF44N6i5NuMMZQ+7jaFsh uAGk/njoY8DKzSk4140R3kUEgNzaHfxlm3YS76oAEXB8Ro9JwzLveWtCHdBmsTfkdZGf BavU9wwVdJjK+1aTnIXEgtbxVBgZdykVGmGy8Q6NX9sJ8XbkD26jM2F46Cs0T3QUfkpw /p+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :ironport-sdr:ironport-sdr; bh=S7Jb/QRokL5NEBMlYTd/TL+p6CTA5sKkkGrt/uJFJ9E=; b=NFivoqQ3vMqxxaRazYFX9ChqpOlOpv/H9jTXxJhVpDQy1J2eDkMVjY7MqZHF03YWiS 0d9FH5+9jBlplK+fLdimiJEhKDBXBL8kQUnWKv4BaJ01emEZ8q9wvNrN8otanH8vBAVd bL+5FRSakR2NFb3WkhMC/EL5loMoB1jSnhHGn91AbMgH6r1NUBEtvNkQLOHxUl3rkB0A uO++MT9Rp7u0A70vhqZhuzdmcYNAVv0qO/ZUwFS+3sumFpJkE4GiXMwEaBrvKuwMzvZI nQvUL0LihsAAEKOcQUCPRdnRAfeKcHQUhitNg3vWAmAWcHardlQ0Dm0kWgzXR5Ium4gi dP7g== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t26si4494224edq.83.2021.06.04.06.02.17; Fri, 04 Jun 2021 06:02:50 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230245AbhFDNBu (ORCPT + 99 others); Fri, 4 Jun 2021 09:01:50 -0400 Received: from mga09.intel.com ([134.134.136.24]:2251 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230004AbhFDNBt (ORCPT ); Fri, 4 Jun 2021 09:01:49 -0400 IronPort-SDR: dxEaBNlq/GraAQ0w88gtMxbv0XmJeHKq/OScZamIV3AGQZ8KmdaMHHr5S43lcWcKOpi2m4cO4e 0xpupnv3FKnQ== X-IronPort-AV: E=McAfee;i="6200,9189,10004"; a="204262151" X-IronPort-AV: E=Sophos;i="5.83,248,1616482800"; d="scan'208";a="204262151" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2021 06:00:01 -0700 IronPort-SDR: PepRvi61ClRrtWbdje6TMu8DIx4w/IYZ2HzVULGz6JGViajMkEJ8nFDoDeG6SQ3oRFBUjnif/K 1Nfn43rfnjHg== X-IronPort-AV: E=Sophos;i="5.83,248,1616482800"; d="scan'208";a="551153872" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jun 2021 05:59:57 -0700 Received: from andy by smile with local (Exim 4.94) (envelope-from ) id 1lp9QY-00HE3g-Ej; Fri, 04 Jun 2021 15:59:54 +0300 Date: Fri, 4 Jun 2021 15:59:54 +0300 From: Andy Shevchenko To: Daniel Scally Cc: "Rafael J . Wysocki" , Lee Jones , Hans de Goede , Maximilian Luz , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-gpio@vger.kernel.org, linux-i2c@vger.kernel.org, platform-driver-x86@vger.kernel.org, devel@acpica.org, Len Brown , Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Wolfram Sang , Mark Gross , Robert Moore , Erik Kaneda , laurent.pinchart@ideasonboard.com, kieran.bingham@ideasonboard.com Subject: Re: [PATCH v5 3/6] gpiolib: acpi: Export acpi_get_gpiod() Message-ID: References: <20210603224007.120560-1-djrscally@gmail.com> <20210603224007.120560-4-djrscally@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210603224007.120560-4-djrscally@gmail.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 03, 2021 at 11:40:04PM +0100, Daniel Scally wrote: > We need to be able to translate GPIO resources in an ACPI device's _CRS > into GPIO descriptor array. Those are represented in _CRS as a pathname > to a GPIO device plus the pin's index number: the acpi_get_gpiod() > function is perfect for that purpose. > > As it's currently only used internally within the GPIO layer, provide and > export a wrapper function that additionally holds a reference to the GPIO > device. The subject is wrong, it should be "Introduce acpi_get_and_request_gpiod() helper" or so. I can fix when applying. Btw, do I understand correctly that I may push GPIO ACPI patches independently (of the ACPI changes)? > Reviewed-by: Andy Shevchenko > Signed-off-by: Daniel Scally > --- > Changes since v4: > - None > > drivers/gpio/gpiolib-acpi.c | 28 ++++++++++++++++++++++++++++ > include/linux/gpio/consumer.h | 2 ++ > 2 files changed, 30 insertions(+) > > diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c > index 5b4111e4be3f..684ddb35d83b 100644 > --- a/drivers/gpio/gpiolib-acpi.c > +++ b/drivers/gpio/gpiolib-acpi.c > @@ -128,6 +128,34 @@ static struct gpio_desc *acpi_get_gpiod(char *path, int pin) > return gpiochip_get_desc(chip, pin); > } > > +/** > + * acpi_get_and_request_gpiod() - Translate ACPI GPIO pin to GPIO descriptor > + * and hold a refcount to the GPIO device. > + * @path: ACPI GPIO controller full path name, (e.g. "\\_SB.GPO1") > + * @pin: ACPI GPIO pin number (0-based, controller-relative) > + * @label: Label to pass to gpiod_request() > + * > + * This function is a simple pass-through to acpi_get_gpiod(), except that > + * as it is intended for use outside of the GPIO layer (in a similar fashion to > + * gpiod_get_index() for example) it also holds a reference to the GPIO device. > + */ > +struct gpio_desc *acpi_get_and_request_gpiod(char *path, int pin, char *label) > +{ > + struct gpio_desc *gpio; > + int ret; > + > + gpio = acpi_get_gpiod(path, pin); > + if (IS_ERR(gpio)) > + return gpio; > + > + ret = gpiod_request(gpio, label); > + if (ret) > + return ERR_PTR(ret); > + > + return gpio; > +} > +EXPORT_SYMBOL_GPL(acpi_get_and_request_gpiod); > + > static irqreturn_t acpi_gpio_irq_handler(int irq, void *data) > { > struct acpi_gpio_event *event = data; > diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h > index c73b25bc9213..566feb56601f 100644 > --- a/include/linux/gpio/consumer.h > +++ b/include/linux/gpio/consumer.h > @@ -692,6 +692,8 @@ int devm_acpi_dev_add_driver_gpios(struct device *dev, > const struct acpi_gpio_mapping *gpios); > void devm_acpi_dev_remove_driver_gpios(struct device *dev); > > +struct gpio_desc *acpi_get_and_request_gpiod(char *path, int pin, char *label); > + > #else /* CONFIG_GPIOLIB && CONFIG_ACPI */ > > struct acpi_device; > -- > 2.25.1 > -- With Best Regards, Andy Shevchenko