From: Thomas Richard <thomas.richard@bootlin.com>
To: Linus Walleij <linus.walleij@linaro.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Bartosz Golaszewski <brgl@bgdev.pl>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Kees Cook <kees@kernel.org>, Andy Shevchenko <andy@kernel.org>
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 <thomas.richard@bootlin.com>
Subject: [PATCH v9 08/10] gpio: aggregator: add possibility to attach data to the forwarder
Date: Mon, 11 Aug 2025 15:25:51 +0200 [thread overview]
Message-ID: <20250811-aaeon-up-board-pinctrl-support-v9-8-29f0cbbdfb30@bootlin.com> (raw)
In-Reply-To: <20250811-aaeon-up-board-pinctrl-support-v9-0-29f0cbbdfb30@bootlin.com>
Add a data pointer to store private data in the forwarder.
Reviewed-by: Andy Shevchenko <andy@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
---
drivers/gpio/gpio-aggregator.c | 20 ++++++++++++++++++--
include/linux/gpio/forwarder.h | 4 +++-
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
index f0d38d76cf73fccbc7baf83f8d0d33732787762b..fb3694d581d1edc412f44c661585643b7b59e31a 100644
--- a/drivers/gpio/gpio-aggregator.c
+++ b/drivers/gpio/gpio-aggregator.c
@@ -246,6 +246,7 @@ struct gpiochip_fwd {
spinlock_t slock; /* protects tmp[] if !can_sleep */
};
struct gpiochip_fwd_timing *delay_timings;
+ void *data;
unsigned long *valid_mask;
unsigned long tmp[]; /* values and descs for multiple ops */
};
@@ -504,6 +505,18 @@ struct gpio_chip *gpiochip_fwd_get_gpiochip(struct gpiochip_fwd *fwd)
}
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_get_gpiochip, "GPIO_FORWARDER");
+/**
+ * gpiochip_fwd_get_data - Get driver-private data for the GPIO forwarder
+ * @fwd: GPIO forwarder
+ *
+ * Returns: The driver-private data for the GPIO forwarder
+ */
+void *gpiochip_fwd_get_data(struct gpiochip_fwd *fwd)
+{
+ return fwd->data;
+}
+EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_get_data, "GPIO_FORWARDER");
+
/**
* gpiochip_fwd_gpio_request - Request a line of the GPIO forwarder
* @fwd: GPIO forwarder
@@ -768,10 +781,11 @@ EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_desc_free, "GPIO_FORWARDER");
/**
* gpiochip_fwd_register - Register a GPIO forwarder
* @fwd: GPIO forwarder
+ * @data: driver-private data associated with this forwarder
*
* Returns: 0 on success, or negative errno on failure.
*/
-int gpiochip_fwd_register(struct gpiochip_fwd *fwd)
+int gpiochip_fwd_register(struct gpiochip_fwd *fwd, void *data)
{
struct gpio_chip *chip = &fwd->chip;
@@ -787,6 +801,8 @@ int gpiochip_fwd_register(struct gpiochip_fwd *fwd)
else
spin_lock_init(&fwd->slock);
+ fwd->data = data;
+
return devm_gpiochip_add_data(chip->parent, chip, fwd);
}
EXPORT_SYMBOL_NS_GPL(gpiochip_fwd_register, "GPIO_FORWARDER");
@@ -831,7 +847,7 @@ static struct gpiochip_fwd *gpiochip_fwd_create(struct device *dev,
return ERR_PTR(error);
}
- error = gpiochip_fwd_register(fwd);
+ error = gpiochip_fwd_register(fwd, NULL);
if (error)
return ERR_PTR(error);
diff --git a/include/linux/gpio/forwarder.h b/include/linux/gpio/forwarder.h
index 45e0190308f09fdf953b71504a82c75fa47771c0..ee5d8355f7355767ff3da85fc42fe244a81ce0da 100644
--- a/include/linux/gpio/forwarder.h
+++ b/include/linux/gpio/forwarder.h
@@ -11,10 +11,12 @@ struct gpiochip_fwd *devm_gpiochip_fwd_alloc(struct device *dev,
int gpiochip_fwd_desc_add(struct gpiochip_fwd *fwd,
struct gpio_desc *desc, unsigned int offset);
void gpiochip_fwd_desc_free(struct gpiochip_fwd *fwd, unsigned int offset);
-int gpiochip_fwd_register(struct gpiochip_fwd *fwd);
+int gpiochip_fwd_register(struct gpiochip_fwd *fwd, void *data);
struct gpio_chip *gpiochip_fwd_get_gpiochip(struct gpiochip_fwd *fwd);
+void *gpiochip_fwd_get_data(struct gpiochip_fwd *fwd);
+
int gpiochip_fwd_gpio_request(struct gpiochip_fwd *fwd, unsigned int offset);
int gpiochip_fwd_gpio_get_direction(struct gpiochip_fwd *fwd,
unsigned int offset);
--
2.47.2
next prev parent reply other threads:[~2025-08-11 13:26 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-11 13:25 [PATCH v9 00/10] Add pinctrl support for the AAEON UP board FPGA Thomas Richard
2025-08-11 13:25 ` [PATCH v9 01/10] gpiolib: add support to register sparse pin range Thomas Richard
2025-08-11 13:25 ` [PATCH v9 02/10] gpio: aggregator: move GPIO forwarder allocation in a dedicated function Thomas Richard
2025-08-11 13:25 ` [PATCH v9 03/10] gpio: aggregator: refactor the code to add GPIO desc in the forwarder Thomas Richard
2025-08-11 13:25 ` [PATCH v9 04/10] gpio: aggregator: refactor the forwarder registration part Thomas Richard
2025-08-11 13:25 ` [PATCH v9 05/10] gpio: aggregator: update gpiochip_fwd_setup_delay_line() parameters Thomas Richard
2025-08-11 13:25 ` [PATCH v9 06/10] gpio: aggregator: export symbols of the GPIO forwarder library Thomas Richard
2025-08-11 13:25 ` [PATCH v9 07/10] gpio: aggregator: handle runtime registration of gpio_desc in gpiochip_fwd Thomas Richard
2025-08-11 13:25 ` Thomas Richard [this message]
2025-08-11 13:25 ` [PATCH v9 09/10] lib/string_choices: Add str_input_output() helper Thomas Richard
2025-08-11 13:25 ` [PATCH v9 10/10] pinctrl: Add pin controller driver for AAEON UP boards Thomas Richard
2025-08-18 15:45 ` Linus Walleij
2025-08-11 13:48 ` (subset) [PATCH v9 00/10] Add pinctrl support for the AAEON UP board FPGA Bartosz Golaszewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250811-aaeon-up-board-pinctrl-support-v9-8-29f0cbbdfb30@bootlin.com \
--to=thomas.richard@bootlin.com \
--cc=DanieleCleri@aaeon.eu \
--cc=GaryWang@aaeon.com.tw \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=brgl@bgdev.pl \
--cc=geert+renesas@glider.be \
--cc=kees@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®