summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2010-10-10 19:57:04 +0200
committerPatrick McHardy <kaber@trash.net>2010-10-10 19:57:04 +0200
commit00cc8509b8c9befad741155dcb340f6ffe7a61d1 (patch)
tree5e2e5f6fda13a6c42919c5455a5510769e4a86dd
parentce4da270718d934ae1580c1c53e6d8cef5052494 (diff)
mm: add function to get an existing or allocate a new MM endpoint
Signed-off-by: Patrick McHardy <kaber@trash.net>
-rw-r--r--include/dect/mm.h2
-rw-r--r--src/mm.c14
2 files changed, 16 insertions, 0 deletions
diff --git a/include/dect/mm.h b/include/dect/mm.h
index 359f417..8770714 100644
--- a/include/dect/mm.h
+++ b/include/dect/mm.h
@@ -232,6 +232,8 @@ struct dect_mm_endpoint;
extern struct dect_mm_endpoint *dect_mm_endpoint_alloc(struct dect_handle *dh,
const struct dect_ipui *ipui);
+extern struct dect_mm_endpoint *dect_mm_endpoint_get(struct dect_handle *dh,
+ const struct dect_ipui *ipui);
extern void dect_mm_endpoint_destroy(struct dect_handle *dh,
struct dect_mm_endpoint *mme);
extern void *dect_mm_priv(struct dect_mm_endpoint *mme);
diff --git a/src/mm.c b/src/mm.c
index 396105d..dd70322 100644
--- a/src/mm.c
+++ b/src/mm.c
@@ -522,6 +522,20 @@ dect_mm_endpoint_get_by_link(const struct dect_handle *dh,
return NULL;
}
+struct dect_mm_endpoint *dect_mm_endpoint_get(struct dect_handle *dh,
+ const struct dect_ipui *ipui)
+{
+ struct dect_mm_endpoint *mme;
+
+ list_for_each_entry(mme, &dh->mme_list, list) {
+ if (!dect_ipui_cmp(&mme->link->ipui, ipui))
+ return mme;
+ }
+
+ return dect_mm_endpoint_alloc(dh, ipui);
+}
+EXPORT_SYMBOL(dect_mm_endpoint_get);
+
struct dect_mm_endpoint *dect_mm_endpoint_alloc(struct dect_handle *dh,
const struct dect_ipui *ipui)
{