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
This commit is contained in:
Houston Hoffman
2016-12-22 13:26:37 -08:00
committed by Gerrit - the friendly Code Review server
parent 94f80a1b70
commit 7dcbb86c23
3 changed files with 30 additions and 7 deletions

View File

@@ -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. * 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 * qdf_spinlock_create - Initialize a spinlock
* @lock: spinlock object pointer * @lock: spinlock object pointer
* Retrun: none * Return: none
*/ */
static inline void qdf_spinlock_create(qdf_spinlock_t *lock) 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_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 * qdf_spin_trylock_bh() - spin trylock bottomhalf
* @lock: spinlock object * @lock: spinlock object
* Return: int *
* Return: nonzero if lock is acquired
*/ */
static inline int qdf_spin_trylock_bh(qdf_spinlock_t *lock) static inline int qdf_spin_trylock_bh(qdf_spinlock_t *lock)
{ {

View File

@@ -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. * 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) \ #define __qdf_spin_unlock_irq(_p_lock, _flags) \
spin_unlock_irqrestore(_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 * __qdf_spin_trylock_bh() - spin trylock bottomhalf
* @lock: spinlock object * @lock: spinlock object
* *
* Retrun: int * Return: nonzero if lock is acquired
*/ */
static inline int __qdf_spin_trylock_bh(__qdf_spinlock_t *lock) static inline int __qdf_spin_trylock_bh(__qdf_spinlock_t *lock)
{ {

View File

@@ -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. * 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 * qdf_spin_trylock_bh_outline() - spin trylock bottomhalf
* @lock: spinlock object * @lock: spinlock object
* Retrun: int * Return: nonzero if lock is acquired
*/ */
int qdf_spin_trylock_bh_outline(qdf_spinlock_t *lock) int qdf_spin_trylock_bh_outline(qdf_spinlock_t *lock)
{ {