Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys More adaptation of the rump component init, to avoid EEX...



details:   https://anonhg.NetBSD.org/src/rev/26ea06270215
branches:  trunk
changeset: 346732:26ea06270215
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sat Jul 30 22:36:14 2016 +0000

description:
More adaptation of the rump component init, to avoid EEXIST during
regular module initialization.

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 3fcc2394bf09 -r 26ea06270215 sys/dev/fss.c
--- a/sys/dev/fss.c     Sat Jul 30 15:38:17 2016 +0000
+++ b/sys/dev/fss.c     Sat Jul 30 22:36:14 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fss.c,v 1.93 2015/08/20 14:40:17 christos Exp $        */
+/*     $NetBSD: fss.c,v 1.94 2016/07/30 22:36:14 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 2015/08/20 14:40:17 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fss.c,v 1.94 2016/07/30 22:36:14 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1290,10 +1290,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) {
@@ -1311,9 +1312,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);
@@ -1323,11 +1323,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 3fcc2394bf09 -r 26ea06270215 sys/rump/dev/lib/libfss/fss_component.c
--- a/sys/rump/dev/lib/libfss/fss_component.c   Sat Jul 30 15:38:17 2016 +0000
+++ b/sys/rump/dev/lib/libfss/fss_component.c   Sat Jul 30 22:36:14 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.3 2016/07/30 22:36:14 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.3 2016/07/30 22:36:14 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_bmaj, fss_cmaj;
        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