summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrw <krw@openbsd.org>2020-08-10 12:12:44 +0000
committerkrw <krw@openbsd.org>2020-08-10 12:12:44 +0000
commitae7c6741dbea97af4407c54e7eff208331d47e3e (patch)
treea09f8f84b759c271f899d503ca5fce77e6cddf65
parentminor polishing: fix typos, add HISTORY and AUTHORS, a few wording (diff)
downloadwireguard-openbsd-ae7c6741dbea97af4407c54e7eff208331d47e3e.tar.xz
wireguard-openbsd-ae7c6741dbea97af4407c54e7eff208331d47e3e.zip
Minor code shuffle to get all *_activate(), *_probe() and *_detach() functions
nestled together. Rename scsibusprint() to scsibussubprint() since it is used with scsibussubmatch().
-rw-r--r--sys/scsi/scsiconf.c120
1 files changed, 60 insertions, 60 deletions
diff --git a/sys/scsi/scsiconf.c b/sys/scsi/scsiconf.c
index 29c9afb7c8a..76004b55b23 100644
--- a/sys/scsi/scsiconf.c
+++ b/sys/scsi/scsiconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsiconf.c,v 1.232 2020/08/09 15:06:01 krw Exp $ */
+/* $OpenBSD: scsiconf.c,v 1.233 2020/08/10 12:12:44 krw Exp $ */
/* $NetBSD: scsiconf.c,v 1.57 1996/05/02 01:09:01 neil Exp $ */
/*
@@ -66,7 +66,7 @@ void scsibusattach(struct device *, struct device *, void *);
int scsibusactivate(struct device *, int);
int scsibusdetach(struct device *, int);
int scsibussubmatch(struct device *, void *, void *);
-int scsibusprint(void *, const char *);
+int scsibussubprint(void *, const char *);
#if NBIO > 0
#include <sys/ioctl.h>
#include <sys/scsiio.h>
@@ -301,7 +301,7 @@ scsibussubmatch(struct device *parent, void *match, void *aux)
* the standard device information.
*/
int
-scsibusprint(void *aux, const char *pnp)
+scsibussubprint(void *aux, const char *pnp)
{
struct scsi_attach_args *sa = aux;
@@ -410,61 +410,6 @@ scsi_activate_link(struct scsi_link *link, int act)
return rv;
}
-void
-scsi_get_target_luns(struct scsi_link *link0, struct scsi_lun_array *lunarray)
-{
- struct scsi_report_luns_data *report;
- int i, nluns, rv = 0;
-
- /* Initialize dumbscan result. Just in case. */
- report = NULL;
- for (i = 0; i < link0->bus->sb_luns; i++)
- lunarray->luns[i] = i;
- lunarray->count = link0->bus->sb_luns;
- lunarray->dumbscan = 1;
-
- /*
- * ATAPI, USB and pre-SPC (i.e. pre-SCSI-3) devices can't ask
- * for a report of valid LUNs.
- */
- if ((link0->flags & (SDEV_UMASS | SDEV_ATAPI)) != 0 ||
- SID_ANSII_REV(&link0->inqdata) < SCSI_REV_SPC)
- goto dumbscan;
-
- report = dma_alloc(sizeof(*report), PR_WAITOK);
- if (report == NULL)
- goto dumbscan;
-
- rv = scsi_report_luns(link0, REPORT_NORMAL, report,
- sizeof(*report), scsi_autoconf | SCSI_SILENT |
- SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY |
- SCSI_IGNORE_MEDIA_CHANGE, 10000);
- if (rv != 0)
- goto dumbscan;
-
- /*
- * XXX In theory we should check if data is full, which
- * would indicate it needs to be enlarged and REPORT
- * LUNS tried again. Solaris tries up to 3 times with
- * larger sizes for data.
- */
-
- /* Return the reported Type-0 LUNs. Type-0 only! */
- lunarray->count = 0;
- lunarray->dumbscan = 0;
- nluns = _4btol(report->length) / RPL_LUNDATA_SIZE;
- for (i = 0; i < nluns; i++) {
- if (report->luns[i].lundata[0] != 0)
- continue;
- lunarray->luns[lunarray->count++] =
- report->luns[i].lundata[RPL_LUNDATA_T0LUN];
- }
-
-dumbscan:
- if (report != NULL)
- dma_free(report, sizeof(*report));
-}
-
int
scsi_probe(struct scsibus_softc *sb, int target, int lun)
{
@@ -752,7 +697,7 @@ scsi_probe_link(struct scsibus_softc *sb, int target, int lun, int dumbscan)
if ((cf = config_search(scsibussubmatch, (struct device *)sb,
&sa)) == 0) {
- scsibusprint(&sa, sb->sc_dev.dv_xname);
+ scsibussubprint(&sa, sb->sc_dev.dv_xname);
printf(" not configured\n");
goto free_devid;
}
@@ -789,7 +734,7 @@ scsi_probe_link(struct scsibus_softc *sb, int target, int lun, int dumbscan)
scsi_autoconf | SCSI_IGNORE_ILLEGAL_REQUEST |
SCSI_IGNORE_NOT_READY | SCSI_IGNORE_MEDIA_CHANGE);
- config_attach((struct device *)sb, cf, &sa, scsibusprint);
+ config_attach((struct device *)sb, cf, &sa, scsibussubprint);
return 0;
@@ -933,6 +878,61 @@ scsi_remove_link(struct scsi_link *link)
}
void
+scsi_get_target_luns(struct scsi_link *link0, struct scsi_lun_array *lunarray)
+{
+ struct scsi_report_luns_data *report;
+ int i, nluns, rv = 0;
+
+ /* Initialize dumbscan result. Just in case. */
+ report = NULL;
+ for (i = 0; i < link0->bus->sb_luns; i++)
+ lunarray->luns[i] = i;
+ lunarray->count = link0->bus->sb_luns;
+ lunarray->dumbscan = 1;
+
+ /*
+ * ATAPI, USB and pre-SPC (i.e. pre-SCSI-3) devices can't ask
+ * for a report of valid LUNs.
+ */
+ if ((link0->flags & (SDEV_UMASS | SDEV_ATAPI)) != 0 ||
+ SID_ANSII_REV(&link0->inqdata) < SCSI_REV_SPC)
+ goto dumbscan;
+
+ report = dma_alloc(sizeof(*report), PR_WAITOK);
+ if (report == NULL)
+ goto dumbscan;
+
+ rv = scsi_report_luns(link0, REPORT_NORMAL, report,
+ sizeof(*report), scsi_autoconf | SCSI_SILENT |
+ SCSI_IGNORE_ILLEGAL_REQUEST | SCSI_IGNORE_NOT_READY |
+ SCSI_IGNORE_MEDIA_CHANGE, 10000);
+ if (rv != 0)
+ goto dumbscan;
+
+ /*
+ * XXX In theory we should check if data is full, which
+ * would indicate it needs to be enlarged and REPORT
+ * LUNS tried again. Solaris tries up to 3 times with
+ * larger sizes for data.
+ */
+
+ /* Return the reported Type-0 LUNs. Type-0 only! */
+ lunarray->count = 0;
+ lunarray->dumbscan = 0;
+ nluns = _4btol(report->length) / RPL_LUNDATA_SIZE;
+ for (i = 0; i < nluns; i++) {
+ if (report->luns[i].lundata[0] != 0)
+ continue;
+ lunarray->luns[lunarray->count++] =
+ report->luns[i].lundata[RPL_LUNDATA_T0LUN];
+ }
+
+dumbscan:
+ if (report != NULL)
+ dma_free(report, sizeof(*report));
+}
+
+void
scsi_strvis(u_char *dst, u_char *src, int len)
{
u_char last;