[Cbe-oss-dev] [PATCH 07/22]MARS/base: Module api combine

Yuji Mano yuji.mano at am.sony.com
Wed Jan 21 11:28:18 EST 2009


Combine module api mars_module_workload_is_* functions to a single
mars_module_workload_query() function.

Signed-off-by: Yuji Mano <yuji.mano at am.sony.com>

---
 base/include/mpu/mars/module.h |   63 +++++++++--------------------------------
 base/src/mpu/lib/module.c      |   58 ++++++++++++++-----------------------
 doxygen/src/doxygen            |    7 ----
 3 files changed, 37 insertions(+), 91 deletions(-)

--- a/base/include/mpu/mars/module.h
+++ b/base/include/mpu/mars/module.h
@@ -124,64 +124,29 @@ struct mars_workload_context *mars_modul
 struct mars_workload_context *mars_module_get_workload_by_id(uint16_t id);
 
 /**
- * \ingroup group_mars_workload_module
- * \brief <b>[MPU]</b> Returns whether or not specified workload is initialized.
- *
- * \param[in] id		- id of workload
- * \return
- *	int			- non-zero if condition satisfied
- */
-int mars_module_workload_is_initialized(uint16_t id);
-
-/**
- * \ingroup group_mars_workload_module
- * \brief <b>[MPU]</b> Returns whether or not specified workload is ready.
+ * \brief MARS workload module query types
  *
- * \param[in] id		- id of workload
- * \return
- *	int			- non-zero if condition satisfied
- */
-int mars_module_workload_is_ready(uint16_t id);
-
-/**
- * \ingroup group_mars_workload_module
- * \brief <b>[MPU]</b> Returns whether or not specified workload is waiting.
- *
- * \param[in] id		- id of workload
- * \return
- *	int			- non-zero if condition satisfied
- */
-int mars_module_workload_is_waiting(uint16_t id);
-
-/**
- * \ingroup group_mars_workload_module
- * \brief <b>[MPU]</b> Returns whether or not specified workload is running.
- *
- * \param[in] id		- id of workload
- * \return
- *	int			- non-zero if condition satisfied
- */
-int mars_module_workload_is_running(uint16_t id);
-
-/**
- * \ingroup group_mars_workload_module
- * \brief <b>[MPU]</b> Returns whether or not specified workload is finished.
- *
- * \param[in] id		- id of workload
- * \return
- *	int			- non-zero if condition satisfied
+ * These are the query types you can pass into \ref mars_module_workload_query
  */
-int mars_module_workload_is_finished(uint16_t id);
+enum {
+	MARS_QUERY_IS_INITIALIZED = 0,	/**< query if workload is initialized */
+	MARS_QUERY_IS_READY,		/**< query if workload is ready */
+	MARS_QUERY_IS_WAITING,		/**< query if workload is waiting */
+	MARS_QUERY_IS_RUNNING,		/**< query if workload is running */
+	MARS_QUERY_IS_FINISHED,		/**< query if workload is finished */
+	MARS_QUERY_IS_SIGNAL_SET,	/**< query if workload signal is set */
+};
 
 /**
  * \ingroup group_mars_workload_module
- * \brief <b>[MPU]</b> Returns whether or not specified workload has signal set.
+ * \brief <b>[MPU]</b> Returns whether or not specified query is satisfied.
  *
  * \param[in] id		- id of workload
+ * \param[in] query		- query type
  * \return
- *	int			- non-zero if condition satisfied
+ *	int			- non-zero if query satisfied
  */
-int mars_module_workload_is_signal_set(uint16_t id);
+int mars_module_workload_query(uint16_t id, int query);
 
 /**
  * \ingroup group_mars_workload_module
--- a/base/src/mpu/lib/module.c
+++ b/base/src/mpu/lib/module.c
@@ -168,46 +168,32 @@ static uint64_t get_block_bits(uint16_t 
 	return block_bits;
 }
 
-int mars_module_workload_is_initialized(uint16_t id)
+int mars_module_workload_query(uint16_t id, int query)
 {
 	uint64_t bits = get_block_bits(id);
 
-	return (MARS_BITS_GET(&bits, STATE) != MARS_WORKLOAD_STATE_NONE);
-}
-
-int mars_module_workload_is_ready(uint16_t id)
-{
-	uint64_t bits = get_block_bits(id);
-
-	return (MARS_BITS_GET(&bits, STATE) == MARS_WORKLOAD_STATE_READY);
-}
-
-int mars_module_workload_is_waiting(uint16_t id)
-{
-	uint64_t bits = get_block_bits(id);
-
-	return (MARS_BITS_GET(&bits, STATE) == MARS_WORKLOAD_STATE_WAITING);
-}
-
-int mars_module_workload_is_running(uint16_t id)
-{
-	uint64_t bits = get_block_bits(id);
-
-	return (MARS_BITS_GET(&bits, STATE) == MARS_WORKLOAD_STATE_RUNNING);
-}
-
-int mars_module_workload_is_finished(uint16_t id)
-{
-	uint64_t bits = get_block_bits(id);
-
-	return (MARS_BITS_GET(&bits, STATE) == MARS_WORKLOAD_STATE_FINISHED);
-}
-
-int mars_module_workload_is_signal_set(uint16_t id)
-{
-	uint64_t bits = get_block_bits(id);
+	switch (query) {
+	case MARS_QUERY_IS_INITIALIZED:
+		return (MARS_BITS_GET(&bits, STATE) !=
+			MARS_WORKLOAD_STATE_NONE);
+	case MARS_QUERY_IS_READY:
+		return (MARS_BITS_GET(&bits, STATE) ==
+			MARS_WORKLOAD_STATE_READY);
+	case MARS_QUERY_IS_WAITING:
+		return (MARS_BITS_GET(&bits, STATE) ==
+			MARS_WORKLOAD_STATE_WAITING);
+	case MARS_QUERY_IS_RUNNING:
+		return (MARS_BITS_GET(&bits, STATE) ==
+			MARS_WORKLOAD_STATE_RUNNING);
+	case MARS_QUERY_IS_FINISHED:
+		return (MARS_BITS_GET(&bits, STATE) ==
+			MARS_WORKLOAD_STATE_FINISHED);
+	case MARS_QUERY_IS_SIGNAL_SET:
+		return (MARS_BITS_GET(&bits, SIGNAL) ==
+			MARS_WORKLOAD_SIGNAL_ON);
+	}
 
-	return (MARS_BITS_GET(&bits, SIGNAL) == MARS_WORKLOAD_SIGNAL_ON);
+	return MARS_ERROR_PARAMS;
 }
 
 static int change_bits(uint16_t id,
--- a/doxygen/src/doxygen
+++ b/doxygen/src/doxygen
@@ -4399,12 +4399,7 @@ This section will describe the MARS API.
   - \ref mars_module_get_workload_id
   - \ref mars_module_get_workload
   - \ref mars_module_get_workload_by_id
-  - \ref mars_module_workload_is_initialized
-  - \ref mars_module_workload_is_ready
-  - \ref mars_module_workload_is_waiting
-  - \ref mars_module_workload_is_running
-  - \ref mars_module_workload_is_finished
-  - \ref mars_module_workload_is_signal_set
+  - \ref mars_module_workload_query
   - \ref mars_module_workload_wait_set
   - \ref mars_module_workload_wait_reset
   - \ref mars_module_workload_signal_set






More information about the cbe-oss-dev mailing list