Jelajahi Sumber

qcacmn: Create new qdf_in_atomic interface to wrap the kernel API

Create the new qdf_in_atomic to wrap the kernel API in_atomic to be
used in the driver to check whether current running thread is in atomic
context.

Change-Id: I69843ff79559612561d57965a6754990e9b6f4f9
CRs-Fixed: 3414725
Tiger Yu 2 tahun lalu
induk
melakukan
60bdb7983d
2 mengubah file dengan 28 tambahan dan 0 penghapusan
  1. 11 0
      qdf/inc/qdf_util.h
  2. 17 0
      qdf/linux/src/i_qdf_util.h

+ 11 - 0
qdf/inc/qdf_util.h

@@ -921,4 +921,15 @@ static inline int qdf_get_smp_processor_id(void)
 {
 	return __qdf_get_smp_processor_id();
 }
+
+/**
+ * qdf_in_atomic: Check whether current thread running in atomic context
+ *
+ * Return: true if current thread is running in the atomic context
+ *	   else it will be return false.
+ */
+static inline bool qdf_in_atomic(void)
+{
+	return __qdf_in_atomic();
+}
 #endif /*_QDF_UTIL_H*/

+ 17 - 0
qdf/linux/src/i_qdf_util.h

@@ -57,6 +57,8 @@
 #include <linux/byteorder/generic.h>
 #endif
 
+#include <linux/rcupdate.h>
+
 typedef wait_queue_head_t __qdf_wait_queue_head_t;
 
 /* Generic compiler-dependent macros if defined by the OS */
@@ -500,4 +502,19 @@ static inline int __qdf_get_smp_processor_id(void)
 {
 	return smp_processor_id();
 }
+
+/**
+ * __qdf_in_atomic: Check whether current thread running in atomic context
+ *
+ * Return: true if current thread is running in the atomic context
+ *	   else it will be return false.
+ */
+static inline bool __qdf_in_atomic(void)
+{
+	if (in_interrupt() || !preemptible() || rcu_preempt_depth())
+		return true;
+
+	return false;
+}
+
 #endif /*_I_QDF_UTIL_H*/