git: bee0133fb937 - main - cam_periph: switch from negative logic to positive logic

From: Warner Losh <imp_at_FreeBSD.org>
Date: Fri, 05 Nov 2021 15:25:37 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=bee0133fb937e519623324fd1ae7214d59a03aca

commit bee0133fb937e519623324fd1ae7214d59a03aca
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2021-11-05 14:56:22 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2021-11-05 14:56:22 +0000

    cam_periph: switch from negative logic to positive logic
    
    When scanning the resources that are wired for this driver, skip any
    that whose number doesn't match newunit. They aren't relevant. Switch to
    positive logic to break out of the loop (and thus go to the next unit)
    if we find either a target resource or an at resource. This makes the
    code easier to read and modify.
    
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D32681
---
 sys/cam/cam_periph.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c
index 990854f992c3..37a54a2d992b 100644
--- a/sys/cam/cam_periph.c
+++ b/sys/cam/cam_periph.c
@@ -579,11 +579,11 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired,
 			r = resource_find_dev(&i, dname, &dunit, NULL, NULL);
 			if (r != 0)
 				break;
-			/* if no "target" and no specific scbus, skip */
-			if (resource_int_value(dname, dunit, "target", &val) &&
-			    resource_string_value(dname, dunit, "at",&strval))
+
+			if (newunit != dunit)
 				continue;
-			if (newunit == dunit)
+			if (resource_int_value(dname, dunit, "target", &val) == 0 ||
+			    resource_string_value(dname, dunit, "at", &strval) == 0)
 				break;
 		}
 		if (r != 0)