1 /* 2 * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved. 3 * 4 * Permission to use, copy, modify, and/or distribute this software for 5 * any purpose with or without fee is hereby granted, provided that the 6 * above copyright notice and this permission notice appear in all 7 * copies. 8 * 9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 10 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 11 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 12 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 13 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 14 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 15 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 * PERFORMANCE OF THIS SOFTWARE. 17 */ 18 19 /** 20 * DOC: qdf_timer 21 * This file abstracts OS timers running in soft IRQ context. 22 */ 23 24 #ifndef _QDF_TIMER_H 25 #define _QDF_TIMER_H 26 27 #include <qdf_types.h> 28 #include <i_qdf_timer.h> 29 30 /* Platform timer object */ 31 typedef __qdf_timer_t qdf_timer_t; 32 33 /** 34 * qdf_timer_init() - initialize a timer 35 * @hdl: OS handle 36 * @timer: Timer object pointer 37 * @func: Timer function 38 * @arg: Arguement of timer function 39 * @type: deferrable or non deferrable timer type 40 * 41 * Timer type QDF_TIMER_TYPE_SW means its a deferrable sw timer which will 42 * not cause CPU wake upon expiry 43 * Timer type QDF_TIMER_TYPE_WAKE_APPS means its a non-deferrable timer which 44 * will cause CPU wake up on expiry 45 * 46 * Return: none 47 */ 48 static inline void qdf_timer_init(qdf_handle_t hdl, qdf_timer_t *timer, 49 qdf_timer_func_t func, void *arg, 50 QDF_TIMER_TYPE type) 51 { 52 __qdf_timer_init(hdl, timer, func, arg, type); 53 } 54 55 /** 56 * qdf_timer_start() - start a one-shot timer 57 * @timer: Timer object pointer 58 * @msec: Expiration period in milliseconds 59 * 60 * Return: none 61 */ 62 static inline void 63 qdf_timer_start(qdf_timer_t *timer, int msec) 64 { 65 __qdf_timer_start(timer, msec); 66 } 67 68 /** 69 * qdf_timer_mod() - modify existing timer to new timeout value 70 * @timer: Timer object pointer 71 * @msec: Expiration period in milliseconds 72 * 73 * Return: none 74 */ 75 static inline void qdf_timer_mod(qdf_timer_t *timer, int msec) 76 { 77 __qdf_timer_mod(timer, msec); 78 } 79 80 /** 81 * qdf_timer_stop() - cancel qdf timer 82 * @timer: Timer object pointer 83 * 84 * return: bool TRUE Timer was cancelled and deactived 85 * FALSE Timer was cancelled but already got fired. 86 * 87 * The function will return after any running timer completes. 88 */ 89 static inline bool qdf_timer_stop(qdf_timer_t *timer) 90 { 91 return __qdf_timer_stop(timer); 92 } 93 94 95 /** 96 * qdf_timer_sync_cancel - Cancel a timer synchronously 97 * The function will return after any running timer completes. 98 * @timer: timer object pointer 99 * 100 * return: bool TRUE timer was cancelled and deactived 101 * FALSE timer was not cancelled 102 */ 103 static inline bool qdf_timer_sync_cancel(qdf_timer_t *timer) 104 { 105 return __qdf_timer_sync_cancel(timer); 106 } 107 108 109 /** 110 * qdf_timer_free() - free qdf timer 111 * @timer: Timer object pointer 112 * 113 * The function will return after any running timer completes. 114 * Return: none 115 */ 116 static inline void qdf_timer_free(qdf_timer_t *timer) 117 { 118 __qdf_timer_free(timer); 119 } 120 121 #endif /* _QDF_TIMER_H */ 122