The branch main has been updated by vexeduxr: URL: https://cgit.FreeBSD.org/src/commit/?id=2c356c8b8f79c08d42b23a72b7a320b59d955a3f
commit 2c356c8b8f79c08d42b23a72b7a320b59d955a3f Author: Ahmad Khalifa <vexed...@freebsd.org> AuthorDate: 2025-07-04 13:51:25 +0000 Commit: Ahmad Khalifa <vexed...@freebsd.org> CommitDate: 2025-07-04 13:55:55 +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 --- 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 2e2618805e7b..6b5379b6084a 100644 --- a/sys/dev/gpio/gpiobus.c +++ b/sys/dev/gpio/gpiobus.c @@ -293,7 +293,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; @@ -307,8 +307,24 @@ gpiobus_attach_bus(device_t dev) #ifdef FDT ofw_gpiobus_register_provider(dev); #endif - bus_attach_children(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_attach_children(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);