From nobody Thu Jan 02 18:28:25 2025 X-Original-To: dev-commits-src-main@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 4YPFZf2PXnz5jnMJ; Thu, 02 Jan 2025 18:28:26 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YPFZd5yqzz4v08; Thu, 2 Jan 2025 18:28:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735842505; 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=CEkv6PxqW5c+LeFtUBhNXGW7i3Cy25oqputV1I4qrw8=; b=cTXhGqfRtn7GmHd5YEiTEPd4tDem+Q5esn37KtYzIncCkrrRP3xkQJ8cJPdx+N+v5DooZX k7Y7vEtr3FuIwF2bOay2XhW50GXr9Q2ke/qeieRjKKuF5/HRJ5CjUgjjbTcSrI2CtBDFaL 38p+cDfOpBYjsRNlJYoZNMNkUveCu0T1PHdxGp56mo4qElKdMDLlZ2r49tqKOt2t14yjf8 cnZ889P5aXIP5rWQK8Cu4d5pYhj3I8HKmnYS9DrQ0V5EiAFOybZtRoV3vk0PUh2W3j9vkG MU1oMWUTOBukceWoQAF45f8gMImh/aCI7LIYUSnAY6OQFFoUxIlKOEXoRPaeSw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735842505; 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=CEkv6PxqW5c+LeFtUBhNXGW7i3Cy25oqputV1I4qrw8=; b=sO4XTCmFym0P32bP+NFV3K2Jix/8M1Mw+7LwTx4+bvZFIWKDtIeY7+y/X5+W+rEKilxf53 vms2JkxuIVFtGmZlYRr7XzROJwSg6vzFOsaFMFDDgu9emgDjwG0qLeyxidxqnQvM/WKdvG Y7nDdgQ8g2VkbC79Vze+rTIxU6fKDrDa7WDxkhRPPpq5HZi/PP3aZLPa1lO643Zl25P8iN nekfx3sBOzBFQlNU3+5XXjtJMjgXu90dA/7ZQc46+RXF5LHE21QjpRxMGEYGXtQYqthQ1A 67792C6KHcuCD5HT1S0w2Wp2ZfmajHEeLLKTylljS8QLg7eAtlFlb2bdU5HvLg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735842505; a=rsa-sha256; cv=none; b=SKR1bjGvrIO9OEPqGDDCuvvz8uAzi7tL0woHvwelJkSPECS0lkpLD75aIjUEMdoZZ3TN7T XKI0h2smKmj9XfOk7JIdmPdWCdNBvb0iDKtl4SF7TK891RwplQ6TQJti+UWHqdZrhcWw1P /Q8Jx4kRxo6w8tnKQgh+Pl5VrcL2uE8zXag6KEEDIEsNt5kyqE/TA0bkhFvgGGGkabgf0K X42ggP+iJ8xgk4aMDJmylKqoBZvhxoD42uvJMkfUaJhJf9ogAteN4remMxX9cx+d31Dm0Z l5c37gITpT1Oddun9fEPtB6DcSQwcDgtOB7CRT6BgUxOAy/8O/D5hbBg5YV4KA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4YPFZd5HQQzp57; Thu, 02 Jan 2025 18:28:25 +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 502ISPa2066422; Thu, 2 Jan 2025 18:28:25 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 502ISPY0066419; Thu, 2 Jan 2025 18:28:25 GMT (envelope-from git) Date: Thu, 2 Jan 2025 18:28:25 GMT Message-Id: <202501021828.502ISPY0066419@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: 6da28bb2a34a - main - csa/emu10kx: Simplify deleting child devices List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 6da28bb2a34ac9e410ba8a49a7d8b8975462e929 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=6da28bb2a34ac9e410ba8a49a7d8b8975462e929 commit 6da28bb2a34ac9e410ba8a49a7d8b8975462e929 Author: John Baldwin AuthorDate: 2025-01-02 18:23:28 +0000 Commit: John Baldwin CommitDate: 2025-01-02 18:23:28 +0000 csa/emu10kx: Simplify deleting child devices Use bus_generic_detach to detach and delete all child devices instead of several explicit calls to device_delete_child. Differential Revision: https://reviews.freebsd.org/D47965 --- sys/dev/sound/pci/csa.c | 18 ++++-------------- sys/dev/sound/pci/emu10kx.c | 31 ++++--------------------------- 2 files changed, 8 insertions(+), 41 deletions(-) diff --git a/sys/dev/sound/pci/csa.c b/sys/dev/sound/pci/csa.c index 4c43c42b1cc3..4bd8ff029f43 100644 --- a/sys/dev/sound/pci/csa.c +++ b/sys/dev/sound/pci/csa.c @@ -317,26 +317,16 @@ csa_detach(device_t dev) scp = device_get_softc(dev); resp = &scp->res; - if (scp->midi != NULL) { - err = device_delete_child(dev, scp->midi); - if (err != 0) - return err; - scp->midi = NULL; - } - - if (scp->pcm != NULL) { - err = device_delete_child(dev, scp->pcm); - if (err != 0) - return err; - scp->pcm = NULL; - } + err = bus_generic_detach(dev); + if (err != 0) + return err; bus_teardown_intr(dev, resp->irq, scp->ih); bus_release_resource(dev, SYS_RES_IRQ, resp->irq_rid, resp->irq); bus_release_resource(dev, SYS_RES_MEMORY, resp->mem_rid, resp->mem); bus_release_resource(dev, SYS_RES_MEMORY, resp->io_rid, resp->io); - return bus_generic_detach(dev); + return (0); } static int diff --git a/sys/dev/sound/pci/emu10kx.c b/sys/dev/sound/pci/emu10kx.c index 0c445482a932..9cd7dbca1cb2 100644 --- a/sys/dev/sound/pci/emu10kx.c +++ b/sys/dev/sound/pci/emu10kx.c @@ -3354,36 +3354,13 @@ static int emu_pci_detach(device_t dev) { struct emu_sc_info *sc; - int devcount, i; - device_t *childlist; int r = 0; sc = device_get_softc(dev); - for (i = 0; i < RT_COUNT; i++) { - if (sc->pcm[i] != NULL) { - r = device_delete_child(dev, sc->pcm[i]); - if (r) return (r); - } - } - - if (sc->midi[0] != NULL) { - r = device_delete_child(dev, sc->midi[0]); - if (r) return (r); - } - - if (sc->midi[1] != NULL) { - r = device_delete_child(dev, sc->midi[1]); - if (r) return (r); - } - - if (device_get_children(dev, &childlist, &devcount) == 0) - for (i = 0; i < devcount - 1; i++) { - device_printf(dev, "removing stale child %d (unit %d)\n", i, device_get_unit(childlist[i])); - device_delete_child(dev, childlist[i]); - } - if (childlist != NULL) - free(childlist, M_TEMP); + r = bus_generic_detach(dev); + if (r != 0) + return (r); r = emu10kx_dev_uninit(sc); if (r) @@ -3403,7 +3380,7 @@ emu_pci_detach(device_t dev) mtx_destroy(&sc->rw); mtx_destroy(&sc->lock); - return (bus_generic_detach(dev)); + return (0); } /* add suspend, resume */ static device_method_t emu_methods[] = {