From bbbe8875f0844bdf4e10cbc01dc9c7f2a2c8368a Mon Sep 17 00:00:00 2001 From: peter Date: Tue, 12 Jun 2001 09:40:04 +0000 Subject: Hints overhaul: - Replace some very poorly thought out API hacks that should have been fixed a long while ago. - Provide some much more flexible search functions (resource_find_*()) - Use strings for storage instead of an outgrowth of the rather inconvenient temporary ioconf table from config(). We already had a fallback to using strings before malloc/vm was running anyway. --- sys/cam/cam_periph.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'sys/cam/cam_periph.c') diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index 18bf45a..d74b04d 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -303,10 +303,10 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, path_id_t pathid, target_id_t target, lun_id_t lun) { struct cam_periph *periph; - char *periph_name, *strval; + char *periph_name; int s; - int i, val, dunit; - const char *dname; + int i, val, dunit, r; + const char *dname, *strval; s = splsoftcam(); periph_name = p_drv->driver_name; @@ -337,10 +337,12 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, * device, but do match entries like "da 4 target 5" * or even "da 4 scbus 1". */ - i = -1; - while ((i = resource_locate(i, periph_name)) != -1) { - dname = resource_query_name(i); - dunit = resource_query_unit(i); + i = 0; + dname = periph_name; + for (;;) { + 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)|| @@ -349,7 +351,7 @@ camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, if (newunit == dunit) break; } - if (i == -1) + if (r != 0) break; } splx(s); @@ -362,18 +364,17 @@ camperiphunit(struct periph_driver *p_drv, path_id_t pathid, { u_int unit; int hit, i, val, dunit; - const char *dname; - char pathbuf[32], *strval, *periph_name; + const char *dname, *strval; + char pathbuf[32], *periph_name; unit = 0; hit = 0; periph_name = p_drv->driver_name; snprintf(pathbuf, sizeof(pathbuf), "scbus%d", pathid); - i = -1; - while ((i = resource_locate(i, periph_name)) != -1) { - dname = resource_query_name(i); - dunit = resource_query_unit(i); + i = 0; + dname = periph_name; + while ((resource_find_dev(&i, dname, &dunit, NULL, NULL)) == 0) { if (resource_string_value(dname, dunit, "at", &strval) == 0) { if (strcmp(strval, pathbuf) != 0) continue; -- cgit v1.1