[Mesa-dev] [PATCH 2/8] pipe-loader: simplify pipe_loader_drm_probe

Emil Velikov emil.l.velikov at gmail.com
Tue Jun 30 08:09:22 PDT 2015


Do not iterate and (attempt to) open the render device, if we're over
the requested number of devices.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
index 009e1df..1ff5f3e 100644
--- a/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
+++ b/src/gallium/auxiliary/pipe-loader/pipe_loader_drm.c
@@ -180,12 +180,13 @@ open_drm_render_node_minor(int minor)
 int
 pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev)
 {
+   struct pipe_loader_device *dev;
    int i, j, fd;
 
    for (i = DRM_RENDER_NODE_MIN_MINOR, j = 0;
-        i <= DRM_RENDER_NODE_MAX_MINOR; i++) {
+        i <= DRM_RENDER_NODE_MAX_MINOR && j < ndev; i++) {
+
       fd = open_drm_render_node_minor(i);
-      struct pipe_loader_device *dev;
       if (fd < 0)
          continue;
 
@@ -194,13 +195,7 @@ pipe_loader_drm_probe(struct pipe_loader_device **devs, int ndev)
          continue;
       }
 
-      if (j < ndev) {
-         devs[j] = dev;
-      } else {
-         close(fd);
-         dev->ops->release(&dev);
-      }
-      j++;
+      devs[j++] = dev;
    }
 
    return j;
-- 
2.4.4



More information about the mesa-dev mailing list