From fanf@dotat.at  Wed Sep 12 16:42:04 2001
Return-Path: <fanf@dotat.at>
Received: from hand.dotat.at (host217-35-41-52.in-addr.btopenworld.com [217.35.41.52])
	by hub.freebsd.org (Postfix) with ESMTP id EA0B437B406
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 12 Sep 2001 16:42:03 -0700 (PDT)
Received: from fanf by hand.dotat.at with local (Exim 3.33 #16)
	id 15hKZg-0001WD-00
	for FreeBSD-gnats-submit@freebsd.org; Thu, 13 Sep 2001 00:41:48 +0000
Message-Id: <E15hKZg-0001WD-00@hand.dotat.at>
Date: Thu, 13 Sep 2001 00:41:48 +0000
From: Tony Finch <dot@dotat.at>
Reply-To: Tony Finch <dot@dotat.at>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: [PATCH] pull some magic numbers out of the ata code
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         30539
>Category:       kern
>Synopsis:       [PATCH] pull some magic numbers out of the ata code
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    sos
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Sep 12 16:50:01 PDT 2001
>Closed-Date:    Thu Sep 13 04:24:45 PDT 2001
>Last-Modified:  Thu Sep 13 04:26:07 PDT 2001
>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:

From: "Alexey V. Neyman" <alex.neyman@auriga.ru>
To: Tony Finch <dot@dotat.at>
Cc: <FreeBSD-gnats-submit@FreeBSD.ORG>
Subject: Re: kern/30539: [PATCH] pull some magic numbers out of the ata code
Date: Thu, 13 Sep 2001 10:17:29 +0400 (MSD)

 Regarding also misc/30536 PR, better yet as a sysctl's than #ifdefs?
 
 Regards,
 Alexey.
 
 
Responsible-Changed-From-To: freebsd-bugs->sos 
Responsible-Changed-By: dd 
Responsible-Changed-When: Thu Sep 13 04:16:08 PDT 2001 
Responsible-Changed-Why:  
Over to maintainer. 

http://www.FreeBSD.org/cgi/query-pr.cgi?pr=30539 
State-Changed-From-To: open->closed 
State-Changed-By: sos 
State-Changed-When: Thu Sep 13 04:24:45 PDT 2001 
State-Changed-Why:  
I'll consider doing this as defines, but there is no need for that, 
and these values should NOT be changed under any circumstances, 
and thats why they should NOT be sysctl's at all. 


http://www.FreeBSD.org/cgi/query-pr.cgi?pr=30539 
>Unformatted:
