[PATCH v3 09/10] gpio: aggregator: add possibility to attach data to the forwarder
From: Thomas Richard
Date: Wed Apr 16 2025 - 10:21:06 EST
Add a data pointer to store private data in the forwarder.
Signed-off-by: Thomas Richard <thomas.richard@xxxxxxxxxxx>
---
drivers/gpio/gpio-aggregator.c | 6 ++++--
include/linux/gpio/forwarder.h | 3 ++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpio-aggregator.c b/drivers/gpio/gpio-aggregator.c
index 0fb890f0793d..9e27ea3f78ec 100644
--- a/drivers/gpio/gpio-aggregator.c
+++ b/drivers/gpio/gpio-aggregator.c
@@ -564,7 +564,7 @@ int gpio_fwd_add_gpio_desc(struct gpiochip_fwd *fwd, struct gpio_desc *desc,
}
EXPORT_SYMBOL_NS_GPL(gpio_fwd_add_gpio_desc, "GPIO_FORWARDER");
-int gpio_fwd_register(struct gpiochip_fwd *fwd)
+int gpio_fwd_register(struct gpiochip_fwd *fwd, void *data)
{
struct gpio_chip *chip = &fwd->chip;
unsigned int ndescs = 0, i;
@@ -586,6 +586,8 @@ int gpio_fwd_register(struct gpiochip_fwd *fwd)
else
spin_lock_init(&fwd->slock);
+ fwd->data = data;
+
error = devm_gpiochip_add_data(chip->parent, chip, fwd);
return error;
@@ -632,7 +634,7 @@ static struct gpiochip_fwd *gpio_fwd_create(struct device *dev,
return ERR_PTR(error);
}
- error = gpio_fwd_register(fwd);
+ error = gpio_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 f3fba3c39bda..304c793313db 100644
--- a/include/linux/gpio/forwarder.h
+++ b/include/linux/gpio/forwarder.h
@@ -18,6 +18,7 @@ struct gpiochip_fwd_timing {
struct gpiochip_fwd {
struct gpio_chip chip;
+ void *data;
struct gpio_desc **descs;
union {
struct mutex mlock; /* protects tmp[] if can_sleep */
@@ -57,6 +58,6 @@ struct gpiochip_fwd *devm_gpio_fwd_alloc(struct device *dev,
int gpio_fwd_add_gpio_desc(struct gpiochip_fwd *fwd,
struct gpio_desc *desc, unsigned int offset);
-int gpio_fwd_register(struct gpiochip_fwd *fwd);
+int gpio_fwd_register(struct gpiochip_fwd *fwd, void *data);
#endif
--
2.39.5