fix(versal2): modify function to have single return

This corrects the MISRA violation C2012-15.5:
A function should have a single point of exit at the end.
Introduced a temporary variable to store the return value to
ensure single return for the function.

Change-Id: Ib152831e84f5ead5b57fd713ebfedb1f3340a727
Signed-off-by: Maheedhar Bollapalli <maheedharsai.bollapalli@amd.com>
diff --git a/plat/amd/versal2/plat_topology.c b/plat/amd/versal2/plat_topology.c
index 0763139..434e08a 100644
--- a/plat/amd/versal2/plat_topology.c
+++ b/plat/amd/versal2/plat_topology.c
@@ -41,6 +41,7 @@
 int32_t plat_core_pos_by_mpidr(u_register_t mpidr)
 {
 	uint32_t cluster_id, cpu_id;
+	int32_t ret = 0;
 
 	mpidr &= MPIDR_AFFINITY_MASK;
 
@@ -48,7 +49,8 @@
 	cpu_id = MPIDR_AFFLVL1_VAL(mpidr);
 
 	if (cluster_id >= PLATFORM_CLUSTER_COUNT) {
-		return -3;
+		ret = E_INVALID_CLUSTER_COUNT;
+		goto exit_label;
 	}
 
 	/*
@@ -56,8 +58,11 @@
 	 * one of the two clusters present on the platform.
 	 */
 	if (cpu_id >= PLATFORM_CORE_COUNT_PER_CLUSTER) {
-		return -1;
+		ret = E_INVALID_CORE_COUNT;
+	} else {
+		ret = (cpu_id + (cluster_id * PLATFORM_CORE_COUNT_PER_CLUSTER));
 	}
 
-	return (cpu_id + (cluster_id * PLATFORM_CORE_COUNT_PER_CLUSTER));
+exit_label:
+	return ret;
 }