Module Name: src
Committed By: ahoka
Date: Tue Apr 26 17:31:58 UTC 2011
Modified Files:
src/sys/dev/nand: nand.c nand.h
Log Message:
it seems we have a config_detach_children (though undocumented)
lets use that to detach flash devices before detaching nand
To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/nand/nand.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/nand/nand.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/nand/nand.c
diff -u src/sys/dev/nand/nand.c:1.9 src/sys/dev/nand/nand.c:1.10
--- src/sys/dev/nand/nand.c:1.9 Tue Apr 26 13:38:13 2011
+++ src/sys/dev/nand/nand.c Tue Apr 26 17:31:57 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nand.c,v 1.9 2011/04/26 13:38:13 ahoka Exp $ */
+/* $NetBSD: nand.c,v 1.10 2011/04/26 17:31:57 ahoka Exp $ */
/*-
* Copyright (c) 2010 Department of Software Engineering,
@@ -34,7 +34,7 @@
/* Common driver for NAND chips implementing the ONFI 2.2 specification */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nand.c,v 1.9 2011/04/26 13:38:13 ahoka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nand.c,v 1.10 2011/04/26 17:31:57 ahoka Exp $");
#include "locators.h"
@@ -58,7 +58,6 @@
void nand_attach(device_t, device_t, void *);
int nand_detach(device_t, int);
bool nand_shutdown(device_t, int);
-void nand_childdet(device_t, device_t);
int nand_print(void *, const char *);
@@ -69,12 +68,8 @@
static int nand_scan_media(device_t, struct nand_chip *);
static bool nand_check_wp(device_t);
-CFATTACH_DECL2_NEW(nand, sizeof(struct nand_softc),
- nand_match, nand_attach, nand_detach,
- NULL, NULL, nand_childdet);
-
-//CFATTACH_DECL_NEW(nand, sizeof(struct nand_softc),
-// nand_match, nand_attach, nand_detach, NULL);
+CFATTACH_DECL_NEW(nand, sizeof(struct nand_softc),
+ nand_match, nand_attach, nand_detach, NULL);
#ifdef NAND_DEBUG
int nanddebug = NAND_DEBUG;
@@ -132,8 +127,6 @@
sc->controller_dev = parent;
sc->nand_if = naa->naa_nand_if;
- sc->sc_children = 0;
-
aprint_naive("\n");
if (nand_check_wp(self)) {
@@ -220,7 +213,6 @@
if (config_match(parent, cf, &faa)) {
if (config_attach(parent, cf, &faa, nand_print) != NULL) {
- atomic_inc_uint(&sc->sc_children);
return 0;
} else {
return 1;
@@ -237,10 +229,11 @@
{
struct nand_softc *sc = device_private(self);
struct nand_chip *chip = &sc->sc_chip;
- int ret = 0;
+ int error = 0;
- if (sc->sc_children != 0) {
- return EBUSY;
+ error = config_detach_children(self, flags);
+ if (error) {
+ return error;
}
nand_sync_thread_stop(self);
@@ -256,16 +249,7 @@
pmf_device_deregister(sc->sc_dev);
- return ret;
-}
-
-void
-nand_childdet(device_t self, device_t child)
-{
- struct nand_softc *sc = device_private(self);
-
- atomic_dec_uint(&sc->sc_children);
- KASSERT(sc->sc_children >= 0);
+ return error;
}
int
Index: src/sys/dev/nand/nand.h
diff -u src/sys/dev/nand/nand.h:1.7 src/sys/dev/nand/nand.h:1.8
--- src/sys/dev/nand/nand.h:1.7 Tue Apr 26 13:38:13 2011
+++ src/sys/dev/nand/nand.h Tue Apr 26 17:31:57 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: nand.h,v 1.7 2011/04/26 13:38:13 ahoka Exp $ */
+/* $NetBSD: nand.h,v 1.8 2011/04/26 17:31:57 ahoka Exp $ */
/*-
* Copyright (c) 2010 Department of Software Engineering,
@@ -161,13 +161,6 @@
kmutex_t sc_io_lock;
kcondvar_t sc_io_cv;
bool sc_io_running;
-
- /* currently we cant automatically detach children
- * so keep count of attached children so we will
- * know, that when is safe to detach...
- * XXX is it a problem only as a module? (ioconf bug?)
- */
- unsigned int sc_children;
};
/* structure holding the nand api */