[Suspend2][ 2/9] [Suspend2] Extent allocation routines.

Nigel Cunningham
2006-06-26T16:55:06Z

Add routines to get and put extents.

Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

kernel/power/extent.c | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/kernel/power/extent.c b/kernel/power/extent.c
index 4027bb1..2fb6a23 100644
--- a/kernel/power/extent.c
+++ b/kernel/power/extent.c
@@ -17,3 +17,33 @@

int suspend_extents_allocated = 0;

+/* suspend_get_extent
+ *
+ * Returns a free extent. May fail, returning NULL instead.
+ */
+static struct extent *suspend_get_extent(void)
+{
+ struct extent *result;
+
+ if (!(result = kmalloc(sizeof(struct extent), GFP_ATOMIC)))
+ return NULL;
+
+ suspend_extents_allocated++;
+ result->minimum = result->maximum = 0;
+ result->next = NULL;
+
+ return result;
+}
+
+/* suspend_put_extent.
+ *
+ * Frees an extent. Assumes unlinking is done by the caller.
+ */
+void suspend_put_extent(struct extent *extent)
+{
+ BUG_ON(!extent);
+
+ kfree(extent);
+ suspend_extents_allocated--;
+}
+

--
Nigel Cunningham nigel at suspend2 dot net