Ver Fonte

qcacmn: Introduce qdf_spin_is_locked

Add a wrapper to check if a spinlock is currently
locked without acquiring it.

Change-Id: I867cfd00a61b1632e9652cdffc896b2654e3c338
CRs-Fixed: 1100505
Houston Hoffman há 8 anos atrás
pai
commit
7dcbb86c23
3 ficheiros alterados com 30 adições e 7 exclusões
  1. 15 3
      qdf/inc/qdf_lock.h
  2. 13 2
      qdf/linux/src/i_qdf_lock.h
  3. 2 2
      qdf/linux/src/qdf_lock.c

+ 15 - 3
qdf/inc/qdf_lock.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -75,7 +75,7 @@ QDF_STATUS qdf_mutex_destroy(qdf_mutex_t *lock);
 /**
  * qdf_spinlock_create - Initialize a spinlock
  * @lock: spinlock object pointer
- * Retrun: none
+ * Return: none
  */
 static inline void qdf_spinlock_create(qdf_spinlock_t *lock)
 {
@@ -92,10 +92,22 @@ static inline void qdf_spinlock_destroy(qdf_spinlock_t *lock)
 	__qdf_spinlock_destroy(lock);
 }
 
+/**
+ * qdf_spin_is_locked() - check if the spinlock is locked
+ * @lock: spinlock object
+ *
+ * Return: nonzero if lock is held.
+ */
+static inline int qdf_spin_is_locked(qdf_spinlock_t *lock)
+{
+	return __qdf_spin_is_locked(&lock->lock);
+}
+
 /**
  * qdf_spin_trylock_bh() - spin trylock bottomhalf
  * @lock: spinlock object
- * Return: int
+ *
+ * Return: nonzero if lock is acquired
  */
 static inline int qdf_spin_trylock_bh(qdf_spinlock_t *lock)
 {

+ 13 - 2
qdf/linux/src/i_qdf_lock.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -237,11 +237,22 @@ static inline void __qdf_spin_unlock_irqrestore(__qdf_spinlock_t *lock)
 #define __qdf_spin_unlock_irq(_p_lock, _flags) \
 	spin_unlock_irqrestore(_p_lock, _flags)
 
+/**
+ * __qdf_spin_is_locked(__qdf_spinlock_t *lock)
+ * @lock: spinlock object
+ *
+ * Return: nonzero if lock is held.
+ */
+static inline int __qdf_spin_is_locked(__qdf_spinlock_t *lock)
+{
+	return spin_is_locked(&lock->spinlock);
+}
+
 /**
  * __qdf_spin_trylock_bh() - spin trylock bottomhalf
  * @lock: spinlock object
  *
- * Retrun: int
+ * Return: nonzero if lock is acquired
  */
 static inline int __qdf_spin_trylock_bh(__qdf_spinlock_t *lock)
 {

+ 2 - 2
qdf/linux/src/qdf_lock.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -636,7 +636,7 @@ EXPORT_SYMBOL(qdf_mutex_destroy);
 /**
  * qdf_spin_trylock_bh_outline() - spin trylock bottomhalf
  * @lock: spinlock object
- * Retrun: int
+ * Return: nonzero if lock is acquired
  */
 int qdf_spin_trylock_bh_outline(qdf_spinlock_t *lock)
 {