From nobody Fri Nov 01 14:13:07 2024 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Xg2rh1nDnz5bpgR; Fri, 01 Nov 2024 14:13:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xg2rg5n6nz4bZD; Fri, 1 Nov 2024 14:13:07 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730470387; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/Z9PvxyaZckmLN+zCEQ4ueMC5RVAcbnFhfX0zRzFArg=; b=Cb5d8XSCpQQhri38dHCe9JOxKeJQK3fGQZrHRgOTehEDnxP4HfahMfZK9CQP5SM0yVWFPN QDONgrnrGHbs8XovOekf4QGXceRMVRFiyhJhYU2cSetAxY3DzQorrBAnbOY77EH5EjeWs8 tSjvAC2o2BevpFiAuRAxyJ80o8KEb/mOO2o1/PUr0riE32eABf0jO83Fne697URtm58zZS CH7bw/oxjyoA6hsiHfzLKwqHOXBMR+cSRGTSKp7p50ajyaMskwrSmfzXeQzjMVQcY4knZg uOsQYukyPHFmnjbfr/TjOPj3TxR7CoHeKX0EccD8HblrGZ4Mgeu2ksBJv/T3mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1730470387; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=/Z9PvxyaZckmLN+zCEQ4ueMC5RVAcbnFhfX0zRzFArg=; b=ePpGcJCmJGyQPh8iBcu0DcVyFHkC7Yqj0FkXtuxDDPISFADBFgI/AtinP1pQmBhZR1G16+ wO9mZHDii1rfx+GnJI9TlVY/L0Sv9RLtMlIlOg+X89wDikUhzTBFJ1/nqICnivE/THLbj+ v9ZMmUF+kTIcz8bomufEFz3oKExszQnYyoSU4SNXtQMc+8aJVJxVoPzTZx7aD7GH8uPKXc CAVUasodOkjJb3AqKp60Tyih0DVssbFmqGavpsfPrxSNkFxjbWQ6ol/zlJodgYYBt+dB7O VqcJZRSKlEH3DfXO/+izj8FFuKYp3YUdvMR93OiTxjy1s7WlKB145b2yciygqg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1730470387; a=rsa-sha256; cv=none; b=WiX0O1jk7rzQvXRYeqcPQRDqGJnnh1HKhQrHDuPx7vkwSELDSxsF9ZlnbNWaDo0yA5mgiA PyMl6+SBlkYrH/3jb+JworrZw404hoCG8JrNokULpZsByZAXjDmwg93bdsKduHKbqicBRk wEXTqhJuCVI4hdP/Ddblh32DUoUAcl+sx/+ZeiXScLRRieecLSQ5S2lg+HtIIlU/gRZEYP qj3GpYJSg6E3tlZVeNj7g98ds2cDIzSvDitlnxdh7wq8KyM4BIM/SmJhk5JefetLPECQEq 0zczU2rNTpzDK2AkDQabzXR9R7UyELjrfU+rpkM6vVjS1YkaqFsChGZVRwnWaQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Xg2rg5DgTzNpD; Fri, 1 Nov 2024 14:13:07 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4A1ED7RD059609; Fri, 1 Nov 2024 14:13:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4A1ED76Q059606; Fri, 1 Nov 2024 14:13:07 GMT (envelope-from git) Date: Fri, 1 Nov 2024 14:13:07 GMT Message-Id: <202411011413.4A1ED76Q059606@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: c9e880c0ceef - main - gpiobus: Use a bus_child_deleted method to free ivars for children List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c9e880c0ceef9541625c18add3f5a8499137e016 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c9e880c0ceef9541625c18add3f5a8499137e016 commit c9e880c0ceef9541625c18add3f5a8499137e016 Author: John Baldwin AuthorDate: 2024-11-01 14:09:39 +0000 Commit: John Baldwin CommitDate: 2024-11-01 14:09:39 +0000 gpiobus: Use a bus_child_deleted method to free ivars for children Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47369 --- sys/dev/gpio/gpiobus.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c index 02c02bcd645d..6b0f8e5ed3ff 100644 --- a/sys/dev/gpio/gpiobus.c +++ b/sys/dev/gpio/gpiobus.c @@ -574,9 +574,7 @@ int gpiobus_detach(device_t dev) { struct gpiobus_softc *sc; - struct gpiobus_ivar *devi; - device_t *devlist; - int i, err, ndevs; + int i, err; sc = GPIOBUS_SOFTC(dev); KASSERT(mtx_initialized(&sc->sc_mtx), @@ -585,17 +583,9 @@ gpiobus_detach(device_t dev) if ((err = bus_generic_detach(dev)) != 0) return (err); - - if ((err = device_get_children(dev, &devlist, &ndevs)) != 0) + if ((err = device_delete_children(dev)) != 0) return (err); - for (i = 0; i < ndevs; i++) { - devi = GPIOBUS_IVAR(devlist[i]); - gpiobus_free_ivars(devi); - resource_list_free(&devi->rl); - free(devi, M_DEVBUF); - device_delete_child(dev, devlist[i]); - } - free(devlist, M_TEMP); + rman_fini(&sc->sc_intr_rman); if (sc->sc_pins) { for (i = 0; i < sc->sc_npins; i++) { @@ -699,6 +689,19 @@ gpiobus_add_child(device_t dev, u_int order, const char *name, int unit) return (child); } +static void +gpiobus_child_deleted(device_t dev, device_t child) +{ + struct gpiobus_ivar *devi; + + devi = GPIOBUS_IVAR(child); + if (devi == NULL) + return; + gpiobus_free_ivars(devi); + resource_list_free(&devi->rl); + free(devi, M_DEVBUF); +} + static int gpiobus_rescan(device_t dev) { @@ -718,7 +721,6 @@ static void gpiobus_hinted_child(device_t bus, const char *dname, int dunit) { struct gpiobus_softc *sc = GPIOBUS_SOFTC(bus); - struct gpiobus_ivar *devi; device_t child; const char *pins; int irq, pinmask; @@ -728,19 +730,14 @@ gpiobus_hinted_child(device_t bus, const char *dname, int dunit) } child = BUS_ADD_CHILD(bus, 0, dname, dunit); - devi = GPIOBUS_IVAR(child); if (resource_int_value(dname, dunit, "pins", &pinmask) == 0) { if (gpiobus_parse_pins(sc, child, pinmask)) { - resource_list_free(&devi->rl); - free(devi, M_DEVBUF); device_delete_child(bus, child); return; } } else if (resource_string_value(dname, dunit, "pin_list", &pins) == 0) { if (gpiobus_parse_pin_list(sc, child, pins)) { - resource_list_free(&devi->rl); - free(devi, M_DEVBUF); device_delete_child(bus, child); return; } @@ -1045,6 +1042,7 @@ static device_method_t gpiobus_methods[] = { DEVMETHOD(bus_get_resource_list, gpiobus_get_resource_list), DEVMETHOD(bus_get_rman, gpiobus_get_rman), DEVMETHOD(bus_add_child, gpiobus_add_child), + DEVMETHOD(bus_child_deleted, gpiobus_child_deleted), DEVMETHOD(bus_rescan, gpiobus_rescan), DEVMETHOD(bus_probe_nomatch, gpiobus_probe_nomatch), DEVMETHOD(bus_print_child, gpiobus_print_child),