From 3a493ce7ea60fba352b9919ffc90fb3626a5872d Mon Sep 17 00:00:00 2001 From: Nicola Mazzucato Date: Fri, 12 Oct 2018 09:51:34 +0100 Subject: [PATCH 1/2] fwk_module: Improve returned error codes Change-Id: I96c1e532c9e9fc75d66ccadf7407b0d7cc93544b Signed-off-by: Nicola Mazzucato --- framework/include/fwk_module.h | 5 +++-- framework/src/fwk_module.c | 8 ++++++-- framework/test/test_fwk_module.c | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/framework/include/fwk_module.h b/framework/include/fwk_module.h index 6934c4659..b207191ec 100644 --- a/framework/include/fwk_module.h +++ b/framework/include/fwk_module.h @@ -423,8 +423,9 @@ const void *fwk_module_get_data(fwk_id_t id); * * \retval FWK_SUCCESS The module or element can service API calls. * \retval FWK_E_PARAM The identifier is invalid. - * \retval FWK_E_STATE The module or the element is not initialized or - * suspended. + * \retval FWK_E_INIT The module or element is not initialized. + * \retval FWK_E_STATE The module or element is suspended. + * */ int fwk_module_check_call(fwk_id_t id); diff --git a/framework/src/fwk_module.c b/framework/src/fwk_module.c index 1b3a6b411..cfff4ceb2 100644 --- a/framework/src/fwk_module.c +++ b/framework/src/fwk_module.c @@ -613,8 +613,12 @@ int fwk_module_check_call(fwk_id_t id) if (status != FWK_SUCCESS) goto error; - if ((state == FWK_MODULE_STATE_UNINITIALIZED) || - (state == FWK_MODULE_STATE_SUSPENDED)) { + if (state == FWK_MODULE_STATE_UNINITIALIZED) { + status = FWK_E_INIT; + goto error; + } + + if (state == FWK_MODULE_STATE_SUSPENDED) { status = FWK_E_STATE; goto error; } diff --git a/framework/test/test_fwk_module.c b/framework/test/test_fwk_module.c index 2e5f67934..b31f72984 100644 --- a/framework/test/test_fwk_module.c +++ b/framework/test/test_fwk_module.c @@ -367,10 +367,10 @@ static void test_fwk_module_check_call_failed(void) result = fwk_module_check_call(id); assert(result == FWK_E_PARAM); - /* Module 0 state is not FWK_MODULE_STATE_INITIALIZED */ + /* Module 0 is not initialized */ id = MODULE0_ID; result = fwk_module_check_call(id); - assert(result == FWK_E_STATE); + assert(result == FWK_E_INIT); } static void test___fwk_module_init_module_desc_bad_params(void) -- GitLab From d4fe560eea3c18ce9366d3fcc41f360276796cb8 Mon Sep 17 00:00:00 2001 From: Nicola Mazzucato Date: Fri, 12 Oct 2018 11:15:13 +0100 Subject: [PATCH 2/2] modules: Update comments for return values Change-Id: Ia272fba0204c4bbfc533e8fb8eb28801c7951cf8 Signed-off-by: Nicola Mazzucato --- module/power_domain/include/mod_power_domain.h | 12 ++++++++---- module/scmi/include/mod_scmi.h | 7 ++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/module/power_domain/include/mod_power_domain.h b/module/power_domain/include/mod_power_domain.h index ed204f83e..e4123d728 100644 --- a/module/power_domain/include/mod_power_domain.h +++ b/module/power_domain/include/mod_power_domain.h @@ -480,7 +480,8 @@ struct mod_pd_public_api { * \param type Pointer to storage for the type of the power domain. * * \retval FWK_SUCCESS The type of the power domain was returned. - * \retval FWK_E_STATE The module has not been initialized. + * \retval FWK_E_INIT The module has not been initialized. + * \retval FWK_E_STATE The power domain module is in an invalid state. * \retval FWK_E_PARAM The power domain identifier is unknown. * \retval FWK_E_PARAM The pointer 'type' is equal to NULL. */ @@ -498,7 +499,8 @@ struct mod_pd_public_api { * * \retval FWK_SUCCESS The identifier of the parent power domain was * returned. - * \retval FWK_E_STATE The component has not been initialized. + * \retval FWK_E_INIT The module has not been initialized. + * \retval FWK_E_STATE The power domain module is in an invalid state. * \retval FWK_E_PARAM The power domain identifier is unknown. * \retval FWK_E_PARAM The pointer 'parent_pd_id' is equal to NULL. */ @@ -522,7 +524,8 @@ struct mod_pd_restricted_api { * \param type Pointer to storage for the type of the power domain. * * \retval FWK_SUCCESS The type of the power domain was returned. - * \retval FWK_E_STATE The module has not been initialized. + * \retval FWK_E_INIT The module has not been initialized. + * \retval FWK_E_STATE The power domain module is in an invalid state. * \retval FWK_E_PARAM The power domain identifier is unknown. * \retval FWK_E_PARAM The pointer 'type' is equal to NULL. */ @@ -540,7 +543,8 @@ struct mod_pd_restricted_api { * * \retval FWK_SUCCESS The identifier of the parent power domain was * returned. - * \retval FWK_E_STATE The component has not been initialized. + * \retval FWK_E_INIT The module has not been initialized. + * \retval FWK_E_STATE The power domain module is in an invalid state. * \retval FWK_E_PARAM The power domain identifier is unknown. * \retval FWK_E_PARAM The pointer 'parent_pd_id' is equal to NULL. */ diff --git a/module/scmi/include/mod_scmi.h b/module/scmi/include/mod_scmi.h index b846064b0..852d0438f 100644 --- a/module/scmi/include/mod_scmi.h +++ b/module/scmi/include/mod_scmi.h @@ -315,7 +315,8 @@ struct mod_scmi_from_protocol_api { * \retval FWK_SUCCESS The agent identifier was returned. * \retval FWK_E_PARAM The service identifier is not valid. * \retval FWK_E_PARAM The parameter 'agent_id' is equal to NULL. - * \retval FWK_E_STATE The service is not initialized. + * \retval FWK_E_INIT The service is not initialized. + * \retval FWK_E_STATE The service is in an invalid state. */ int (*get_agent_id)(fwk_id_t service_id, unsigned int *agent_id); @@ -331,7 +332,6 @@ struct mod_scmi_from_protocol_api { * \retval FWK_SUCCESS The agent identifier was returned. * \retval FWK_E_PARAM The agent identifier is not valid. * \retval FWK_E_PARAM The parameter 'agent_type' is equal to NULL. - * \retval FWK_E_STATE The component is not initialized. */ int (*get_agent_type)(uint32_t agent_id, enum scmi_agent_type *agent_type); @@ -346,7 +346,8 @@ struct mod_scmi_from_protocol_api { * \retval FWK_SUCCESS The operation succeeded. * \retval FWK_E_PARAM The service_id parameter is invalid. * \retval FWK_E_PARAM The size parameter is NULL. - * \retval FWK_E_STATE The service is not initialized. + * \retval FWK_E_INIT The service is not initialized. + * \retval FWK_E_STATE The service is in an invalid sate. * \return One of the standard error codes for implementation-defined * errors. */ -- GitLab