sched/wait: Add init_wait_func() helper

Add an init_wait_func() helper and implement init_wait() in terms of
init_wait_func().  Use the new helper wherever init_wait(wait) is
followed by replacing wait.func.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
diff --git a/fs/dax.c b/fs/dax.c
index cd03485..de11f8d 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -226,8 +226,7 @@ static void *get_unlocked_entry(struct xa_state *xas, unsigned int order)
 	struct wait_exceptional_entry_queue ewait;
 	wait_queue_head_t *wq;
 
-	init_wait(&ewait.wait);
-	ewait.wait.func = wake_exceptional_entry_func;
+	init_wait_func(&ewait.wait, wake_exceptional_entry_func);
 
 	for (;;) {
 		entry = xas_find_conflict(xas);
@@ -259,8 +258,7 @@ static void wait_entry_unlocked(struct xa_state *xas, void *entry)
 	struct wait_exceptional_entry_queue ewait;
 	wait_queue_head_t *wq;
 
-	init_wait(&ewait.wait);
-	ewait.wait.func = wake_exceptional_entry_func;
+	init_wait_func(&ewait.wait, wake_exceptional_entry_func);
 
 	wq = dax_entry_waitqueue(xas, entry, &ewait.key);
 	/*
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c
index b7ab843..66a5eeb 100644
--- a/fs/gfs2/glock.c
+++ b/fs/gfs2/glock.c
@@ -1111,8 +1111,7 @@ static struct gfs2_glock *find_insert_glock(struct lm_lockname *name,
 	struct gfs2_glock *gl;
 
 	wait.name = name;
-	init_wait(&wait.wait);
-	wait.wait.func = glock_wake_function;
+	init_wait_func(&wait.wait, glock_wake_function);
 
 again:
 	prepare_to_wait(wq, &wait.wait, TASK_UNINTERRUPTIBLE);
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index ee3bc79..b45d645 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -7313,8 +7313,7 @@ nfs4_retry_setlk(struct nfs4_state *state, int cmd, struct file_lock *request)
 	if (!test_bit(NFS_STATE_MAY_NOTIFY_LOCK, &state->flags))
 		return nfs4_retry_setlk_simple(state, cmd, request);
 
-	init_wait(&waiter.wait);
-	waiter.wait.func = nfs4_wake_lock_waiter;
+	init_wait_func(&waiter.wait, nfs4_wake_lock_waiter);
 	add_wait_queue(q, &waiter.wait);
 
 	do {
diff --git a/include/linux/wait.h b/include/linux/wait.h
index 851e07d..481ba52 100644
--- a/include/linux/wait.h
+++ b/include/linux/wait.h
@@ -1178,14 +1178,16 @@ int autoremove_wake_function(struct wait_queue_entry *wq_entry, unsigned mode, i
 
 #define DEFINE_WAIT(name) DEFINE_WAIT_FUNC(name, autoremove_wake_function)
 
-#define init_wait(wait)								\
+#define init_wait_func(wait, function)						\
 	do {									\
 		(wait)->private = current;					\
-		(wait)->func = autoremove_wake_function;			\
+		(wait)->func = function;					\
 		INIT_LIST_HEAD(&(wait)->entry);					\
 		(wait)->flags = 0;						\
 	} while (0)
 
+#define init_wait(wait) init_wait_func(wait, autoremove_wake_function);
+
 typedef int (*task_call_f)(struct task_struct *p, void *arg);
 extern int task_call_func(struct task_struct *p, task_call_f func, void *arg);
 
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 33f1106..bac668f 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -3156,8 +3156,7 @@ static bool __cancel_work_timer(struct work_struct *work, bool is_dwork)
 		if (unlikely(ret == -ENOENT)) {
 			struct cwt_wait cwait;
 
-			init_wait(&cwait.wait);
-			cwait.wait.func = cwt_wakefn;
+			init_wait_func(&cwait.wait, cwt_wakefn);
 			cwait.work = work;
 
 			prepare_to_wait_exclusive(&cancel_waitq, &cwait.wait,