summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2020-10-14 23:40:34 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2020-10-14 23:40:34 +0000
commit6848f0c6a4e8fc67fadae63fce5f7d919080fddc (patch)
tree95a870fe4d94aae60f6afe7fb07257786fde669c /sys
parent40f4e95e0a4ab830c1f27d59d9c5e76233cd2b7d (diff)
Introduce scsi_copy_internal_data() to copy 'faked' data from a driver to a
scsi_xfer. Will replace various equivalent functions/hand-rolled chunks, none of which were setting xs->resid.
Diffstat (limited to 'sys')
-rw-r--r--sys/scsi/scsi_base.c22
-rw-r--r--sys/scsi/scsiconf.h3
2 files changed, 23 insertions, 2 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c
index 645790e961a..dcd9f0e5544 100644
--- a/sys/scsi/scsi_base.c
+++ b/sys/scsi/scsi_base.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsi_base.c,v 1.276 2020/09/22 19:32:53 krw Exp $ */
+/* $OpenBSD: scsi_base.c,v 1.277 2020/10/14 23:40:33 krw Exp $ */
/* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */
/*
@@ -1445,6 +1445,26 @@ scsi_xs_exec(struct scsi_xfer *xs)
}
/*
+ * Used by device drivers that fake various scsi commands.
+ */
+void
+scsi_copy_internal_data(struct scsi_xfer *xs, void *data, size_t datalen)
+{
+ size_t copy_cnt;
+
+ SC_DEBUG(xs->sc_link, SDEV_DB3, ("scsi_copy_internal_data\n"));
+
+ if (xs->datalen == 0) {
+ sc_print_addr(xs->sc_link);
+ printf("uio internal data copy not supported\n");
+ } else {
+ copy_cnt = MIN(datalen, xs->datalen);
+ memcpy(xs->data, data, copy_cnt);
+ xs->resid = xs->datalen - copy_cnt;
+ }
+}
+
+/*
* This routine is called by the adapter when its xs handling is done.
*/
void
diff --git a/sys/scsi/scsiconf.h b/sys/scsi/scsiconf.h
index 9c7488531f1..69f2b71af7d 100644
--- a/sys/scsi/scsiconf.h
+++ b/sys/scsi/scsiconf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: scsiconf.h,v 1.199 2020/09/22 19:32:53 krw Exp $ */
+/* $OpenBSD: scsiconf.h,v 1.200 2020/10/14 23:40:33 krw Exp $ */
/* $NetBSD: scsiconf.h,v 1.35 1997/04/02 02:29:38 mycroft Exp $ */
/*
@@ -486,6 +486,7 @@ int scsi_mode_select(struct scsi_link *, int, struct scsi_mode_header *,
int, int);
int scsi_mode_select_big(struct scsi_link *, int,
struct scsi_mode_header_big *, int, int);
+void scsi_copy_internal_data(struct scsi_xfer *, void *, size_t);
void scsi_done(struct scsi_xfer *);
int scsi_do_ioctl(struct scsi_link *, u_long, caddr_t, int);
void sc_print_addr(struct scsi_link *);