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 /** 55 * qdf_timer_start() - start a timer 56 * @timer: timer to start 57 * @msec: Expiration period in milliseconds 58 * 59 * If QDF timer multiplier is set, the timeout value may get scaled. 60 * 61 * Return: none 62 */ 63 static inline void qdf_timer_start(qdf_timer_t *timer, int msec) 64 { 65 __qdf_timer_start(timer, msec); 66 } 67 68 /** 69 * qdf_timer_mod() - modify the timeout on a timer 70 * @timer: timer to modify 71 * @msec: Expiration period in milliseconds 72 * 73 * If @timer is not active, it will be activated. 74 * 75 * If QDF timer multiplier is set, the timeout value may get scaled. 76 * 77 * Return: none 78 */ 79 static inline void qdf_timer_mod(qdf_timer_t *timer, int msec) 80 { 81 __qdf_timer_mod(timer, msec); 82 } 83 84 /** 85 * qdf_timer_stop() - cancel a timer 86 * @timer: timer to cancel 87 * 88 * Note! The timer callback may be executing when this function call returns. 89 * If you want to ensure that it is not, use qdf_timer_sync_cancel() instead. 90 * 91 * Return: true if @timer was deactivated, false if @timer was not active 92 */ 93 static inline bool qdf_timer_stop(qdf_timer_t *timer) 94 { 95 return __qdf_timer_stop(timer); 96 } 97 98 /** 99 * qdf_timer_sync_cancel - Cancel a timer synchronously 100 * @timer: timer to cancel 101 * 102 * If the timer callback is already running, this function blocks until it 103 * completes. 104 * 105 * Return: true if @timer was deactivated, false if @timer was not active 106 */ 107 static inline bool qdf_timer_sync_cancel(qdf_timer_t *timer) 108 { 109 return __qdf_timer_sync_cancel(timer); 110 } 111 112 /** 113 * qdf_timer_free() - free a timer 114 * @timer: timer to free 115 * 116 * If the timer callback is already running, this function blocks until it 117 * completes. 118 * 119 * Return: none 120 */ 121 static inline void qdf_timer_free(qdf_timer_t *timer) 122 { 123 __qdf_timer_free(timer); 124 } 125 126 #endif /* _QDF_TIMER_H */ 127