From nobody Mon Feb 9 19:04:38 2026 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) (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 C30681E231E; Tue, 29 Apr 2025 14:08:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.194 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745935714; cv=none; b=fxraLv5S19Rmxbl8XI2J6A8crdVVcoAx/xoHF/5FrkAaWa6OUPwBa/P1QpdEv3PaaYUe9ILSNjywO4PWKyXSBj6Xe8Tx4yfNM3Itbsx2VvcEJfXIbRSXtMeAKtj7iWCecP8ugHNw1Zw9pbjyrZ9YkDetIS8YQr2jpKHQk2a57oA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745935714; c=relaxed/simple; bh=w4N7KqRA8Nlo0iFeeW1pPDRKcPmWnBcx7ukfAQkiz5k=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Kmy6WqAO3pbWKS6O/Ju63j0DM+UqpSQoJexOMOovc692nXUXFdY8HK1r0/cs/K6HLw7ldGeWKK+iqZpebriutf7HSQFfbEiLwMWim7ENS7I+OK5AlDoDJHBqkgj9kOxw0quYFGzeMMVkjyNYoBXTEeVzWwTrXxxXOelYVTP4HF4= 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=oarOEi01; arc=none smtp.client-ip=217.70.183.194 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="oarOEi01" Received: by mail.gandi.net (Postfix) with ESMTPSA id 5E458438CC; Tue, 29 Apr 2025 14:08:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1745935710; 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=uG8S/JidauisAuQdchy3W96wedqpyUbkFYJXuGX6xqw=; b=oarOEi01KpGnmo5wNy+5zN+OH1cDhiojuadqWJbFSqAbTVs4qAc+qCglVKKo13SsghhUwW GSghOw0vHfZaWBpvvEEngFYvgi3HKzS3QeFD1WP1NsWFVUwos+enOXF2wkHlBAiyQ/6Vw2 ivWdwHo6ptaedlOS3MiWNlB2qksgCiYqU/ATNF360IasjS+XXp9YKdF2RctM55lJYTwbxI CGAd6LHdZLVIzXqPlsQY52Ink9H5IGqqzMRxCYyI/Y5UdBmt3SVT7MSkxcMSpTFXIU8480 VKuvlf5jEOVy/EsGI/FMwQWlGpeQ5Oqd3gZMuVlg6tDe+yIQ+RU81FQcS+TmyA== From: Thomas Richard Date: Tue, 29 Apr 2025 16:08:18 +0200 Subject: [PATCH v4 04/12] gpio: aggregator: move GPIO forwarder allocation in a dedicated function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250429-aaeon-up-board-pinctrl-support-v4-4-b3fffc11417d@bootlin.com> References: <20250429-aaeon-up-board-pinctrl-support-v4-0-b3fffc11417d@bootlin.com> In-Reply-To: <20250429-aaeon-up-board-pinctrl-support-v4-0-b3fffc11417d@bootlin.com> To: Linus Walleij , Andy Shevchenko , Bartosz Golaszewski , Geert Uytterhoeven , Kees Cook , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, thomas.petazzoni@bootlin.com, DanieleCleri@aaeon.eu, GaryWang@aaeon.com.tw, linux-hardening@vger.kernel.org, Thomas Richard X-Mailer: b4 0.14.1 X-GND-State: clean X-GND-Score: -100 X-GND-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgddvieegtddvucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuifetpfffkfdpucggtfgfnhhsuhgsshgtrhhisggvnecuuegrihhlohhuthemuceftddunecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredtjeenucfhrhhomhepvfhhohhmrghsucftihgthhgrrhguuceothhhohhmrghsrdhrihgthhgrrhgusegsohhothhlihhnrdgtohhmqeenucggtffrrghtthgvrhhnpeektdehvdeiteehtdelteffheduveelgeelvdetgedvueejgefhhfekgefgfeduveenucfkphepvdgrtddumegtsgdugeemheehieemjegrtddtmegutgekudemrggrugdtmehfuggtrgemtggtudgrnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepvdgrtddumegtsgdugeemheehieemjegrtddtmegutgekudemrggrugdtmehfuggtrgemtggtudgrpdhhvghloheplgduvdejrddtrddurddungdpmhgrihhlfhhrohhmpehthhhomhgrshdrrhhitghhrghrugessghoohhtlhhinhdrtghomhdpnhgspghrtghpthhtohepudefpdhrtghpthhtoheplhhinhhugidqhhgrrhguvghnihhnghesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehlihhnuhhsrdifrghllhgvihhjsehlihhnrghrohdrohhrghdprhgtphhtthhopegrnhguhieskhgvrhhnvghlrdhorhhgp dhrtghpthhtohepkhgvvghssehkvghrnhgvlhdrohhrghdprhgtphhtthhopehgvggvrhhtodhrvghnvghsrghssehglhhiuggvrhdrsggvpdhrtghpthhtohepffgrnhhivghlvgevlhgvrhhisegrrggvohhnrdgvuhdprhgtphhtthhopegrnhgurhhihidrshhhvghvtghhvghnkhhosehlihhnuhigrdhinhhtvghlrdgtohhmpdhrtghpthhtohepthhhohhmrghsrdhpvghtrgiiiihonhhisegsohhothhlihhnrdgtohhm X-GND-Sasl: thomas.richard@bootlin.com Move the GPIO forwarder allocation and static initialization in a dedicated function. Reviewed-by: Andy Shevchenko Signed-off-by: Thomas Richard --- drivers/gpio/gpio-aggregator.c | 47 ++++++++++++++++++++++++++++----------= ---- 1 file changed, 31 insertions(+), 16 deletions(-) diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c index d232ea865356..4268ef94914d 100644 --- a/drivers/gpio/gpio-aggregator.c +++ b/drivers/gpio/gpio-aggregator.c @@ -498,6 +498,36 @@ static int gpiochip_fwd_setup_delay_line(struct device= *dev, struct gpio_chip *c } #endif /* !CONFIG_OF_GPIO */ =20 +static struct gpiochip_fwd * +devm_gpiochip_fwd_alloc(struct device *dev, unsigned int ngpios) +{ + const char *label =3D dev_name(dev); + struct gpiochip_fwd *fwd; + struct gpio_chip *chip; + + fwd =3D devm_kzalloc(dev, struct_size(fwd, tmp, fwd_tmp_size(ngpios)), GF= P_KERNEL); + if (!fwd) + return ERR_PTR(-ENOMEM); + + chip =3D &fwd->chip; + + chip->label =3D label; + chip->parent =3D dev; + chip->owner =3D THIS_MODULE; + chip->get_direction =3D gpio_fwd_get_direction; + chip->direction_input =3D gpio_fwd_direction_input; + chip->direction_output =3D gpio_fwd_direction_output; + chip->get =3D gpio_fwd_get; + chip->get_multiple =3D gpio_fwd_get_multiple_locked; + chip->set_rv =3D gpio_fwd_set; + chip->set_multiple_rv =3D gpio_fwd_set_multiple_locked; + chip->to_irq =3D gpio_fwd_to_irq; + chip->base =3D -1; + chip->ngpio =3D ngpios; + + return fwd; +} + /** * gpiochip_fwd_create() - Create a new GPIO forwarder * @dev: Parent device pointer @@ -518,14 +548,12 @@ static struct gpiochip_fwd *gpiochip_fwd_create(struc= t device *dev, struct gpio_desc *descs[], unsigned long features) { - const char *label =3D dev_name(dev); struct gpiochip_fwd *fwd; struct gpio_chip *chip; unsigned int i; int error; =20 - fwd =3D devm_kzalloc(dev, struct_size(fwd, tmp, fwd_tmp_size(ngpios)), - GFP_KERNEL); + fwd =3D devm_gpiochip_fwd_alloc(dev, ngpios); if (!fwd) return ERR_PTR(-ENOMEM); =20 @@ -549,19 +577,6 @@ static struct gpiochip_fwd *gpiochip_fwd_create(struct= device *dev, chip->set_config =3D gpio_fwd_set_config; } =20 - chip->label =3D label; - chip->parent =3D dev; - chip->owner =3D THIS_MODULE; - chip->get_direction =3D gpio_fwd_get_direction; - chip->direction_input =3D gpio_fwd_direction_input; - chip->direction_output =3D gpio_fwd_direction_output; - chip->get =3D gpio_fwd_get; - chip->get_multiple =3D gpio_fwd_get_multiple_locked; - chip->set_rv =3D gpio_fwd_set; - chip->set_multiple_rv =3D gpio_fwd_set_multiple_locked; - chip->to_irq =3D gpio_fwd_to_irq; - chip->base =3D -1; - chip->ngpio =3D ngpios; fwd->descs =3D descs; =20 if (chip->can_sleep) --=20 2.39.5