Commit 9d24d353 authored by Sandrine Bailleux's avatar Sandrine Bailleux
Browse files

Improvements to runtime service init code

Light refactoring of the code in runtime_svc.c file.

 - Declare validate_rt_svc_desc()'s argument as const.

 - Remove 'goto' path in runtime_svc_init(). It was used in one
   place only.

 - Improve code readability by declaring a local variable holding the
   service pointer.

Change-Id: I3b15c5adb9f37b786b5b993a9be70ea9dd017a83
parent a1c3faa6
...@@ -54,7 +54,7 @@ static rt_svc_desc_t *rt_svc_descs; ...@@ -54,7 +54,7 @@ static rt_svc_desc_t *rt_svc_descs;
/******************************************************************************* /*******************************************************************************
* Simple routine to sanity check a runtime service descriptor before using it * Simple routine to sanity check a runtime service descriptor before using it
******************************************************************************/ ******************************************************************************/
static int32_t validate_rt_svc_desc(rt_svc_desc_t *desc) static int32_t validate_rt_svc_desc(const rt_svc_desc_t *desc)
{ {
if (desc == NULL) if (desc == NULL)
return -EINVAL; return -EINVAL;
...@@ -98,18 +98,18 @@ void runtime_svc_init(void) ...@@ -98,18 +98,18 @@ void runtime_svc_init(void)
rt_svc_descs = (rt_svc_desc_t *) RT_SVC_DESCS_START; rt_svc_descs = (rt_svc_desc_t *) RT_SVC_DESCS_START;
for (index = 0; index < RT_SVC_DECS_NUM; index++) { for (index = 0; index < RT_SVC_DECS_NUM; index++) {
rt_svc_desc_t *service = &rt_svc_descs[index];
/* /*
* An invalid descriptor is an error condition since it is * An invalid descriptor is an error condition since it is
* difficult to predict the system behaviour in the absence * difficult to predict the system behaviour in the absence
* of this service. * of this service.
*/ */
rc = validate_rt_svc_desc(&rt_svc_descs[index]); rc = validate_rt_svc_desc(service);
if (rc) { if (rc) {
ERROR("Invalid runtime service descriptor %p (%s)\n", ERROR("Invalid runtime service descriptor %p (%s)\n",
(void *) &rt_svc_descs[index], (void *) service, service->name);
rt_svc_descs[index].name); panic();
goto error;
} }
/* /*
...@@ -119,11 +119,11 @@ void runtime_svc_init(void) ...@@ -119,11 +119,11 @@ void runtime_svc_init(void)
* an initialisation routine defined. Call the initialisation * an initialisation routine defined. Call the initialisation
* routine for this runtime service, if it is defined. * routine for this runtime service, if it is defined.
*/ */
if (rt_svc_descs[index].init) { if (service->init) {
rc = rt_svc_descs[index].init(); rc = service->init();
if (rc) { if (rc) {
ERROR("Error initializing runtime service %s\n", ERROR("Error initializing runtime service %s\n",
rt_svc_descs[index].name); service->name);
continue; continue;
} }
} }
...@@ -135,15 +135,10 @@ void runtime_svc_init(void) ...@@ -135,15 +135,10 @@ void runtime_svc_init(void)
* entity range. * entity range.
*/ */
start_idx = get_unique_oen(rt_svc_descs[index].start_oen, start_idx = get_unique_oen(rt_svc_descs[index].start_oen,
rt_svc_descs[index].call_type); service->call_type);
end_idx = get_unique_oen(rt_svc_descs[index].end_oen, end_idx = get_unique_oen(rt_svc_descs[index].end_oen,
rt_svc_descs[index].call_type); service->call_type);
for (; start_idx <= end_idx; start_idx++) for (; start_idx <= end_idx; start_idx++)
rt_svc_descs_indices[start_idx] = index; rt_svc_descs_indices[start_idx] = index;
} }
return;
error:
panic();
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment