aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichel Dänzer2017-11-30 11:28:01 -0600
committerMichel Dänzer2017-12-01 09:52:01 -0600
commit85c6b0b00ab894116880d2338776727ccff2d5c3 (patch)
treea4d8d3738b77fb3ab1edc1cf04294671cf97baff /amdgpu/amdgpu_asic_id.c
parentbc21168fa924d3fc4a000492e861f50a1a135b25 (diff)
downloadexternal-libgbm-85c6b0b00ab894116880d2338776727ccff2d5c3.tar.gz
external-libgbm-85c6b0b00ab894116880d2338776727ccff2d5c3.tar.xz
external-libgbm-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/amdgpu_asic_id.c')
-rw-r--r--amdgpu/amdgpu_asic_id.c16
1 files changed, 10 insertions, 6 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:
109 return r; 109 return r;
110} 110}
111 111
112int amdgpu_parse_asic_ids(struct amdgpu_asic_id **p_asic_id_table) 112void amdgpu_parse_asic_ids(struct amdgpu_asic_id **p_asic_id_table)
113{ 113{
114 struct amdgpu_asic_id *asic_id_table; 114 struct amdgpu_asic_id *asic_id_table;
115 struct amdgpu_asic_id *id; 115 struct amdgpu_asic_id *id;
@@ -126,7 +126,7 @@ int amdgpu_parse_asic_ids(struct amdgpu_asic_id **p_asic_id_table)
126 if (!fp) { 126 if (!fp) {
127 fprintf(stderr, "%s: %s\n", AMDGPU_ASIC_ID_TABLE, 127 fprintf(stderr, "%s: %s\n", AMDGPU_ASIC_ID_TABLE,
128 strerror(errno)); 128 strerror(errno));
129 return -EINVAL; 129 return;
130 } 130 }
131 131
132 asic_id_table = calloc(table_max_size + 1, 132 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)
177 line_num++; 177 line_num++;
178 continue; 178 continue;
179 } 179 }
180 fprintf(stderr, "Invalid format: %s: line %d: %s\n",
181 AMDGPU_ASIC_ID_TABLE, line_num, line);
182 goto free; 180 goto free;
183 } 181 }
184 182
@@ -201,6 +199,14 @@ int amdgpu_parse_asic_ids(struct amdgpu_asic_id **p_asic_id_table)
201 memset(id, 0, sizeof(struct amdgpu_asic_id)); 199 memset(id, 0, sizeof(struct amdgpu_asic_id));
202 200
203free: 201free:
202 if (r == -EINVAL) {
203 fprintf(stderr, "Invalid format: %s: line %d: %s\n",
204 AMDGPU_ASIC_ID_TABLE, line_num, line);
205 } else if (r) {
206 fprintf(stderr, "%s: Cannot parse ASIC IDs: %s\n",
207 __func__, strerror(-r));
208 }
209
204 free(line); 210 free(line);
205 211
206 if (r && asic_id_table) { 212 if (r && asic_id_table) {
@@ -215,6 +221,4 @@ close:
215 fclose(fp); 221 fclose(fp);
216 222
217 *p_asic_id_table = asic_id_table; 223 *p_asic_id_table = asic_id_table;
218
219 return r;
220} 224}