Browse Source

qcacmn: Add workqueue APIs in QDF

Add qdf workqueue APIs for schedule_delayed_work, cancel_work_sync,
cancel_delayed_work_sync and flush_delayed_work

Change-Id: Idb4de3c30c9c8cfdeb9af5b92f40a6e3dc954a6d
CRs-Fixed: 1009560
Yuanyuan Liu 8 years ago
parent
commit
26476b51eb
2 changed files with 149 additions and 1 deletions
  1. 69 1
      qdf/inc/qdf_defer.h
  2. 80 0
      qdf/linux/src/i_qdf_defer.h

+ 69 - 1
qdf/inc/qdf_defer.h

@@ -203,10 +203,64 @@ static inline void qdf_sched_work(qdf_handle_t hdl, qdf_work_t *work)
 	__qdf_sched_work(hdl, work);
 }
 
+/**
+ * qdf_sched_delayed_work() - Schedule a delayed task
+ * @hdl: OS handle
+ * @work: pointer to delayed work
+ * @delay: delay interval
+ * Return: none
+ */
+static inline void qdf_sched_delayed_work(qdf_handle_t hdl,
+					  qdf_delayed_work_t *work,
+					  uint32_t delay)
+{
+	__qdf_sched_delayed_work(hdl, work, delay);
+}
+
+/**
+ * qdf_cancel_work() - Cancel a work
+ * @hdl: OS handle
+ * @work: pointer to work
+ *
+ * Cancel work and wait for its execution to finish.
+ * This function can be used even if the work re-queues
+ * itself or migrates to another workqueue. On return
+ * from this function, work is guaranteed to be not
+ * pending or executing on any CPU. The caller must
+ * ensure that the workqueue on which work was last
+ * queued can't be destroyed before this function returns.
+ *
+ * Return: true if work was pending, false otherwise
+ */
+static inline bool qdf_cancel_work(qdf_handle_t hdl,
+				   qdf_work_t *work)
+{
+	return __qdf_cancel_work(hdl, work);
+}
+
+/**
+ * qdf_cancel_delayed_work() - Cancel a delayed work
+ * @hdl: OS handle
+ * @work: pointer to delayed work
+ *
+ * This is qdf_cancel_work for delayed works.
+ *
+ * Return: true if work was pending, false otherwise
+ */
+static inline bool qdf_cancel_delayed_work(qdf_handle_t hdl,
+					   qdf_delayed_work_t *work)
+{
+	return __qdf_cancel_delayed_work(hdl, work);
+}
+
 /**
  * qdf_flush_work - Flush a deferred task on non-interrupt context
  * @hdl: OS handle
  * @work: pointer to work
+ *
+ * Wait until work has finished execution. work is guaranteed to be
+ * idle on return if it hasn't been requeued since flush started.
+ *
  * Return: none
  */
 static inline void qdf_flush_work(qdf_handle_t hdl, qdf_work_t *work)
@@ -214,6 +268,21 @@ static inline void qdf_flush_work(qdf_handle_t hdl, qdf_work_t *work)
 	__qdf_flush_work(hdl, work);
 }
 
