Date: Sun, 1 Dec 2024 04:57:19 GMT From: John Baldwin <jhb@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 35c71ac2b6d5 - stable/14 - spibus: Use a bus_child_deleted method to free ivars for children Message-ID: <202412010457.4B14vJ0w095617@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=35c71ac2b6d5dc0d77755154cf8edddc1d4caab0 commit 35c71ac2b6d5dc0d77755154cf8edddc1d4caab0 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2024-11-01 14:10:19 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2024-12-01 02:46:07 +0000 spibus: Use a bus_child_deleted method to free ivars for children Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47373 (cherry picked from commit 84553ccd0c8b1fa5b3f0b5b70a42a244f26cea75) --- sys/dev/spibus/acpi_spibus.c | 1 + sys/dev/spibus/ofw_spibus.c | 7 +++++++ sys/dev/spibus/spibus.c | 13 +++++++++++++ sys/dev/spibus/spibusvar.h | 1 + 4 files changed, 22 insertions(+) diff --git a/sys/dev/spibus/acpi_spibus.c b/sys/dev/spibus/acpi_spibus.c index 7241ad15bdab..9bce45b93dba 100644 --- a/sys/dev/spibus/acpi_spibus.c +++ b/sys/dev/spibus/acpi_spibus.c @@ -561,6 +561,7 @@ static device_method_t acpi_spibus_methods[] = { DEVMETHOD(bus_alloc_resource, acpi_spibus_alloc_resource), #endif DEVMETHOD(bus_add_child, acpi_spibus_add_child), + DEVMETHOD(bus_child_deleted, spibus_child_deleted), DEVMETHOD(bus_probe_nomatch, acpi_spibus_probe_nomatch), DEVMETHOD(bus_driver_added, acpi_spibus_driver_added), DEVMETHOD(bus_child_deleted, acpi_spibus_child_deleted), diff --git a/sys/dev/spibus/ofw_spibus.c b/sys/dev/spibus/ofw_spibus.c index f9323ab342ee..3342bf874553 100644 --- a/sys/dev/spibus/ofw_spibus.c +++ b/sys/dev/spibus/ofw_spibus.c @@ -191,6 +191,12 @@ ofw_spibus_add_child(device_t dev, u_int order, const char *name, int unit) return (child); } +static void +ofw_spibus_child_deleted(device_t dev, device_t child) +{ + free(device_get_ivars(child), M_DEVBUF); +} + static const struct ofw_bus_devinfo * ofw_spibus_get_devinfo(device_t bus, device_t dev) { @@ -217,6 +223,7 @@ static device_method_t ofw_spibus_methods[] = { /* Bus interface */ DEVMETHOD(bus_child_pnpinfo, ofw_bus_gen_child_pnpinfo), DEVMETHOD(bus_add_child, ofw_spibus_add_child), + DEVMETHOD(bus_child_deleted, ofw_spibus_child_deleted), DEVMETHOD(bus_get_resource_list, ofw_spibus_get_resource_list), /* ofw_bus interface */ diff --git a/sys/dev/spibus/spibus.c b/sys/dev/spibus/spibus.c index d72475a3fdba..95d3759002df 100644 --- a/sys/dev/spibus/spibus.c +++ b/sys/dev/spibus/spibus.c @@ -199,6 +199,18 @@ spibus_add_child_common(device_t dev, u_int order, const char *name, int unit, return (child); } +void +spibus_child_deleted(device_t dev, device_t child) +{ + struct spibus_ivar *devi; + + devi = device_get_ivars(child); + if (devi == NULL) + return; + resource_list_free(&devi->rl); + free(devi, M_DEVBUF); +} + static device_t spibus_add_child(device_t dev, u_int order, const char *name, int unit) { @@ -263,6 +275,7 @@ static device_method_t spibus_methods[] = { DEVMETHOD(bus_get_resource_list, spibus_get_resource_list), DEVMETHOD(bus_add_child, spibus_add_child), + DEVMETHOD(bus_child_deleted, spibus_child_deleted), DEVMETHOD(bus_print_child, spibus_print_child), DEVMETHOD(bus_probe_nomatch, spibus_probe_nomatch), DEVMETHOD(bus_read_ivar, spibus_read_ivar), diff --git a/sys/dev/spibus/spibusvar.h b/sys/dev/spibus/spibusvar.h index 338bacd82dcf..6a74f9b1053d 100644 --- a/sys/dev/spibus/spibusvar.h +++ b/sys/dev/spibus/spibusvar.h @@ -79,6 +79,7 @@ extern driver_t ofw_spibus_driver; int spibus_attach(device_t); int spibus_detach(device_t); device_t spibus_add_child_common(device_t, u_int, const char *, int, size_t); +void spibus_child_deleted(device_t, device_t); void spibus_probe_nomatch(device_t, device_t); int spibus_child_location(device_t, device_t, struct sbuf *); int spibus_read_ivar(device_t, device_t, int, uintptr_t *);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202412010457.4B14vJ0w095617>