Fix cstyle issue in mutex.h

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
This commit is contained in:
Brian Behlendorf 2015-02-25 09:20:38 -08:00
parent c1bc8e610b
commit a900e28e71

View File

@ -1,4 +1,4 @@
/*****************************************************************************\ /*
* Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC. * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
* Copyright (C) 2007 The Regents of the University of California. * Copyright (C) 2007 The Regents of the University of California.
* Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER). * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
@ -20,7 +20,7 @@
* *
* You should have received a copy of the GNU General Public License along * You should have received a copy of the GNU General Public License along
* with the SPL. If not, see <http://www.gnu.org/licenses/>. * with the SPL. If not, see <http://www.gnu.org/licenses/>.
\*****************************************************************************/ */
#ifndef _SPL_MUTEX_H #ifndef _SPL_MUTEX_H
#define _SPL_MUTEX_H #define _SPL_MUTEX_H
@ -38,10 +38,6 @@ typedef enum {
#if defined(HAVE_MUTEX_OWNER) && defined(CONFIG_SMP) && \ #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 { typedef struct {
struct mutex m; struct mutex m;
spinlock_t m_lock; /* used for serializing mutex_exit */ spinlock_t m_lock; /* used for serializing mutex_exit */
@ -51,13 +47,13 @@ static inline kthread_t *
mutex_owner(kmutex_t *mp) mutex_owner(kmutex_t *mp)
{ {
#if defined(HAVE_MUTEX_OWNER_TASK_STRUCT) #if defined(HAVE_MUTEX_OWNER_TASK_STRUCT)
return ACCESS_ONCE(mp->m.owner); return (ACCESS_ONCE(mp->m.owner));
#else #else
struct thread_info *owner = ACCESS_ONCE(mp->m.owner); struct thread_info *owner = ACCESS_ONCE(mp->m.owner);
if (owner) if (owner)
return owner->task; return (owner->task);
return NULL; return (NULL);
#endif #endif
} }
@ -66,26 +62,26 @@ mutex_owner(kmutex_t *mp)
#define MUTEX_NOT_HELD(mp) (!MUTEX_HELD(mp)) #define MUTEX_NOT_HELD(mp) (!MUTEX_HELD(mp))
#undef mutex_init #undef mutex_init
#define mutex_init(mp, name, type, ibc) \ #define mutex_init(mp, name, type, ibc) \
({ \ { \
static struct lock_class_key __key; \ static struct lock_class_key __key; \
ASSERT(type == MUTEX_DEFAULT); \ ASSERT(type == MUTEX_DEFAULT); \
\ \
__mutex_init(&(mp)->m, #mp, &__key); \ __mutex_init(&(mp)->m, #mp, &__key); \
spin_lock_init(&(mp)->m_lock); \ spin_lock_init(&(mp)->m_lock); \
}) }
#undef mutex_destroy #undef mutex_destroy
#define mutex_destroy(mp) \ #define mutex_destroy(mp) \
({ \ { \
VERIFY3P(mutex_owner(mp), ==, NULL); \ VERIFY3P(mutex_owner(mp), ==, NULL); \
}) }
#define mutex_tryenter(mp) mutex_trylock(&(mp)->m) #define mutex_tryenter(mp) mutex_trylock(&(mp)->m)
#define mutex_enter(mp) \ #define mutex_enter(mp) \
({ \ { \
ASSERT3P(mutex_owner(mp), !=, current); \ ASSERT3P(mutex_owner(mp), !=, current); \
mutex_lock(&(mp)->m); \ mutex_lock(&(mp)->m); \
}) }
/* /*
* The reason for the spinlock: * The reason for the spinlock:
* *
@ -106,17 +102,17 @@ mutex_owner(kmutex_t *mp)
* See http://lwn.net/Articles/575477/ for the information about the race. * See http://lwn.net/Articles/575477/ for the information about the race.
*/ */
#define mutex_exit(mp) \ #define mutex_exit(mp) \
({ \ { \
spin_lock(&(mp)->m_lock); \ spin_lock(&(mp)->m_lock); \
mutex_unlock(&(mp)->m); \ mutex_unlock(&(mp)->m); \
spin_unlock(&(mp)->m_lock); \ spin_unlock(&(mp)->m_lock); \
}) }
#else /* HAVE_MUTEX_OWNER */ #else /* HAVE_MUTEX_OWNER */
typedef struct { typedef struct {
struct mutex m_mutex; struct mutex m_mutex;
spinlock_t m_lock; spinlock_t m_lock; /* used for serializing mutex_exit */
kthread_t *m_owner; kthread_t *m_owner;
} kmutex_t; } kmutex_t;
@ -147,20 +143,20 @@ spl_mutex_clear_owner(kmutex_t *mp)
*/ */
#undef mutex_init #undef mutex_init
#define mutex_init(mp, name, type, ibc) \ #define mutex_init(mp, name, type, ibc) \
({ \ { \
static struct lock_class_key __key; \ static struct lock_class_key __key; \
ASSERT(type == MUTEX_DEFAULT); \ ASSERT(type == MUTEX_DEFAULT); \
\ \
__mutex_init(MUTEX(mp), #mp, &__key); \ __mutex_init(MUTEX(mp), #mp, &__key); \
spin_lock_init(&(mp)->m_lock); \ spin_lock_init(&(mp)->m_lock); \
spl_mutex_clear_owner(mp); \ spl_mutex_clear_owner(mp); \
}) }
#undef mutex_destroy #undef mutex_destroy
#define mutex_destroy(mp) \ #define mutex_destroy(mp) \
({ \ { \
VERIFY3P(mutex_owner(mp), ==, NULL); \ VERIFY3P(mutex_owner(mp), ==, NULL); \
}) }
#define mutex_tryenter(mp) \ #define mutex_tryenter(mp) \
({ \ ({ \
@ -173,19 +169,19 @@ spl_mutex_clear_owner(kmutex_t *mp)
}) })
#define mutex_enter(mp) \ #define mutex_enter(mp) \
({ \ { \
ASSERT3P(mutex_owner(mp), !=, current); \ ASSERT3P(mutex_owner(mp), !=, current); \
mutex_lock(MUTEX(mp)); \ mutex_lock(MUTEX(mp)); \
spl_mutex_set_owner(mp); \ spl_mutex_set_owner(mp); \
}) }
#define mutex_exit(mp) \ #define mutex_exit(mp) \
({ \ { \
spin_lock(&(mp)->m_lock); \ spin_lock(&(mp)->m_lock); \
spl_mutex_clear_owner(mp); \ spl_mutex_clear_owner(mp); \
mutex_unlock(MUTEX(mp)); \ mutex_unlock(MUTEX(mp)); \
spin_unlock(&(mp)->m_lock); \ spin_unlock(&(mp)->m_lock); \
}) }
#endif /* HAVE_MUTEX_OWNER */ #endif /* HAVE_MUTEX_OWNER */