Browse Source

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
Pavankumar Nandeshwar 7 years ago
parent
commit
205aeca91d
2 changed files with 31 additions and 2 deletions
  1. 19 1
      qdf/inc/qdf_lock.h
  2. 12 1
      qdf/linux/src/i_qdf_lock.h

+ 19 - 1
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

+ 12 - 1
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