cam_periph.c (76158) | cam_periph.c (78135) |
---|---|
1/* 2 * Common functions for CAM "type" (peripheral) drivers. 3 * 4 * Copyright (c) 1997, 1998 Justin T. Gibbs. 5 * Copyright (c) 1997, 1998, 1999, 2000 Kenneth D. Merry. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * | 1/* 2 * Common functions for CAM "type" (peripheral) drivers. 3 * 4 * Copyright (c) 1997, 1998 Justin T. Gibbs. 5 * Copyright (c) 1997, 1998, 1999, 2000 Kenneth D. Merry. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 12 unchanged lines hidden (view full) --- 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/cam/cam_periph.c 76158 2001-04-30 21:02:57Z ken $ | 29 * $FreeBSD: head/sys/cam/cam_periph.c 78135 2001-06-12 09:40:04Z peter $ |
30 */ 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/types.h> 35#include <sys/malloc.h> 36#include <sys/linker_set.h> 37#include <sys/bio.h> --- 260 unchanged lines hidden (view full) --- 298 * first time through the loop since after that we'll be looking at unit 299 * numbers that did not match a wiring entry. 300 */ 301static u_int 302camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, 303 path_id_t pathid, target_id_t target, lun_id_t lun) 304{ 305 struct cam_periph *periph; | 30 */ 31 32#include <sys/param.h> 33#include <sys/systm.h> 34#include <sys/types.h> 35#include <sys/malloc.h> 36#include <sys/linker_set.h> 37#include <sys/bio.h> --- 260 unchanged lines hidden (view full) --- 298 * first time through the loop since after that we'll be looking at unit 299 * numbers that did not match a wiring entry. 300 */ 301static u_int 302camperiphnextunit(struct periph_driver *p_drv, u_int newunit, int wired, 303 path_id_t pathid, target_id_t target, lun_id_t lun) 304{ 305 struct cam_periph *periph; |
306 char *periph_name, *strval; | 306 char *periph_name; |
307 int s; | 307 int s; |
308 int i, val, dunit; 309 const char *dname; | 308 int i, val, dunit, r; 309 const char *dname, *strval; |
310 311 s = splsoftcam(); 312 periph_name = p_drv->driver_name; 313 for (;;newunit++) { 314 315 for (periph = TAILQ_FIRST(&p_drv->units); 316 periph != NULL && periph->unit_number != newunit; 317 periph = TAILQ_NEXT(periph, unit_links)) --- 14 unchanged lines hidden (view full) --- 332 if (wired) 333 break; 334 335 /* 336 * Don't match entries like "da 4" as a wired down 337 * device, but do match entries like "da 4 target 5" 338 * or even "da 4 scbus 1". 339 */ | 310 311 s = splsoftcam(); 312 periph_name = p_drv->driver_name; 313 for (;;newunit++) { 314 315 for (periph = TAILQ_FIRST(&p_drv->units); 316 periph != NULL && periph->unit_number != newunit; 317 periph = TAILQ_NEXT(periph, unit_links)) --- 14 unchanged lines hidden (view full) --- 332 if (wired) 333 break; 334 335 /* 336 * Don't match entries like "da 4" as a wired down 337 * device, but do match entries like "da 4 target 5" 338 * or even "da 4 scbus 1". 339 */ |
340 i = -1; 341 while ((i = resource_locate(i, periph_name)) != -1) { 342 dname = resource_query_name(i); 343 dunit = resource_query_unit(i); | 340 i = 0; 341 dname = periph_name; 342 for (;;) { 343 r = resource_find_dev(&i, dname, &dunit, NULL, NULL); 344 if (r != 0) 345 break; |
344 /* if no "target" and no specific scbus, skip */ 345 if (resource_int_value(dname, dunit, "target", &val) && 346 (resource_string_value(dname, dunit, "at",&strval)|| 347 strcmp(strval, "scbus") == 0)) 348 continue; 349 if (newunit == dunit) 350 break; 351 } | 346 /* if no "target" and no specific scbus, skip */ 347 if (resource_int_value(dname, dunit, "target", &val) && 348 (resource_string_value(dname, dunit, "at",&strval)|| 349 strcmp(strval, "scbus") == 0)) 350 continue; 351 if (newunit == dunit) 352 break; 353 } |
352 if (i == -1) | 354 if (r != 0) |
353 break; 354 } 355 splx(s); 356 return (newunit); 357} 358 359static u_int 360camperiphunit(struct periph_driver *p_drv, path_id_t pathid, 361 target_id_t target, lun_id_t lun) 362{ 363 u_int unit; 364 int hit, i, val, dunit; | 355 break; 356 } 357 splx(s); 358 return (newunit); 359} 360 361static u_int 362camperiphunit(struct periph_driver *p_drv, path_id_t pathid, 363 target_id_t target, lun_id_t lun) 364{ 365 u_int unit; 366 int hit, i, val, dunit; |
365 const char *dname; 366 char pathbuf[32], *strval, *periph_name; | 367 const char *dname, *strval; 368 char pathbuf[32], *periph_name; |
367 368 unit = 0; 369 hit = 0; 370 371 periph_name = p_drv->driver_name; 372 snprintf(pathbuf, sizeof(pathbuf), "scbus%d", pathid); | 369 370 unit = 0; 371 hit = 0; 372 373 periph_name = p_drv->driver_name; 374 snprintf(pathbuf, sizeof(pathbuf), "scbus%d", pathid); |
373 i = -1; 374 while ((i = resource_locate(i, periph_name)) != -1) { 375 dname = resource_query_name(i); 376 dunit = resource_query_unit(i); | 375 i = 0; 376 dname = periph_name; 377 while ((resource_find_dev(&i, dname, &dunit, NULL, NULL)) == 0) { |
377 if (resource_string_value(dname, dunit, "at", &strval) == 0) { 378 if (strcmp(strval, pathbuf) != 0) 379 continue; 380 hit++; 381 } 382 if (resource_int_value(dname, dunit, "target", &val) == 0) { 383 if (val != target) 384 continue; --- 1280 unchanged lines hidden --- | 378 if (resource_string_value(dname, dunit, "at", &strval) == 0) { 379 if (strcmp(strval, pathbuf) != 0) 380 continue; 381 hit++; 382 } 383 if (resource_int_value(dname, dunit, "target", &val) == 0) { 384 if (val != target) 385 continue; --- 1280 unchanged lines hidden --- |