From nobody Sun Dec 01 04:58:03 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 4Y1F6M58sXz5gDFs; Sun, 01 Dec 2024 04:58:03 +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 4Y1F6M3mJCz4Ctw; Sun, 1 Dec 2024 04:58:03 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733029083; 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=LYVg//Z98Npo6iQnURluica7X1T6cM9fA596XMgQ5ys=; b=EfV+452GLiITNZvN5SccsmZSMSE8HxC34BytF+uubnCgFcse79MAvRmqyLBmTuYYPvDWww 08QhUZeD7Z3f0HRvY3Wjd6iI1700zM6yZkSLnZIQHDmbGl0i+1xGHBZHR7ZsEgAlhaQ3q2 e0EWQbOGpQf8K5FZGMc/HQGY4vCIiEnBQpsDgjTXBNgdOO126uqRtzSESsQP/rp4ihEj9o RdPNdew2rH8c9DRUEqJPxBgPr5O7ZhIuUzYO1UybhKrwBFywt1/Yu27phl0Mb9A3ILV0Lc XcvW98gJOtDA5rNTjTRcQx6MUBxEqmqo83L7oqMSzOZokBCuwXmnjjvzLNaJzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1733029083; 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=LYVg//Z98Npo6iQnURluica7X1T6cM9fA596XMgQ5ys=; b=XoEmT1RM4UNEocl9Nhg4VciCOnmM7uc+v2lvTSu1hExiUlIU14r8k0cidC+HWNptHJuwGU 68PLRU9/BenApto83ygjHAHfxT/3Uaw5282MRIbe5666syWNRo54y6k1Bvx7xUhMYcO+rQ 9OjTqmH7clzPRTraOwJKPOrrcBu9CR75qw/9yJXHPSDnZBp2y3ZgqOZM6u0iIk3ZOIkG5P 0SKqZfNRX4kuJEdF5JUWl8mT0pGpxsmV1mLFkSzJGcblrqUIK8psLYXucd59oiJyJ9mWdA dlzK2gyi4eaAu3WFOiSvqtd28R/TP6AVR5C9wx0nbxkdEG55AN1rZkRQWXfDlw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1733029083; a=rsa-sha256; cv=none; b=PlcZr2vgWEw/fWQ3uZB6YXUCGv/fETKP+1vvbuF9mS1f112tvFsERb80+X6EoungjVYncY JrRu/h6d9NX+E98X+KHctdnHgz8bJ2ahVD8qA/wTq8AW4DQxymHBo3mvKIfuom8BGlpeYK ofVgjAN7zzpBMA5Q2QFplLWn8YQM7B8klgQHJJvdCpX2rbGplCFMt2WAIxS2c55CGcXOHR q5f6dwAWZ5wqmHZ8N5FxMbk5rpDp4ZPP6W/ng3Qctg1ncBW0eJ7l23aN+7s38Yk2B+LTzK eAnPg3T6v7R7hkzsh/g7nowFYj8AaOmP+v2L/T3xJMV5dVa1c5H7IBE0TOjlAA== 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 4Y1F6M3Cwyzdxj; Sun, 1 Dec 2024 04:58:03 +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 4B14w38c097734; Sun, 1 Dec 2024 04:58:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4B14w3iR097731; Sun, 1 Dec 2024 04:58:03 GMT (envelope-from git) Date: Sun, 1 Dec 2024 04:58:03 GMT Message-Id: <202412010458.4B14w3iR097731@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: John Baldwin Subject: git: dd47685dbdc8 - stable/13 - 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/stable/13 X-Git-Reftype: branch X-Git-Commit: dd47685dbdc89e33632d1e7da25e112849c324f7 Auto-Submitted: auto-generated The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=dd47685dbdc89e33632d1e7da25e112849c324f7 commit dd47685dbdc89e33632d1e7da25e112849c324f7 Author: John Baldwin AuthorDate: 2024-11-01 14:09:39 +0000 Commit: John Baldwin CommitDate: 2024-11-30 21:43:55 +0000 gpiobus: Use a bus_child_deleted method to free ivars for children Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47369 (cherry picked from commit c9e880c0ceef9541625c18add3f5a8499137e016) --- 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 4dceea15b00d..8e4b8be7e931 100644 --- a/sys/dev/gpio/gpiobus.c +++ b/sys/dev/gpio/gpiobus.c @@ -587,9 +587,7 @@ static 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), @@ -598,17 +596,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++) { @@ -723,6 +713,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) { @@ -742,7 +745,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; @@ -752,19 +754,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; } @@ -1103,6 +1100,7 @@ static device_method_t gpiobus_methods[] = { DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource), DEVMETHOD(bus_get_resource_list, gpiobus_get_resource_list), 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),