1 /* 2 * Copyright (c) 2014-2018 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_defer.c 21 * This file provides OS dependent deferred API's. 22 */ 23 24 #include <linux/kernel.h> 25 #include <linux/version.h> 26 #include <linux/module.h> 27 #include <linux/workqueue.h> 28 29 #include "i_qdf_defer.h" 30 #include <qdf_module.h> 31 32 /** 33 * __qdf_defer_func() - defer work handler 34 * @work: Pointer to defer work 35 * 36 * Return: none 37 */ 38 void __qdf_defer_func(struct work_struct *work) 39 { 40 __qdf_work_t *ctx = container_of(work, __qdf_work_t, work); 41 42 if (ctx->fn == NULL) { 43 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, 44 "No callback registered !!"); 45 return; 46 } 47 ctx->fn(ctx->arg); 48 } 49 qdf_export_symbol(__qdf_defer_func); 50 51 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19) 52 /** 53 * __qdf_defer_delayed_func() - defer work handler 54 * @dwork: Pointer to defer work 55 * 56 * Return: none 57 */ 58 void 59 __qdf_defer_delayed_func(struct work_struct *dwork) 60 { 61 return; 62 } 63 #else 64 void 65 __qdf_defer_delayed_func(struct work_struct *dwork) 66 { 67 __qdf_delayed_work_t *ctx = container_of(dwork, __qdf_delayed_work_t, 68 dwork.work); 69 if (ctx->fn == NULL) { 70 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, 71 "BugCheck: Callback is not initilized while creating delayed work queue"); 72 return; 73 } 74 ctx->fn(ctx->arg); 75 } 76 #endif 77 qdf_export_symbol(__qdf_defer_delayed_func); 78