patch-2.3.49 linux/kernel/resource.c

Next file: linux/kernel/sched.c
Previous file: linux/kernel/ksyms.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.48/linux/kernel/resource.c linux/kernel/resource.c
@@ -92,17 +92,7 @@
 	}
 }
 
-int request_resource(struct resource *root, struct resource *new)
-{
-	struct resource *conflict;
-
-	write_lock(&resource_lock);
-	conflict = __request_resource(root, new);
-	write_unlock(&resource_lock);
-	return conflict ? -EBUSY : 0;
-}
-
-int release_resource(struct resource *old)
+static int __release_resource(struct resource *old)
 {
 	struct resource *tmp, **p;
 
@@ -119,6 +109,40 @@
 		p = &tmp->sibling;
 	}
 	return -EINVAL;
+}
+
+int request_resource(struct resource *root, struct resource *new)
+{
+	struct resource *conflict;
+
+	write_lock(&resource_lock);
+	conflict = __request_resource(root, new);
+	write_unlock(&resource_lock);
+	return conflict ? -EBUSY : 0;
+}
+
+int release_resource(struct resource *old)
+{
+	int retval;
+
+	write_lock(&resource_lock);
+	retval = __release_resource(old);
+	write_unlock(&resource_lock);
+	return retval;
+}
+
+int check_resource(struct resource *root, unsigned long start, unsigned long len)
+{
+	struct resource *conflict, tmp;
+
+	tmp.start = start;
+	tmp.end = start + len - 1;
+	write_lock(&resource_lock);
+	conflict = __request_resource(root, &tmp);
+	if (!conflict)
+		__release_resource(&tmp);
+	write_unlock(&resource_lock);
+	return conflict ? -EBUSY : 0;
 }
 
 /*

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)