+/**
+ * qdf_flush_delayed_work() - Flush a delayed work
+ * @hdl: OS handle
+ * @work: pointer to delayed work
+ *
+ * This is qdf_flush_work for delayed works.
+ *
+ * Return: none
+ */
+static inline void qdf_flush_delayed_work(qdf_handle_t hdl,
+					  qdf_delayed_work_t *work)
+{
+	__qdf_flush_delayed_work(hdl, work);
+}
+
 /**
  * qdf_disable_work - disable the deferred task (synchronous)
  * @hdl: OS handle
@@ -225,7 +294,6 @@ static inline uint32_t qdf_disable_work(qdf_handle_t hdl, qdf_work_t *work)
 	return __qdf_disable_work(hdl, work);
 }
 
-
 /**
  * qdf_destroy_work - destroy the deferred task (synchronous)
  * @hdl: OS handle

+ 80 - 0
qdf/linux/src/i_qdf_defer.h

@@ -156,6 +156,45 @@ static inline QDF_STATUS __qdf_sched_work(qdf_handle_t hdl, __qdf_work_t *work)
 	return QDF_STATUS_SUCCESS;
 }
 
+/**
+ * __qdf_sched_delayed_work() - Schedule a delayed work
+ * @hdl: OS handle
+ * @work: pointer to delayed work
+ * @delay: delay interval
+ * Return: none
+ */
+static inline QDF_STATUS __qdf_sched_delayed_work(qdf_handle_t hdl,
+						  __qdf_delayed_work_t *work,
+						  uint32_t delay)
+{
+	schedule_delayed_work(work, delay);
+	return QDF_STATUS_SUCCESS;
+}
+
+/**
+ * __qdf_cancel_work() - Cancel a work
+ * @hdl: OS handle
+ * @work: pointer to work
+ * Return: true if work was pending, false otherwise
+ */
+static inline bool __qdf_cancel_work(qdf_handle_t hdl,
+					   __qdf_work_t *work)
+{
+	return cancel_work_sync(work);
+}
+
+/**
+ * __qdf_cancel_delayed_work() - Cancel a delayed work
+ * @hdl: OS handle
+ * @work: pointer to delayed work
+ * Return: true if work was pending, false otherwise
+ */
+static inline bool __qdf_cancel_delayed_work(qdf_handle_t hdl,
+					     __qdf_delayed_work_t *work)
+{
+	return cancel_delayed_work_sync(work);
+}
+
 /**
  * __qdf_flush_work - Flush a deferred task on non-interrupt context
  * @hdl: OS handle
@@ -167,6 +206,20 @@ static inline uint32_t __qdf_flush_work(qdf_handle_t hdl, __qdf_work_t *work)
 	flush_work(work);
 	return QDF_STATUS_SUCCESS;
 }
+
+/**
+ * __qdf_flush_delayed_work() - Flush a delayed work
+ * @hdl: OS handle
+ * @work: pointer to delayed work
+ * Return: none
+ */
+static inline uint32_t __qdf_flush_delayed_work(qdf_handle_t hdl,
+						__qdf_delayed_work_t *work)
+{
+	flush_delayed_work(work);
+	return QDF_STATUS_SUCCESS;
+}
+
 #else
 static inline QDF_STATUS __qdf_init_work(qdf_handle_t hdl,
 					 __qdf_work_t *work,
@@ -210,11 +263,38 @@ static inline QDF_STATUS __qdf_sched_work(qdf_handle_t hdl, __qdf_work_t *work)
 	return QDF_STATUS_SUCCESS;
 }
 
+static inline QDF_STATUS __qdf_sched_delayed_work(qdf_handle_t hdl,
+						  __qdf_delayed_work_t *work,
+						  uint32_t delay)
+{
+	schedule_delayed_work(&work->dwork, delay);
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline bool __qdf_cancel_work(qdf_handle_t hdl,
+					   __qdf_work_t *work)
+{
+	return cancel_work_sync(&work->work);
+}
+
+static inline bool __qdf_cancel_delayed_work(qdf_handle_t hdl,
+					     __qdf_delayed_work_t *work)
+{
+	return cancel_delayed_work_sync(&work->dwork);
+}
+
 static inline uint32_t __qdf_flush_work(qdf_handle_t hdl, __qdf_work_t *work)
 {
 	flush_work(&work->work);
 	return QDF_STATUS_SUCCESS;
 }
+static inline uint32_t __qdf_flush_delayed_work(qdf_handle_t hdl,
+						__qdf_delayed_work_t *work)
+{
+	flush_delayed_work(&work->dwork);
+	return QDF_STATUS_SUCCESS;
+}
+
 #endif
 
 /**