Module Name:    src
Committed By:   bouyer
Date:           Tue Jul 31 15:59:57 UTC 2012

Modified Files:
        src/sys/dev/scsipi: atapi_wdc.c

Log Message:
Move a check for the drive type to the right place. This bug would cause
ATA drives to not be detected when the PATA (or emulated PATA) bus is shared
with an ATAPI device.
Should fix the problem reported by various peoples.
Thanks to Onno van der Linden and [email protected] for pointing out the
code in error.


To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/sys/dev/scsipi/atapi_wdc.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/atapi_wdc.c
diff -u src/sys/dev/scsipi/atapi_wdc.c:1.118 src/sys/dev/scsipi/atapi_wdc.c:1.119
--- src/sys/dev/scsipi/atapi_wdc.c:1.118	Tue Jul 31 15:50:37 2012
+++ src/sys/dev/scsipi/atapi_wdc.c	Tue Jul 31 15:59:57 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: atapi_wdc.c,v 1.118 2012/07/31 15:50:37 bouyer Exp $	*/
+/*	$NetBSD: atapi_wdc.c,v 1.119 2012/07/31 15:59:57 bouyer Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001 Manuel Bouyer.
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.118 2012/07/31 15:50:37 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: atapi_wdc.c,v 1.119 2012/07/31 15:59:57 bouyer Exp $");
 
 #ifndef ATADEBUG
 #define ATADEBUG
@@ -198,13 +198,6 @@ wdc_atapi_get_params(struct scsipi_chann
 	struct ata_channel *chp = atac->atac_channels[chan->chan_channel];
 	struct ata_command ata_c;
 
-	/* if no ATAPI device detected at wdc attach time, skip */
-	if (chp->ch_drive[drive].drive_type != ATA_DRIVET_ATAPI) {
-		ATADEBUG_PRINT(("wdc_atapi_get_params: drive %d not present\n",
-		    drive), DEBUG_PROBE);
-		return -1;
-	}
-
 	memset(&ata_c, 0, sizeof(struct ata_command));
 	ata_c.r_command = ATAPI_SOFT_RESET;
 	ata_c.r_st_bmask = 0;
@@ -259,6 +252,13 @@ wdc_atapi_probe_device(struct atapibus_s
 	if (scsipi_lookup_periph(chan, target, 0) != NULL)
 		return;
 
+	/* if no ATAPI device detected at wdc attach time, skip */
+	if (drvp->drive_type != ATA_DRIVET_ATAPI) {
+		ATADEBUG_PRINT(("wdc_atapi_probe_device: "
+		    "drive %d not present\n", target), DEBUG_PROBE);
+		return;
+	}
+
 	if (wdc_atapi_get_params(chan, target, id) == 0) {
 #ifdef ATAPI_DEBUG_PROBE
 		printf("%s drive %d: cmdsz 0x%x drqtype 0x%x\n",

Reply via email to