[RFC PATCH v4 21/38] NTB: ntb_transport: Export common helpers for modularization

Koichiro Den posted 38 patches 3 weeks, 1 day ago
[RFC PATCH v4 21/38] NTB: ntb_transport: Export common helpers for modularization
Posted by Koichiro Den 3 weeks, 1 day ago
Upcoming changes introduce multiple ntb_client drivers and transport
backends that share common list/queue helpers.

Export the shared helper functions and declare them in the internal
header so they can be reused by split-out code.

No functional change.

Signed-off-by: Koichiro Den <den@valinux.co.jp>
---
 drivers/ntb/ntb_transport_core.c     | 17 +++++++++--------
 drivers/ntb/ntb_transport_internal.h |  7 +++++++
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/drivers/ntb/ntb_transport_core.c b/drivers/ntb/ntb_transport_core.c
index 71f01fa0ff05..04a13fdce71c 100644
--- a/drivers/ntb/ntb_transport_core.c
+++ b/drivers/ntb/ntb_transport_core.c
@@ -371,8 +371,7 @@ static int ntb_qp_debugfs_stats_show(struct seq_file *s, void *v)
 }
 DEFINE_SHOW_ATTRIBUTE(ntb_qp_debugfs_stats);
 
-static void ntb_list_add(spinlock_t *lock, struct list_head *entry,
-			 struct list_head *list)
+void ntb_list_add(spinlock_t *lock, struct list_head *entry, struct list_head *list)
 {
 	unsigned long flags;
 
@@ -380,9 +379,9 @@ static void ntb_list_add(spinlock_t *lock, struct list_head *entry,
 	list_add_tail(entry, list);
 	spin_unlock_irqrestore(lock, flags);
 }
+EXPORT_SYMBOL_GPL(ntb_list_add);
 
-static struct ntb_queue_entry *ntb_list_rm(spinlock_t *lock,
-					   struct list_head *list)
+struct ntb_queue_entry *ntb_list_rm(spinlock_t *lock, struct list_head *list)
 {
 	struct ntb_queue_entry *entry;
 	unsigned long flags;
@@ -400,10 +399,10 @@ static struct ntb_queue_entry *ntb_list_rm(spinlock_t *lock,
 
 	return entry;
 }
+EXPORT_SYMBOL_GPL(ntb_list_rm);
 
-static struct ntb_queue_entry *ntb_list_mv(spinlock_t *lock,
-					   struct list_head *list,
-					   struct list_head *to_list)
+struct ntb_queue_entry *ntb_list_mv(spinlock_t *lock, struct list_head *list,
+				    struct list_head *to_list)
 {
 	struct ntb_queue_entry *entry;
 	unsigned long flags;
@@ -421,6 +420,7 @@ static struct ntb_queue_entry *ntb_list_mv(spinlock_t *lock,
 
 	return entry;
 }
+EXPORT_SYMBOL_GPL(ntb_list_mv);
 
 static int ntb_transport_setup_qp_mw(struct ntb_transport_ctx *nt,
 				     unsigned int qp_num)
@@ -820,10 +820,11 @@ static void ntb_qp_link_cleanup_work(struct work_struct *work)
 				      msecs_to_jiffies(NTB_LINK_DOWN_TIMEOUT));
 }
 
-static void ntb_qp_link_down(struct ntb_transport_qp *qp)
+void ntb_qp_link_down(struct ntb_transport_qp *qp)
 {
 	schedule_work(&qp->link_cleanup);
 }
+EXPORT_SYMBOL_GPL(ntb_qp_link_down);
 
 static void ntb_transport_link_cleanup(struct ntb_transport_ctx *nt)
 {
diff --git a/drivers/ntb/ntb_transport_internal.h b/drivers/ntb/ntb_transport_internal.h
index aff9b70671c6..6b45790cc88e 100644
--- a/drivers/ntb/ntb_transport_internal.h
+++ b/drivers/ntb/ntb_transport_internal.h
@@ -156,4 +156,11 @@ enum {
 	LINK_DOWN_FLAG = BIT(1),
 };
 
+void ntb_list_add(spinlock_t *lock, struct list_head *entry,
+		  struct list_head *list);
+struct ntb_queue_entry *ntb_list_rm(spinlock_t *lock, struct list_head *list);
+struct ntb_queue_entry *ntb_list_mv(spinlock_t *lock, struct list_head *list,
+				    struct list_head *to_list);
+void ntb_qp_link_down(struct ntb_transport_qp *qp);
+
 #endif /* _NTB_TRANSPORT_INTERNAL_H_ */
-- 
2.51.0