lkml.org 
[lkml]   [2008]   [Apr]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 06/10] Introduce ridr_get_new()
[PATCH 06/10]

This patch introduces the ridr_get_new() routine.

Signed-off-by: Nadia Derbey <Nadia.Derbey@bull.net>

---
include/linux/ridr.h | 1 +
lib/ridr.c | 27 +++++++++++++++++++++++++++
2 files changed, 28 insertions(+)

Index: linux-2.6.25-mm1/include/linux/ridr.h
===================================================================
--- linux-2.6.25-mm1.orig/include/linux/ridr.h 2008-04-29 14:03:35.000000000 +0200
+++ linux-2.6.25-mm1/include/linux/ridr.h 2008-04-29 14:16:09.000000000 +0200
@@ -44,6 +44,7 @@ struct ridr {
* This is what we export.
*/
int ridr_pre_get(struct ridr *, gfp_t);
+int ridr_get_new(struct ridr *, void *, int *);
int ridr_get_new_above(struct ridr *, void *, int, int *);
void ridr_init(struct ridr *);

Index: linux-2.6.25-mm1/lib/ridr.c
===================================================================
--- linux-2.6.25-mm1.orig/lib/ridr.c 2008-04-29 14:03:35.000000000 +0200
+++ linux-2.6.25-mm1/lib/ridr.c 2008-04-29 14:17:05.000000000 +0200
@@ -232,6 +232,33 @@ int ridr_get_new_above(struct ridr *idp,
}
EXPORT_SYMBOL(ridr_get_new_above);

+/**
+ * ridr_get_new - allocate new ridr entry
+ * @idp: ridr handle
+ * @ptr: pointer you want associated with the ide
+ * @id: pointer to the allocated handle
+ *
+ * This is the allocate id function. It should be called with any
+ * required locks.
+ *
+ * If memory is required, it will return -EAGAIN, you should unlock
+ * and go back to the ridr_pre_get() call. If the ridr is full, it will
+ * return -ENOSPC.
+ *
+ * @id returns a value in the range 0 ... 0x7fffffff
+ */
+int ridr_get_new(struct ridr *idp, void *ptr, int *id)
+{
+ int rv;
+
+ rv = ridr_get_new_above_int(idp, ptr, 0);
+ if (rv < 0)
+ return _idr_rc_to_errno(rv);
+ *id = rv;
+ return 0;
+}
+EXPORT_SYMBOL(ridr_get_new);
+
static void ridr_cache_ctor(struct kmem_cache *ridr_layer_cache,
void *ridr_layer)
{
--


\
 
 \ /
  Last update: 2008-04-29 16:43    [W:0.107 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site