diff options
Diffstat (limited to 'src/intel')
-rw-r--r-- | src/intel/common/gen_decoder.c | 32 | ||||
-rw-r--r-- | src/intel/common/gen_decoder.h | 1 |
2 files changed, 21 insertions, 12 deletions
diff --git a/src/intel/common/gen_decoder.c b/src/intel/common/gen_decoder.c index 90b0f97965f..69c68ff85f0 100644 --- a/src/intel/common/gen_decoder.c +++ b/src/intel/common/gen_decoder.c @@ -649,23 +649,16 @@ gen_spec_load(const struct gen_device_info *devinfo) } struct gen_spec * -gen_spec_load_from_path(const struct gen_device_info *devinfo, - const char *path) +gen_spec_load_filename(const char *filename) { struct parser_context ctx; - size_t len, filename_len = strlen(path) + 20; - char *filename = malloc(filename_len); - void *buf; FILE *input; - - len = snprintf(filename, filename_len, "%s/gen%i.xml", - path, devinfo_to_gen(devinfo, false)); - assert(len < filename_len); + void *buf; + size_t len; input = fopen(filename, "r"); if (input == NULL) { fprintf(stderr, "failed to open xml description\n"); - free(filename); return NULL; } @@ -675,7 +668,6 @@ gen_spec_load_from_path(const struct gen_device_info *devinfo, if (ctx.parser == NULL) { fprintf(stderr, "failed to create parser\n"); fclose(input); - free(filename); return NULL; } @@ -716,7 +708,6 @@ gen_spec_load_from_path(const struct gen_device_info *devinfo, XML_ParserFree(ctx.parser); fclose(input); - free(filename); /* free ctx.spec if genxml is empty */ if (ctx.spec && @@ -731,6 +722,23 @@ gen_spec_load_from_path(const struct gen_device_info *devinfo, return ctx.spec; } +struct gen_spec * +gen_spec_load_from_path(const struct gen_device_info *devinfo, + const char *path) +{ + size_t len, filename_len = strlen(path) + 20; + char *filename = malloc(filename_len); + + len = snprintf(filename, filename_len, "%s/gen%i.xml", + path, devinfo_to_gen(devinfo, false)); + assert(len < filename_len); + + struct gen_spec *spec = gen_spec_load_filename(filename); + free(filename); + + return spec; +} + void gen_spec_destroy(struct gen_spec *spec) { ralloc_free(spec); diff --git a/src/intel/common/gen_decoder.h b/src/intel/common/gen_decoder.h index b4c85ab0c1d..2dba6f1898a 100644 --- a/src/intel/common/gen_decoder.h +++ b/src/intel/common/gen_decoder.h @@ -54,6 +54,7 @@ struct gen_group *gen_spec_find_struct(struct gen_spec *spec, const char *name); struct gen_spec *gen_spec_load(const struct gen_device_info *devinfo); struct gen_spec *gen_spec_load_from_path(const struct gen_device_info *devinfo, const char *path); +struct gen_spec *gen_spec_load_filename(const char *filename); void gen_spec_destroy(struct gen_spec *spec); uint32_t gen_spec_get_gen(struct gen_spec *spec); struct gen_group *gen_spec_find_instruction(struct gen_spec *spec, |