PERFORCE change 94268 for review

Marcel Moolenaar marcel at FreeBSD.org
Wed Mar 29 22:25:26 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=94268

Change 94268 by marcel at marcel_nfs on 2006/03/29 22:24:25

	Implement scc_bfe_detach().

Affected files ...

.. //depot/projects/uart/dev/scc/scc_core.c#14 edit

Differences ...

==== //depot/projects/uart/dev/scc/scc_core.c#14 (text+ko) ====

@@ -271,8 +271,44 @@
 int
 scc_bfe_detach(device_t dev)
 {
+	struct scc_chan *ch;
+	struct scc_class *cl;
+	struct scc_mode *m;
+	struct scc_softc *sc;
+	int chan, error, mode;
+
+	sc = device_get_softc(dev);
+	cl = sc->sc_class;
+
+	/* Detach our children. */
+	error = 0;
+	for (chan = 0; chan < cl->cl_channels; chan++) {
+		ch = &sc->sc_chan[chan];
+		for (mode = 0; mode < SCC_NMODES; mode++) {
+			m = &ch->ch_mode[mode];
+			if (!m->m_attached)
+				continue;
+			if (device_detach(m->m_dev) != 0)
+				error = ENXIO;
+			else
+				m->m_attached = 0;
+		}
+	}
+
+	if (error)
+		return (error);
 
-	return (ENXIO);
+	if (sc->sc_ires != NULL) {
+		bus_teardown_intr(dev, sc->sc_ires, sc->sc_icookie);
+		bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irid,
+		    sc->sc_ires);
+	}
+	bus_release_resource(dev, sc->sc_rtype, sc->sc_rrid, sc->sc_rres);
+
+	free(sc->sc_chan, M_SCC);
+
+	mtx_destroy(&sc->sc_hwmtx);
+	return (0);
 }
 
 int


More information about the p4-projects mailing list