Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6746847ybc; Thu, 28 Nov 2019 04:52:14 -0800 (PST) X-Google-Smtp-Source: APXvYqz8ThR/kLjNh6Pal2kHmChFEJHCoFyPx6uwp3f4Y1UTudb8CrnQp2OeG9ZoPcU86hKXFWTr X-Received: by 2002:a05:6402:2036:: with SMTP id ay22mr32687956edb.303.1574945534184; Thu, 28 Nov 2019 04:52:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574945534; cv=none; d=google.com; s=arc-20160816; b=nY2gi4xL5RDvstIbZWOcB0Zu3Eqd9rR9LPcuJ//4WFeeGRbX86D/l0hA9Fo1Unh50W pwok3Lw38BTiqTjxjNslGDvT/4L6LflbV9+U9EUqGXVo51VqPqDEkfy5vQeX4P0Sw3w3 AzmHYpk7sgS+7EZOvHDef36qB/SIKLiSyiROjaJyC159f9VEqGWEJQoi8dvyEA/lzdK3 1TKX2YPB4zEIdon6eQX59yATNqxI9bnMz7ZWkbPhRLsCo9UTuNQqwdWc5Sede8r+0QZa AFElU/LsAPcKb3m7T4LF/uv7WLK4RG9yx1sHYGb1b5Lu0tiW1WOskYhzay9xD8BSWVOl OaVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=/zKAExeBupdd3rXLyuq6FAkCXHMCHY2Razb8gCVnez8=; b=Z065fFidId7L7ST0eGcp3eeQeC1cW3EO7lJuqvNFgnmMJDW5vPjaWlhqIgGx/ULOcL KIcn0Oxe5/k1s4qDaJ06NlIKfjJSjMNzJfQEx0EyFHsyUgY6OsHKk0rYZq2DCtZTMD2C VjpgckkWdPYD+zvfp7FNDE4Dj3CBBbjsBzT/LNaL5Rb4VHdpTgQrKNaz0gSRv/yqerjz 8Jq5qFy4aIjAM9un5i4T8ZNaw1oYBDno7pCY9ke95tcr/6qLa+NdXT2owqh4sZCZLN5R psx5j4t3ofQ11vZmZlb+vTRiAfeEeQz9xvBmcatGKvUBCLZFQInQ1FvVmXLrJSL3+Sy7 UN6w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n11si895666ejs.314.2019.11.28.04.51.48; Thu, 28 Nov 2019 04:52:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726569AbfK1Mtu (ORCPT + 99 others); Thu, 28 Nov 2019 07:49:50 -0500 Received: from metis.ext.pengutronix.de ([85.220.165.71]:57769 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbfK1Mtu (ORCPT ); Thu, 28 Nov 2019 07:49:50 -0500 Received: from pty.hi.pengutronix.de ([2001:67c:670:100:1d::c5]) by metis.ext.pengutronix.de with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iaJEt-0001j4-6d; Thu, 28 Nov 2019 13:49:43 +0100 Received: from mfe by pty.hi.pengutronix.de with local (Exim 4.89) (envelope-from ) id 1iaJEs-00048Y-61; Thu, 28 Nov 2019 13:49:42 +0100 Date: Thu, 28 Nov 2019 13:49:42 +0100 From: Marco Felsch To: Bartosz Golaszewski Cc: Linus Walleij , Support Opensource , Lee Jones , Rob Herring , Liam Girdwood , Mark Brown , Steve Twiss , Adam.Thomson.Opensource@diasemi.com, linux-devicetree , LKML , kernel@pengutronix.de Subject: Re: [PATCH v2 1/5] gpio: add support to get local gpio number Message-ID: <20191128124942.4ddyi5eeclvxmqbg@pengutronix.de> References: <20191127135932.7223-1-m.felsch@pengutronix.de> <20191127135932.7223-2-m.felsch@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 13:45:17 up 13 days, 4:03, 23 users, load average: 0.29, 0.10, 0.03 User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c5 X-SA-Exim-Mail-From: mfe@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 19-11-28 11:46, Bartosz Golaszewski wrote: > śr., 27 lis 2019 o 14:59 Marco Felsch napisał(a): > > > > Sometimes consumers needs to know the gpio-chip local gpio number of a > > 'struct gpio_desc' for further configuration. This is often the case for > > mfd devices. > > > > We already have this support. It's just a matter of exporting it, so > maybe adjust the commit message to not be confusing. Therefore I mentioned the consumers. > That being said: I'm not really a fan of this - the whole idea of gpio > descriptors was to make them opaque and their hardware offsets > irrelevant. :( I know therefore I added a driver local helper but this wasn't the way Linus wanted to go.. > > Signed-off-by: Marco Felsch > > --- > > drivers/gpio/gpiolib.c | 6 ++++++ > > include/linux/gpio/consumer.h | 10 ++++++++++ > > 2 files changed, 16 insertions(+) > > > > diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c > > index 104ed299d5ea..7709648313fc 100644 > > --- a/drivers/gpio/gpiolib.c > > +++ b/drivers/gpio/gpiolib.c > > @@ -4377,6 +4377,12 @@ int gpiod_count(struct device *dev, const char *con_id) > > } > > EXPORT_SYMBOL_GPL(gpiod_count); > > > > +int gpiod_to_offset(struct gpio_desc *desc) > > Maybe call it: gpiod_desc_to_offset()? The function name is proposed by Linus too so Linus what's your oppinion? Regards, Marco > > +{ > > + return gpio_chip_hwgpio(desc); > > +} > > +EXPORT_SYMBOL_GPL(gpiod_to_offset); > > + > > /** > > * gpiod_get - obtain a GPIO for a given GPIO function > > * @dev: GPIO consumer, can be NULL for system-global GPIOs > > diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h > > index b70af921c614..e2178c3bf7fd 100644 > > --- a/include/linux/gpio/consumer.h > > +++ b/include/linux/gpio/consumer.h > > @@ -60,6 +60,9 @@ enum gpiod_flags { > > /* Return the number of GPIOs associated with a device / function */ > > int gpiod_count(struct device *dev, const char *con_id); > > > > +/* Get the local chip offset from a global desc */ > > +int gpiod_to_offset(struct gpio_desc *desc); > > + > > /* Acquire and dispose GPIOs */ > > struct gpio_desc *__must_check gpiod_get(struct device *dev, > > const char *con_id, > > @@ -189,6 +192,13 @@ static inline int gpiod_count(struct device *dev, const char *con_id) > > return 0; > > } > > > > +static inline int gpiod_to_offset(struct gpio_desc *desc) > > +{ > > + /* GPIO can never have been requested */ > > + WARN_ON(desc); > > + return 0; > > +} > > + > > static inline struct gpio_desc *__must_check gpiod_get(struct device *dev, > > const char *con_id, > > enum gpiod_flags flags) > > -- > > 2.20.1 > >