summaryrefslogtreecommitdiff
path: root/amdgpu
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2017-11-30 18:28:01 +0100
committerMichel Dänzer <michel@daenzer.net>2017-12-01 16:52:01 +0100
commit85c6b0b00ab894116880d2338776727ccff2d5c3 (patch)
treea4d8d3738b77fb3ab1edc1cf04294671cf97baff /amdgpu
parentbc21168fa924d3fc4a000492e861f50a1a135b25 (diff)
downloadlibdrm-85c6b0b00ab894116880d2338776727ccff2d5c3.tar.gz
libdrm-85c6b0b00ab894116880d2338776727ccff2d5c3.tar.bz2
libdrm-85c6b0b00ab894116880d2338776727ccff2d5c3.zip
amdgpu: Clean up amdgpu_parse_asic_ids error handling
* 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 Acked-by: Slava Abramov <slava.abramov@amd.com> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'amdgpu')
-rw-r--r--amdgpu/amdgpu_asic_id.c16
-rw-r--r--amdgpu/amdgpu_device.c6
-rw-r--r--amdgpu/amdgpu_internal.h2
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);