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/i_qdf_timer.h | |
| 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/i_qdf_timer.h')
| -rw-r--r-- | qdf/linux/src/i_qdf_timer.h | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/qdf/linux/src/i_qdf_timer.h b/qdf/linux/src/i_qdf_timer.h new file mode 100644 index 000000000000..7909015627d1 --- /dev/null +++ b/qdf/linux/src/i_qdf_timer.h @@ -0,0 +1,154 @@ +/* + * 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: i_qdf_timer + * This file provides OS dependent timer API's. + */ + +#ifndef _I_QDF_TIMER_H +#define _I_QDF_TIMER_H + +#include <linux/version.h> +#include <linux/delay.h> +#include <linux/timer.h> +#include <linux/jiffies.h> +#include <qdf_types.h> + +/* timer data type */ +typedef struct timer_list __qdf_timer_t; + +typedef void (*qdf_dummy_timer_func_t)(unsigned long arg); + +/** + * __qdf_timer_init() - initialize a softirq timer + * @hdl: OS handle + * @timer: Pointer to timer object + * @func: Function pointer + * @arg: Arguement + * @type: deferrable or non deferrable timer type + * + * Timer type QDF_TIMER_TYPE_SW means its a deferrable sw timer which will + * not cause CPU wake upon expiry + * Timer type QDF_TIMER_TYPE_WAKE_APPS means its a non-deferrable timer which + * will cause CPU wake up on expiry + * + * Return: QDF_STATUS + */ +static inline QDF_STATUS __qdf_timer_init(qdf_handle_t hdl, + struct timer_list *timer, + qdf_timer_func_t func, void *arg, + QDF_TIMER_TYPE type) +{ + if (QDF_TIMER_TYPE_SW == type) + init_timer_deferrable(timer); + else + init_timer(timer); + timer->function = (qdf_dummy_timer_func_t) func; + timer->data = (unsigned long)arg; + + return QDF_STATUS_SUCCESS; +} + +/** + * __qdf_timer_start() - start a qdf softirq timer + * @timer: Pointer to timer object + * @delay: Delay in milli seconds + * + * Return: QDF_STATUS + */ +static inline QDF_STATUS __qdf_timer_start(struct timer_list *timer, + uint32_t delay) +{ + timer->expires = jiffies + msecs_to_jiffies(delay); + add_timer(timer); + + return QDF_STATUS_SUCCESS; +} + +/** + * __qdf_timer_mod() - modify a timer + * @timer: Pointer to timer object + * @delay: Delay in milli seconds + * + * Return: QDF_STATUS + */ +static inline QDF_STATUS __qdf_timer_mod(struct timer_list *timer, + uint32_t delay) +{ + mod_timer(timer, jiffies + msecs_to_jiffies(delay)); + + return QDF_STATUS_SUCCESS; +} + +/** + * __qdf_timer_stop() - cancel a timer + * @timer: Pointer to timer object + * + * Return: true if timer was cancelled and deactived, + * false if timer was cancelled but already got fired. + */ +static inline bool __qdf_timer_stop(struct timer_list *timer) +{ + if (likely(del_timer(timer))) + return 1; + else + return 0; +} + +/** + * __qdf_timer_free() - free a qdf timer + * @timer: Pointer to timer object + * + * Return: true if timer was cancelled and deactived, + * false if timer was cancelled but already got fired. + */ +static inline void __qdf_timer_free(struct timer_list *timer) +{ + del_timer_sync(timer); +} + +/** + * __qdf_sostirq_timer_sync_cancel() - Synchronously canel a timer + * @timer: Pointer to timer object + * + * Synchronization Rules: + * 1. caller must make sure timer function will not use + * qdf_set_timer to add iteself again. + * 2. caller must not hold any lock that timer function + * is likely to hold as well. + * 3. It can't be called from interrupt context. + * + * Return: true if timer was cancelled and deactived, + * false if timer was cancelled but already got fired. + */ +static inline bool __qdf_timer_sync_cancel(struct timer_list *timer) +{ + return del_timer_sync(timer); +} + +#endif /*_QDF_TIMER_PVT_H*/ |
