From nobody Wed Oct 16 03:18:57 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 4XSx5G1hJMz5ZNcC; Wed, 16 Oct 2024 03:18:58 +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 4XSx5G0yzcz4Mc5; Wed, 16 Oct 2024 03:18:58 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729048738; 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=EhVb+LOc0MzdIu+tzLMhCV9WPdF6YKiTAC9LUnBaHZE=; b=ihZofiMMm6aGJB/3B5GJ6FGo2Bc8+tj+IBTr4ZPuV1FUdf0oQlWNPAc1M8aG6L+oR7RBNw fB+meihh90dmOQKeu9PqJyyUs6toieIrsEu0sWgNhGtwoXLty1oZ85791Ys3dr7sr89j/N pi01XLAkZNGN/MUrB1FuTx4+NnL0KEKO0Unhyy1UhY1EFOBT6UhiFtq5jwhE40ACjXTk65 Pd0+RAgCBacwHSAn/hXAz4n/mp/zvQxxP6Co+EpyRRq0qc5yzrDQlYULdcHBHuxg1OrmNS DiIkw+f/oqIChhpGJrMWoQazpm3Xe+LymVlkvh216wDSeqPxEaCvr0RTTrOnkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729048738; 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=EhVb+LOc0MzdIu+tzLMhCV9WPdF6YKiTAC9LUnBaHZE=; b=CUt5wRnn1X8RHMKOYIQ4ANIirucsLZd7CKGGKFBcoL7uy6jtrh/jaHzoYdnLosDwVlQz7d 2dA7P3YFwyK6jFFw4DoobqIDK65FmMnT7Lh/ibDwmrIMWcJEttdwwJbO5OiFscHmzBXXtW Hor6YPWO9OA5YpU+VsBmJjJWbYYvJCXOQNGD1KNtAa7wKS658NP+DSAp4fVpBaLOM1QEBM 6ljWggtwokoxFa6WH6ABWclk/VdI0XjViTIE9X0ymlyPAppUzkvtWuF9QA/onyhPiycjXZ 4zvRHAbYrhAr2ZVVL4hV8QzbPkSBgVBE/4V9S7MJjKDqXfoIjPdUgqPs9qZW3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729048738; a=rsa-sha256; cv=none; b=DT5SwF+hFfqWq/7CjbSyPtbCStqejC8soxqLevBCT8wKkSeIaelN83W8b1kgqTzHsrXmkJ hVB96AIrhBv/0Fj3faMSOY93Gm1Fb4hW4Jbunf11pLxT85s2wNboVEB5GBQcerE2nV+j3K m6MaNLN+SHFMuirqo0tuEAHC3GdOxB9qcZaP4QeRKmPkoJ5O1vsUI1tdUG528XfiBjiVKB Zm7ARU8RmNST5m3VB5O1JtovbYpO4G5tH0Xjs7X8GF5NPbauZGgqPSIwSD0KAgU9aiB11E fl9oPIByKvrRXvxmjdJ4AtXi5e8BCLZLl6pb8K7LOoEOl9hPhosRfvAFzHjXzA== 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 4XSx5G0ZBTzpKl; Wed, 16 Oct 2024 03:18:58 +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 49G3IvWv034287; Wed, 16 Oct 2024 03:18:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49G3IvgV034284; Wed, 16 Oct 2024 03:18:57 GMT (envelope-from git) Date: Wed, 16 Oct 2024 03:18:57 GMT Message-Id: <202410160318.49G3IvgV034284@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 42b7e9c4a9c5 - main - newbus: Remove redundant check for 0 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 42b7e9c4a9c53f3d51926cf57858a17887363662 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=42b7e9c4a9c53f3d51926cf57858a17887363662 commit 42b7e9c4a9c53f3d51926cf57858a17887363662 Author: Warner Losh AuthorDate: 2024-10-16 03:19:11 +0000 Commit: Warner Losh CommitDate: 2024-10-16 03:19:27 +0000 newbus: Remove redundant check for 0 We already checked to see if the return code is 0 above. This code is redundant. However, it's here so we can break out two layers, which a simple goto fixes. A subsequent change makes the pri < 0 condition no longer hold. This allows us to simplify a few things. Sponsored by: Netflix Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D44269 --- sys/kern/subr_bus.c | 57 +++++++++++++++++++++++------------------------------ 1 file changed, 25 insertions(+), 32 deletions(-) diff --git a/sys/kern/subr_bus.c b/sys/kern/subr_bus.c index d0c41b59dbb6..ef71588f7157 100644 --- a/sys/kern/subr_bus.c +++ b/sys/kern/subr_bus.c @@ -1662,13 +1662,13 @@ device_probe_child(device_t dev, device_t child) result = DEVICE_PROBE(child); /* - * If the driver returns SUCCESS, there can be - * no higher match for this device. + * If probe returns 0, this is the driver that wins this + * device. */ if (result == 0) { best = dl; pri = 0; - break; + goto exact_match; /* C doesn't have break 2 */ } /* Reset flags and devclass before the next probe. */ @@ -1712,12 +1712,6 @@ device_probe_child(device_t dev, device_t child) continue; } } - /* - * If we have an unambiguous match in this devclass, - * don't look in the parent. - */ - if (best && pri == 0) - break; } if (best == NULL) @@ -1725,35 +1719,34 @@ device_probe_child(device_t dev, device_t child) /* * If we found a driver, change state and initialise the devclass. + * Set the winning driver, devclass, and flags. */ - if (pri < 0) { - /* Set the winning driver, devclass, and flags. */ - result = device_set_driver(child, best->driver); - if (result != 0) - return (result); - if (!child->devclass) { - result = device_set_devclass(child, best->driver->name); - if (result != 0) { - (void)device_set_driver(child, NULL); - return (result); - } - } - resource_int_value(best->driver->name, child->unit, - "flags", &child->devflags); - - /* - * A bit bogus. Call the probe method again to make sure - * that we have the right description. - */ - result = DEVICE_PROBE(child); - if (result > 0) { - if (!hasclass) - (void)device_set_devclass(child, NULL); + result = device_set_driver(child, best->driver); + if (result != 0) + return (result); + if (!child->devclass) { + result = device_set_devclass(child, best->driver->name); + if (result != 0) { (void)device_set_driver(child, NULL); return (result); } } + resource_int_value(best->driver->name, child->unit, + "flags", &child->devflags); + + /* + * A bit bogus. Call the probe method again to make sure that we have + * the right description for the device. + */ + result = DEVICE_PROBE(child); + if (result > 0) { + if (!hasclass) + (void)device_set_devclass(child, NULL); + (void)device_set_driver(child, NULL); + return (result); + } +exact_match: child->state = DS_ALIVE; bus_data_generation_update(); return (0);