summaryrefslogtreecommitdiffstats
path: root/sys/cam
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2001-06-12 09:40:04 +0000
committerpeter <peter@FreeBSD.org>2001-06-12 09:40:04 +0000
commitbbbe8875f0844bdf4e10cbc01dc9c7f2a2c8368a (patch)
treeddf23af998adfeb85fbbf912b89e3fa83f84fd4b /sys/cam
parentb44fc46ed5521eb3028aafbc0c4aef220ed24141 (diff)
downloadFreeBSD-src-bbbe8875f0844bdf4e10cbc01dc9c7f2a2c8368a.zip
FreeBSD-src-bbbe8875f0844bdf4e10cbc01dc9c7f2a2c8368a.tar.gz
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.
Diffstat (limited to 'sys/cam')
-rw-r--r--sys/cam/cam_periph.c29
-rw-r--r--sys/cam/cam_xpt.c10
2 files changed, 20 insertions, 19 deletions
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;
diff --git a/sys/cam/cam_xpt.c b/sys/cam/cam_xpt.c
index 6c3cf99..6374e47 100644
--- a/sys/cam/cam_xpt.c
+++ b/sys/cam/cam_xpt.c
@@ -4346,7 +4346,7 @@ xptnextfreepathid(void)
{
struct cam_eb *bus;
path_id_t pathid;
- char *strval;
+ const char *strval;
pathid = 0;
bus = TAILQ_FIRST(&xpt_busses);
@@ -4377,16 +4377,16 @@ xptpathid(const char *sim_name, int sim_unit, int sim_bus)
path_id_t pathid;
int i, dunit, val;
char buf[32];
+ const char *dname;
pathid = CAM_XPT_PATH_ID;
snprintf(buf, sizeof(buf), "%s%d", sim_name, sim_unit);
- i = -1;
- while ((i = resource_query_string(i, "at", buf)) != -1) {
- if (strcmp(resource_query_name(i), "scbus")) {
+ i = 0;
+ while ((resource_find_match(&i, &dname, &dunit, "at", buf)) == 0) {
+ if (strcmp(dname, "scbus")) {
/* Avoid a bit of foot shooting. */
continue;
}
- dunit = resource_query_unit(i);
if (dunit < 0) /* unwired?! */
continue;
if (resource_int_value("scbus", dunit, "bus", &val) == 0) {
OpenPOWER on IntegriCloud