Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Apr 2006 20:27:42 GMT
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 95523 for review
Message-ID:  <200604182027.k3IKRg0Z060071@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=95523

Change 95523 by marcel@marcel_nfs on 2006/04/18 20:26:48

	o  Implement puc_bfe_detach().

Affected files ...

.. //depot/projects/uart/dev/puc/puc.c#28 edit

Differences ...

==== //depot/projects/uart/dev/puc/puc.c#28 (text+ko) ====

@@ -290,7 +290,46 @@
 int
 puc_bfe_detach(device_t dev)
 {
-	return (ENXIO);
+	struct puc_bar *bar;
+	struct puc_port *port;
+	struct puc_softc *sc;
+	int error, idx;
+
+	sc = device_get_softc(dev);
+
+	/* Detach our children. */
+	error = 0;
+	for (idx = 0; idx < sc->sc_nports; idx++) {
+		port = &sc->sc_port[idx];
+		if (port->p_dev == NULL)
+			continue;
+		if (device_detach(port->p_dev) == 0) {
+			device_delete_child(dev, port->p_dev);
+			if (port->p_rres != NULL)
+				rman_release_resource(port->p_rres);
+			if (port->p_ires != NULL)
+				rman_release_resource(port->p_ires);
+		} else
+			error = ENXIO;
+	}
+	if (error)
+		return (error);
+
+	bus_teardown_intr(dev, sc->sc_ires, sc->sc_icookie);
+	bus_release_resource(dev, SYS_RES_IRQ, sc->sc_irid, sc->sc_ires);
+
+	for (idx = 0; idx < PUC_PCI_BARS; idx++) {
+		bar = &sc->sc_bar[idx];
+		if (bar->b_res != NULL)
+			bus_release_resource(sc->sc_dev, bar->b_type,
+			    bar->b_rid, bar->b_res);
+	}
+
+	rman_fini(&sc->sc_irq);
+	rman_fini(&sc->sc_iomem);
+	rman_fini(&sc->sc_ioport);
+	free(sc->sc_port, M_PUC);
+	return (0);
 }
 
 int



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