PERFORCE change 189688 for review
John Baldwin
jhb at FreeBSD.org
Mon Mar 7 22:30:56 UTC 2011
http://p4web.freebsd.org/@@189688?ac=10
Change 189688 by jhb at jhb_jhbbsd on 2011/03/07 22:30:28
Flesh out and compile.
Affected files ...
.. //depot/projects/pci/sys/modules/rman/rman.c#2 edit
Differences ...
==== //depot/projects/pci/sys/modules/rman/rman.c#2 (text+ko) ====
@@ -2,6 +2,8 @@
* Regression tests for rman_adjust_resource().
*/
+#include <sys/param.h>
+#include <sys/kernel.h>
#include <sys/module.h>
#include <sys/rman.h>
#include <sys/sysctl.h>
@@ -24,6 +26,8 @@
SYSCTL_ULONG(_debug_rman, OID_AUTO, count, CTLFLAG_RW, &count_value, 0,
"count parameter");
+static void unload(void);
+
static int
sysctl_rman_alloc(SYSCTL_HANDLER_ARGS)
{
@@ -47,6 +51,45 @@
sysctl_rman_alloc, "I", "allocate a resource");
static int
+sysctl_rman_adjust(SYSCTL_HANDLER_ARGS)
+{
+ int error, i = 0;
+
+ error = sysctl_handle_int(oidp, &i, sizeof(i), req);
+ if (error || req->newptr == NULL || i == 0)
+ return (error);
+ if (r == NULL)
+ return (EINVAL);
+ error = rman_adjust_resource(r, start_value, end_value);
+ if (error)
+ printf("Failed to adjust resource\n");
+ else
+ printf("Adjusted to (%lu, %lu)\n", rman_get_start(r),
+ rman_get_end(r));
+ return (error);
+}
+SYSCTL_PROC(_debug_rman, OID_AUTO, adjust, CTLTYPE_INT | CTLFLAG_RW, 0, 0,
+ sysctl_rman_adjust, "I", "adjust a resource");
+
+static int
+sysctl_rman_release(SYSCTL_HANDLER_ARGS)
+{
+ int error, i = 0;
+
+ error = sysctl_handle_int(oidp, &i, sizeof(i), req);
+ if (error || req->newptr == NULL || i == 0)
+ return (error);
+ if (r == NULL)
+ return (EINVAL);
+ error = rman_release_resource(r);
+ if (error == 0)
+ r = NULL;
+ return (error);
+}
+SYSCTL_PROC(_debug_rman, OID_AUTO, release, CTLTYPE_INT | CTLFLAG_RW, 0, 0,
+ sysctl_rman_release, "I", "release a resource");
+
+static int
load(void)
{
int error;
@@ -80,15 +123,6 @@
printf("Failed to destroy rman: %d\n", error);
}
-static void
-run_rman_tests(void)
-{
- error = rman_adjust_resource(r, 10, 15);
- if (error != EINVAL) {
- printf("Hmm, adjust to (10, 15) should have failed\n");
- kdb_enter(KDB_W
-}
-
static int
mod_event(struct module *module, int cmd, void *arg)
{
More information about the p4-projects
mailing list