Mesa (master): loader: simplify codeflow in drm_get_pci_id_for_fd
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Apr 1 16:53:34 UTC 2020
Module: Mesa
Branch: master
Commit: e3572f977fc662bdecdac4f525f415bdc7e62147
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e3572f977fc662bdecdac4f525f415bdc7e62147
Author: Emil Velikov <emil.velikov at collabora.com>
Date: Thu Mar 5 13:50:46 2020 +0000
loader: simplify codeflow in drm_get_pci_id_for_fd
Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
Reviewed-by: Adam Jackson <ajax at redhat.com>
Reviewed-by: Eric Engestrom <eric at engestrom.ch>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4084>
---
src/loader/loader.c | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/src/loader/loader.c b/src/loader/loader.c
index 1a438a4fcc7..a2e726465af 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -385,26 +385,22 @@ static bool
drm_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id)
{
drmDevicePtr device;
- bool ret;
- if (drmGetDevice2(fd, 0, &device) == 0) {
- if (device->bustype == DRM_BUS_PCI) {
- *vendor_id = device->deviceinfo.pci->vendor_id;
- *chip_id = device->deviceinfo.pci->device_id;
- ret = true;
- }
- else {
- log_(_LOADER_DEBUG, "MESA-LOADER: device is not located on the PCI bus\n");
- ret = false;
- }
- drmFreeDevice(&device);
- }
- else {
+ if (drmGetDevice2(fd, 0, &device) != 0) {
log_(_LOADER_WARNING, "MESA-LOADER: failed to retrieve device information\n");
- ret = false;
+ return false;
}
- return ret;
+ if (device->bustype != DRM_BUS_PCI) {
+ drmFreeDevice(&device);
+ log_(_LOADER_DEBUG, "MESA-LOADER: device is not located on the PCI bus\n");
+ return false;
+ }
+
+ *vendor_id = device->deviceinfo.pci->vendor_id;
+ *chip_id = device->deviceinfo.pci->device_id;
+ drmFreeDevice(&device);
+ return true;
}
#endif
More information about the mesa-commit
mailing list