git: 710a519ebbe3 - main - cam_periph: fix bug in camperiphunitnext logic

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

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

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

    cam_periph: fix bug in camperiphunitnext logic
    
    If we assigned just a lun as a wired unit (something that camperiphunit
    will accept), we failed to properly skip over that unit when computing a
    next unit number. Add lun so the code matches the comments that we have
    to skip all the same criteria that camperiphunit uses to select wired
    units for a driver.
    
    Sponsored by:           Netflix
    Differential Revision:  https://reviews.freebsd.org/D32682
---
 sys/cam/cam_periph.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c
index 37a54a2d992b..8fbc2e3926fa 100644
--- a/sys/cam/cam_periph.c
+++ b/sys/cam/cam_periph.c
@@ -582,7 +582,8 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired,
 
 			if (newunit != dunit)
 				continue;
-			if (resource_int_value(dname, dunit, "target", &val) == 0 ||
+			if (resource_int_value(dname, dunit, "lun", &val) == 0 ||
+			    resource_int_value(dname, dunit, "target", &val) == 0 ||
 			    resource_string_value(dname, dunit, "at", &strval) == 0)
 				break;
 		}