]> git.proxmox.com Git - mirror_spl.git/commitdiff
Fix cstyle issue in mutex.h
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 25 Feb 2015 17:20:38 +0000 (09:20 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 3 Mar 2015 18:13:25 +0000 (10:13 -0800)
This patch only addresses the issues identified by the style checker
in mutex.h.  It contains no functional changes.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tim Chase <tim@chase2k.com>
Issue #435

include/sys/mutex.h

index 31497f6a1f49cb7af911b5205bc052b75c804a36..43467223c6c795645033544782e43616ff2abd0a 100644 (file)
@@ -1,4 +1,4 @@
-/*****************************************************************************\
+/*
  *  Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
  *  Copyright (C) 2007 The Regents of the University of California.
  *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
  *
  *  You should have received a copy of the GNU General Public License along
  *  with the SPL.  If not, see <http://www.gnu.org/licenses/>.
-\*****************************************************************************/
+ */
 
 #ifndef _SPL_MUTEX_H
-#define _SPL_MUTEX_H
+#define        _SPL_MUTEX_H
 
 #include <sys/types.h>
 #include <linux/mutex.h>
 #include <linux/compiler_compat.h>
 
 typedef enum {
-        MUTEX_DEFAULT  = 0,
-        MUTEX_SPIN     = 1,
-        MUTEX_ADAPTIVE = 2
+       MUTEX_DEFAULT   = 0,
+       MUTEX_SPIN      = 1,
+       MUTEX_ADAPTIVE  = 2
 } kmutex_type_t;
 
 #if defined(HAVE_MUTEX_OWNER) && defined(CONFIG_SMP) && \
-    !defined(CONFIG_DEBUG_MUTEXES)
+       !defined(CONFIG_DEBUG_MUTEXES)
 
-/*
- * We define a 1-field struct rather than a straight typedef to enforce type
- * safety.
- */
 typedef struct {
-        struct mutex m;
-       spinlock_t m_lock;      /* used for serializing mutex_exit */
+       struct mutex            m;
+       spinlock_t              m_lock; /* used for serializing mutex_exit */
 } kmutex_t;
 
 static inline kthread_t *
 mutex_owner(kmutex_t *mp)
 {
 #if defined(HAVE_MUTEX_OWNER_TASK_STRUCT)
-       return ACCESS_ONCE(mp->m.owner);
+       return (ACCESS_ONCE(mp->m.owner));
 #else
        struct thread_info *owner = ACCESS_ONCE(mp->m.owner);
        if (owner)
-               return owner->task;
+               return (owner->task);
 
-       return NULL;
+       return (NULL);
 #endif
 }
 
-#define mutex_owned(mp)         (mutex_owner(mp) == current)
-#define MUTEX_HELD(mp)          mutex_owned(mp)
-#define MUTEX_NOT_HELD(mp)      (!MUTEX_HELD(mp))
+#define        mutex_owned(mp)         (mutex_owner(mp) == current)
+#define        MUTEX_HELD(mp)          mutex_owned(mp)
+#define        MUTEX_NOT_HELD(mp)      (!MUTEX_HELD(mp))
 #undef mutex_init
-#define mutex_init(mp, name, type, ibc)                                 \
-({                                                                      \
-        static struct lock_class_key __key;                             \
-        ASSERT(type == MUTEX_DEFAULT);                                  \
-                                                                        \
-        __mutex_init(&(mp)->m, #mp, &__key);                            \
-       spin_lock_init(&(mp)->m_lock);                                  \
-})
+#define        mutex_init(mp, name, type, ibc)                         \
+{                                                              \
+       static struct lock_class_key __key;                     \
+       ASSERT(type == MUTEX_DEFAULT);                          \
+                                                               \
+       __mutex_init(&(mp)->m, #mp, &__key);                    \
+       spin_lock_init(&(mp)->m_lock);                          \
+}
 
 #undef mutex_destroy
-#define mutex_destroy(mp)                                               \
-({                                                                      \
-        VERIFY3P(mutex_owner(mp), ==, NULL);                            \
-})
+#define        mutex_destroy(mp)                                       \
+{                                                              \
+       VERIFY3P(mutex_owner(mp), ==, NULL);                    \
+}
 
-#define mutex_tryenter(mp)              mutex_trylock(&(mp)->m)
-#define mutex_enter(mp)                                                 \
-({                                                                      \
-        ASSERT3P(mutex_owner(mp), !=, current);                                \
-        mutex_lock(&(mp)->m);                                          \
-})
+#define        mutex_tryenter(mp)      mutex_trylock(&(mp)->m)
+#define        mutex_enter(mp)                                         \
+{                                                              \
+       ASSERT3P(mutex_owner(mp), !=, current);                 \
+       mutex_lock(&(mp)->m);                                   \
+}
 /*
  * The reason for the spinlock:
  *
@@ -105,39 +101,39 @@ mutex_owner(kmutex_t *mp)
  *
  * See http://lwn.net/Articles/575477/ for the information about the race.
  */
-#define mutex_exit(mp)                                                 \
-({                                                                     \
-       spin_lock(&(mp)->m_lock);                                       \
-       mutex_unlock(&(mp)->m);                                         \
-       spin_unlock(&(mp)->m_lock);                                     \
-})
+#define        mutex_exit(mp)                                          \
+{                                                              \
+       spin_lock(&(mp)->m_lock);                               \
+       mutex_unlock(&(mp)->m);                                 \
+       spin_unlock(&(mp)->m_lock);                             \
+}
 
 #else /* HAVE_MUTEX_OWNER */
 
 typedef struct {
-        struct mutex m_mutex;
-       spinlock_t m_lock;
-        kthread_t *m_owner;
+       struct mutex            m_mutex;
+       spinlock_t              m_lock; /* used for serializing mutex_exit */
+       kthread_t               *m_owner;
 } kmutex_t;
 
-#define MUTEX(mp)               (&((mp)->m_mutex))
+#define        MUTEX(mp)               (&((mp)->m_mutex))
 
 static inline void
 spl_mutex_set_owner(kmutex_t *mp)
 {
-        mp->m_owner = current;
+       mp->m_owner = current;
 }
 
 static inline void
 spl_mutex_clear_owner(kmutex_t *mp)
 {
-        mp->m_owner = NULL;
+       mp->m_owner = NULL;
 }
 
-#define mutex_owner(mp)         (ACCESS_ONCE((mp)->m_owner))
-#define mutex_owned(mp)         (mutex_owner(mp) == current)
-#define MUTEX_HELD(mp)          mutex_owned(mp)
-#define MUTEX_NOT_HELD(mp)      (!MUTEX_HELD(mp))
+#define        mutex_owner(mp)         (ACCESS_ONCE((mp)->m_owner))
+#define        mutex_owned(mp)         (mutex_owner(mp) == current)
+#define        MUTEX_HELD(mp)          mutex_owned(mp)
+#define        MUTEX_NOT_HELD(mp)      (!MUTEX_HELD(mp))
 
 /*
  * The following functions must be a #define and not static inline.
@@ -146,46 +142,46 @@ spl_mutex_clear_owner(kmutex_t *mp)
  * for the built in kernel lock analysis tools
  */
 #undef mutex_init
-#define mutex_init(mp, name, type, ibc)                                 \
-({                                                                      \
-        static struct lock_class_key __key;                             \
-        ASSERT(type == MUTEX_DEFAULT);                                  \
-                                                                        \
-        __mutex_init(MUTEX(mp), #mp, &__key);                           \
-       spin_lock_init(&(mp)->m_lock);                                  \
-        spl_mutex_clear_owner(mp);                                      \
-})
+#define        mutex_init(mp, name, type, ibc)                         \
+{                                                              \
+       static struct lock_class_key __key;                     \
+       ASSERT(type == MUTEX_DEFAULT);                          \
+                                                               \
+       __mutex_init(MUTEX(mp), #mp, &__key);                   \
+       spin_lock_init(&(mp)->m_lock);                          \
+       spl_mutex_clear_owner(mp);                              \
+}
 
 #undef mutex_destroy
-#define mutex_destroy(mp)                                               \
-({                                                                      \
-        VERIFY3P(mutex_owner(mp), ==, NULL);                            \
-})
+#define        mutex_destroy(mp)                                       \
+{                                                              \
+       VERIFY3P(mutex_owner(mp), ==, NULL);                    \
+}
 
-#define mutex_tryenter(mp)                                              \
-({                                                                      \
-        int _rc_;                                                       \
-                                                                        \
-        if ((_rc_ = mutex_trylock(MUTEX(mp))) == 1)                     \
-                spl_mutex_set_owner(mp);                                \
-                                                                        \
-        _rc_;                                                           \
+#define        mutex_tryenter(mp)                                      \
+({                                                             \
+       int _rc_;                                               \
+                                                               \
+       if ((_rc_ = mutex_trylock(MUTEX(mp))) == 1)             \
+               spl_mutex_set_owner(mp);                        \
+                                                               \
+       _rc_;                                                   \
 })
 
-#define mutex_enter(mp)                                                 \
-({                                                                      \
-       ASSERT3P(mutex_owner(mp), !=, current);                         \
-       mutex_lock(MUTEX(mp));                                          \
-       spl_mutex_set_owner(mp);                                        \
-})
+#define        mutex_enter(mp)                                         \
+{                                                              \
+       ASSERT3P(mutex_owner(mp), !=, current);                 \
+       mutex_lock(MUTEX(mp));                                  \
+       spl_mutex_set_owner(mp);                                \
+}
 
-#define mutex_exit(mp)                                                  \
-({                                                                      \
-       spin_lock(&(mp)->m_lock);                                       \
-        spl_mutex_clear_owner(mp);                                      \
-        mutex_unlock(MUTEX(mp));                                        \
-       spin_unlock(&(mp)->m_lock);                                     \
-})
+#define        mutex_exit(mp)                                          \
+{                                                              \
+       spin_lock(&(mp)->m_lock);                               \
+       spl_mutex_clear_owner(mp);                              \
+       mutex_unlock(MUTEX(mp));                                \
+       spin_unlock(&(mp)->m_lock);                             \
+}
 
 #endif /* HAVE_MUTEX_OWNER */