[Mesa-dev] [PATCH 2/5] loader: use drmGetDeviceNameFromFd2 from libdrm
Eric Engestrom
eric.engestrom at imgtec.com
Tue Oct 24 13:26:25 UTC 2017
On Monday, 2017-10-23 23:20:40 +0300, Greg V wrote:
> Reduce code duplication and automatically benefit from OS-specific
> fixes to libdrm (e.g. in FreeBSD ports).
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=103283
drmGetDeviceNameFromFd2 was introduced in libdrm-2.4.74, and we already
require 2.4.75 globally, so this is fine.
Reviewed-by: Eric Engestrom <eric.engestrom at imgtec.com>
That said, the drm_get_device_name_for_fd() function is now a plain
alias for drmGetDeviceNameFromFd2(), and is only used in one place.
Might as well drop it, but this can be a follow up patch, don't send
a v2 just for this :)
> ---
> src/loader/loader.c | 36 +-----------------------------------
> 1 file changed, 1 insertion(+), 35 deletions(-)
>
> diff --git a/src/loader/loader.c b/src/loader/loader.c
> index 182ba90a0d..f7f85e37c2 100644
> --- a/src/loader/loader.c
> +++ b/src/loader/loader.c
> @@ -244,29 +244,6 @@ int loader_get_user_preferred_fd(int default_fd, bool *different_device)
> }
> #endif
>
> -#if defined(HAVE_LIBDRM)
> -static int
> -dev_node_from_fd(int fd, unsigned int *maj, unsigned int *min)
> -{
> - struct stat buf;
> -
> - if (fstat(fd, &buf) < 0) {
> - log_(_LOADER_WARNING, "MESA-LOADER: failed to stat fd %d\n", fd);
> - return -1;
> - }
> -
> - if (!S_ISCHR(buf.st_mode)) {
> - log_(_LOADER_WARNING, "MESA-LOADER: fd %d not a character device\n", fd);
> - return -1;
> - }
> -
> - *maj = major(buf.st_rdev);
> - *min = minor(buf.st_rdev);
> -
> - return 0;
> -}
> -#endif
> -
> #if defined(HAVE_LIBDRM)
>
> static int
> @@ -312,18 +289,7 @@ loader_get_pci_id_for_fd(int fd, int *vendor_id, int *chip_id)
> static char *
> drm_get_device_name_for_fd(int fd)
> {
> - unsigned int maj, min;
> - char buf[0x40];
> - int n;
> -
> - if (dev_node_from_fd(fd, &maj, &min) < 0)
> - return NULL;
> -
> - n = snprintf(buf, sizeof(buf), DRM_DEV_NAME, DRM_DIR_NAME, min);
> - if (n == -1 || n >= sizeof(buf))
> - return NULL;
> -
> - return strdup(buf);
> + return drmGetDeviceNameFromFd2(fd);
> }
> #endif
>
> --
> 2.14.2
>
More information about the mesa-dev
mailing list