Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/nand it seems we have a config_detach_children (thou...
details: https://anonhg.NetBSD.org/src/rev/d3efea96f668
branches: trunk
changeset: 764535:d3efea96f668
user: ahoka <ahoka%NetBSD.org@localhost>
date: Tue Apr 26 17:31:57 2011 +0000
description:
it seems we have a config_detach_children (though undocumented)
lets use that to detach flash devices before detaching nand
diffstat:
sys/dev/nand/nand.c | 34 +++++++++-------------------------
sys/dev/nand/nand.h | 9 +--------
2 files changed, 10 insertions(+), 33 deletions(-)
diffs (114 lines):
diff -r beb14c300c19 -r d3efea96f668 sys/dev/nand/nand.c
--- a/sys/dev/nand/nand.c Tue Apr 26 17:30:45 2011 +0000
+++ b/sys/dev/nand/nand.c Tue Apr 26 17:31:57 2011 +0000
@@ -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
diff -r beb14c300c19 -r d3efea96f668 sys/dev/nand/nand.h
--- a/sys/dev/nand/nand.h Tue Apr 26 17:30:45 2011 +0000
+++ b/sys/dev/nand/nand.h Tue Apr 26 17:31:57 2011 +0000
@@ -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 */
Home |
Main Index |
Thread Index |
Old Index