Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/pgoyette-localcount]: src/sys When initializing the rump component, deta...
details: https://anonhg.NetBSD.org/src/rev/7529db078c73
branches: pgoyette-localcount
changeset: 852888:7529db078c73
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Sun Jul 31 01:36:49 2016 +0000
description:
When initializing the rump component, detach the [bc]devsw after
using the devmajors to create the device nodes. Normal module
initialization will reattach them.
XXX This code sequence is fairly common, and probably should be
XXX extracted into a separate routine and/or macro. But there's
XXX a lot of variables/parameters involved...
diffstat:
sys/dev/fss.c | 19 +++++++++++--------
sys/rump/dev/lib/libfss/fss_component.c | 20 +++++++++++---------
2 files changed, 22 insertions(+), 17 deletions(-)
diffs (108 lines):
diff -r d6c88c29ac0c -r 7529db078c73 sys/dev/fss.c
--- a/sys/dev/fss.c Sun Jul 31 01:33:21 2016 +0000
+++ b/sys/dev/fss.c Sun Jul 31 01:36:49 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fss.c,v 1.93.2.5 2016/07/27 03:25:00 pgoyette Exp $ */
+/* $NetBSD: fss.c,v 1.93.2.6 2016/07/31 01:36:49 pgoyette Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.5 2016/07/27 03:25:00 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.93.2.6 2016/07/31 01:36:49 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1321,10 +1321,11 @@
MODULE(MODULE_CLASS_DRIVER, fss, NULL);
CFDRIVER_DECL(fss, DV_DISK, NULL);
+devmajor_t fss_bmajor = -1, fss_cmajor = -1;
+
static int
fss_modcmd(modcmd_t cmd, void *arg)
{
- devmajor_t bmajor = -1, cmajor = -1;
int error = 0;
switch (cmd) {
@@ -1342,9 +1343,8 @@
break;
}
error = devsw_attach(fss_cd.cd_name,
- &fss_bdevsw, &bmajor, &fss_cdevsw, &cmajor);
- if (error == EEXIST)
- error = 0;
+ &fss_bdevsw, &fss_bmajor, &fss_cdevsw, &fss_cmajor);
+
if (error) {
config_cfattach_detach(fss_cd.cd_name, &fss_ca);
config_cfdriver_detach(&fss_cd);
@@ -1354,11 +1354,14 @@
break;
case MODULE_CMD_FINI:
+ devsw_detach(&fss_bdevsw, &fss_cdevsw);
error = config_cfattach_detach(fss_cd.cd_name, &fss_ca);
- if (error)
+ if (error) {
+ devsw_attach(fss_cd.cd_name, &fss_bdevsw, &fss_bmajor,
+ &fss_cdevsw, &fss_cmajor);
break;
+ }
config_cfdriver_detach(&fss_cd);
- devsw_detach(&fss_bdevsw, &fss_cdevsw);
mutex_destroy(&fss_device_lock);
break;
diff -r d6c88c29ac0c -r 7529db078c73 sys/rump/dev/lib/libfss/fss_component.c
--- a/sys/rump/dev/lib/libfss/fss_component.c Sun Jul 31 01:33:21 2016 +0000
+++ b/sys/rump/dev/lib/libfss/fss_component.c Sun Jul 31 01:36:49 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fss_component.c,v 1.2 2016/01/26 23:12:15 pooka Exp $ */
+/* $NetBSD: fss_component.c,v 1.2.2.1 2016/07/31 01:36:49 pgoyette Exp $ */
/*
* Copyright (c) 2009 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fss_component.c,v 1.2 2016/01/26 23:12:15 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss_component.c,v 1.2.2.1 2016/07/31 01:36:49 pgoyette Exp $");
#include <sys/param.h>
#include <sys/conf.h>
@@ -40,20 +40,22 @@
{
extern const struct bdevsw fss_bdevsw;
extern const struct cdevsw fss_cdevsw;
- devmajor_t bmaj, cmaj;
+ extern devmajor_t fss_bmajor, fss_cmajor;
int error;
- bmaj = bdevsw_lookup_major(&fss_bdevsw);
- cmaj = cdevsw_lookup_major(&fss_cdevsw);
+ fss_bmajor = bdevsw_lookup_major(&fss_bdevsw);
+ fss_cmajor = cdevsw_lookup_major(&fss_cdevsw);
- if ((error = devsw_attach("fss", &fss_bdevsw, &bmaj,
- &fss_cdevsw, &cmaj)) != 0)
+ if ((error = devsw_attach("fss", &fss_bdevsw, &fss_bmajor,
+ &fss_cdevsw, &fss_cmajor)) != 0)
panic("cannot attach fss: %d", error);
if ((error = rump_vfs_makedevnodes(S_IFBLK, "/dev/fss", '0',
- bmaj, 0, 4)) != 0)
+ fss_bmajor, 0, 4)) != 0)
panic("cannot create cooked fss dev nodes: %d", error);
if ((error = rump_vfs_makedevnodes(S_IFCHR, "/dev/rfss", '0',
- cmaj, 0, 4)) != 0)
+ fss_cmajor, 0, 4)) != 0)
panic("cannot create raw fss dev nodes: %d", error);
+
+ devsw_detach(&fss_bdevsw, &fss_cdevsw);
}
Home |
Main Index |
Thread Index |
Old Index