1 /* 2 * Copyright (c) 2014-2016, 2018-2019 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 typedef struct __qdf_timer_t qdf_timer_t; 31 32 /** 33 * qdf_timer_init() - initialize a timer 34 * @hdl: OS handle 35 * @timer: Timer object pointer 36 * @func: Timer function 37 * @arg: Argument of timer function 38 * @type: deferrable or non deferrable timer type 39 * 40 * Timer type QDF_TIMER_TYPE_SW means its a deferrable sw timer which will 41 * not cause CPU wake upon expiry 42 * Timer type QDF_TIMER_TYPE_WAKE_APPS means its a non-deferrable timer which 43 * will cause CPU wake up on expiry 44 * 45 * Return: QDF_STATUS 46 */ 47 static inline QDF_STATUS 48 qdf_timer_init(qdf_handle_t hdl, qdf_timer_t *timer, qdf_timer_func_t func, 49 void *arg, QDF_TIMER_TYPE type) 50 { 51 return __qdf_timer_init(timer, func, arg, type); 52 } 53 54 #ifdef QDF_TIMER_MULTIPLIER_FRAC 55 #define qdf_msecs_to_jiffies(msec) \ 56 (QDF_TIMER_MULTIPLIER_FRAC * __qdf_msecs_to_jiffies(msec)) 57 #else 58 #define qdf_msecs_to_jiffies(msec) \ 59 (qdf_timer_get_multiplier() * __qdf_msecs_to_jiffies(msec)) 60 #endif 61 62 /** 63 * qdf_timer_start() - start a timer 64 * @timer: timer to start 65 * @msec: Expiration period in milliseconds 66 * 67 * Return: none 68 */ 69 static inline void qdf_timer_start(qdf_timer_t *timer, int msec) 70 { 71 __qdf_timer_start(timer, msec); 72 } 73 74 /** 75 * qdf_timer_mod() - modify the timeout on a timer 76 * @timer: timer to modify 77 * @msec: Expiration period in milliseconds 78 * 79 * If @timer is not active, it will be activated. 80 * 81 * Return: none 82 */ 83 static inline void qdf_timer_mod(qdf_timer_t *timer, int msec) 84 { 85 __qdf_timer_mod(timer, msec); 86 } 87 88 /** 89 * qdf_timer_stop() - cancel a timer 90 * @timer: timer to cancel 91 * 92 * Note! The timer callback may be executing when this function call returns. 93 * If you want to ensure that it is not, use qdf_timer_sync_cancel() instead. 94 * 95 * Return: true if @timer was deactivated, false if @timer was not active 96 */ 97 static inline bool qdf_timer_stop(qdf_timer_t *timer) 98 { 99 return __qdf_timer_stop(timer); 100 } 101 102 /** 103 * qdf_timer_sync_cancel - Cancel a timer synchronously 104 * @timer: timer to cancel 105 * 106 * If the timer callback is already running, this function blocks until it 107 * completes. 108 * 109 * Return: true if @timer was deactivated, false if @timer was not active 110 */ 111 static inline bool qdf_timer_sync_cancel(qdf_timer_t *timer) 112 { 113 return __qdf_timer_sync_cancel(timer); 114 } 115 116 /** 117 * qdf_timer_free() - free a timer 118 * @timer: timer to free 119 * 120 * If the timer callback is already running, this function blocks until it 121 * completes. 122 * 123 * Return: none 124 */ 125 static inline void qdf_timer_free(qdf_timer_t *timer) 126 { 127 __qdf_timer_free(timer); 128 } 129 130 #endif /* _QDF_TIMER_H */ 131