Module Name:    src
Committed By:   bouyer
Date:           Thu Apr 19 17:45:21 UTC 2012

Modified Files:
        src/sys/dev/scsipi: atapiconf.c cd.c scsiconf.c scsiconf.h
            scsipi_base.c scsipi_ioctl.c scsipiconf.h sd.c st.c st_atapi.c
            st_scsi.c
        src/sys/dev/usb: umass_scsipi.c

Log Message:
Expand struct scsipi_bustype {} in a ABI-backward-compatible way to
pass more informations about the bus:
- bustype_type has 2 different bytes, one holding the existing
  SCSIPI_BUSTYPE_* (scsi, atapi, ata), and one for a per-SCSIPI_BUSTYPE_*
  subtype. Introduce macros to build or extract bustype_type.
- for SCSIPI_BUSTYPE_SCSI, define subtypes for parallel SCSI, Fibre Channel,
  SAS and USB, to specify the transport method. SCSIPI_BUSTYPE_SCSI_PSCSI
  is 0 so that bustype_type value doesn't change for existing code
- for non-SCSIPI_BUSTYPE_SCSI busses there's no defined subtype yet,
  so the bustype_type value doesn't change.
- provide scsi_fc_bustype, scsi_sas_bustype and scsi_usb_bustype
  along with scsi_bustype to be used by bus driver where appropriate
- scsipi_print_xfer_mode(): more existing code under a
  (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI) case, as
  sync/wide parameters only make sense for parallel SCSI.
  For (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC) and
  (SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS), only print
  tagged queing status if enabled. Just be silent for other
  bustypes.

