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/module.h> 26 #include <linux/workqueue.h> 27 28 #include "i_qdf_defer.h" 29 #include <qdf_module.h> 30 31 /** 32 * __qdf_defer_func() - defer work handler 33 * @work: Pointer to defer work 34 * 35 * Return: none 36 */ 37 void __qdf_defer_func(struct work_struct *work) 38 { 39 __qdf_work_t *ctx = container_of(work, __qdf_work_t, work); 40 41 if (ctx->fn == NULL) { 42 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, 43 "No callback registered !!"); 44 return; 45 } 46 ctx->fn(ctx->arg); 47 } 48 qdf_export_symbol(__qdf_defer_func); 49 50 /** 51 * __qdf_defer_delayed_func() - defer work handler 52 * @dwork: Pointer to defer work 53 * 54 * Return: none 55 */ 56 void 57 __qdf_defer_delayed_func(struct work_struct *dwork) 58 { 59 __qdf_delayed_work_t *ctx = container_of(dwork, __qdf_delayed_work_t, 60 dwork.work); 61 if (ctx->fn == NULL) { 62 QDF_TRACE(QDF_MODULE_ID_QDF, QDF_TRACE_LEVEL_ERROR, 63 "BugCheck: Callback is not initilized while creating delayed work queue"); 64 return; 65 } 66 ctx->fn(ctx->arg); 67 } 68 qdf_export_symbol(__qdf_defer_delayed_func); 69