[PATCH libdrm v6 1/1] amdgpu: move asic id table to a separate file

Michel Dänzer michel at daenzer.net
Mon Jun 5 02:09:58 UTC 2017


On 01/06/17 05:22 AM, Samuel Li wrote:
> From: Xiaojie Yuan <Xiaojie.Yuan at amd.com>
> 
> v2: fix an off by one error and leading white spaces
> v3: use thread safe strtok_r(); initialize len before calling getline();
>     change printf() to drmMsg(); add initial amdgpu.ids
> v4: integrate some recent internal changes, including format changes
> v5: fix line number for empty/commented lines; realloc to save memory; indentation changes
> v6: remove a line error
> 
> Change-Id: I12216da14910f5e2b0970bc1fafc2a20b0ef1ba9
> Reviewed-by: Junwei Zhang <Jerry.Zhang at amd.com>
> Signed-off-by: Samuel Li <Samuel.Li at amd.com>

[...]

> +	/* 1st valid line is file version */
> +	while ((n = getline(&line, &len, fp)) != -1) {
> +		/* trim trailing newline */
> +		if (line[n - 1] == '\n')
> +			line[n - 1] = '\0';
> +
> +		/* ignore empty line and commented line */
> +		if (strlen(line) == 0 || line[0] == '#') {
> +			line_num++;
> +			continue;
> +		}
> +
> +		drmMsg("%s version: %s\n", AMDGPU_ASIC_ID_TABLE, line);
> +		break;
> +	}

BTW, what is the purpose of the file version? If it's about the format
of the file, we need to check here that the file has a format we can
parse, something like

	if (<major version> != 1)
		return -EINVAL;


Note that making backwards incompatible changes to the file format would
pretty much kill the idea of updating the file with a script like
update-pciids.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer


More information about the amd-gfx mailing list