diff --git a/qdf/inc/qdf_lock.h b/qdf/inc/qdf_lock.h index a5a623d139..15370ec170 100644 --- a/qdf/inc/qdf_lock.h +++ b/qdf/inc/qdf_lock.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -298,6 +298,24 @@ static inline int qdf_spin_trylock_bh(qdf_spinlock_t *lock, const char *func) int qdf_spin_trylock_bh_outline(qdf_spinlock_t *lock); +/** + * qdf_spin_trylock() - spin trylock + * @lock: spinlock object + * Return: int + */ +static inline int qdf_spin_trylock(qdf_spinlock_t *lock, const char *func) +{ + int result = 0; + + BEFORE_LOCK(lock, qdf_spin_is_locked(lock)); + result = __qdf_spin_trylock(&lock->lock); + AFTER_LOCK(lock, func); + + return result; +} + +#define qdf_spin_trylock(lock) qdf_spin_trylock(lock, __func__) + /** * qdf_spin_lock_bh() - locks the spinlock mutex in soft irq context * @lock: spinlock object pointer diff --git a/qdf/linux/src/i_qdf_lock.h b/qdf/linux/src/i_qdf_lock.h index 0a26bdbd5a..98f499b1d9 100644 --- a/qdf/linux/src/i_qdf_lock.h +++ b/qdf/linux/src/i_qdf_lock.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2017 The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. * * Permission to use, copy, modify, and/or distribute this software for * any purpose with or without fee is hereby granted, provided that the @@ -266,6 +266,17 @@ static inline int __qdf_spin_trylock_bh(__qdf_spinlock_t *lock) return 0; } +/** + * __qdf_spin_trylock() - spin trylock + * @lock: spinlock object + * + * Return: int + */ +static inline int __qdf_spin_trylock(__qdf_spinlock_t *lock) +{ + return spin_trylock(&lock->spinlock); +} + /** * __qdf_spin_lock_bh() - Acquire the spinlock and disable bottom halves * @lock: Lock object