libhsakmt: Fix and simplify debug_get_reg_status

The NULL pointer check was the only way for that function to fail. And it
was done after the pointer was accessed. Simplify this by just returning
the result as a return value instead of using a pointer as output
parameter. This way the function can never fail and the caller doesn't
need to do any error handling.

Declare the function in libhsakmt.h instead of duplicating the
declaration in fmm.c.

Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Change-Id: I91b90d66166fd3b5cdc47c73a9bbc369c45b51fe
This commit is contained in:
Felix Kuehling
2022-11-25 13:53:31 -05:00
parent 8a746bdaed
commit 2d53430ce3
3 changed files with 8 additions and 15 deletions
+5 -12
View File
@@ -33,8 +33,6 @@
static bool *is_device_debugged;
int debug_get_reg_status(uint32_t node_id, bool *is_debugged);
HSAKMT_STATUS init_device_debugging_memory(unsigned int NumNodes)
{
unsigned int i;
@@ -57,6 +55,11 @@ void destroy_device_debugging_memory(void)
}
}
bool debug_get_reg_status(uint32_t node_id)
{
return is_device_debugged[node_id];
}
HSAKMT_STATUS HSAKMTAPI hsaKmtDbgRegister(HSAuint32 NodeId)
{
HSAKMT_STATUS result;
@@ -262,16 +265,6 @@ HSAKMT_STATUS HSAKMTAPI hsaKmtDbgAddressWatch(HSAuint32 NodeId,
return HSAKMT_STATUS_SUCCESS;
}
int debug_get_reg_status(uint32_t node_id, bool *is_debugged)
{
*is_debugged = NULL;
if (!is_device_debugged)
return -1;
*is_debugged = is_device_debugged[node_id];
return 0;
}
/* Get the major and minor version of the kernel debugger support. */
HSAKMT_STATUS
HSAKMTAPI