[Nouveau] [PATCH] dri3: remove spurious {f,}stat calls
Emil Velikov
emil.l.velikov at gmail.com
Tue Jul 21 16:10:03 PDT 2015
... and use drmGetNodeTypeFromFd where possible.
Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
src/nouveau_dri2.c | 24 +++---------------------
1 file changed, 3 insertions(+), 21 deletions(-)
diff --git a/src/nouveau_dri2.c b/src/nouveau_dri2.c
index ce6f53e..d3cce4e 100644
--- a/src/nouveau_dri2.c
+++ b/src/nouveau_dri2.c
@@ -1020,24 +1020,12 @@ nouveau_dri2_fini(ScreenPtr pScreen)
}
#ifdef DRI3
-static int is_render_node(int fd, struct stat *st)
-{
- if (fstat(fd, st))
- return 0;
-
- if (!S_ISCHR(st->st_mode))
- return 0;
-
- return st->st_rdev & 0x80;
- }
-
static int
nouveau_dri3_open(ScreenPtr screen, RRProviderPtr provider, int *out)
{
ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
NVPtr pNv = NVPTR(pScrn);
int fd = -1;
- struct stat buff;
#ifdef O_CLOEXEC
fd = open(pNv->render_node, O_RDWR | O_CLOEXEC);
@@ -1047,11 +1035,7 @@ nouveau_dri3_open(ScreenPtr screen, RRProviderPtr provider, int *out)
if (fd < 0)
return -BadAlloc;
- if (fstat(fd, &buff)) {
- close(fd);
- return -BadMatch;
- }
- if (!is_render_node(fd, &buff)) {
+ if (drmGetNodeTypeFromFd(fd) != DRM_NODE_RENDER) {
drm_magic_t magic;
if (drmGetMagic(fd, &magic) || drmAuthMagic(pNv->dev->fd, magic)) {
@@ -1124,15 +1108,13 @@ nouveau_dri3_screen_init(ScreenPtr screen)
#ifdef DRI3
ScrnInfoPtr pScrn = xf86ScreenToScrn(screen);
NVPtr pNv = NVPTR(pScrn);
- struct stat master, render;
char *buf;
- if (is_render_node(pNv->dev->fd, &master))
+ if (drmGetNodeTypeFromFd(pNv->dev->fd) == DRM_NODE_RENDER)
return TRUE;
buf = drmGetRenderDeviceNameFromFd(pNv->dev->fd);
- if (buf && stat(buf, &render) == 0 &&
- master.st_mode == render.st_mode) {
+ if (buf) {
pNv->render_node = buf;
return dri3_screen_init(screen, &nouveau_dri3_screen_info);
} else
--
2.4.4
More information about the Nouveau
mailing list