This change is prompted by this problem:
right now, FC (e.g. isp(4)) and SAS (e.g. mfi(4)) don't
  do anything for ADAPTER_REQ_SET_XFER_MODE, and especially never
  call scsipi_async_event(ASYNC_EVENT_XFER_MODE), so sd(4) always
  runs untagged. Doing a scsipi_async_event(ASYNC_EVENT_XFER_MODE) with
  appropriate parameters is enough to enable tagged queuing,
  but then scsipi will print:
  sd0: async, 8-bit transfers, tagged queueing
  which is harmless (async, 8-bit transfers doens't make sense on SAS anyway)
  but will confuse users. With this change scsipi will only print:
  sd0: tagged queueing
  which is correct.

In the long run, knowning the underlying transport in scsipi will
allow better handling of device which are not parallel SCSI.

Another change adding an extra callback to struct scsipi_bustype {}
will come (so that scsipi_print_xfer_mode(), which is SCSI-specific,
can be moved out of scsipi_base, and split into per-subtype callback),
but this will break kernel ABI and so is not suitable for
netbsd-6, so will be commmited later. The above is enough to get
tagged queuing on FC and SAS in netbsd-6.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/dev/scsipi/atapiconf.c
cvs rdiff -u -r1.306 -r1.307 src/sys/dev/scsipi/cd.c
cvs rdiff -u -r1.265 -r1.266 src/sys/dev/scsipi/scsiconf.c
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/scsipi/scsiconf.h
cvs rdiff -u -r1.157 -r1.158 src/sys/dev/scsipi/scsipi_base.c
cvs rdiff -u -r1.66 -r1.67 src/sys/dev/scsipi/scsipi_ioctl.c
cvs rdiff -u -r1.119 -r1.120 src/sys/dev/scsipi/scsipiconf.h
cvs rdiff -u -r1.297 -r1.298 src/sys/dev/scsipi/sd.c
cvs rdiff -u -r1.220 -r1.221 src/sys/dev/scsipi/st.c
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/scsipi/st_atapi.c
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/scsipi/st_scsi.c
cvs rdiff -u -r1.43 -r1.44 src/sys/dev/usb/umass_scsipi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/scsipi/atapiconf.c
diff -u src/sys/dev/scsipi/atapiconf.c:1.84 src/sys/dev/scsipi/atapiconf.c:1.85
--- src/sys/dev/scsipi/atapiconf.c:1.84	Fri Apr  6 17:12:45 2012
+++ src/sys/dev/scsipi/atapiconf.c	Thu Apr 19 17:45:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: atapiconf.c,v 1.84 2012/04/06 17:12:45 chs Exp $	*/
+/*	$NetBSD: atapiconf.c,v 1.85 2012/04/19 17:45:20 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1996, 2001 Manuel Bouyer.  All rights reserved.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.84 2012/04/06 17:12:45 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atapiconf.c,v 1.85 2012/04/19 17:45:20 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -117,7 +117,8 @@ atapibusmatch(device_t parent, cfdata_t 
 	if (chan == NULL)
 		return (0);
 
-	if (chan->chan_bustype->bustype_type != SCSIPI_BUSTYPE_ATAPI)
+	if (SCSIPI_BUSTYPE_TYPE(chan->chan_bustype->bustype_type) !=
+	    SCSIPI_BUSTYPE_ATAPI)
 		return (0);
 
 	return (1);

Index: src/sys/dev/scsipi/cd.c
diff -u src/sys/dev/scsipi/cd.c:1.306 src/sys/dev/scsipi/cd.c:1.307
--- src/sys/dev/scsipi/cd.c:1.306	Sat Feb 25 10:17:14 2012
+++ src/sys/dev/scsipi/cd.c	Thu Apr 19 17:45:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: cd.c,v 1.306 2012/02/25 10:17:14 shattered Exp $	*/
+/*	$NetBSD: cd.c,v 1.307 2012/04/19 17:45:20 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001, 2003, 2004, 2005, 2008 The NetBSD Foundation,
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.306 2012/02/25 10:17:14 shattered Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cd.c,v 1.307 2012/04/19 17:45:20 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -251,8 +251,8 @@ cdattach(device_t parent, device_t self,
 
 	mutex_init(&cd->sc_lock, MUTEX_DEFAULT, IPL_NONE);
 
-	if (scsipi_periph_bustype(sa->sa_periph) == SCSIPI_BUSTYPE_SCSI &&
-	    periph->periph_version == 0)
+	if (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(sa->sa_periph)) ==
+	    SCSIPI_BUSTYPE_SCSI && periph->periph_version == 0)
 		cd->flags |= CDF_ANCIENT;
 
 	bufq_alloc(&cd->buf_queue, "disksort", BUFQ_SORT_RAWBLOCK);
@@ -1682,7 +1682,7 @@ cdgetdefaultlabel(struct cd_softc *cd, s
 	lp->d_ncylinders = (cd->params.disksize / 100) + 1;
 	lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
 
-	switch (scsipi_periph_bustype(cd->sc_periph)) {
+	switch (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(cd->sc_periph))) {
 	case SCSIPI_BUSTYPE_SCSI:
 		lp->d_type = DTYPE_SCSI;
 		break;

Index: src/sys/dev/scsipi/scsiconf.c
diff -u src/sys/dev/scsipi/scsiconf.c:1.265 src/sys/dev/scsipi/scsiconf.c:1.266
--- src/sys/dev/scsipi/scsiconf.c:1.265	Fri Apr  6 22:50:39 2012
+++ src/sys/dev/scsipi/scsiconf.c	Thu Apr 19 17:45:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsiconf.c,v 1.265 2012/04/06 22:50:39 christos Exp $	*/
+/*	$NetBSD: scsiconf.c,v 1.266 2012/04/19 17:45:20 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.265 2012/04/06 22:50:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsiconf.c,v 1.266 2012/04/19 17:45:20 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -114,7 +114,31 @@ static int	scsibusprint(void *, const ch
 static void	scsibus_config(struct scsipi_channel *, void *);
 
 const struct scsipi_bustype scsi_bustype = {
-	SCSIPI_BUSTYPE_SCSI,
+	SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI),
+	scsi_scsipi_cmd,
+	scsipi_interpret_sense,
+	scsi_print_addr,
+	scsi_kill_pending,
+};
+
+const struct scsipi_bustype scsi_fc_bustype = {
+	SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC),
+	scsi_scsipi_cmd,
+	scsipi_interpret_sense,
+	scsi_print_addr,
+	scsi_kill_pending,
+};
+
+const struct scsipi_bustype scsi_sas_bustype = {
+	SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS),
+	scsi_scsipi_cmd,
+	scsipi_interpret_sense,
+	scsi_print_addr,
+	scsi_kill_pending,
+};
+
+const struct scsipi_bustype scsi_usb_bustype = {
+	SCSIPI_BUSTYPE_BUSTYPE(SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_USB),
 	scsi_scsipi_cmd,
 	scsipi_interpret_sense,
 	scsi_print_addr,
@@ -153,7 +177,8 @@ scsibusmatch(device_t parent, cfdata_t c
 {
 	struct scsipi_channel *chan = aux;
 
-	if (chan->chan_bustype->bustype_type != SCSIPI_BUSTYPE_SCSI)
+	if (SCSIPI_BUSTYPE_TYPE(chan->chan_bustype->bustype_type) !=
+	    SCSIPI_BUSTYPE_SCSI)
 		return 0;
 
 	if (cf->cf_loc[SCSICF_CHANNEL] != chan->chan_channel &&

Index: src/sys/dev/scsipi/scsiconf.h
diff -u src/sys/dev/scsipi/scsiconf.h:1.56 src/sys/dev/scsipi/scsiconf.h:1.57
--- src/sys/dev/scsipi/scsiconf.h:1.56	Wed Jul 16 18:50:58 2008
+++ src/sys/dev/scsipi/scsiconf.h	Thu Apr 19 17:45:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsiconf.h,v 1.56 2008/07/16 18:50:58 drochner Exp $	*/
+/*	$NetBSD: scsiconf.h,v 1.57 2012/04/19 17:45:20 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2004 The NetBSD Foundation, Inc.
@@ -64,6 +64,9 @@ struct scsibus_softc {
 #define	SCSIBUSF_OPEN	0x00000001	/* bus is open */
 
 extern const struct scsipi_bustype scsi_bustype;
+extern const struct scsipi_bustype scsi_fc_bustype;
+extern const struct scsipi_bustype scsi_sas_bustype;
+extern const struct scsipi_bustype scsi_usb_bustype;
 
 int	scsi_change_def(struct scsipi_periph *, int);
 void	scsi_kill_pending(struct scsipi_periph *);

Index: src/sys/dev/scsipi/scsipi_base.c
diff -u src/sys/dev/scsipi/scsipi_base.c:1.157 src/sys/dev/scsipi/scsipi_base.c:1.158
--- src/sys/dev/scsipi/scsipi_base.c:1.157	Wed Apr 18 20:37:49 2012
+++ src/sys/dev/scsipi/scsipi_base.c	Thu Apr 19 17:45:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsipi_base.c,v 1.157 2012/04/18 20:37:49 bouyer Exp $	*/
+/*	$NetBSD: scsipi_base.c,v 1.158 2012/04/19 17:45:20 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2002, 2003, 2004 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.157 2012/04/18 20:37:49 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsipi_base.c,v 1.158 2012/04/19 17:45:20 bouyer Exp $");
 
 #include "opt_scsi.h"
 
@@ -2181,42 +2181,63 @@ scsipi_print_xfer_mode(struct scsipi_per
 	if ((periph->periph_flags & PERIPH_MODE_VALID) == 0)
 		return;
 
-	aprint_normal_dev(periph->periph_dev, "");
-	if (periph->periph_mode & (PERIPH_CAP_SYNC | PERIPH_CAP_DT)) {
-		period = scsipi_sync_factor_to_period(periph->periph_period);
-		aprint_normal("sync (%d.%02dns offset %d)",
-		    period / 100, period % 100, periph->periph_offset);
-	} else
-		aprint_normal("async");
-
-	if (periph->periph_mode & PERIPH_CAP_WIDE32)
-		aprint_normal(", 32-bit");
-	else if (periph->periph_mode & (PERIPH_CAP_WIDE16 | PERIPH_CAP_DT))
-		aprint_normal(", 16-bit");
-	else
-		aprint_normal(", 8-bit");
+	switch(scsipi_periph_bustype(periph)) {
+	case SCSIPI_BUSTYPE_BUSTYPE(
+	    SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_PSCSI):
+		aprint_normal_dev(periph->periph_dev, "");
+		if (periph->periph_mode & (PERIPH_CAP_SYNC | PERIPH_CAP_DT)) {
+			period =
+			    scsipi_sync_factor_to_period(periph->periph_period);
+			aprint_normal("sync (%d.%02dns offset %d)",
+			    period / 100, period % 100, periph->periph_offset);
+		} else
+			aprint_normal("async");
 
-	if (periph->periph_mode & (PERIPH_CAP_SYNC | PERIPH_CAP_DT)) {
-		freq = scsipi_sync_factor_to_freq(periph->periph_period);
-		speed = freq;
 		if (periph->periph_mode & PERIPH_CAP_WIDE32)
-			speed *= 4;
-		else if (periph->periph_mode &
-		    (PERIPH_CAP_WIDE16 | PERIPH_CAP_DT))
-			speed *= 2;
-		mbs = speed / 1000;
-		if (mbs > 0)
-			aprint_normal(" (%d.%03dMB/s)", mbs, speed % 1000);
+			aprint_normal(", 32-bit");
+		else if (
+		    periph->periph_mode & (PERIPH_CAP_WIDE16 | PERIPH_CAP_DT))
+			aprint_normal(", 16-bit");
 		else
-			aprint_normal(" (%dKB/s)", speed % 1000);
-	}
+			aprint_normal(", 8-bit");
+
+		if (periph->periph_mode & (PERIPH_CAP_SYNC | PERIPH_CAP_DT)) {
+			freq =
+			    scsipi_sync_factor_to_freq(periph->periph_period);
+			speed = freq;
+			if (periph->periph_mode & PERIPH_CAP_WIDE32)
+				speed *= 4;
+			else if (periph->periph_mode &
+			    (PERIPH_CAP_WIDE16 | PERIPH_CAP_DT))
+				speed *= 2;
+			mbs = speed / 1000;
+			if (mbs > 0) {
+				aprint_normal(" (%d.%03dMB/s)", mbs,
+				    speed % 1000);
+			} else
+				aprint_normal(" (%dKB/s)", speed % 1000);
+		}
 
-	aprint_normal(" transfers");
+		aprint_normal(" transfers");
 
-	if (periph->periph_mode & PERIPH_CAP_TQING)
-		aprint_normal(", tagged queueing");
+		if (periph->periph_mode & PERIPH_CAP_TQING)
+			aprint_normal(", tagged queueing");
 
-	aprint_normal("\n");
+		aprint_normal("\n");
+		break;
+	case SCSIPI_BUSTYPE_BUSTYPE(
+	    SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_FC):
+	case SCSIPI_BUSTYPE_BUSTYPE(
+	    SCSIPI_BUSTYPE_SCSI, SCSIPI_BUSTYPE_SCSI_SAS):
+		if (periph->periph_mode & PERIPH_CAP_TQING) {
+			aprint_normal_dev(periph->periph_dev,
+			    "tagged queueing\n");
+		}
+		break;
+	default:
+		/* nothing */
+		break;
+	}
 }
 
 /*

Index: src/sys/dev/scsipi/scsipi_ioctl.c
diff -u src/sys/dev/scsipi/scsipi_ioctl.c:1.66 src/sys/dev/scsipi/scsipi_ioctl.c:1.67
--- src/sys/dev/scsipi/scsipi_ioctl.c:1.66	Mon Jul 14 12:36:44 2008
+++ src/sys/dev/scsipi/scsipi_ioctl.c	Thu Apr 19 17:45:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsipi_ioctl.c,v 1.66 2008/07/14 12:36:44 drochner Exp $	*/
+/*	$NetBSD: scsipi_ioctl.c,v 1.67 2012/04/19 17:45:20 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scsipi_ioctl.c,v 1.66 2008/07/14 12:36:44 drochner Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scsipi_ioctl.c,v 1.67 2012/04/19 17:45:20 bouyer Exp $");
 
 #include "opt_compat_freebsd.h"
 #include "opt_compat_netbsd.h"
@@ -379,7 +379,7 @@ scsipi_do_ioctl(struct scsipi_periph *pe
 	case SCIOCIDENTIFY: {
 		struct scsi_addr *sca = (struct scsi_addr *)addr;
 
-		switch (scsipi_periph_bustype(periph)) {
+		switch (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(periph))) {
 		case SCSIPI_BUSTYPE_SCSI:
 			sca->type = TYPE_SCSI;
 			sca->addr.scsi.scbus =
@@ -401,7 +401,7 @@ scsipi_do_ioctl(struct scsipi_periph *pe
 	case OSCIOCIDENTIFY: {
 		struct oscsi_addr *sca = (struct oscsi_addr *)addr;
 
-		switch (scsipi_periph_bustype(periph)) {
+		switch (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(periph))) {
 		case SCSIPI_BUSTYPE_SCSI:
 			sca->scbus =
 			    device_unit(device_parent(periph->periph_dev));

Index: src/sys/dev/scsipi/scsipiconf.h
diff -u src/sys/dev/scsipi/scsipiconf.h:1.119 src/sys/dev/scsipi/scsipiconf.h:1.120
--- src/sys/dev/scsipi/scsipiconf.h:1.119	Fri Apr  6 22:50:39 2012
+++ src/sys/dev/scsipi/scsipiconf.h	Thu Apr 19 17:45:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: scsipiconf.h,v 1.119 2012/04/06 22:50:39 christos Exp $	*/
+/*	$NetBSD: scsipiconf.h,v 1.120 2012/04/19 17:45:20 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2004 The NetBSD Foundation, Inc.
@@ -239,10 +239,25 @@ struct scsipi_bustype {
 };
 
 /* bustype_type */
