Module Name:    src
Committed By:   riastradh
Date:           Sun Sep  8 16:08:38 UTC 2013

Modified Files:
        src/sys/external/bsd/drm2/dist/drm [riastradh-drm2]: drm_auth.c

Log Message:
Use Linux atomics, not spinlocks or NetBSD atomics in drm_auth.c.

Removes an #ifdef __NetBSD__.


To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1.2.3 -r1.1.1.1.2.4 \
    src/sys/external/bsd/drm2/dist/drm/drm_auth.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/drm2/dist/drm/drm_auth.c
diff -u src/sys/external/bsd/drm2/dist/drm/drm_auth.c:1.1.1.1.2.3 src/sys/external/bsd/drm2/dist/drm/drm_auth.c:1.1.1.1.2.4
--- src/sys/external/bsd/drm2/dist/drm/drm_auth.c:1.1.1.1.2.3	Wed Jul 24 02:00:22 2013
+++ src/sys/external/bsd/drm2/dist/drm/drm_auth.c	Sun Sep  8 16:08:38 2013
@@ -141,10 +141,7 @@ int drm_remove_magic(struct drm_master *
  */
 int drm_getmagic(struct drm_device *dev, void *data, struct drm_file *file_priv)
 {
-	static drm_magic_t sequence = 0;
-#ifndef __NetBSD__
-	static DEFINE_SPINLOCK(lock);
-#endif
+	static atomic_t sequence = ATOMIC_INIT(0);
 	struct drm_auth *auth = data;
 
 	/* Find unique magic */
@@ -152,15 +149,7 @@ int drm_getmagic(struct drm_device *dev,
 		auth->magic = file_priv->magic;
 	} else {
 		do {
-#ifdef __NetBSD__
-			auth->magic = atomic_inc_uint_nv(&sequence);
-#else
-			spin_lock(&lock);
-			if (!sequence)
-				++sequence;	/* reserve 0 */
-			auth->magic = sequence++;
-			spin_unlock(&lock);
-#endif
+			auth->magic = atomic_inc_return(&sequence);
 		} while (drm_find_file(file_priv->master, auth->magic));
 		file_priv->magic = auth->magic;
 		drm_add_magic(file_priv->master, file_priv, auth->magic);

Reply via email to