NetBSD Problem Report #18434

Received: (qmail 620 invoked by uid 605); 27 Sep 2002 09:14:32 -0000
Message-Id: <200209270913.g8R9Ddb20325@mail.fukaumi.org>
Date: Fri, 27 Sep 2002 18:13:39 +0900 (JST)
From: naoki@fukaumi.org
Sender: gnats-bugs-owner@netbsd.org
Reply-To: naoki@fukaumi.org
To: gnats-bugs@gnats.netbsd.org
Cc: naoki@fukaumi.org
Subject: wi.c can't compile on hpcmips (maybe all mips ports)
X-Send-Pr-Version: 3.95

>Number:         18434
>Category:       kern
>Synopsis:       wi.c can't compile on hpcmips (maybe all mips ports)
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    dyoung
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Sep 27 09:15:00 +0000 2002
>Closed-Date:    Thu Aug 05 21:26:21 +0000 2004
>Last-Modified:  Thu Aug 05 21:26:21 +0000 2004
>Originator:     FUKAUMI Naoki
>Release:        NetBSD 1.6I (2002/9/26 source)
>Organization:
	FUKAUMI Naoki
>Environment:
	NetBSD 1.6I
>Description:
	When I compiled hpcmips kernel, I got error:
/home/t/hpcmips/bin/mipsel--netbsd-gcc  -mips2 -EL -G 10 -mno-abicalls -mno-half-pic -ffreestanding  -Os -mmemcpy -Werror -Wall -Wno-main -Wno-format-zero-length -Wpointer-arith -Wmissing-prototypes -Wstrict-prototypes -Wno-uninitialized  -Dhpcmips -I.  -I/usr/src/sys/arch -I/usr/src/sys -nostdinc -DSOFTFLOAT -DMIPS3 -DMIPS3_4100 -DMIPS1 -DENABLE_MIPS_TX3900 -DKSEG2IOBUFSIZE="0x8000000" -DTX392X -DMSGBUFSIZE="0x2000" -DLKM -DMAXUSERS=16 -D_KERNEL -D_KERNEL_OPT   -c /usr/src/sys/dev/ic/wi.c
/usr/src/sys/dev/ic/wi.c: In function `wi_cmd':
/usr/src/sys/dev/ic/wi.c:1410: parse error before `{'
/usr/src/sys/dev/ic/wi.c:1410: `N' undeclared (first use in this function)
/usr/src/sys/dev/ic/wi.c:1410: (Each undeclared identifier is reported only once
/usr/src/sys/dev/ic/wi.c:1410: for each function it appears in.)
cc1: warnings being treated as errors
/usr/src/sys/dev/ic/wi.c:1407: warning: unused variable `s'
/usr/src/sys/dev/ic/wi.c:1410: warning: control reaches end of non-void function
/usr/src/sys/dev/ic/wi.c: At top level:
/usr/src/sys/dev/ic/wi.c:1410: parse error before `)'
/usr/src/sys/dev/ic/wi.c:1421: parse error before `bus_space_tag_t'
/usr/src/sys/dev/ic/wi.c:1422: parse error before `bus_space_tag_t'
/usr/src/sys/dev/ic/wi.c:1423: parse error before `bus_space_tag_t'
/usr/src/sys/dev/ic/wi.c:1424: parse error before `bus_space_tag_t'
/usr/src/sys/dev/ic/wi.c:1438: parse error before `bus_space_tag_t'
/usr/src/sys/dev/ic/wi.c: In function `wi_reset':
/usr/src/sys/dev/ic/wi.c:1471: parse error before `{'
/usr/src/sys/dev/ic/wi.c:1471: `N' undeclared (first use in this function)
/usr/src/sys/dev/ic/wi.c: At top level:
/usr/src/sys/dev/ic/wi.c:1471: parse error before `)'
/usr/src/sys/dev/ic/wi.c:1481: parse error before `bus_space_tag_t'
/usr/src/sys/dev/ic/wi.c:1482: parse error before `bus_space_tag_t'
/usr/src/sys/dev/ic/wi.c:1485: parse error before `&'
/usr/src/sys/dev/ic/wi.c:1485: warning: type defaults to `int' in declaration of `wi_write_record'
/usr/src/sys/dev/ic/wi.c:1485: warning: function declaration isn't a prototype
/usr/src/sys/dev/ic/wi.c:1485: warning: data definition has no type or storage class
/usr/src/sys/dev/ic/wi.c: In function `wi_seek':
/usr/src/sys/dev/ic/wi.c:1761: parse error before `{'
/usr/src/sys/dev/ic/wi.c:1761: `N' undeclared (first use in this function)
/usr/src/sys/dev/ic/wi.c:1726: warning: unused variable `status'
/usr/src/sys/dev/ic/wi.c:1761: warning: control reaches end of non-void function
/usr/src/sys/dev/ic/wi.c: At top level:
/usr/src/sys/dev/ic/wi.c:1761: parse error before `)'
/usr/src/sys/dev/ic/wi.c: In function `wi_alloc_nicmem':
/usr/src/sys/dev/ic/wi.c:1889: parse error before `{'
/usr/src/sys/dev/ic/wi.c:1889: `N' undeclared (first use in this function)
/usr/src/sys/dev/ic/wi.c:1889: warning: control reaches end of non-void function
/usr/src/sys/dev/ic/wi.c: At top level:
/usr/src/sys/dev/ic/wi.c:1889: parse error before `)'
/usr/src/sys/dev/ic/wi.c:1899: warning: type defaults to `int' in declaration of `id'
/usr/src/sys/dev/ic/wi.c:1899: `sc' undeclared here (not in a function)
/usr/src/sys/dev/ic/wi.c:1899: `sc' undeclared here (not in a function)
/usr/src/sys/dev/ic/wi.c:1899: `sc' undeclared here (not in a function)
/usr/src/sys/dev/ic/wi.c:1899: `sc' undeclared here (not in a function)
/usr/src/sys/dev/ic/wi.c:1899: warning: data definition has no type or storage class
/usr/src/sys/dev/ic/wi.c:1900: parse error before `bus_space_tag_t'
*** Error code 1

Stop.
nbmake: stopped in /usr/obj/hpcmips/sys/arch/hpcmips/compile/GENERIC

>How-To-Repeat:
	Compile recent hpcmips kernel.

>Fix:
	DELAY() on mips ports are different to another ports.
	See sys/arch/*/include/param.h.

	wi.c after rev. 1.84 uses "for (;; DELAY())" style code.
	Is it wrong? I don't know. But I changed this style, I can
	compile wi.c without errors.

	This is diffs, please review it :)

--- wi.c.orig	Fri Sep 27 10:52:24 2002
+++ wi.c	Fri Sep 27 17:30:52 2002
@@ -1407,9 +1407,10 @@
 	int			i, s = 0;

 	/* Wait 100us for the busy bit to clear. */
-	for (i = 10; i--; DELAY(10)) {
+	for (i = 10; i > 0; i--) {
 		if (!(CSR_READ_2(sc, WI_COMMAND) & WI_CMD_BUSY))
 			break;
+		DELAY(10);
 	}

 	if (i < 0) {
@@ -1426,7 +1427,7 @@
 	/* wait .4 second for the command to complete. study the
 	 * distribution of times.
 	 */
-	for (i = 2000; i--; DELAY(200)) {
+	for (i = 2000; i > 0; i--) {
 		/*
 		 * Wait for 'command complete' bit to be
 		 * set in the event status register.
@@ -1444,6 +1445,7 @@
 				return(EIO);
 			break;
 		}
+		DELAY(200);
 	}

 	if (i < 0) {
@@ -1468,9 +1470,10 @@
 	bzero(&sc->wi_current_bssid, sizeof(sc->wi_current_bssid));
 	bzero(&sc->wi_stats, sizeof(sc->wi_stats));

-	for (i = 5; i--; DELAY(5 * 1000)) {
+	for (i = 5; i > 0; i--) {
 		if (wi_cmd(sc, WI_CMD_INI, 0, 0, 0) == 0)
 			break;
+		DELAY(5 * 1000);
 	}

 	if (i < 0)
@@ -1758,9 +1761,11 @@
 	CSR_WRITE_2(sc, selreg, id);
 	CSR_WRITE_2(sc, offreg, off);

-	for (i = WI_TIMEOUT; i--; DELAY(10))
+	for (i = WI_TIMEOUT; i > 0; i--) {
 		if (!(CSR_READ_2(sc, offreg) & (WI_OFF_BUSY|WI_OFF_ERR)))
 			break;
+		DELAY(10);
+	}

 	if (i < 0) {
 		printf("%s: timeout in wi_seek to %x/%x; last status %x\n",
@@ -1886,9 +1891,10 @@
 		return(ENOMEM);
 	}

-	for (i = WI_TIMEOUT; i--; DELAY(10)) {
+	for (i = WI_TIMEOUT; i > 0; i--) {
 		if (CSR_READ_2(sc, WI_EVENT_STAT) & WI_EV_ALLOC)
 			break;
+		DELAY(10);
 	}

 	if (i < 0) {
>Release-Note:
>Audit-Trail:

From: Jason R Thorpe <thorpej@wasabisystems.com>
To: naoki@fukaumi.org
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/18434: wi.c can't compile on hpcmips (maybe all mips ports)
Date: Fri, 27 Sep 2002 07:07:48 -0700

 On Fri, Sep 27, 2002 at 06:13:39PM +0900, naoki@fukaumi.org wrote:

  > >Fix:
  > 	DELAY() on mips ports are different to another ports.
  > 	See sys/arch/*/include/param.h.

 DELAY() on the MIPS ports should be changed to be function-like.

 -- 
         -- Jason R. Thorpe <thorpej@wasabisystems.com>

From: FUKAUMI Naoki <naoki@fukaumi.org>
To: Jason R Thorpe <thorpej@wasabisystems.com>
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: kern/18434: wi.c can't compile on hpcmips (maybe all mips ports)
Date: Sat, 28 Sep 2002 12:06:31 +0900

 Hi

 I'm sorry. previous patch was wrong. End of for loop, i value is different
 from pre-patch code.

   before: i takes 9 to -1 in loop
   after : i takes 10 to 0 in loop

 it breaks next if (i < 0) checking...
 (A.NAKAMURA advised me in japanese ML, thanks)

 At Fri, 27 Sep 2002 07:07:48 -0700,
 Jason R Thorpe wrote:
 > DELAY() on the MIPS ports should be changed to be function-like.

 Yes.

 messege from Y.KUWANA in japanese ML:
 > gcc only
 > #define DELAY(n) ({ register int N = cpuspeed * (n); while (--N > 0); })
 > may work.
 > 
 > in C style
 > inline void DELAY(n){ register int N = cpuspeed * (n); while (--N > 0); }
 > would be better

 --
 FUKAUMI Naoki
Responsible-Changed-From-To: kern-bug-people->dyoung 
Responsible-Changed-By: dyoung 
Responsible-Changed-When: Tue Apr 20 06:04:38 UTC 2004 
Responsible-Changed-Why:  
I will make sure this gets closed. 
State-Changed-From-To: open->closed 
State-Changed-By: mycroft 
State-Changed-When: Thu Aug 5 21:24:58 UTC 2004 
State-Changed-Why:  
This was fixed some time ago, and I've personally used wi on hpcmips since 
then. 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.