diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-03-02 13:58:09 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-03-02 13:58:09 +0000 |
commit | f7c30260ae4141b882d57c950073b8d4568fbb6f (patch) | |
tree | 7a1e81ecbc69eb4f56db9ea4f0d2d5342b49cae2 /sys/scsi | |
parent | 0c08d3ed22ea50ebac307e6634cce26410730920 (diff) |
Move the code obtaining the LUN 0 scsi_link used to determine the
LUNs available to a target into scsi_get_target_luns(). Clearer
code and prep for future changes.
No functional change.
Extracted from a larger diff submitted by Scott Nicholas via
tech@.
Diffstat (limited to 'sys/scsi')
-rw-r--r-- | sys/scsi/scsiconf.c | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c index 7a74a66cd9d..6db18c2fd81 100644 --- a/sys/scsi/scsiconf.c +++ b/sys/scsi/scsiconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsiconf.c,v 1.239 2022/02/28 14:48:11 krw Exp $ */ +/* $OpenBSD: scsiconf.c,v 1.240 2022/03/02 13:58:08 krw Exp $ */ /* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */ /* @@ -75,7 +75,8 @@ int scsibussubprint(void *, const char *); int scsibusbioctl(struct device *, u_long, caddr_t); #endif /* NBIO > 0 */ -void scsi_get_target_luns(struct scsi_link *, struct scsi_lun_array *); +void scsi_get_target_luns(struct scsibus_softc *, int, + struct scsi_lun_array *); void scsi_add_link(struct scsi_link *); void scsi_remove_link(struct scsi_link *); void scsi_print_link(struct scsi_link *); @@ -441,18 +442,15 @@ int scsi_probe_target(struct scsibus_softc *sb, int target) { struct scsi_lun_array lunarray; - struct scsi_link *link0; int i, r, rv = 0; if (target < 0 || target == sb->sb_adapter_target) return EINVAL; - /* Probe all possible luns on target. */ - scsi_probe_link(sb, target, 0, 0); - link0 = scsi_get_link(sb, target, 0); - if (link0 == NULL) + scsi_get_target_luns(sb, target, &lunarray); + if (lunarray.count == 0) return EINVAL; - scsi_get_target_luns(link0, &lunarray); + for (i = 0; i < lunarray.count; i++) { r = scsi_probe_link(sb, target, lunarray.luns[i], lunarray.dumbscan); @@ -862,11 +860,21 @@ scsi_remove_link(struct scsi_link *link) } void -scsi_get_target_luns(struct scsi_link *link0, struct scsi_lun_array *lunarray) +scsi_get_target_luns(struct scsibus_softc *sb, int target, + struct scsi_lun_array *lunarray) { struct scsi_report_luns_data *report; + struct scsi_link *link0; int i, nluns, rv = 0; + /* LUN 0 *must* be present. */ + scsi_probe_link(sb, target, 0, 0); + link0 = scsi_get_link(sb, target, 0); + if (link0 == NULL) { + lunarray->count = 0; + return; + } + /* Initialize dumbscan result. Just in case. */ report = NULL; for (i = 0; i < link0->bus->sb_luns; i++) |