diff mbox

[v7,8/9] lib/dlock-list: Export symbols and add warnings

Message ID 1508268996-8959-1-git-send-email-longman@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Waiman Long Oct. 17, 2017, 7:36 p.m. UTC
The EXPORT_SYMBOL() macro is now used in lib/dlock-list.c to enable
kernel modules to use dlock-list. Some warning messages are also added.

Signed-off-by: Waiman Long <longman@redhat.com>
---
 lib/dlock-list.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
diff mbox

Patch

diff --git a/lib/dlock-list.c b/lib/dlock-list.c
index 4fded20..6ce5c7193 100644
--- a/lib/dlock-list.c
+++ b/lib/dlock-list.c
@@ -132,6 +132,7 @@  int alloc_dlock_list_heads(struct dlock_list_heads *dlist, int irqsafe)
 	}
 	return 0;
 }
+EXPORT_SYMBOL(alloc_dlock_list_heads);
 
 /**
  * free_dlock_list_heads - Free all the heads entries of the dlock list
@@ -145,6 +146,7 @@  void free_dlock_list_heads(struct dlock_list_heads *dlist)
 	kfree(dlist->heads);
 	dlist->heads = NULL;
 }
+EXPORT_SYMBOL(free_dlock_list_heads);
 
 /**
  * dlock_lists_empty - Check if all the dlock lists are empty
@@ -159,11 +161,15 @@  bool dlock_lists_empty(struct dlock_list_heads *dlist)
 {
 	int idx;
 
+	/* Shouldn't be called before nr_dlock_lists is initialized */
+	WARN_ON_ONCE(!nr_dlock_lists);
+
 	for (idx = 0; idx < nr_dlock_lists; idx++)
 		if (!list_empty(&dlist->heads[idx].list))
 			return false;
 	return true;
 }
+EXPORT_SYMBOL(dlock_lists_empty);
 
 /**
  * dlock_list_hash - Hash the given context to a particular list
@@ -187,6 +193,7 @@  struct dlock_list_head *dlock_list_hash(struct dlock_list_heads *dlist,
 				% nr_dlock_lists;
 	return &dlist->heads[hash];
 }
+EXPORT_SYMBOL(dlock_list_hash);
 
 /**
  * dlock_list_add - Add a node to a particular head of dlock list
@@ -210,6 +217,7 @@  void dlock_list_add(struct dlock_list_node *node,
 		spin_unlock(&head->lock);
 	}
 }
+EXPORT_SYMBOL(dlock_list_add);
 
 /**
  * dlock_lists_add - Adds a node to the given dlock list
@@ -226,6 +234,7 @@  void dlock_lists_add(struct dlock_list_node *node,
 
 	dlock_list_add(node, head);
 }
+EXPORT_SYMBOL(dlock_lists_add);
 
 /**
  * dlock_lists_del - Delete a node from a dlock list
@@ -273,6 +282,7 @@  void dlock_lists_del(struct dlock_list_node *node)
 			spin_unlock(&head->lock);
 	} while (retry);
 }
+EXPORT_SYMBOL(dlock_lists_del);
 
 /**
  * __dlock_list_next_list: Find the first entry of the next available list
@@ -287,6 +297,9 @@  struct dlock_list_node *__dlock_list_next_list(struct dlock_list_iter *iter)
 	struct dlock_list_node *next;
 	struct dlock_list_head *head;
 
+	/* Shouldn't be called before nr_dlock_lists is initialized */
+	WARN_ON_ONCE(!nr_dlock_lists);
+
 restart:
 	if (iter->entry) {
 		dlock_list_unlock(iter);
@@ -320,3 +333,4 @@  struct dlock_list_node *__dlock_list_next_list(struct dlock_list_iter *iter)
 
 	return next;
 }
+EXPORT_SYMBOL(__dlock_list_next_list);