From 205aeca91d4857b0dd85149c2d74988c5f3e2857 Mon Sep 17 00:00:00 2001 From: Pavankumar Nandeshwar Date: Wed, 11 Oct 2017 19:08:05 +0530 Subject: [PATCH] qcacmn: Add a new qdf API for spin_trylock This change adds a qdf wrapper api qdf_spin_trylock for spin_trylock. Change-Id: I3406ed96f7f40df24949bd4e21ceb144d919d58d --- qdf/inc/qdf_lock.h | 20 +++++++++++++++++++- qdf/linux/src/i_qdf_lock.h | 13 ++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/qdf/inc/qdf_lock.h b/qdf/inc/qdf_lock.h index a5a623d139a2..15370ec170a8 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 0a26bdbd5aa8..98f499b1d93b 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