From patchwork Fri Feb 14 11:49:55 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Dubois-Briand X-Patchwork-Id: 865179 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8BEC52641F7; Fri, 14 Feb 2025 11:50:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.197 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739533825; cv=none; b=V0RJAo3h4O/wPHJ/ZnVtpKAUdc8FzSMPrKINJayHSyzXNTYq83LHeu3xvIRYk5CP3H2eXPXjpH5txIn7gb+kmZ6SXnHvpyyIROB+lQbM0Ulns2dBsbC/YwFJ40ml2A6fTBR1/osqeYM8/gIm4Rn7oXDOrb69VTGxZASGkVopaZI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739533825; c=relaxed/simple; bh=HXxkaspPnOSHffFaaCFOnNwmjHEf0gB01arX3laHS+M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mzIlZvWMyaL4LIapc736vcBJRCcCIhqfPbzVOz70gTZwa1DEElzOdFhIsNxuwf3m4qvdYm1bKgcA9Xq1wzQTcWEFzqlyTMd9qIm4Wi1CL+Pg9YAGyrUz1DPwLuwUvNT8XaOqGPyQB5EIZmbZa3ywACvE4/zwOVFDoDMtJsPAzXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=hccMvHQC; arc=none smtp.client-ip=217.70.183.197 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="hccMvHQC" Received: by mail.gandi.net (Postfix) with ESMTPSA id 9A141442E2; Fri, 14 Feb 2025 11:50:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1739533815; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Lil4E8fY9Or1EESTp42XtfVLm65FbceH7FB2DR+3Qv0=; b=hccMvHQCYFO9XbOMNsSHLowwuqFjrRiSryNPN8T47AOIhbzN5o48SDZkGjXgcKQIhnwItX TAl7Lok3/MXd/zgyw0UetFo2mvufquj5lwb2u3t1yBmKym6Xghur0Kcpgqgl4PrszwgNmS ZU5pUj2J4QeZsyAA80bhyOAZD3FT1Ea4PEsL3ZbU8L+OV1Nz69NzGHFq6CFc1KC6lf5MzM oAT15JSz4BI+BYQdeJtjfkDslB6FwbYGc2bbRGhkRyotuX4V3qYkAtbaENlN4K/m7tDKta SVqdXPIVAErfegXZt1LI4Vdigh3QABOHO/PM2oHVSj+tWWbu863nnN+xsaiaaQ== From: Mathieu Dubois-Briand Date: Fri, 14 Feb 2025 12:49:55 +0100 Subject: [PATCH v4 05/10] gpio: regmap: Allow to retrieve ngpio Precedence: bulk X-Mailing-List: linux-gpio@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20250214-mdb-max7360-support-v4-5-8a35c6dbb966@bootlin.com> References: <20250214-mdb-max7360-support-v4-0-8a35c6dbb966@bootlin.com> In-Reply-To: <20250214-mdb-max7360-support-v4-0-8a35c6dbb966@bootlin.com> To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Kamel Bouhara , Linus Walleij , Bartosz Golaszewski , Dmitry Torokhov , =?utf-8?q?Uwe_Kleine-K=C3=B6n?= =?utf-8?q?ig?= , Michael Walle , Mark Brown , Greg Kroah-Hartman , "Rafael J. Wysocki" , Danilo Krummrich Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-gpio@vger.kernel.org, linux-input@vger.kernel.org, linux-pwm@vger.kernel.org, andriy.shevchenko@intel.com, =?utf-8?q?Gr=C3=A9?= =?utf-8?q?gory_Clement?= , Thomas Petazzoni , Mathieu Dubois-Briand X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=ed25519-sha256; t=1739533806; l=1793; i=mathieu.dubois-briand@bootlin.com; s=20241219; h=from:subject:message-id; bh=HXxkaspPnOSHffFaaCFOnNwmjHEf0gB01arX3laHS+M=; b=482K44vzklse1KrUmJSFdjVsm8fhdYP1BMAYtekeCyMy4gdE8T6Hs6tMfARXLDuZI4DL2txEy igFIWVGviG8DEdA7DGngRWcEGynGOU4US/mwUsNUyWic7pjYChO3PwG X-Developer-Key: i=mathieu.dubois-briand@bootlin.com; a=ed25519; pk=1PVTmzPXfKvDwcPUzG0aqdGoKZJA3b9s+3DqRlm0Lww= X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdegleehjecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfitefpfffkpdcuggftfghnshhusghstghrihgsvgenuceurghilhhouhhtmecufedtudenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephfffufggtgfgkfhfjgfvvefosehtjeertdertdejnecuhfhrohhmpeforghthhhivghuucffuhgsohhishdquehrihgrnhguuceomhgrthhhihgvuhdrughusghoihhsqdgsrhhirghnugessghoohhtlhhinhdrtghomheqnecuggftrfgrthhtvghrnheptdfhgeetvddvheejieehheehueetjeelkedtfeehhefgfeeglefhteegtddthfetnecukfhppedvrgdtudemtggsudegmeehheeimeejrgdttdemfehftghfmehfsgdtugemuddviedvmedvvgejieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepihhnvghtpedvrgdtudemtggsudegmeehheeimeejrgdttdemfehftghfmehfsgdtugemuddviedvmedvvgejiedphhgvlhhopegluddvjedrtddruddrudgnpdhmrghilhhfrhhomhepmhgrthhhihgvuhdrughusghoihhsqdgsrhhirghnugessghoohhtlhhinhdrtghomhdpnhgspghrtghpthhtohepvdefpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepmhgrthhhihgvuhdrughusghoihhsqdgsrhhirghnugessghoohhtlhhinhdrt ghomhdprhgtphhtthhopehrrghfrggvlheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepghhrvghgohhrhidrtghlvghmvghnthessghoohhtlhhinhdrtghomhdprhgtphhtthhopegurghkrheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohepthhhohhmrghsrdhpvghtrgiiiihonhhisegsohhothhlihhnrdgtohhmpdhrtghpthhtohepsghrghhlsegsghguvghvrdhplhdprhgtphhtthhopehlihhnuhigqdhgphhiohesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-GND-Sasl: mathieu.dubois-briand@bootlin.com Drivers can leave the ngpio field of the gpio_regmap_config structure uninitialized, letting gpio_regmap_register() retrieve its value from the "ngpios" device property. Yet, the driver might still need to know the ngpio value later: allow to extract this value from the gpio_regmap structure. Signed-off-by: Mathieu Dubois-Briand --- drivers/gpio/gpio-regmap.c | 6 ++++++ include/linux/gpio/regmap.h | 3 +++ 2 files changed, 9 insertions(+) diff --git a/drivers/gpio/gpio-regmap.c b/drivers/gpio/gpio-regmap.c index ba72c23bcf97..7d8bfde386a4 100644 --- a/drivers/gpio/gpio-regmap.c +++ b/drivers/gpio/gpio-regmap.c @@ -195,6 +195,12 @@ void *gpio_regmap_get_drvdata(struct gpio_regmap *gpio) } EXPORT_SYMBOL_GPL(gpio_regmap_get_drvdata); +u16 gpio_regmap_get_ngpio(struct gpio_regmap *gpio) +{ + return gpio->gpio_chip.ngpio; +} +EXPORT_SYMBOL_GPL(gpio_regmap_get_ngpio); + /** * gpio_regmap_register() - Register a generic regmap GPIO controller * @config: configuration for gpio_regmap diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h index 16f0c33df75d..0fdc213178d1 100644 --- a/include/linux/gpio/regmap.h +++ b/include/linux/gpio/regmap.h @@ -3,6 +3,8 @@ #ifndef _LINUX_GPIO_REGMAP_H #define _LINUX_GPIO_REGMAP_H +#include + struct device; struct fwnode_handle; struct gpio_regmap; @@ -97,5 +99,6 @@ void gpio_regmap_unregister(struct gpio_regmap *gpio); struct gpio_regmap *devm_gpio_regmap_register(struct device *dev, const struct gpio_regmap_config *config); void *gpio_regmap_get_drvdata(struct gpio_regmap *gpio); +u16 gpio_regmap_get_ngpio(struct gpio_regmap *gpio); #endif /* _LINUX_GPIO_REGMAP_H */