Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 19 Nov 2009 11:22:02 -0500
From:      John Baldwin <jhb@freebsd.org>
To:        arm@freebsd.org
Subject:   [PATCH] Fix a few nits in ate(4)
Message-ID:  <200911191122.02975.jhb@freebsd.org>

next in thread | raw e-mail | index | archive | help
I ran into this while working on purging if_watchdog/if_timer use from the 
tree.  This patch fixes a few things in ate(4):

- Initialize callout before it is used in atestop() during attach.
- Fixup detach.

By fixing detach, I mean that it calls ether_ifdetach() to remove outside 
references to the device before shutting down the device.  Please test.

--- //depot/vendor/freebsd/src/sys/arm/at91/if_ate.c	2009/06/26 11:50:17
+++ //depot/user/jhb/cleanup/sys/arm/at91/if_ate.c	2009/11/17 18:08:42
@@ -75,8 +75,7 @@
 /*
  * Driver-specific flags.
  */
-#define	ATE_FLAG_DETACHING	0x01
-#define	ATE_FLAG_MULTICAST	0x02
+#define	ATE_FLAG_MULTICAST	0x01
 
 struct ate_softc
 {
@@ -196,6 +195,7 @@
 	sc = device_get_softc(dev);
 	sc->dev = dev;
 	ATE_LOCK_INIT(sc);
+	callout_init_mtx(&sc->tick_ch, &sc->sc_mtx, 0);
 	
 	/*
 	 * Allocate resources.
@@ -233,7 +233,6 @@
 	ATE_LOCK(sc);
 	atestop(sc);
 	ATE_UNLOCK(sc);
-	callout_init_mtx(&sc->tick_ch, &sc->sc_mtx, 0);
 
 	if ((err = ate_get_mac(sc, eaddr)) != 0) {
 		/*
@@ -311,12 +309,11 @@
 	KASSERT(sc != NULL, ("[ate: %d]: sc is NULL", __LINE__));
 	ifp = sc->ifp;
 	if (device_is_attached(dev)) {
+		ether_ifdetach(ifp);
 		ATE_LOCK(sc);
-			sc->flags |= ATE_FLAG_DETACHING;
-			atestop(sc);
+		atestop(sc);
 		ATE_UNLOCK(sc);
 		callout_drain(&sc->tick_ch);
-		ether_ifdetach(ifp);
 	}
 	if (sc->miibus != NULL) {
 		device_delete_child(dev, sc->miibus);
@@ -1109,11 +1105,9 @@
 				    & (IFF_PROMISC | IFF_ALLMULTI)) != 0)
 					ate_rxfilter(sc);
 			} else {
-				if ((sc->flags & ATE_FLAG_DETACHING) == 0)
-					ateinit_locked(sc);
+				ateinit_locked(sc);
 			}
 		} else if ((drv_flags & IFF_DRV_RUNNING) != 0) {
-			ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
 			atestop(sc);
 		}
 		sc->if_flags = flags;

-- 
John Baldwin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200911191122.02975.jhb>