-#define	SCSIPI_BUSTYPE_SCSI	0
+/* type is stored in the first byte */
+#define SCSIPI_BUSTYPE_TYPE_SHIFT 0
+#define SCSIPI_BUSTYPE_TYPE(x) (((x) >> SCSIPI_BUSTYPE_TYPE_SHIFT) & 0xff)
+#define	SCSIPI_BUSTYPE_SCSI	0 /* parallel SCSI */
 #define	SCSIPI_BUSTYPE_ATAPI	1
 /* #define SCSIPI_BUSTYPE_ATA	2 */
-
+/* subtype is stored in the second byte */
+#define SCSIPI_BUSTYPE_SUBTYPE_SHIFT 8
+#define SCSIPI_BUSTYPE_SUBTYPE(x) (((x) >> SCSIPI_BUSTYPE_SUBTYPE_SHIFT) & 0xff)
+
+#define SCSIPI_BUSTYPE_BUSTYPE(t, s) \
+    ((t) << SCSIPI_BUSTYPE_TYPE_SHIFT | (s) << SCSIPI_BUSTYPE_SUBTYPE_SHIFT)
+/* subtypes are defined in each bus type headers */
+/* XXX this should be in scsiconf.h but is used in scsipi_base.c */
+/* SCSI subtypes */
+#define SCSIPI_BUSTYPE_SCSI_PSCSI       0 /* parallel SCSI */
+#define SCSIPI_BUSTYPE_SCSI_FC          1 /* Fiber channel */
+#define SCSIPI_BUSTYPE_SCSI_SAS         2 /* SAS */
+#define SCSIPI_BUSTYPE_SCSI_USB         3 /* USB */
 
 /*
  * scsipi_channel:

Index: src/sys/dev/scsipi/sd.c
diff -u src/sys/dev/scsipi/sd.c:1.297 src/sys/dev/scsipi/sd.c:1.298
--- src/sys/dev/scsipi/sd.c:1.297	Fri Apr  6 22:50:39 2012
+++ src/sys/dev/scsipi/sd.c	Thu Apr 19 17:45:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: sd.c,v 1.297 2012/04/06 22:50:39 christos Exp $	*/
+/*	$NetBSD: sd.c,v 1.298 2012/04/19 17:45:20 bouyer Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2003, 2004 The NetBSD Foundation, Inc.
@@ -47,7 +47,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.297 2012/04/06 22:50:39 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sd.c,v 1.298 2012/04/19 17:45:20 bouyer Exp $");
 
 #include "opt_scsi.h"
 
@@ -227,8 +227,8 @@ sdattach(device_t parent, device_t self,
 	if (sd->type == T_SIMPLE_DIRECT)
 		periph->periph_quirks |= PQUIRK_ONLYBIG | PQUIRK_NOBIGMODESENSE;
 
-	if (scsipi_periph_bustype(sa->sa_periph) == SCSIPI_BUSTYPE_SCSI &&
-	    periph->periph_version == 0)
+	if (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(sa->sa_periph)) ==
+	    SCSIPI_BUSTYPE_SCSI && periph->periph_version == 0)
 		sd->flags |= SDF_ANCIENT;
 
 	bufq_alloc(&sd->buf_queue, BUFQ_DISK_DEFAULT_STRAT, BUFQ_SORT_RAWBLOCK);
@@ -1304,7 +1304,7 @@ sdgetdefaultlabel(struct sd_softc *sd, s
 	lp->d_ncylinders = sd->params.cyls;
 	lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
 
-	switch (scsipi_periph_bustype(sd->sc_periph)) {
+	switch (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(sd->sc_periph))) {
 	case SCSIPI_BUSTYPE_SCSI:
 		lp->d_type = DTYPE_SCSI;
 		break;

Index: src/sys/dev/scsipi/st.c
diff -u src/sys/dev/scsipi/st.c:1.220 src/sys/dev/scsipi/st.c:1.221
--- src/sys/dev/scsipi/st.c:1.220	Tue Feb 28 10:58:10 2012
+++ src/sys/dev/scsipi/st.c	Thu Apr 19 17:45:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: st.c,v 1.220 2012/02/28 10:58:10 mbalmer Exp $ */
+/*	$NetBSD: st.c,v 1.221 2012/04/19 17:45:20 bouyer Exp $ */
 
 /*-
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.220 2012/02/28 10:58:10 mbalmer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: st.c,v 1.221 2012/04/19 17:45:20 bouyer Exp $");
 
 #include "opt_scsi.h"
 
@@ -1735,7 +1735,8 @@ st_write_filemarks(struct st_softc *st, 
 
 	memset(&cmd, 0, sizeof(cmd));
 	cmd.opcode = WRITE_FILEMARKS;
-	if (scsipi_periph_bustype(st->sc_periph) == SCSIPI_BUSTYPE_ATAPI)
+	if (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(st->sc_periph)) ==
+	    SCSIPI_BUSTYPE_ATAPI)
 		cmd.byte2 = SR_IMMED;
 	/*
 	 * The ATAPI Onstream DI-30 doesn't support writing filemarks, but
@@ -1811,7 +1812,8 @@ st_load(struct st_softc *st, u_int type,
 
 	memset(&cmd, 0, sizeof(cmd));
 	cmd.opcode = LOAD;
-	if (scsipi_periph_bustype(st->sc_periph) == SCSIPI_BUSTYPE_ATAPI)
+	if (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(st->sc_periph)) ==
+	    SCSIPI_BUSTYPE_ATAPI)
 		cmd.byte2 = SR_IMMED;
 	cmd.how = type;
 

Index: src/sys/dev/scsipi/st_atapi.c
diff -u src/sys/dev/scsipi/st_atapi.c:1.28 src/sys/dev/scsipi/st_atapi.c:1.29
--- src/sys/dev/scsipi/st_atapi.c:1.28	Tue Feb 28 10:58:11 2012
+++ src/sys/dev/scsipi/st_atapi.c	Thu Apr 19 17:45:21 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: st_atapi.c,v 1.28 2012/02/28 10:58:11 mbalmer Exp $ */
+/*	$NetBSD: st_atapi.c,v 1.29 2012/04/19 17:45:21 bouyer Exp $ */
 
 /*
  * Copyright (c) 2001 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: st_atapi.c,v 1.28 2012/02/28 10:58:11 mbalmer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: st_atapi.c,v 1.29 2012/04/19 17:45:21 bouyer Exp $");
 
 #include "opt_scsi.h"
 
@@ -65,7 +65,8 @@ st_atapibus_match(device_t parent, cfdat
 	struct scsipibus_attach_args *sa = aux;
 	int priority;
 
-	if (scsipi_periph_bustype(sa->sa_periph) != SCSIPI_BUSTYPE_ATAPI)
+	if (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(sa->sa_periph)) !=
+	    SCSIPI_BUSTYPE_ATAPI)
 		return 0;
 
 	(void)scsipi_inqmatch(&sa->sa_inqbuf,

Index: src/sys/dev/scsipi/st_scsi.c
diff -u src/sys/dev/scsipi/st_scsi.c:1.34 src/sys/dev/scsipi/st_scsi.c:1.35
--- src/sys/dev/scsipi/st_scsi.c:1.34	Tue Feb 28 10:58:11 2012
+++ src/sys/dev/scsipi/st_scsi.c	Thu Apr 19 17:45:21 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: st_scsi.c,v 1.34 2012/02/28 10:58:11 mbalmer Exp $ */
+/*	$NetBSD: st_scsi.c,v 1.35 2012/04/19 17:45:21 bouyer Exp $ */
 
 /*-
  * Copyright (c) 1998, 2004 The NetBSD Foundation, Inc.
@@ -50,7 +50,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: st_scsi.c,v 1.34 2012/02/28 10:58:11 mbalmer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: st_scsi.c,v 1.35 2012/04/19 17:45:21 bouyer Exp $");
 
 #include "opt_scsi.h"
 
@@ -93,7 +93,8 @@ st_scsibus_match(device_t parent, cfdata
 	struct scsipibus_attach_args *sa = aux;
 	int priority;
 
-	if (scsipi_periph_bustype(sa->sa_periph) != SCSIPI_BUSTYPE_SCSI)
+	if (SCSIPI_BUSTYPE_TYPE(scsipi_periph_bustype(sa->sa_periph)) !=
+	    SCSIPI_BUSTYPE_SCSI)
 		return 0;
 
 	(void)scsipi_inqmatch(&sa->sa_inqbuf,

Index: src/sys/dev/usb/umass_scsipi.c
diff -u src/sys/dev/usb/umass_scsipi.c:1.43 src/sys/dev/usb/umass_scsipi.c:1.44
--- src/sys/dev/usb/umass_scsipi.c:1.43	Sun Mar 11 01:06:07 2012
+++ src/sys/dev/usb/umass_scsipi.c	Thu Apr 19 17:45:21 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: umass_scsipi.c,v 1.43 2012/03/11 01:06:07 mrg Exp $	*/
+/*	$NetBSD: umass_scsipi.c,v 1.44 2012/04/19 17:45:21 bouyer Exp $	*/
 
 /*
  * Copyright (c) 2001, 2003, 2012 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.43 2012/03/11 01:06:07 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_scsipi.c,v 1.44 2012/04/19 17:45:21 bouyer Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_umass.h"
@@ -245,7 +245,8 @@ umass_scsipi_request(struct scsipi_chann
 		}
 
 #ifdef UMASS_DEBUG
-		if (chan->chan_bustype->bustype_type == SCSIPI_BUSTYPE_ATAPI ?
+		if (SCSIPI_BUSTYPE_TYPE(chan->chan_bustype->bustype_type) ==
+		    SCSIPI_BUSTYPE_ATAPI ?
 		    periph->periph_target != UMASS_ATAPI_DRIVE :
 		    periph->periph_target == chan->chan_id) {
 			DPRINTF(UDMASS_SCSI, ("%s: wrong SCSI ID %d\n",

Reply via email to