Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Clean up the spkr_modcmd() routine so it returns ENO...



details:   https://anonhg.NetBSD.org/src/rev/997298dc5cbf
branches:  trunk
changeset: 824608:997298dc5cbf
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Sun Jun 11 09:41:40 2017 +0000

description:
Clean up the spkr_modcmd() routine so it returns ENOTTY for all commands
other than MODULE_CMD_{INIT,FINI}

diffstat:

 sys/dev/spkr.c |  14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diffs (61 lines):

diff -r 0b14d96b46d1 -r 997298dc5cbf sys/dev/spkr.c
--- a/sys/dev/spkr.c    Sun Jun 11 05:28:28 2017 +0000
+++ b/sys/dev/spkr.c    Sun Jun 11 09:41:40 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: spkr.c,v 1.10 2017/06/11 05:26:52 pgoyette Exp $       */
+/*     $NetBSD: spkr.c,v 1.11 2017/06/11 09:41:40 pgoyette Exp $       */
 
 /*
  * Copyright (c) 1990 Eric S. Raymond (esr%snark.thyrsus.com@localhost)
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.10 2017/06/11 05:26:52 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: spkr.c,v 1.11 2017/06/11 09:41:40 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "wsmux.h"
@@ -521,12 +521,14 @@
 int
 spkr_modcmd(modcmd_t cmd, void *arg)
 {
+       int error = 0;
 #ifdef _MODULE
        devmajor_t bmajor, cmajor;
-       int error = 0;
+#endif
 
        switch(cmd) {
        case MODULE_CMD_INIT:
+#ifdef _MODULE
                bmajor = cmajor = -1;
                error = devsw_attach(spkr_cd.cd_name, NULL, &bmajor,
                    &spkr_cdevsw, &cmajor);
@@ -538,15 +540,18 @@
                if (error) {
                        devsw_detach(NULL, &spkr_cdevsw);
                }
+#endif
                break;
 
        case MODULE_CMD_FINI:
+#ifdef _MODULE
                devsw_detach(NULL, &spkr_cdevsw);
                error = config_fini_component(cfdriver_ioconf_spkr,
                    cfattach_ioconf_spkr, cfdata_ioconf_spkr);
                if (error)
                        devsw_attach(spkr_cd.cd_name, NULL, &bmajor,
                            &spkr_cdevsw, &cmajor);
+#endif
                break;
 
        default:
@@ -555,7 +560,4 @@
        }
 
        return error;
-#else
-       return 0;
-#endif
 }



Home | Main Index | Thread Index | Old Index