Module Name:    src
Committed By:   snj
Date:           Sun Aug 30 02:52:31 UTC 2009

Modified Files:
        src/sys/external/bsd/drm/dist/bsd-core [netbsd-5]: drm_drv.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #927):
        sys/external/bsd/drm/dist/bsd-core/drm_drv.c: revision 1.15
on netbsd with the single final close() action, make sure we clean up
all the files attached to dev->files.  we check for one per "open_count"
that is above 1.  could perhaps assert() that we are empty afterwards.
this fixes restarting X + drm after actually using drm.


To generate a diff of this commit:
cvs rdiff -u -r1.10.10.1 -r1.10.10.2 \
    src/sys/external/bsd/drm/dist/bsd-core/drm_drv.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/external/bsd/drm/dist/bsd-core/drm_drv.c
diff -u src/sys/external/bsd/drm/dist/bsd-core/drm_drv.c:1.10.10.1 src/sys/external/bsd/drm/dist/bsd-core/drm_drv.c:1.10.10.2
--- src/sys/external/bsd/drm/dist/bsd-core/drm_drv.c:1.10.10.1	Sat Jun 20 23:36:59 2009
+++ src/sys/external/bsd/drm/dist/bsd-core/drm_drv.c	Sun Aug 30 02:52:31 2009
@@ -932,7 +932,17 @@
 #if defined(__NetBSD__)
 	/* On NetBSD, close will only be called once */
 	DRM_DEBUG("setting open_count %d to 1\n", (int)dev->open_count);
-	dev->open_count = 1;
+	while (dev->open_count != 1) {
+		/*
+		 * XXXMRG probably should assert that we are freeing
+		 * one of these each time.  i think.
+		 */
+		if (!TAILQ_EMPTY(&dev->files)) {
+			file_priv = TAILQ_FIRST(&dev->files);
+			TAILQ_REMOVE(&dev->files, file_priv, link);
+		}
+		dev->open_count--;
+	}
 #endif
 	if (--dev->open_count == 0) {
 		retcode = drm_lastclose(dev);

Reply via email to