asoc: update wakeup_source API

wakeup_source_init and wakeup_source_trash are removed
in new kernel. Update these two APIs to wakeup_source_register
and wakeup_source_unregister.

Change-Id: If628aac4f5391b483bb20e66b49cdf47618462c9
Signed-off-by: Meng Wang <mengw@codeaurora.org>
diff --git a/dsp/usf.c b/dsp/usf.c
index e408c7d..d0f6ed3 100644
--- a/dsp/usf.c
+++ b/dsp/usf.c
@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
- * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2011-2017, 2020, The Linux Foundation. All rights reserved.
  */
 
 #include <linux/compat.h>
@@ -15,6 +15,7 @@
 #include <linux/time.h>
 #include <linux/kmemleak.h>
 #include <linux/mutex.h>
+#include <linux/version.h>
 #include <dsp/apr_audio-v2.h>
 #include "q6usm.h"
 #include "usf.h"
@@ -173,7 +174,7 @@
 /* The opened devices container */
 static atomic_t s_opened_devs[MAX_DEVS_NUMBER];
 
-static struct wakeup_source usf_wakeup_source;
+static struct wakeup_source *usf_wakeup_source;
 
 #define USF_NAME_PREFIX "usf_"
 #define USF_NAME_PREFIX_SIZE 4
@@ -442,7 +443,7 @@
 	case Q6USM_EVENT_READ_DONE:
 		pr_debug("%s: acquiring %d msec wake lock\n", __func__,
 				STAY_AWAKE_AFTER_READ_MSECS);
-		__pm_wakeup_event(&usf_wakeup_source,
+		__pm_wakeup_event(usf_wakeup_source,
 				  STAY_AWAKE_AFTER_READ_MSECS);
 		if (token == USM_WRONG_TOKEN)
 			usf_xx->usf_state = USF_ERROR_STATE;
@@ -2369,8 +2370,11 @@
 	usf = kzalloc(sizeof(struct usf_type), GFP_KERNEL);
 	if (usf == NULL)
 		return -ENOMEM;
-
-	wakeup_source_init(&usf_wakeup_source, "usf");
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 110))
+	usf_wakeup_source = wakeup_source_register(NULL, "usf");
+#else
+	usf_wakeup_source = wakeup_source_register("usf");
+#endif
 
 	file->private_data = usf;
 	usf->dev_ind = dev_ind;
@@ -2401,7 +2405,7 @@
 
 	atomic_set(&s_opened_devs[usf->dev_ind], 0);
 
-	wakeup_source_trash(&usf_wakeup_source);
+	wakeup_source_unregister(usf_wakeup_source);
 	mutex_unlock(&usf->mutex);
 	mutex_destroy(&usf->mutex);
 	kfree(usf);