diff options
author | Emil Velikov <[email protected]> | 2016-09-07 16:36:51 +0100 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2016-10-18 17:06:04 +0100 |
commit | d561e064a8940e14901cadc4ca5b9e26ab1e7f0e (patch) | |
tree | 83426dd4d74e523f5f9f86c25889f257755997ec /src/loader/loader.c | |
parent | be239326aa4f9317d42ee07f0f51179c8b3d5b22 (diff) |
loader: separate USE_DRICONF code into separate function
Improves readability and allows us to do further cleanups a lot easier.
Signed-off-by: Emil Velikov <[email protected]>
Reviewed-by: Axel Davy <[email protected]>
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/loader/loader.c')
-rw-r--r-- | src/loader/loader.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/loader/loader.c b/src/loader/loader.c index 320a393ecca..0aa86344603 100644 --- a/src/loader/loader.c +++ b/src/loader/loader.c @@ -303,15 +303,27 @@ DRI_CONF_BEGIN DRI_CONF_DEVICE_ID_PATH_TAG() DRI_CONF_SECTION_END DRI_CONF_END; -#endif -int loader_get_user_preferred_fd(int default_fd, int *different_device) +static char *loader_get_dri_config_device_id(void) { - struct udev *udev; -#ifdef USE_DRICONF driOptionCache defaultInitOptions; driOptionCache userInitOptions; + char *prime = NULL; + + driParseOptionInfo(&defaultInitOptions, __driConfigOptionsLoader); + driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0, "loader"); + if (driCheckOption(&userInitOptions, "device_id", DRI_STRING)) + prime = strdup(driQueryOptionstr(&userInitOptions, "device_id")); + driDestroyOptionCache(&userInitOptions); + driDestroyOptionInfo(&defaultInitOptions); + + return prime; +} #endif + +int loader_get_user_preferred_fd(int default_fd, int *different_device) +{ + struct udev *udev; const char *dri_prime = getenv("DRI_PRIME"); char *prime = NULL; int is_different_device = 0, fd = default_fd; @@ -324,14 +336,8 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device) if (dri_prime) prime = strdup(dri_prime); #ifdef USE_DRICONF - else { - driParseOptionInfo(&defaultInitOptions, __driConfigOptionsLoader); - driParseConfigFiles(&userInitOptions, &defaultInitOptions, 0, "loader"); - if (driCheckOption(&userInitOptions, "device_id", DRI_STRING)) - prime = strdup(driQueryOptionstr(&userInitOptions, "device_id")); - driDestroyOptionCache(&userInitOptions); - driDestroyOptionInfo(&defaultInitOptions); - } + else + prime = loader_get_dri_config_device_id(); #endif if (prime == NULL) { |