Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Sep 2001 00:41:48 +0000
From:      Tony Finch <dot@dotat.at>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   kern/30539: [PATCH] pull some magic numbers out of the ata code
Message-ID:  <E15hKZg-0001WD-00@hand.dotat.at>

next in thread | raw e-mail | index | archive | help

>Number:         30539
>Category:       kern
>Synopsis:       [PATCH] pull some magic numbers out of the ata code
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 12 16:50:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     Tony Finch
>Release:        FreeBSD 4.4-RC i386
>Organization:
dotat labs
>Environment:
System: FreeBSD hand.dotat.at 4.4-RC FreeBSD 4.4-RC #4: Sat Sep 1 19:06:27 GMT 2001 fanf@hand.dotat.at:/FreeBSD/obj/FreeBSD/releng4/sys/SHARP i386
>Description:
There are some magic numbers in the ata code related to timeouts
and so forth that would be better coded as #defined constants.
>How-To-Repeat:
>Fix:

Index: sys/dev/ata/ata-all.c
===================================================================
RCS file: /home/ncvs/src/sys/dev/ata/ata-all.c,v
retrieving revision 1.50.2.20
diff -u -r1.50.2.20 ata-all.c
--- sys/dev/ata/ata-all.c	2001/08/28 17:56:14	1.50.2.20
+++ sys/dev/ata/ata-all.c	2001/08/28 22:19:33
@@ -77,6 +77,8 @@
 #else
 #define ATA_MASTERDEV(dev)	(1)
 #endif
+#define ATA_WAIT_DELAY		(5000000)	/* microseconds */
+#define ATA_INTR_DELAY		(10 * hz)	/* ticks */
 
 /* prototypes */
 static int ata_probe(device_t);
@@ -1431,7 +1433,7 @@
     int statio = scp->ioaddr + ATA_STATUS;
     
     DELAY(1);
-    while (timeout < 5000000) {	/* timeout 5 secs */
+    while (timeout < ATA_WAIT_DELAY) {
 	scp->status = inb(statio);
 
 	/* if drive fails status, reselect the drive just to be sure */
@@ -1457,7 +1459,7 @@
     }	 
     if (scp->status & ATA_S_ERROR)
 	scp->error = inb(scp->ioaddr + ATA_ERROR);
-    if (timeout >= 5000000)	 
+    if (timeout >= ATA_WAIT_DELAY)
 	return -1;	    
     if (!mask)	   
 	return (scp->status & ATA_S_ERROR);	 
@@ -1514,14 +1516,14 @@
     switch (flags) {
     case ATA_WAIT_INTR:
 	scp->active = ATA_WAIT_INTR;
-	asleep((caddr_t)scp, PRIBIO, "atacmd", 10 * hz);
+	asleep((caddr_t)scp, PRIBIO, "atacmd", ATA_INTR_DELAY);
 	outb(scp->ioaddr + ATA_CMD, command);
 
 	/* enable interrupt */
 	if (scp->flags & ATA_QUEUED)
 	    outb(scp->altioaddr, ATA_A_4BIT);
 
-	if (await(PRIBIO, 10 * hz)) {
+	if (await(PRIBIO, ATA_INTR_DELAY)) {
 	    ata_printf(scp, device, "ata_command: timeout waiting for intr\n");
 	    scp->active = ATA_IDLE;
 	    error = -1;
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E15hKZg-0001WD-00>