Module Name:    src
Committed By:   phx
Date:           Mon Jan 30 15:47:01 UTC 2012

Modified Files:
        src/sys/arch/sandpoint/sandpoint: flash_cfi.c

Log Message:
Revert my last modification.
The detach function might make sense to unload and replace a driver module.
http://mail-index.netbsd.org/source-changes-d/2012/01/24/msg004538.html


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/sandpoint/sandpoint/flash_cfi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/sandpoint/sandpoint/flash_cfi.c
diff -u src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.2 src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.3
--- src/sys/arch/sandpoint/sandpoint/flash_cfi.c:1.2	Mon Jan 23 15:16:37 2012
+++ src/sys/arch/sandpoint/sandpoint/flash_cfi.c	Mon Jan 30 15:47:01 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: flash_cfi.c,v 1.2 2012/01/23 15:16:37 phx Exp $ */
+/* $NetBSD: flash_cfi.c,v 1.3 2012/01/30 15:47:01 phx Exp $ */
 
 /*-
  * Copyright (c) 2011 Frank Wille.
@@ -32,7 +32,7 @@
  * NOR CFI driver support for sandpoint
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: flash_cfi.c,v 1.2 2012/01/23 15:16:37 phx Exp $");
+__KERNEL_RCSID(0, "$NetBSD: flash_cfi.c,v 1.3 2012/01/30 15:47:01 phx Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: flash_cfi.c,
 
 static int  sandpointcfi_probe(device_t, cfdata_t, void *);
 static void sandpointcfi_attach(device_t, device_t, void *);
+static int  sandpointcfi_detach(device_t, int);
 
 struct sandpointcfi_softc {
 	device_t		sc_dev;
@@ -55,7 +56,7 @@ struct sandpointcfi_softc {
 };
 
 CFATTACH_DECL_NEW(sandpointcfi, sizeof(struct sandpointcfi_softc),
-    sandpointcfi_probe, sandpointcfi_attach, NULL, NULL);
+    sandpointcfi_probe, sandpointcfi_attach, sandpointcfi_detach, NULL);
 
 static int
 sandpointcfi_probe(device_t parent, cfdata_t cf, void *aux)
@@ -152,3 +153,20 @@ sandpointcfi_attach(device_t parent, dev
 
 	sc->sc_nordev = nor_attach_mi(&sc->sc_nor_if, self);
 }
+
+static int
+sandpointcfi_detach(device_t self, int flags)
+{
+	struct sandpointcfi_softc *sc;
+	int rv;
+
+	pmf_device_deregister(self);
+	sc = device_private(self);
+	rv = 0;
+
+	if (sc->sc_nordev != NULL)
+		rv = config_detach(sc->sc_nordev, flags);
+
+	bus_space_unmap(sc->sc_cfi.cfi_bst, sc->sc_cfi.cfi_bsh, sc->sc_size);
+	return rv;
+}

Reply via email to