git: 9c99ba9a0677 - main - iicbus: Use a bus_child_deleted method to free ivars for children
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 01 Nov 2024 14:13:08 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=9c99ba9a0677a7b5c3c578c430211dafb4ad0dd5 commit 9c99ba9a0677a7b5c3c578c430211dafb4ad0dd5 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2024-11-01 14:09:50 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2024-11-01 14:09:50 +0000 iicbus: Use a bus_child_deleted method to free ivars for children Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47370 --- sys/dev/iicbus/iicbus.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/sys/dev/iicbus/iicbus.c b/sys/dev/iicbus/iicbus.c index 33fb5c875c50..f48338865e0a 100644 --- a/sys/dev/iicbus/iicbus.c +++ b/sys/dev/iicbus/iicbus.c @@ -248,6 +248,18 @@ iicbus_add_child(device_t dev, u_int order, const char *name, int unit) dev, order, name, unit, sizeof(struct iicbus_ivar))); } +static void +iicbus_child_deleted(device_t dev, device_t child) +{ + struct iicbus_ivar *devi; + + devi = device_get_ivars(child); + if (devi == NULL) + return; + resource_list_free(&devi->rl); + free(devi, M_DEVBUF); +} + static void iicbus_hinted_child(device_t bus, const char *dname, int dunit) { @@ -360,6 +372,7 @@ static device_method_t iicbus_methods[] = { DEVMETHOD(bus_set_resource, bus_generic_rl_set_resource), DEVMETHOD(bus_get_resource_list, iicbus_get_resource_list), DEVMETHOD(bus_add_child, iicbus_add_child), + DEVMETHOD(bus_child_deleted, iicbus_child_deleted), DEVMETHOD(bus_print_child, iicbus_print_child), DEVMETHOD(bus_probe_nomatch, iicbus_probe_nomatch), DEVMETHOD(bus_read_ivar, iicbus_read_ivar),