git: c6a6b94b6613 - stable/14 - gpiobus: add a gpiobus_add_bus function
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 07 Jul 2025 19:23:05 UTC
The branch stable/14 has been updated by vexeduxr:
URL: https://cgit.FreeBSD.org/src/commit/?id=c6a6b94b661378961179d832be6f1eceef91f953
commit c6a6b94b661378961179d832be6f1eceef91f953
Author: Ahmad Khalifa <vexeduxr@FreeBSD.org>
AuthorDate: 2025-07-04 13:51:25 +0000
Commit: Ahmad Khalifa <vexeduxr@FreeBSD.org>
CommitDate: 2025-07-07 18:48:59 +0000
gpiobus: add a gpiobus_add_bus function
Some drivers need to postpone the attachment of gpiobus until hardware
init is done. Add a new gpiobus_add_bus function to accommodate this
case.
Suggested by: mmel, andrew
Reviewed by: mmel, imp, andrew
Approved by: imp (mentor)
MFC after: 3 days
Differential Revision: https://reviews.freebsd.org/D51133
(cherry picked from commit 2c356c8b8f79c08d42b23a72b7a320b59d955a3f)
---
sys/dev/gpio/gpiobus.c | 20 ++++++++++++++++++--
sys/dev/gpio/gpiobusvar.h | 1 +
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c
index a8dd8a753676..266fe1a29c3b 100644
--- a/sys/dev/gpio/gpiobus.c
+++ b/sys/dev/gpio/gpiobus.c
@@ -294,7 +294,7 @@ gpiobus_print_pins(struct gpiobus_ivar *devi, struct sbuf *sb)
}
device_t
-gpiobus_attach_bus(device_t dev)
+gpiobus_add_bus(device_t dev)
{
device_t busdev;
@@ -308,8 +308,24 @@ gpiobus_attach_bus(device_t dev)
#ifdef FDT
ofw_gpiobus_register_provider(dev);
#endif
- bus_generic_attach(dev);
+ return (busdev);
+}
+/*
+ * Attach a gpiobus child.
+ * Note that the controller is expected
+ * to be fully initialized at this point.
+ */
+device_t
+gpiobus_attach_bus(device_t dev)
+{
+ device_t busdev;
+
+ busdev = gpiobus_add_bus(dev);
+ if (busdev == NULL)
+ return (NULL);
+
+ bus_generic_attach(dev);
return (busdev);
}
diff --git a/sys/dev/gpio/gpiobusvar.h b/sys/dev/gpio/gpiobusvar.h
index 74783e112f89..3ae0767466c9 100644
--- a/sys/dev/gpio/gpiobusvar.h
+++ b/sys/dev/gpio/gpiobusvar.h
@@ -172,6 +172,7 @@ struct resource *gpio_alloc_intr_resource(device_t consumer_dev, int *rid,
* these should not be called directly by other drivers.
*/
int gpio_check_flags(uint32_t, uint32_t);
+device_t gpiobus_add_bus(device_t);
device_t gpiobus_attach_bus(device_t);
int gpiobus_detach_bus(device_t);
int gpiobus_attach(device_t);