Module Name:    src
Committed By:   christos
Date:           Sun Oct  8 13:35:04 UTC 2017

Modified Files:
        src/sys/dev/ata: ata_wdc.c

Log Message:
Re-use the err label more so it is not unused for drivers that don't support
dma.


To generate a diff of this commit:
cvs rdiff -u -r1.106 -r1.107 src/sys/dev/ata/ata_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/ata/ata_wdc.c
diff -u src/sys/dev/ata/ata_wdc.c:1.106 src/sys/dev/ata/ata_wdc.c:1.107
--- src/sys/dev/ata/ata_wdc.c:1.106	Sat Oct  7 12:05:32 2017
+++ src/sys/dev/ata/ata_wdc.c	Sun Oct  8 09:35:03 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ata_wdc.c,v 1.106 2017/10/07 16:05:32 jdolecek Exp $	*/
+/*	$NetBSD: ata_wdc.c,v 1.107 2017/10/08 13:35:03 christos Exp $	*/
 
 /*
  * Copyright (c) 1998, 2001, 2003 Manuel Bouyer.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.106 2017/10/07 16:05:32 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ata_wdc.c,v 1.107 2017/10/08 13:35:03 christos Exp $");
 
 #include "opt_ata.h"
 #include "opt_wdc.h"
@@ -647,9 +647,7 @@ wdc_ata_bio_intr(struct ata_channel *chp
 	 */
 	if ((xfer->c_flags & (C_TIMEOU | C_DMA)) == C_TIMEOU) {
 		ata_bio->error = TIMEOUT;
-		ata_channel_unlock(chp);
-		wdc_ata_bio_done(chp, xfer);
-		return 1;
+		goto err;
 	}
 
 #if NATA_PIOBM
@@ -667,12 +665,10 @@ wdc_ata_bio_intr(struct ata_channel *chp
 			return 0; /* IRQ was not for us */
 		}
 		printf("%s:%d:%d: device timeout, c_bcount=%d, c_skip%d\n",
-		    device_xname(atac->atac_dev), chp->ch_channel, xfer->c_drive,
-		    xfer->c_bcount, xfer->c_skip);
+		    device_xname(atac->atac_dev), chp->ch_channel,
+		    xfer->c_drive, xfer->c_bcount, xfer->c_skip);
 		ata_bio->error = TIMEOUT;
-		ata_channel_unlock(chp);
-		wdc_ata_bio_done(chp, xfer);
-		return 1;
+		goto err;
 	}
 	if (wdc->irqack)
 		wdc->irqack(chp);
@@ -720,19 +716,17 @@ wdc_ata_bio_intr(struct ata_channel *chp
 			goto end;
 		if (ata_bio->r_error & WDCE_CRC || ata_bio->error == ERR_DMA) {
 			ata_channel_unlock(chp);
-			ata_dmaerr(drvp, (xfer->c_flags & C_POLL) ? AT_POLL : 0);
+			ata_dmaerr(drvp,
+			    (xfer->c_flags & C_POLL) ? AT_POLL : 0);
+			ata_channel_lock(chp);
 			goto err;
 		}
 	}
 #endif	/* NATA_DMA */
 
 	/* if we had an error, end */
-	if (drv_err == WDC_ATA_ERR) {
-		ata_channel_unlock(chp);
-err:
-		wdc_ata_bio_done(chp, xfer);
-		return 1;
-	}
+	if (drv_err == WDC_ATA_ERR)
+		goto err;
 
 	/* If this was a read and not using DMA, fetch the data. */
 	if ((ata_bio->flags & ATA_READ) != 0) {
@@ -741,9 +735,7 @@ err:
 			    device_xname(atac->atac_dev), chp->ch_channel,
 			    xfer->c_drive);
 			ata_bio->error = TIMEOUT;
-			ata_channel_unlock(chp);
-			wdc_ata_bio_done(chp, xfer);
-			return 1;
+			goto err;
 		}
 #if NATA_PIOBM
 		if (xfer->c_flags & C_PIOBM) {
@@ -755,7 +747,7 @@ err:
 			chp->ch_flags |= ATACH_DMA_WAIT | ATACH_PIOBM_WAIT;
 			ata_channel_unlock(chp);
 			return 1;
-		} else
+		}
 #endif
 		wdc->datain_pio(chp, drvp->drive_flags,
 		    (char *)xfer->c_databuf + xfer->c_skip, ata_bio->nbytes);
@@ -778,11 +770,13 @@ end:
 			/* Let _wdc_ata_bio_start do the loop */
 		}
 		ata_channel_unlock(chp);
-	} else { /* Done with this transfer */
-		ata_bio->error = NOERROR;
-		ata_channel_unlock(chp);
-		wdc_ata_bio_done(chp, xfer);
+		return 1;
 	}
+
+	/* Done with this transfer */
+	ata_bio->error = NOERROR;
+err:	ata_channel_unlock(chp);
+	wdc_ata_bio_done(chp, xfer);
 	return 1;
 }
 

Reply via email to