prettify and add to all the modules that have it.

This commit is contained in:
christos 2014-11-12 03:14:00 +00:00
parent 93ead2dad3
commit 8ba1623f54
6 changed files with 58 additions and 34 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: drm_module.c,v 1.8 2014/09/14 20:08:21 riastradh Exp $ */
/* $NetBSD: drm_module.c,v 1.9 2014/11/12 03:14:00 christos Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: drm_module.c,v 1.8 2014/09/14 20:08:21 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: drm_module.c,v 1.9 2014/11/12 03:14:00 christos Exp $");
#include <sys/types.h>
#include <sys/conf.h>
@ -45,6 +45,7 @@ __KERNEL_RCSID(0, "$NetBSD: drm_module.c,v 1.8 2014/09/14 20:08:21 riastradh Exp
#include <linux/mutex.h>
#include <drm/drmP.h>
#include <drm/drm_sysctl.h>
/*
* XXX I2C stuff should be moved to a separate drmkms_i2c module.
@ -53,6 +54,8 @@ MODULE(MODULE_CLASS_DRIVER, drmkms, "iic,drmkms_linux");
struct mutex drm_global_mutex;
struct drm_sysctl_def drm_def = DRM_SYSCTL_INIT();
static int
drm_init(void)
{
@ -71,6 +74,7 @@ drm_init(void)
linux_mutex_init(&drm_global_mutex);
drm_connector_ida_init();
drm_global_init();
drm_sysctl_init(&drm_def);
return 0;
}
@ -91,7 +95,7 @@ drm_guarantee_initialized(void)
static void
drm_fini(void)
{
drm_sysctl_fini(&drm_def);
drm_global_release();
drm_connector_ida_destroy();
linux_mutex_destroy(&drm_global_mutex);

View File

@ -27,7 +27,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: drm_sysctl.c,v 1.1 2014/11/12 02:24:40 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: drm_sysctl.c,v 1.2 2014/11/12 03:14:00 christos Exp $");
#include <sys/param.h>
#include <sys/types.h>
@ -41,9 +41,10 @@ __KERNEL_RCSID(0, "$NetBSD: drm_sysctl.c,v 1.1 2014/11/12 02:24:40 christos Exp
#include <drm/drm_sysctl.h>
static const char *
drm_sysctl_get_description(const struct linux_module_param_info *p, const void **v)
drm_sysctl_get_description(const struct linux_module_param_info *p,
const struct drm_sysctl_def *def)
{
const void * const *b = v[0], * const *e = v[1];
const void * const *b = def->bd, * const *e = def->ed;
for (; b < e; b++) {
const struct linux_module_param_desc *d = *b;
@ -112,14 +113,14 @@ drm_sysctl_node(const char *name, const struct sysctlnode **node,
void
drm_sysctl_init(const void **v, struct sysctllog **log)
drm_sysctl_init(struct drm_sysctl_def *def)
{
const void * const *b = v[0], * const *e = v[1];
const void * const *b = def->bp, * const *e = def->ep;
const struct sysctlnode *rnode = NULL, *cnode;
const char *name = "drm2";
int error;
if ((error = sysctl_createv(log, 0, NULL, &rnode,
if ((error = sysctl_createv(&def->log, 0, NULL, &rnode,
CTLFLAG_PERMANENT, CTLTYPE_NODE, name,
SYSCTL_DESCR("DRM driver parameters"),
NULL, 0, NULL, 0, CTL_HW, CTL_CREATE, CTL_EOL)) != 0) {
@ -135,17 +136,18 @@ drm_sysctl_init(const void **v, struct sysctllog **log)
cnode = rnode;
for (n = copy; (nn = strchr(n, '.')) != NULL; n = nn) {
*nn++ = '\0';
if ((error = drm_sysctl_node(n, &cnode, log)) != 0) {
if ((error = drm_sysctl_node(n, &cnode, &def->log))
!= 0) {
aprint_error("sysctl_createv returned %d, "
"for %s ignoring\n", error, n);
continue;
}
}
if ((error = sysctl_createv(log, 0, &cnode,
if ((error = sysctl_createv(&def->log, 0, &cnode,
&cnode, p->mode == 0600 ? CTLFLAG_READWRITE : 0,
drm_sysctl_get_type(p), n,
SYSCTL_DESCR(drm_sysctl_get_description(p, v + 2)),
SYSCTL_DESCR(drm_sysctl_get_description(p, def)),
NULL, 0, p->ptr, 0, CTL_CREATE, CTL_EOL)) != 0)
aprint_error("sysctl_createv returned %d, "
"for %s ignoring\n", error, n);
@ -153,7 +155,7 @@ drm_sysctl_init(const void **v, struct sysctllog **log)
}
void
drm_sysctl_fini(struct sysctllog **log)
drm_sysctl_fini(struct drm_sysctl_def *def)
{
sysctl_teardown(log);
sysctl_teardown(&def->log);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: i915_module.c,v 1.4 2014/11/12 02:24:40 christos Exp $ */
/* $NetBSD: i915_module.c,v 1.5 2014/11/12 03:14:00 christos Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: i915_module.c,v 1.4 2014/11/12 02:24:40 christos Exp $");
__KERNEL_RCSID(0, "$NetBSD: i915_module.c,v 1.5 2014/11/12 03:14:00 christos Exp $");
#include <sys/types.h>
#include <sys/module.h>
@ -55,9 +55,7 @@ extern struct drm_driver *const i915_drm_driver;
extern const struct pci_device_id *const i915_device_ids;
extern const size_t i915_n_device_ids;
static struct sysctllog *i915_sysctllog;
__link_set_decl(linux_module_param_info, struct linux_module_param_info);
__link_set_decl(linux_module_param_desc, struct linux_module_param_desc);
struct drm_sysctl_def i915_def = DRM_SYSCTL_INIT();
static int
i915drmkms_init(void)
@ -79,13 +77,7 @@ i915drmkms_init(void)
error);
return error;
}
const void *v[] = {
__link_set_start(linux_module_param_info),
__link_set_end(linux_module_param_info),
__link_set_start(linux_module_param_desc),
__link_set_end(linux_module_param_desc),
};
drm_sysctl_init(v, &i915_sysctllog);
drm_sysctl_init(&i915_def);
return 0;
}
@ -108,7 +100,7 @@ i915drmkms_fini(void)
{
drm_pci_exit(i915_drm_driver, NULL);
drm_sysctl_fini(&i915_sysctllog);
drm_sysctl_fini(&i915_def);
}
static int

View File

@ -27,5 +27,22 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
struct sysctllog;
extern void drm_sysctl_init(const void **, struct sysctllog **);
extern void drm_sysctl_fini(struct sysctllog **);
struct drm_sysctl_def {
struct sysctllog *log;
const void *bp, *ep, *bd, *ed;
};
void drm_sysctl_init(struct drm_sysctl_def *);
void drm_sysctl_fini(struct drm_sysctl_def *);
#define DRM_SYSCTL_INIT() { \
NULL, \
__link_set_start(linux_module_param_info), \
__link_set_end(linux_module_param_info), \
__link_set_start(linux_module_param_desc), \
__link_set_end(linux_module_param_desc), \
};
__link_set_decl(linux_module_param_info, struct linux_module_param_info);
__link_set_decl(linux_module_param_desc, struct linux_module_param_desc);

View File

@ -1,4 +1,4 @@
/* $NetBSD: nouveau_module.c,v 1.2 2014/08/23 08:03:34 riastradh Exp $ */
/* $NetBSD: nouveau_module.c,v 1.3 2014/11/12 03:14:00 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nouveau_module.c,v 1.2 2014/08/23 08:03:34 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: nouveau_module.c,v 1.3 2014/11/12 03:14:00 christos Exp $");
#include <sys/types.h>
#include <sys/module.h>
@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: nouveau_module.c,v 1.2 2014/08/23 08:03:34 riastradh
#include <sys/systm.h>
#include <drm/drmP.h>
#include <drm/drm_sysctl.h>
#include <core/object.h>
#include <engine/device.h>
@ -50,6 +51,8 @@ MODULE(MODULE_CLASS_DRIVER, nouveau, "drmkms,drmkms_pci"); /* XXX drmkms_i2c, dr
#include "ioconf.c"
#endif
struct drm_sysctl_def nouveau_def = DRM_SYSCTL_INIT();
extern struct drm_driver *const nouveau_drm_driver; /* XXX */
static int
@ -73,6 +76,7 @@ nouveau_init(void)
#if 0 /* XXX nouveau acpi */
nouveau_register_dsm_handler();
#endif
drm_sysctl_init(&nouveau_def);
return 0;
}
@ -94,6 +98,7 @@ static void
nouveau_fini(void)
{
drm_sysctl_fini(&nouveau_def);
#if 0 /* XXX nouveau acpi */
nouveau_unregister_dsm_handler();
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: radeon_module.c,v 1.2 2014/07/26 21:12:43 riastradh Exp $ */
/* $NetBSD: radeon_module.c,v 1.3 2014/11/12 03:14:00 christos Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: radeon_module.c,v 1.2 2014/07/26 21:12:43 riastradh Exp $");
__KERNEL_RCSID(0, "$NetBSD: radeon_module.c,v 1.3 2014/11/12 03:14:00 christos Exp $");
#include <sys/types.h>
#include <sys/module.h>
@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: radeon_module.c,v 1.2 2014/07/26 21:12:43 riastradh
#include <sys/systm.h>
#include <drm/drmP.h>
#include <drm/drm_sysctl.h>
#include "radeon_drv.h"
@ -53,6 +54,8 @@ MODULE(MODULE_CLASS_DRIVER, radeon, "drmkms,drmkms_pci"); /* XXX drmkms_i2c, drm
extern struct drm_driver *const radeon_drm_driver;
extern int radeon_max_kms_ioctl;
struct drm_sysctl_def radeon_def = DRM_SYSCTL_INIT();
static int
radeon_init(void)
{
@ -72,6 +75,7 @@ radeon_init(void)
error);
return error;
}
drm_sysctl_init(&radeon_def);
return 0;
}
@ -92,7 +96,7 @@ radeon_guarantee_initialized(void)
static void
radeon_fini(void)
{
drm_sysctl_fini(&radeon_def);
drm_pci_exit(radeon_drm_driver, NULL);
}