[PATCH libdrm 1/3] amdgpu: Clean up amdgpu_parse_asic_ids error handling
Michel Dänzer
michel at daenzer.net
Fri Dec 1 16:56:16 UTC 2017
From: Michel Dänzer <michel.daenzer at amd.com>
* Move error message printing into amdgpu_parse_asic_ids and make it
return void
* Print only "Invalid format" error message if parse_one_line returns
-EINVAL
* Use strerror instead of printing the (negative) error code in hex
Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>
---
amdgpu/amdgpu_asic_id.c | 16 ++++++++++------
amdgpu/amdgpu_device.c | 6 +-----
amdgpu/amdgpu_internal.h | 2 +-
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/amdgpu/amdgpu_asic_id.c b/amdgpu/amdgpu_asic_id.c
index e8218974..eb42bbc2 100644
--- a/amdgpu/amdgpu_asic_id.c
+++ b/amdgpu/amdgpu_asic_id.c
@@ -109,7 +109,7 @@ out:
return r;
}
-int amdgpu_parse_asic_ids(struct amdgpu_asic_id **p_asic_id_table)
+void amdgpu_parse_asic_ids(struct amdgpu_asic_id **p_asic_id_table)
{
struct amdgpu_asic_id *asic_id_table;
struct amdgpu_asic_id *id;
@@ -126,7 +126,7 @@ int amdgpu_parse_asic_ids(struct amdgpu_asic_id **p_asic_id_table)
if (!fp) {
fprintf(stderr, "%s: %s\n", AMDGPU_ASIC_ID_TABLE,
strerror(errno));
- return -EINVAL;
+ return;
}
asic_id_table = calloc(table_max_size + 1,
@@ -177,8 +177,6 @@ int amdgpu_parse_asic_ids(struct amdgpu_asic_id **p_asic_id_table)
line_num++;
continue;
}
- fprintf(stderr, "Invalid format: %s: line %d: %s\n",
- AMDGPU_ASIC_ID_TABLE, line_num, line);
goto free;
}
@@ -201,6 +199,14 @@ int amdgpu_parse_asic_ids(struct amdgpu_asic_id **p_asic_id_table)
memset(id, 0, sizeof(struct amdgpu_asic_id));
free:
+ if (r == -EINVAL) {
+ fprintf(stderr, "Invalid format: %s: line %d: %s\n",
+ AMDGPU_ASIC_ID_TABLE, line_num, line);
+ } else if (r) {
+ fprintf(stderr, "%s: Cannot parse ASIC IDs: %s\n",
+ __func__, strerror(-r));
+ }
+
free(line);
if (r && asic_id_table) {
@@ -215,6 +221,4 @@ close:
fclose(fp);
*p_asic_id_table = asic_id_table;
-
- return r;
}
diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
index 344e87ed..e7aaf4fc 100644
--- a/amdgpu/amdgpu_device.c
+++ b/amdgpu/amdgpu_device.c
@@ -280,11 +280,7 @@ int amdgpu_device_initialize(int fd,
amdgpu_vamgr_init(&dev->vamgr, start, max,
dev->dev_info.virtual_address_alignment);
- r = amdgpu_parse_asic_ids(&dev->asic_ids);
- if (r) {
- fprintf(stderr, "%s: Cannot parse ASIC IDs, 0x%x.",
- __func__, r);
- }
+ amdgpu_parse_asic_ids(&dev->asic_ids);
*major_version = dev->major_version;
*minor_version = dev->minor_version;
diff --git a/amdgpu/amdgpu_internal.h b/amdgpu/amdgpu_internal.h
index e26e5190..1aff7f8e 100644
--- a/amdgpu/amdgpu_internal.h
+++ b/amdgpu/amdgpu_internal.h
@@ -148,7 +148,7 @@ drm_private void amdgpu_vamgr_init(struct amdgpu_bo_va_mgr *mgr, uint64_t start,
drm_private void amdgpu_vamgr_deinit(struct amdgpu_bo_va_mgr *mgr);
-drm_private int amdgpu_parse_asic_ids(struct amdgpu_asic_id **asic_ids);
+drm_private void amdgpu_parse_asic_ids(struct amdgpu_asic_id **asic_ids);
drm_private int amdgpu_query_gpu_info_init(amdgpu_device_handle dev);
--
2.15.0
More information about the amd-gfx
mailing list