Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Feb 2012 22:29:36 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r232087 - stable/9/sys/dev/acpica/Osd
Message-ID:  <201202232229.q1NMTaFb028767@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jkim
Date: Thu Feb 23 22:29:36 2012
New Revision: 232087
URL: http://svn.freebsd.org/changeset/base/232087

Log:
  MFC:	r231474
  
  De-obfuscate acpi_acquire_global_lock().

Modified:
  stable/9/sys/dev/acpica/Osd/OsdSynch.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/dev/acpica/Osd/OsdSynch.c
==============================================================================
--- stable/9/sys/dev/acpica/Osd/OsdSynch.c	Thu Feb 23 22:26:14 2012	(r232086)
+++ stable/9/sys/dev/acpica/Osd/OsdSynch.c	Thu Feb 23 22:29:36 2012	(r232087)
@@ -566,11 +566,8 @@ AcpiOsReleaseLock(ACPI_SPINLOCK Handle, 
 }
 
 /* Section 5.2.10.1: global lock acquire/release functions */
-#define	GL_ACQUIRED	(-1)
-#define	GL_BUSY		0
 #define	GL_BIT_PENDING	0x01
 #define	GL_BIT_OWNED	0x02
-#define	GL_BIT_MASK	(GL_BIT_PENDING | GL_BIT_OWNED)
 
 /*
  * Acquire the global lock.  If busy, set the pending bit.  The caller
@@ -584,11 +581,12 @@ acpi_acquire_global_lock(uint32_t *lock)
 
 	do {
 		old = *lock;
-		new = ((old & ~GL_BIT_MASK) | GL_BIT_OWNED) |
-			((old >> 1) & GL_BIT_PENDING);
+		new = (old & ~GL_BIT_PENDING) | GL_BIT_OWNED;
+		if ((old & GL_BIT_OWNED) != 0)
+			new |= GL_BIT_PENDING;
 	} while (atomic_cmpset_acq_int(lock, old, new) == 0);
 
-	return ((new < GL_BIT_MASK) ? GL_ACQUIRED : GL_BUSY);
+	return ((new & GL_BIT_PENDING) == 0);
 }
 
 /*
@@ -603,8 +601,8 @@ acpi_release_global_lock(uint32_t *lock)
 
 	do {
 		old = *lock;
-		new = old & ~GL_BIT_MASK;
+		new = old & ~(GL_BIT_PENDING | GL_BIT_OWNED);
 	} while (atomic_cmpset_rel_int(lock, old, new) == 0);
 
-	return (old & GL_BIT_PENDING);
+	return ((old & GL_BIT_PENDING) != 0);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202232229.q1NMTaFb028767>