diff options
| author | Chouhan, Anurag <achouhan@codeaurora.org> | 2016-03-03 18:57:27 +0530 |
|---|---|---|
| committer | Gerrit - the friendly Code Review server <code-review@localhost> | 2016-03-16 12:18:26 -0700 |
| commit | 5776318d1934b14c3b4eb4eb98c74830d64d00a7 (patch) | |
| tree | 911b2792f6d5ce402cd339455bc17bebf4e2dfb6 /qdf/linux/src/qdf_threads.c | |
| parent | 5693683262e239d48dbc3134404db1bf3f380252 (diff) | |
qcacmn: Add QDF OS abstraction convergence
Converge ADF and CDF API's and move them to
QDF folder. MCL/WIN driver use this QDF converged
module for OS abstraction.
Change-Id: I1d0cdfd8730a5c021aaa50b7dc8549d491d760b3
CRs-Fixed: 981187
Diffstat (limited to 'qdf/linux/src/qdf_threads.c')
| -rw-r--r-- | qdf/linux/src/qdf_threads.c | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/qdf/linux/src/qdf_threads.c b/qdf/linux/src/qdf_threads.c new file mode 100644 index 000000000000..758b5db99eb4 --- /dev/null +++ b/qdf/linux/src/qdf_threads.c @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved. + * + * Previously licensed under the ISC license by Qualcomm Atheros, Inc. + * + * + * Permission to use, copy, modify, and/or distribute this software for + * any purpose with or without fee is hereby granted, provided that the + * above copyright notice and this permission notice appear in all + * copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL + * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE + * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + * PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * This file was originally distributed by Qualcomm Atheros, Inc. + * under proprietary terms before Copyright ownership was assigned + * to the Linux Foundation. + */ + +/** + * DOC: qdf_threads + * QCA driver framework (QDF) thread APIs + */ + +/* Include Files */ +#include <qdf_threads.h> +#include <qdf_types.h> +#include <qdf_trace.h> +#include <linux/jiffies.h> +#include <linux/sched.h> +#include <linux/delay.h> +#include <linux/interrupt.h> + +/* Function declarations and documenation */ + +/** + * qdf_sleep() - sleep + * @ms_interval : Number of milliseconds to suspend the current thread. + * A value of 0 may or may not cause the current thread to yield. + * + * This function suspends the execution of the current thread + * until the specified time out interval elapses. + * + * Return: none + */ +void qdf_sleep(uint32_t ms_interval) +{ + if (in_interrupt()) { + QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, + "%s cannot be called from interrupt context!!!", + __func__); + return; + } + msleep_interruptible(ms_interval); +} +EXPORT_SYMBOL(qdf_sleep); + +/** + * qdf_sleep_us() - sleep + * @us_interval : Number of microseconds to suspend the current thread. + * A value of 0 may or may not cause the current thread to yield. + * + * This function suspends the execution of the current thread + * until the specified time out interval elapses. + * + * Return : none + */ +void qdf_sleep_us(uint32_t us_interval) +{ + unsigned long timeout = usecs_to_jiffies(us_interval) + 1; + if (in_interrupt()) { + QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, + "%s cannot be called from interrupt context!!!", + __func__); + return; + } + + while (timeout && !signal_pending(current)) + timeout = schedule_timeout_interruptible(timeout); +} +EXPORT_SYMBOL(qdf_sleep_us); + +/** + * qdf_busy_wait() - busy wait + * @us_interval : Number of microseconds to busy wait. + * + * This function places the current thread in busy wait until the specified + * time out interval elapses. If the interval is greater than 50us on WM, the + * behaviour is undefined. + * + * Return : none + */ +void qdf_busy_wait(uint32_t us_interval) +{ + udelay(us_interval); +} +EXPORT_SYMBOL(qdf_busy_wait); |
