From aa06ac6d0fad9ee774db5dfd60cc82d98c7f3d4d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Wed, 2 Dec 2020 12:11:32 +0100
Subject: [PATCH 025/463] 8723cs: Resume wifi in a workqueue

Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
 drivers/staging/rtl8723cs/Makefile           | 1 +
 drivers/staging/rtl8723cs/core/rtw_pwrctrl.c | 7 +++++--
 drivers/staging/rtl8723cs/include/drv_conf.h | 7 -------
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/rtl8723cs/Makefile b/drivers/staging/rtl8723cs/Makefile
index 0fe39a873866b..60c1c864db42f 100644
--- a/drivers/staging/rtl8723cs/Makefile
+++ b/drivers/staging/rtl8723cs/Makefile
@@ -1333,6 +1333,7 @@ ifeq ($(CONFIG_PLATFORM_I386_PC), y)
 EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
 EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211 -DRTW_USE_CFG80211_STA_EVENT
 EXTRA_CFLAGS += -DCONFIG_RTW_80211R
+EXTRA_CFLAGS += -DCONFIG_RESUME_IN_WORKQUEUE
 
 SUBARCH := $(shell uname -m | sed -e s/i.86/i386/)
 ARCH ?= $(SUBARCH)
diff --git a/drivers/staging/rtl8723cs/core/rtw_pwrctrl.c b/drivers/staging/rtl8723cs/core/rtw_pwrctrl.c
index 03dfaf9a6ed75..5c519a5d39bb7 100644
--- a/drivers/staging/rtl8723cs/core/rtw_pwrctrl.c
+++ b/drivers/staging/rtl8723cs/core/rtw_pwrctrl.c
@@ -2468,20 +2468,23 @@ static void resume_workitem_callback(struct work_struct *work)
 	struct pwrctrl_priv *pwrpriv = container_of(work, struct pwrctrl_priv, resume_work);
 	struct dvobj_priv *dvobj = pwrctl_to_dvobj(pwrpriv);
 	_adapter *adapter = dvobj_get_primary_adapter(dvobj);
+        PSDIO_DATA psdio = &dvobj->intf_data;
 
 	RTW_INFO("%s\n", __FUNCTION__);
 
 	rtw_resume_process(adapter);
 
-	rtw_resume_unlock_suspend();
+	pm_relax(&psdio->func->dev);
 }
 
 void rtw_resume_in_workqueue(struct pwrctrl_priv *pwrpriv)
 {
 	/* accquire system's suspend lock preventing from falliing asleep while resume in workqueue */
 	/* rtw_lock_suspend(); */
+	struct dvobj_priv *dvobj = pwrctl_to_dvobj(pwrpriv);
+        PSDIO_DATA psdio = &dvobj->intf_data;
 
-	rtw_resume_lock_suspend();
+	pm_stay_awake(&psdio->func->dev);
 
 #if 1
 	queue_work(pwrpriv->rtw_workqueue, &pwrpriv->resume_work);
diff --git a/drivers/staging/rtl8723cs/include/drv_conf.h b/drivers/staging/rtl8723cs/include/drv_conf.h
index e8a8a7a8819e5..5b528680380fd 100644
--- a/drivers/staging/rtl8723cs/include/drv_conf.h
+++ b/drivers/staging/rtl8723cs/include/drv_conf.h
@@ -166,13 +166,6 @@
 #endif
 */
 
-#ifdef CONFIG_RESUME_IN_WORKQUEUE /* this can be removed, because there is no case for this... */
-	#if !defined(CONFIG_WAKELOCK) && !defined(CONFIG_ANDROID_POWER)
-		#error "enable CONFIG_RESUME_IN_WORKQUEUE without CONFIG_WAKELOCK or CONFIG_ANDROID_POWER will suffer from the danger of wifi's unfunctionality..."
-		#error "If you still want to enable CONFIG_RESUME_IN_WORKQUEUE in this case, mask this preprossor checking and GOOD LUCK..."
-	#endif
-#endif
-
 /* About USB VENDOR REQ */
 #if defined(CONFIG_USB_VENDOR_REQ_BUFFER_PREALLOC) && !defined(CONFIG_USB_VENDOR_REQ_MUTEX)
 	#warning "define CONFIG_USB_VENDOR_REQ_MUTEX for CONFIG_USB_VENDOR_REQ_BUFFER_PREALLOC automatically"
-- 
2.46.0

