From: "Henri Häkkinen" <henuxd@gmail.com>
To: gregkh@suse.de, ossama.othman@intel.com, henuxd@gmail.com,
alan@linux.intel.com, mattij.lammi@gmail.com,
randy.dunlap@oracle.com
Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH 1/2] Staging: memrar: Moved memrar_allocator struct to memrar_allocator.c
Date: Thu, 24 Jun 2010 10:09:45 +0300 [thread overview]
Message-ID: <1277363386-4817-1-git-send-email-henuxd@gmail.com> (raw)
Forward declared memrar_allocator structure in memrar_allocator.h and
moved the definition to memrar_allocator.c. Implemented
memrar_allocator_capacity() and memrar_allocator_largest_free_area().
Signed-off-by: Henri Häkkinen <henuxd@gmail.com>
---
drivers/staging/memrar/memrar_allocator.c | 43 ++++++++++++++++++++++++++
drivers/staging/memrar/memrar_allocator.h | 48 ++++++++++++-----------------
2 files changed, 63 insertions(+), 28 deletions(-)
diff --git a/drivers/staging/memrar/memrar_allocator.c b/drivers/staging/memrar/memrar_allocator.c
index a4f8c58..cb74e3c 100644
--- a/drivers/staging/memrar/memrar_allocator.c
+++ b/drivers/staging/memrar/memrar_allocator.c
@@ -41,6 +41,36 @@
#include <linux/kernel.h>
+/**
+ * struct memrar_allocator - encapsulation of the memory allocator state
+ * @lock: Lock used to synchronize access to the memory
+ * allocator state.
+ * @base: Base (start) address of the allocator memory
+ * space.
+ * @capacity: Size of the allocator memory space in bytes.
+ * @block_size: The size in bytes of individual blocks within
+ * the allocator memory space.
+ * @largest_free_area: Largest free area of memory in the allocator
+ * in bytes.
+ * @allocated_list: List of allocated memory block address
+ * ranges.
+ * @free_list: List of free address ranges.
+ *
+ * This structure contains all memory allocator state, including the
+ * base address, capacity, free list, lock, etc.
+ */
+struct memrar_allocator {
+/* private: internal use only */
+ struct mutex lock;
+ unsigned long base;
+ size_t capacity;
+ size_t block_size;
+ size_t largest_free_area;
+ struct memrar_address_ranges allocated_list;
+ struct memrar_address_ranges free_list;
+};
+
+
struct memrar_allocator *memrar_create_allocator(unsigned long base,
size_t capacity,
size_t block_size)
@@ -423,6 +453,19 @@ exit_memrar_free:
return 0;
}
+size_t memrar_allocator_largest_free_area(struct memrar_allocator *allocator)
+{
+ if (allocator == NULL)
+ return 0;
+ return allocator->largest_free_area;
+}
+
+size_t memrar_allocator_capacity(struct memrar_allocator *allocator)
+{
+ if (allocator == NULL)
+ return 0;
+ return allocator->capacity;
+}
/*
diff --git a/drivers/staging/memrar/memrar_allocator.h b/drivers/staging/memrar/memrar_allocator.h
index 0b80dea..49dbc6e 100644
--- a/drivers/staging/memrar/memrar_allocator.h
+++ b/drivers/staging/memrar/memrar_allocator.h
@@ -50,34 +50,10 @@ struct memrar_address_ranges {
struct memrar_address_range range;
};
-/**
- * struct memrar_allocator - encapsulation of the memory allocator state
- * @lock: Lock used to synchronize access to the memory
- * allocator state.
- * @base: Base (start) address of the allocator memory
- * space.
- * @capacity: Size of the allocator memory space in bytes.
- * @block_size: The size in bytes of individual blocks within
- * the allocator memory space.
- * @largest_free_area: Largest free area of memory in the allocator
- * in bytes.
- * @allocated_list: List of allocated memory block address
- * ranges.
- * @free_list: List of free address ranges.
- *
- * This structure contains all memory allocator state, including the
- * base address, capacity, free list, lock, etc.
- */
-struct memrar_allocator {
-/* private: internal use only */
- struct mutex lock;
- unsigned long base;
- size_t capacity;
- size_t block_size;
- size_t largest_free_area;
- struct memrar_address_ranges allocated_list;
- struct memrar_address_ranges free_list;
-};
+
+/* Forward declaration */
+struct memrar_allocator;
+
/**
* memrar_create_allocator() - create a memory allocator
@@ -139,6 +115,22 @@ unsigned long memrar_allocator_alloc(struct memrar_allocator *allocator,
long memrar_allocator_free(struct memrar_allocator *allocator,
unsigned long address);
+/**
+ * memrar_allocator_largest_area() - largest free area of memory
+ * @allocator: The allocator instance the free area is returned for.
+ *
+ * Return the largest free area of memory in the allocator in bytes.
+ */
+size_t memrar_allocator_largest_free_area(struct memrar_allocator *allocator);
+
+/**
+ * memrar_allocator_capacity() - size of the allocator memory
+ * @allocator: The allocator instance the capicity is returned for.
+ *
+ * Return the size of the allocator memory space in bytes.
+ */
+size_t memrar_allocator_capacity(struct memrar_allocator *allocator);
+
#endif /* MEMRAR_ALLOCATOR_H */
--
1.7.1
next reply other threads:[~2010-06-24 7:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-24 7:09 Henri Häkkinen [this message]
2010-06-24 7:09 ` [PATCH 2/2] Staging: memrar: Fixed memrar_handler.c Henri Häkkinen
2010-06-24 9:09 ` Alan Cox
2010-06-24 17:36 ` Othman, Ossama
2010-06-24 9:16 ` [PATCH 1/2] Staging: memrar: Moved memrar_allocator struct to memrar_allocator.c Alan Cox
2010-06-24 9:27 ` Henri Häkkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1277363386-4817-1-git-send-email-henuxd@gmail.com \
--to=henuxd@gmail.com \
--cc=alan@linux.intel.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=mattij.lammi@gmail.com \
--cc=ossama.othman@intel.com \
--cc=randy.dunlap@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).