Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 18 Aug 2016 07:11:31 +0000 (UTC)
From:      Pyun YongHyeon <yongari@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r304336 - head/sys/dev/usb/net
Message-ID:  <201608180711.u7I7BVRt044700@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: yongari
Date: Thu Aug 18 07:11:31 2016
New Revision: 304336
URL: https://svnweb.freebsd.org/changeset/base/304336

Log:
  When device is detached make sure to stop the controller and make
  it return zero-length USB packet.

Modified:
  head/sys/dev/usb/net/if_axge.c

Modified: head/sys/dev/usb/net/if_axge.c
==============================================================================
--- head/sys/dev/usb/net/if_axge.c	Thu Aug 18 06:46:14 2016	(r304335)
+++ head/sys/dev/usb/net/if_axge.c	Thu Aug 18 07:11:31 2016	(r304336)
@@ -580,9 +580,27 @@ axge_detach(device_t dev)
 {
 	struct axge_softc *sc;
 	struct usb_ether *ue;
+	uint16_t val;
 
 	sc = device_get_softc(dev);
 	ue = &sc->sc_ue;
+	if (device_is_attached(dev)) {
+		AXGE_LOCK(sc);
+		/*
+		 * XXX
+		 * ether_ifdetach(9) should be called first.
+		 */
+		axge_stop(ue);
+		/* Force bulk-in to return a zero-length USB packet. */
+		val = axge_read_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_EPPRCR);
+		val |= EPPRCR_BZ | EPPRCR_IPRL;
+		axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_EPPRCR, val);
+		/* Change clock. */
+		axge_write_cmd_1(sc, AXGE_ACCESS_MAC, AXGE_CLK_SELECT, 0);
+		/* Disable MAC. */
+		axge_write_cmd_2(sc, AXGE_ACCESS_MAC, 2, AXGE_RCR, 0);
+		AXGE_UNLOCK(sc);
+	}
 	usbd_transfer_unsetup(sc->sc_xfer, AXGE_N_TRANSFER);
 	uether_ifdetach(ue);
 	mtx_destroy(&sc->sc_mtx);



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