On Fri, Dec 1, 2017 at 5:56 PM, Michel Dänzer <michel at daenzer.net> wrote: > 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)); This is a good example how strerror should not be used in graphics drivers. It makes no sense: "amdgpu_parse_asic_ids: Cannot parse ASIC IDs: Resource temporarily unavailable" Is my graphics card temporary unavailable? Marek