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
This commit is contained in:
Warner Losh 2021-11-05 08:56:22 -06:00
parent 00f79c97a4
commit bee0133fb9

View file

@ -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)