Update handling of sysctl stuff when built as modules

This commit is contained in:
pgoyette 2012-05-31 16:09:33 +00:00
parent 5f373d7584
commit 865357bdaf
3 changed files with 26 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: dbcool.c,v 1.36 2012/04/28 17:27:08 wiz Exp $ */
/* $NetBSD: dbcool.c,v 1.37 2012/05/31 16:09:33 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -50,7 +50,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.36 2012/04/28 17:27:08 wiz Exp $");
__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.37 2012/05/31 16:09:33 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1115,7 +1115,11 @@ dbcool_read_volt(struct dbcool_softc *sc, uint8_t reg, int nom_idx, bool extres)
SYSCTL_SETUP(sysctl_dbcoolsetup, "sysctl dBCool subtree setup")
{
sysctl_createv(clog, 0, NULL, NULL,
#ifdef _MODULE
0,
#else
CTLFLAG_PERMANENT,
#endif
CTLTYPE_NODE, "hw", NULL,
NULL, 0, NULL, 0,
CTL_HW, CTL_EOL);
@ -2178,18 +2182,23 @@ static int
dbcool_modcmd(modcmd_t cmd, void *opaque)
{
int error = 0;
#ifdef _MODULE
static struct sysctllog *dbcool_sysctl_clog;
#endif
switch (cmd) {
case MODULE_CMD_INIT:
#ifdef _MODULE
error = config_init_component(cfdriver_ioconf_dbcool,
cfattach_ioconf_dbcool, cfdata_ioconf_dbcool);
sysctl_dbcoolsetup(&dbcool_sysctl_clog);
#endif
return error;
case MODULE_CMD_FINI:
#ifdef _MODULE
error = config_fini_component(cfdriver_ioconf_dbcool,
cfattach_ioconf_dbcool, cfdata_ioconf_dbcool);
sysctl_teardown(&dbcool_sysctl_clog);
#endif
return error;
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: spdmem_i2c.c,v 1.4 2012/01/22 10:36:52 nakayama Exp $ */
/* $NetBSD: spdmem_i2c.c,v 1.5 2012/05/31 16:09:33 pgoyette Exp $ */
/*
* Copyright (c) 2007 Nicolas Joly
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: spdmem_i2c.c,v 1.4 2012/01/22 10:36:52 nakayama Exp $");
__KERNEL_RCSID(0, "$NetBSD: spdmem_i2c.c,v 1.5 2012/05/31 16:09:33 pgoyette Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -145,18 +145,23 @@ static int
spdmem_modcmd(modcmd_t cmd, void *opaque)
{
int error = 0;
#ifdef _MODULE
static struct sysctllog *spdmem_sysctl_clog;
#endif
switch (cmd) {
case MODULE_CMD_INIT:
#ifdef _MODULE
error = config_init_component(cfdriver_ioconf_spdmem,
cfattach_ioconf_spdmem, cfdata_ioconf_spdmem);
sysctl_spdmem_setup(&spdmem_sysctl_clog);
#endif
return error;
case MODULE_CMD_FINI:
#ifdef _MODULE
error = config_fini_component(cfdriver_ioconf_spdmem,
cfattach_ioconf_spdmem, cfdata_ioconf_spdmem);
sysctl_teardown(&spdmem_sysctl_clog);
#endif
return error;
default:

View File

@ -1,4 +1,4 @@
/* $NetBSD: spdmem.c,v 1.5 2011/08/19 09:46:10 wiz Exp $ */
/* $NetBSD: spdmem.c,v 1.6 2012/05/31 16:09:34 pgoyette Exp $ */
/*
* Copyright (c) 2007 Nicolas Joly
@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: spdmem.c,v 1.5 2011/08/19 09:46:10 wiz Exp $");
__KERNEL_RCSID(0, "$NetBSD: spdmem.c,v 1.6 2012/05/31 16:09:34 pgoyette Exp $");
#include <sys/param.h>
#include <sys/device.h>
@ -276,9 +276,6 @@ spdmem_common_attach(struct spdmem_softc *sc, device_t self)
* Setup our sysctl subtree, hw.spdmemN
*/
sc->sc_sysctl_log = NULL;
#ifdef _MODULE
sysctl_spdmem_setup(&sc->sc_sysctl_log);
#endif
if (hw_node != CTL_EOL)
sysctl_createv(&sc->sc_sysctl_log, 0, NULL, &node,
0, CTLTYPE_NODE,
@ -401,7 +398,12 @@ SYSCTL_SETUP(sysctl_spdmem_setup, "sysctl hw.spdmem subtree setup")
{
const struct sysctlnode *node;
if (sysctl_createv(clog, 0, NULL, &node, CTLFLAG_PERMANENT,
if (sysctl_createv(clog, 0, NULL, &node,
#ifdef _MODULE
0,
#else
CTLFLAG_PERMANENT,
#endif
CTLTYPE_NODE, "hw", NULL, NULL, 0, NULL, 0,
CTL_HW, CTL_EOL) != 0)
return;