From nobody Thu Jan 02 18:28:31 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 4YPFZm0KDrz5jnSC; Thu, 02 Jan 2025 18:28:32 +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 4YPFZl3LHxz4tvP; Thu, 2 Jan 2025 18:28:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735842511; 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=snel+eqPsIlGbl1t/x6uK+18GKWDPXRn4awkZMKHsn4=; b=eUMc/q+Y4sRib/GOTP2sV/2O2dc9LVl00IzzBX6A/cVc6tdJEJWdl0/5073C7yr1R7LuMn USOPovGxQUSRJHFJgvaWGegjDX5JIGsu9iJSRj5pvOS1HwCtde6bAFJ9rS/fc5jHzhdh1t SofVVwJkY9pvKhztOxDaJ7iUUVuAlo0sh8A2gp5xkfLmRDkWaYBO+YnfkBgfHMoiLiUXGf eJVtBNFyXSIs/p67dqIvywUy5Bi0bbMrFrr8ZHAl067L9RieZvmDz5y5fBBsivGPpt+Pv/ Dpg7KX2xurt3jJiSF9VrsO1CwMzhcLYuNi0jw0v3gngzYov+3hne4D2y8KXgVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1735842511; 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=snel+eqPsIlGbl1t/x6uK+18GKWDPXRn4awkZMKHsn4=; b=W+pnm6SgLowWsRh31yVf/Ia9azM31kpFctdPkuiugDnZRAO8g+5BCqzF5IQk5nGp3DbkrL zZ1Lu63N/66venjU1HgX4LtZW2uCBpCCM5Xt7B9LKxdpES9QfjbJDUY1jn12Pr9z2U8mAk 19IziUARELPIRDacgovo01faNgYwKVqJzKweIH4sTfTtNzO4K8spbKCG0eHX2zJBC36FLr 9ngV30Gicx65vop9PChtSgfNPY7o3358BuWwvCv4RFjV29JurE4yrHzPcs6fBH6R5fHH77 Gqwe3T6Xp5J0BGv7Ho12MHggYxfXg5/KCA1sCJYzSjvIrYKpQfZ0g4SP2UlvrA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1735842511; a=rsa-sha256; cv=none; b=XbU1T4XNyG6hTGLXFQJ20+uj6Nhvzh1Aihjyn842/U5R7Sg0+LWq3SA0u7jkh7Zn4sWU/w Z7aRZzudQaEi81MbvP8OtyppD4bQ5t3T3bbIhmzRgttRW39dEBAT+9FYRjjYPJ0xW5IU5M +JvguzsN+KX/1T+f5BdEe/fufvPnj4bBw4hPvDap9at1UKCn54VUiAkT0kjY7SIxzd9iZh dCwIQ9wiL01HYpMtE1xCO07F3MGPH+k4OYLDzf5uD/VpzbDEemqJTkVGFFpBaS5o5UQgkX UxtOhAytfpiIUQOCv0xg1jDGpPOfqD+vgXhLWZRauEGrrtMUCDzkK1wsjAf7RQ== 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 4YPFZl2qrlzp59; Thu, 02 Jan 2025 18:28:31 +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 502ISVkH066681; Thu, 2 Jan 2025 18:28:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 502ISVn5066678; Thu, 2 Jan 2025 18:28:31 GMT (envelope-from git) Date: Thu, 2 Jan 2025 18:28:31 GMT Message-Id: <202501021828.502ISVn5066678@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: aa48c1ae0831 - main - etherswitch: Cleanup detach and delete of child devices during detach 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: aa48c1ae0831789c6aa34bf3a85b9a2289d425e2 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=aa48c1ae0831789c6aa34bf3a85b9a2289d425e2 commit aa48c1ae0831789c6aa34bf3a85b9a2289d425e2 Author: John Baldwin AuthorDate: 2025-01-02 18:24:46 +0000 Commit: John Baldwin CommitDate: 2025-01-02 18:24:46 +0000 etherswitch: Cleanup detach and delete of child devices during detach Call bus_generic_detach first and return any error. Remove no longer needed individual device_delete_child calls. Differential Revision: https://reviews.freebsd.org/D47970 --- sys/dev/etherswitch/ar40xx/ar40xx_main.c | 9 +++++---- sys/dev/etherswitch/arswitch/arswitch.c | 9 +++++---- sys/dev/etherswitch/e6000sw/e6060sw.c | 9 +++++---- sys/dev/etherswitch/infineon/adm6996fc.c | 9 +++++---- sys/dev/etherswitch/ip17x/ip17x.c | 9 +++++---- sys/dev/etherswitch/micrel/ksz8995ma.c | 9 +++++---- sys/dev/etherswitch/mtkswitch/mtkswitch.c | 9 +++++---- sys/dev/etherswitch/rtl8366/rtl8366rb.c | 9 +++++---- sys/dev/etherswitch/ukswitch/ukswitch.c | 9 +++++---- 9 files changed, 45 insertions(+), 36 deletions(-) diff --git a/sys/dev/etherswitch/ar40xx/ar40xx_main.c b/sys/dev/etherswitch/ar40xx/ar40xx_main.c index 41e6813bc840..d5636d26120b 100644 --- a/sys/dev/etherswitch/ar40xx/ar40xx_main.c +++ b/sys/dev/etherswitch/ar40xx/ar40xx_main.c @@ -254,22 +254,23 @@ static int ar40xx_detach(device_t dev) { struct ar40xx_softc *sc = device_get_softc(dev); - int i; + int error, i; device_printf(sc->sc_dev, "%s: called\n", __func__); + error = bus_generic_detach(dev); + if (error != 0) + return (error); + callout_drain(&sc->sc_phy_callout); /* Free PHYs */ for (i = 0; i < AR40XX_NUM_PHYS; i++) { - if (sc->sc_phys.miibus[i] != NULL) - device_delete_child(dev, sc->sc_phys.miibus[i]); if (sc->sc_phys.ifp[i] != NULL) if_free(sc->sc_phys.ifp[i]); free(sc->sc_phys.ifname[i], M_DEVBUF); } - bus_generic_detach(dev); mtx_destroy(&sc->sc_mtx); return (0); diff --git a/sys/dev/etherswitch/arswitch/arswitch.c b/sys/dev/etherswitch/arswitch/arswitch.c index 92c3460e5f78..924793a0488f 100644 --- a/sys/dev/etherswitch/arswitch/arswitch.c +++ b/sys/dev/etherswitch/arswitch/arswitch.c @@ -666,13 +666,15 @@ static int arswitch_detach(device_t dev) { struct arswitch_softc *sc = device_get_softc(dev); - int i; + int error, i; callout_drain(&sc->callout_tick); + error = bus_generic_detach(dev); + if (error != 0) + return (error); + for (i=0; i < sc->numphys; i++) { - if (sc->miibus[i] != NULL) - device_delete_child(dev, sc->miibus[i]); if (sc->ifp[i] != NULL) if_free(sc->ifp[i]); free(sc->ifname[i], M_DEVBUF); @@ -680,7 +682,6 @@ arswitch_detach(device_t dev) free(sc->atu.entries, M_DEVBUF); - bus_generic_detach(dev); mtx_destroy(&sc->sc_mtx); return (0); diff --git a/sys/dev/etherswitch/e6000sw/e6060sw.c b/sys/dev/etherswitch/e6000sw/e6060sw.c index 374eb8c5316b..901f887ffdc6 100644 --- a/sys/dev/etherswitch/e6000sw/e6060sw.c +++ b/sys/dev/etherswitch/e6000sw/e6060sw.c @@ -321,18 +321,20 @@ static int e6060sw_detach(device_t dev) { struct e6060sw_softc *sc; - int i, port; + int error, i, port; sc = device_get_softc(dev); + error = bus_generic_detach(dev); + if (error != 0) + return (error); + callout_drain(&sc->callout_tick); for (i = 0; i < MII_NPHY; i++) { if (((1 << i) & sc->phymask) == 0) continue; port = e6060sw_portforphy(sc, i); - if (sc->miibus[port] != NULL) - device_delete_child(dev, (*sc->miibus[port])); if (sc->ifp[port] != NULL) if_free(sc->ifp[port]); free(sc->ifname[port], M_E6060SW); @@ -344,7 +346,6 @@ e6060sw_detach(device_t dev) free(sc->ifname, M_E6060SW); free(sc->ifp, M_E6060SW); - bus_generic_detach(dev); mtx_destroy(&sc->sc_mtx); return (0); diff --git a/sys/dev/etherswitch/infineon/adm6996fc.c b/sys/dev/etherswitch/infineon/adm6996fc.c index 2a8ee58107ee..58a3f9625d4a 100644 --- a/sys/dev/etherswitch/infineon/adm6996fc.c +++ b/sys/dev/etherswitch/infineon/adm6996fc.c @@ -281,18 +281,20 @@ static int adm6996fc_detach(device_t dev) { struct adm6996fc_softc *sc; - int i, port; + int error, i, port; sc = device_get_softc(dev); + error = bus_generic_detach(dev); + if (error != 0) + return (error); + callout_drain(&sc->callout_tick); for (i = 0; i < MII_NPHY; i++) { if (((1 << i) & sc->phymask) == 0) continue; port = adm6996fc_portforphy(sc, i); - if (sc->miibus[port] != NULL) - device_delete_child(dev, (*sc->miibus[port])); if (sc->ifp[port] != NULL) if_free(sc->ifp[port]); free(sc->ifname[port], M_ADM6996FC); @@ -304,7 +306,6 @@ adm6996fc_detach(device_t dev) free(sc->ifname, M_ADM6996FC); free(sc->ifp, M_ADM6996FC); - bus_generic_detach(dev); mtx_destroy(&sc->sc_mtx); return (0); diff --git a/sys/dev/etherswitch/ip17x/ip17x.c b/sys/dev/etherswitch/ip17x/ip17x.c index 1eee45148040..c90d46c49857 100644 --- a/sys/dev/etherswitch/ip17x/ip17x.c +++ b/sys/dev/etherswitch/ip17x/ip17x.c @@ -274,7 +274,11 @@ static int ip17x_detach(device_t dev) { struct ip17x_softc *sc; - int i, port; + int error, i, port; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); if (sc->miipoll) @@ -284,8 +288,6 @@ ip17x_detach(device_t dev) if (((1 << i) & sc->phymask) == 0) continue; port = sc->phyport[i]; - if (sc->miibus[port] != NULL) - device_delete_child(dev, (*sc->miibus[port])); if (sc->ifp[port] != NULL) if_free(sc->ifp[port]); free(sc->miibus[port], M_IP17X); @@ -299,7 +301,6 @@ ip17x_detach(device_t dev) /* Reset the switch. */ sc->hal.ip17x_reset(sc); - bus_generic_detach(dev); mtx_destroy(&sc->sc_mtx); return (0); diff --git a/sys/dev/etherswitch/micrel/ksz8995ma.c b/sys/dev/etherswitch/micrel/ksz8995ma.c index a51bdb50fdfc..c2ac994fe882 100644 --- a/sys/dev/etherswitch/micrel/ksz8995ma.c +++ b/sys/dev/etherswitch/micrel/ksz8995ma.c @@ -339,7 +339,11 @@ static int ksz8995ma_detach(device_t dev) { struct ksz8995ma_softc *sc; - int i, port; + int error, i, port; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); @@ -349,8 +353,6 @@ ksz8995ma_detach(device_t dev) if (((1 << i) & sc->phymask) == 0) continue; port = ksz8995ma_portforphy(sc, i); - if (sc->miibus[port] != NULL) - device_delete_child(dev, (*sc->miibus[port])); if (sc->ifp[port] != NULL) if_free(sc->ifp[port]); free(sc->ifname[port], M_KSZ8995MA); @@ -362,7 +364,6 @@ ksz8995ma_detach(device_t dev) free(sc->ifname, M_KSZ8995MA); free(sc->ifp, M_KSZ8995MA); - bus_generic_detach(dev); mtx_destroy(&sc->sc_mtx); return (0); diff --git a/sys/dev/etherswitch/mtkswitch/mtkswitch.c b/sys/dev/etherswitch/mtkswitch/mtkswitch.c index 7c4e8ae6f934..89e092d02ac4 100644 --- a/sys/dev/etherswitch/mtkswitch/mtkswitch.c +++ b/sys/dev/etherswitch/mtkswitch/mtkswitch.c @@ -248,19 +248,20 @@ static int mtkswitch_detach(device_t dev) { struct mtkswitch_softc *sc = device_get_softc(dev); - int phy; + int error, phy; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); callout_drain(&sc->callout_tick); for (phy = 0; phy < MTKSWITCH_MAX_PHYS; phy++) { - if (sc->miibus[phy] != NULL) - device_delete_child(dev, sc->miibus[phy]); if (sc->ifp[phy] != NULL) if_free(sc->ifp[phy]); free(sc->ifname[phy], M_DEVBUF); } - bus_generic_detach(dev); mtx_destroy(&sc->sc_mtx); return (0); diff --git a/sys/dev/etherswitch/rtl8366/rtl8366rb.c b/sys/dev/etherswitch/rtl8366/rtl8366rb.c index 304e7f7b8325..079244b2f745 100644 --- a/sys/dev/etherswitch/rtl8366/rtl8366rb.c +++ b/sys/dev/etherswitch/rtl8366/rtl8366rb.c @@ -268,18 +268,19 @@ static int rtl8366rb_detach(device_t dev) { struct rtl8366rb_softc *sc; - int i; + int error, i; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); sc = device_get_softc(dev); for (i=0; i < sc->numphys; i++) { - if (sc->miibus[i]) - device_delete_child(dev, sc->miibus[i]); if (sc->ifp[i] != NULL) if_free(sc->ifp[i]); free(sc->ifname[i], M_DEVBUF); } - bus_generic_detach(dev); callout_drain(&sc->callout_tick); mtx_destroy(&sc->callout_mtx); mtx_destroy(&sc->sc_mtx); diff --git a/sys/dev/etherswitch/ukswitch/ukswitch.c b/sys/dev/etherswitch/ukswitch/ukswitch.c index ed1a27a19494..a2e30c3af8a1 100644 --- a/sys/dev/etherswitch/ukswitch/ukswitch.c +++ b/sys/dev/etherswitch/ukswitch/ukswitch.c @@ -224,7 +224,11 @@ static int ukswitch_detach(device_t dev) { struct ukswitch_softc *sc = device_get_softc(dev); - int i, port; + int error, i, port; + + error = bus_generic_detach(dev); + if (error != 0) + return (error); callout_drain(&sc->callout_tick); @@ -232,8 +236,6 @@ ukswitch_detach(device_t dev) if (((1 << i) & sc->phymask) == 0) continue; port = ukswitch_portforphy(sc, i); - if (sc->miibus[port] != NULL) - device_delete_child(dev, (*sc->miibus[port])); if (sc->ifp[port] != NULL) if_free(sc->ifp[port]); free(sc->ifname[port], M_UKSWITCH); @@ -245,7 +247,6 @@ ukswitch_detach(device_t dev) free(sc->ifname, M_UKSWITCH); free(sc->ifp, M_UKSWITCH); - bus_generic_detach(dev); mtx_destroy(&sc->sc_mtx); return (0);