qcacmn: Do not call sleeping API from atomic context

WMI unified detach holds spin lock bh and calls kernel API
to remove debugfs directory. Remove debug fs kernel API uses
mutex for internal synchronization and hence kernel complains
WLAN is calling sleeping API from non sleeping context. Fix this
issue by keeping debug fs remove API call outside spin lock bh
protection.

Change-Id: I15d9a3735ed3c914af51aed9885f48f9c1d1ded2
CRs-Fixed: 1021379
diff --git a/wmi_unified.c b/wmi_unified.c
index e00d03b..96dbe5b 100644
--- a/wmi_unified.c
+++ b/wmi_unified.c
@@ -826,7 +826,6 @@
 
 /**
  * wmi_debugfs_remove() - Remove debugfs entry for wmi logging.
- *
  * @wmi_handle: wmi handle
  * @dentry: debugfs directory entry
  * @id: Index to debug info data array
@@ -877,6 +876,17 @@
 
 	return QDF_STATUS_SUCCESS;
 }
+#else
+/**
+ * wmi_debugfs_remove() - Remove debugfs entry for wmi logging.
+ * @wmi_handle: wmi handle
+ * @dentry: debugfs directory entry
+ * @id: Index to debug info data array
+ *
+ * Return: none
+ */
+static void wmi_debugfs_remove(wmi_unified_t wmi_handle, struct dentry *dentry
+		, int id) { }
 #endif /*WMI_INTERFACE_EVENT_LOGGING */
 
 int wmi_get_host_credits(wmi_unified_t wmi_handle);
@@ -2175,6 +2185,10 @@
 	wmi_buf_t buf;
 
 	cancel_work_sync(&wmi_handle->rx_event_work);
+
+	wmi_debugfs_remove(wmi_handle, wmi_handle->log_info.wmi_log_debugfs_dir,
+				wmi_handle->log_info.wmi_instance_id);
+
 	qdf_spin_lock_bh(&wmi_handle->eventq_lock);
 	buf = qdf_nbuf_queue_remove(&wmi_handle->event_queue);
 	while (buf) {
@@ -2183,8 +2197,6 @@
 	}
 
 #ifdef WMI_INTERFACE_EVENT_LOGGING
-	wmi_debugfs_remove(wmi_handle, wmi_handle->log_info.wmi_log_debugfs_dir,
-				wmi_handle->log_info.wmi_instance_id);
 	wmi_log_buffer_free(wmi_handle);
 #endif