refactor: remove out parameter from `get_share_state`

`get_share_state` returned a `struct ffa_memory_share_state *` via an
out parameter and indicated success by returning a `bool`. This patch
removes the out parameter and returns the `struct ffa_memory_share_state
*` directly.

Signed-off-by: Karl Meakin <karl.meakin@arm.com>
Change-Id: I114f4f562df2600036da9903a87ccee2a7afc31c
diff --git a/src/ffa_memory.c b/src/ffa_memory.c
index 7de8a7f..238dabb 100644
--- a/src/ffa_memory.c
+++ b/src/ffa_memory.c
@@ -113,46 +113,41 @@
 
 /**
  * If the given handle is a valid handle for an allocated share state then
- * initialises `share_state_ret` to point to the share state and returns true.
- * Otherwise returns false.
+ * returns a pointer to the share state. Otherwise returns NULL.
  */
-bool get_share_state(struct share_states_locked share_states,
-		     ffa_memory_handle_t handle,
-		     struct ffa_memory_share_state **share_state_ret)
+struct ffa_memory_share_state *get_share_state(
+	struct share_states_locked share_states, ffa_memory_handle_t handle)
 {
 	struct ffa_memory_share_state *share_state;
-	uint64_t index;
 
 	assert(share_states.share_states != NULL);
-	assert(share_state_ret != NULL);
 
 	/*
 	 * First look for a share_state allocated by us, in which case the
 	 * handle is based on the index.
 	 */
 	if (plat_ffa_memory_handle_allocated_by_current_world(handle)) {
-		index = ffa_memory_handle_get_index(handle);
+		uint64_t index = ffa_memory_handle_get_index(handle);
+
 		if (index < MAX_MEM_SHARES) {
 			share_state = &share_states.share_states[index];
 			if (share_state->share_func != 0) {
-				*share_state_ret = share_state;
-				return true;
+				return share_state;
 			}
 		}
 	}
 
 	/* Fall back to a linear scan. */
-	for (index = 0; index < MAX_MEM_SHARES; ++index) {
+	for (uint64_t index = 0; index < MAX_MEM_SHARES; ++index) {
 		share_state = &share_states.share_states[index];
 		if (share_state->memory_region != NULL &&
 		    share_state->memory_region->handle == handle &&
 		    share_state->share_func != 0) {
-			*share_state_ret = share_state;
-			return true;
+			return share_state;
 		}
 	}
 
-	return false;
+	return NULL;
 }
 
 /** Marks a share state as unallocated. */
@@ -1593,7 +1588,8 @@
 	 * Look up the share state by handle and make sure that the VM ID
 	 * matches.
 	 */
-	if (!get_share_state(share_states, handle, &share_state)) {
+	share_state = get_share_state(share_states, handle);
+	if (!share_state) {
 		dlog_verbose(
 			"Invalid handle %#x for memory send continuation.\n",
 			handle);
@@ -2382,7 +2378,8 @@
 	}
 
 	share_states = share_states_lock();
-	if (!get_share_state(share_states, handle, share_state)) {
+	share_state = get_share_state(share_states, handle);
+	if (!share_state) {
 		dlog_verbose("Invalid handle %#x for FFA_MEM_RETRIEVE_REQ.\n",
 			     handle);
 		ret = ffa_error(FFA_INVALID_PARAMETERS);
@@ -2629,7 +2626,8 @@
 	dump_share_states();
 
 	share_states = share_states_lock();
-	if (!get_share_state(share_states, handle, &share_state)) {
+	share_state = get_share_state(share_states, handle);
+	if (!share_state) {
 		dlog_verbose("Invalid handle %#x for FFA_MEM_FRAG_RX.\n",
 			     handle);
 		ret = ffa_error(FFA_INVALID_PARAMETERS);
@@ -2808,7 +2806,8 @@
 	dump_share_states();
 
 	share_states = share_states_lock();
-	if (!get_share_state(share_states, handle, &share_state)) {
+	share_state = get_share_state(share_states, handle);
+	if (!share_state) {
 		dlog_verbose("Invalid handle %#x for FFA_MEM_RELINQUISH.\n",
 			     handle);
 		ret = ffa_error(FFA_INVALID_PARAMETERS);
@@ -2924,14 +2923,14 @@
 
 	share_states = share_states_lock();
 
-	if (get_share_state(share_states, handle, &share_state)) {
-		memory_region = share_state->memory_region;
-	} else {
+	share_state = get_share_state(share_states, handle);
+	if (!share_state) {
 		dlog_verbose("Invalid handle %#x for FFA_MEM_RECLAIM.\n",
 			     handle);
 		ret = ffa_error(FFA_INVALID_PARAMETERS);
 		goto out;
 	}
+	memory_region = share_state->memory_region;
 
 	CHECK(memory_region != NULL);