1 /* 2 * Copyright (c) 2014-2018 The Linux Foundation. All rights reserved. 3 * 4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc. 5 * 6 * 7 * Permission to use, copy, modify, and/or distribute this software for 8 * any purpose with or without fee is hereby granted, provided that the 9 * above copyright notice and this permission notice appear in all 10 * copies. 11 * 12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL 13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED 14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE 15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER 18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 19 * PERFORMANCE OF THIS SOFTWARE. 20 */ 21 22 /* 23 * This file was originally distributed by Qualcomm Atheros, Inc. 24 * under proprietary terms before Copyright ownership was assigned 25 * to the Linux Foundation. 26 */ 27 28 /** 29 * DOC: qdf_defer.c 30 * This file provides OS dependent deferred API's. 31 */ 32 33 #include <linux/kernel.h> 34 #include <linux/version.h> 35 #include <linux/module.h> 36 #include <linux/workqueue.h> 37 38 #include "i_qdf_defer.h" 39 #include <qdf_module.h> 40 41 /** 42 * __qdf_defer_func() - defer work handler 43 * @work: Pointer to defer work 44 * 45 * Return: none 46 */ 47 void __qdf_defer_func(struct work_struct *work) 48 { 49 __qdf_work_t *ctx = container_of(work, __qdf_work_t, work); 50 51 if (ctx->fn == NULL) { 52 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, 53 "No callback registered !!"); 54 return; 55 } 56 ctx->fn(ctx->arg); 57 } 58 qdf_export_symbol(__qdf_defer_func); 59 60 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 19) 61 /** 62 * __qdf_defer_delayed_func() - defer work handler 63 * @dwork: Pointer to defer work 64 * 65 * Return: none 66 */ 67 void 68 __qdf_defer_delayed_func(struct work_struct *dwork) 69 { 70 return; 71 } 72 #else 73 void 74 __qdf_defer_delayed_func(struct work_struct *dwork) 75 { 76 __qdf_delayed_work_t *ctx = container_of(dwork, __qdf_delayed_work_t, 77 dwork.work); 78 if (ctx->fn == NULL) { 79 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, 80 "BugCheck: Callback is not initilized while creating delayed work queue"); 81 return; 82 } 83 ctx->fn(ctx->arg); 84 } 85 #endif 86 qdf_export_symbol(__qdf_defer_delayed_func); 87