Subject: kern/9870: To catch up with if_rl.c rev 1.10
To: None <gnats-bugs@gnats.netbsd.org>
From: None <kanaoka@ann.hi-ho.ne.jp>
List: netbsd-bugs
Date: 04/13/2000 19:40:10
>Number:         9870
>Category:       kern
>Synopsis:       To catch up with if_rl.c rev 1.10
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 13 19:41:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Masanori Kanaoka
>Release:        NetBSD-current(1.4X)
>Organization:
>Environment:
NetBSD kana1.ann.hi-ho.ne.jp 1.4X NetBSD 1.4X (PCIBIOS) #1: Fri Apr 14 11:22:44 JST 2000     root@kana1.ann.hi-ho.ne.jp:/usr/src/sys/arch/i386/compile/PCIBIOS i386

>Description:
I rewrite rl driver with CardBus and PCI that based if_rl.c rev 1.8.

	if_rl.c: rev 1.10
	Remove register declarations.

	if_rl.c: rev 1.9
	Rather than guessing at the location of the PMCSR,
	 use the pointer returned by pci_get_capability().  
	(This is, after all, a standardized interface...)

To catch up with if_rl.c rev 1.10, plase apply next patch. 
>How-To-Repeat:


>Fix:
Index: sys/dev/ic/rtl81x9.c
===================================================================
RCS file: /home/ftp/cvs/syssrc/sys/dev/ic/rtl81x9.c,v
retrieving revision 1.1
diff -u -r1.1 rtl81x9.c
--- sys/dev/ic/rtl81x9.c	2000/04/10 07:42:56	1.1
+++ sys/dev/ic/rtl81x9.c	2000/04/14 02:13:38
@@ -191,7 +191,7 @@
 	struct rl_softc		*sc;
 	int			addr;
 {
-	register int		d, i;
+	int		d, i;
 
 	d = addr | RL_EECMD_READ;
 
@@ -222,7 +222,7 @@
 	int			addr;
 	u_int16_t		*dest;
 {
-	register int		i;
+	int		i;
 	u_int16_t		word = 0;
 
 	/* Enter EEPROM access mode. */
@@ -301,7 +301,7 @@
 STATIC void rl_mii_sync(sc)
 	struct rl_softc		*sc;
 {
-	register int		i;
+	int		i;
 
 	MII_SET(RL_MII_DIR|RL_MII_DATAOUT);
 
@@ -667,7 +667,7 @@
 void rl_reset(sc)
 	struct rl_softc		*sc;
 {
-	register int		i;
+	int		i;
 
 	CSR_WRITE_1(sc, RL_COMMAND, RL_CMD_RESET);
 
@@ -1393,7 +1393,7 @@
 #ifdef NS
 		case AF_NS:
 		    {
-			 register struct ns_addr *ina = &IA_SNS(ifa)->sns_addr;
+			 struct ns_addr *ina = &IA_SNS(ifa)->sns_addr;
 
 			 if (ns_nullhost(*ina))
 				ina->x_host = *(union ns_host *)
@@ -1487,7 +1487,7 @@
 STATIC void rl_stop(sc)
 	struct rl_softc		*sc;
 {
-	register int		i;
+	int		i;
 	struct ifnet		*ifp;
 
 	ifp = &sc->ethercom.ec_if;
Index: sys/dev/pci/if_rl_pci.c
===================================================================
RCS file: /home/ftp/cvs/syssrc/sys/dev/pci/if_rl_pci.c,v
retrieving revision 1.1
diff -u -r1.1 if_rl_pci.c
--- sys/dev/pci/if_rl_pci.c	2000/04/10 07:42:56	1.1
+++ sys/dev/pci/if_rl_pci.c	2000/04/14 02:18:10
@@ -215,12 +215,12 @@
 	struct device *parent, *self;
 	void *aux;
 {
-	int			s;
+	int			s, pmreg;
 #ifndef RL_USEIOSPACE
 	vm_offset_t		pbase, vbase;
 #endif
 	u_char			eaddr[ETHER_ADDR_LEN];
-	u_int32_t		command;
+	pcireg_t		command;
 	struct rl_pci_softc *psc = (struct rl_pci_softc *)self;
 	struct rl_softc *sc = &psc->sc_rl;
 	u_int16_t		rl_did = 0;
@@ -238,10 +238,10 @@
 	 * Handle power management nonsense.
 	 */
 
-	if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, 0, 0)) {
-		command = pci_conf_read(pc, pa->pa_tag, RL_PCI_PWRMGMTCTRL);
+	if (pci_get_capability(pc, pa->pa_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
+		command = pci_conf_read(pc, pa->pa_tag, pmreg + 4);
 		if (command & RL_PSTATE_MASK) {
-			u_int32_t		iobase, membase, irq;
+			pcireg_t		iobase, membase, irq;
 
 			/* Save important PCI config data. */
 			iobase = pci_conf_read(pc, pa->pa_tag, RL_PCI_LOIO);
@@ -253,7 +253,7 @@
 			"-- setting to D0\n", sc->sc_dev.dv_xname,
 			       command & RL_PSTATE_MASK);
 			command &= 0xFFFFFFFC;
-			pci_conf_write(pc, pa->pa_tag, RL_PCI_PWRMGMTCTRL, command);
+			pci_conf_write(pc, pa->pa_tag, pmreg + 4, command);
 
 			/* Restore PCI config data. */
 			pci_conf_write(pc, pa->pa_tag, RL_PCI_LOIO, iobase);
Index: sys/dev/cardbus/if_rl_cardbus.c
===================================================================
RCS file: /home/ftp/cvs/syssrc/sys/dev/cardbus/if_rl_cardbus.c,v
retrieving revision 1.2
diff -u -r1.2 if_rl_cardbus.c
--- sys/dev/cardbus/if_rl_cardbus.c	2000/04/11 06:57:59	1.2
+++ sys/dev/cardbus/if_rl_cardbus.c	2000/04/14 02:21:46
@@ -163,12 +163,12 @@
 	struct device *parent, *self;
 	void *aux;
 {
-	int			s;
+	int			s, pmreg;
 #ifndef RL_USEIOSPACE
 	vm_offset_t		pbase, vbase;
 #endif
 	u_char			eaddr[ETHER_ADDR_LEN];
-	u_int32_t		command;
+	pcireg_t		command;
 	struct rl_cardbus_softc *csc = (struct rl_cardbus_softc *)self;
 	struct rl_softc *sc = &csc->sc_rl;
 	struct cardbus_attach_args *ca = aux;
@@ -195,10 +195,10 @@
 	/*
 	 * Handle power management nonsense.
 	 */
-	if (cardbus_get_capability(cc, cf, csc->sc_tag, PCI_CAP_PWRMGMT, 0, 0)) {
-		command = cardbus_conf_read(cc, cf, csc->sc_tag, RL_PCI_PWRMGMTCTRL);
+	if (cardbus_get_capability(cc, cf, csc->sc_tag, PCI_CAP_PWRMGMT, &pmreg, 0)) {
+		command = cardbus_conf_read(cc, cf, csc->sc_tag, pmreg + 4);
 		if (command & RL_PSTATE_MASK) {
-			u_int32_t		iobase, membase, irq;
+			pcireg_t		iobase, membase, irq;
 
 			/* Save important PCI config data. */
 			iobase = cardbus_conf_read(cc, cf, csc->sc_tag, RL_PCI_LOIO);
@@ -210,7 +210,7 @@
 			"-- setting to D0\n", sc->sc_dev.dv_xname,
 			       command & RL_PSTATE_MASK);
 			command &= 0xFFFFFFFC;
-			cardbus_conf_write(cc, cf, csc->sc_tag, RL_PCI_PWRMGMTCTRL, command);
+			cardbus_conf_write(cc, cf, csc->sc_tag, pmreg + 4, command);
 
 			/* Restore PCI config data. */
 			cardbus_conf_write(cc, cf, csc->sc_tag, RL_PCI_LOIO, iobase);

>Release-Note:
>Audit-Trail:
>Unformatted: