Prakash Dhavali | 7090c5f | 2015-11-02 17:55:19 -0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2014-2015 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 | #ifndef _I_CDF_DEFER_H |
| 29 | #define _I_CDF_DEFER_H |
| 30 | |
| 31 | #include <linux/version.h> |
| 32 | #include <linux/workqueue.h> |
| 33 | #include <linux/interrupt.h> |
| 34 | #ifdef CONFIG_CNSS |
| 35 | #include <net/cnss.h> |
| 36 | #endif |
| 37 | #include <cdf_types.h> |
| 38 | #include <cdf_status.h> |
| 39 | #include <cdf_trace.h> |
| 40 | |
| 41 | typedef struct tasklet_struct __cdf_bh_t; |
| 42 | |
| 43 | typedef void (*__cdf_bh_fn_t)(unsigned long arg); |
| 44 | |
| 45 | /* wrapper around the real task func */ |
| 46 | typedef struct { |
| 47 | struct work_struct work; |
| 48 | cdf_defer_fn_t fn; |
| 49 | void *arg; |
| 50 | } __cdf_work_t; |
| 51 | |
| 52 | extern void __cdf_defer_func(struct work_struct *work); |
| 53 | |
| 54 | static inline CDF_STATUS |
| 55 | __cdf_init_work(cdf_handle_t hdl, |
| 56 | __cdf_work_t *work, cdf_defer_fn_t func, void *arg) |
| 57 | { |
| 58 | /*Initilize func and argument in work struct */ |
| 59 | work->fn = func; |
| 60 | work->arg = arg; |
| 61 | #ifdef CONFIG_CNSS |
| 62 | cnss_init_work(&work->work, __cdf_defer_func); |
| 63 | #else |
| 64 | INIT_WORK(&work->work, __cdf_defer_func); |
| 65 | #endif |
| 66 | return CDF_STATUS_SUCCESS; |
| 67 | } |
| 68 | |
| 69 | static inline CDF_STATUS __cdf_sched_work(cdf_handle_t hdl, __cdf_work_t *work) |
| 70 | { |
| 71 | schedule_work(&work->work); |
| 72 | return CDF_STATUS_SUCCESS; |
| 73 | } |
| 74 | |
| 75 | static inline CDF_STATUS |
| 76 | __cdf_disable_work(cdf_handle_t hdl, __cdf_work_t *work) |
| 77 | { |
| 78 | return CDF_STATUS_SUCCESS; |
| 79 | } |
| 80 | |
| 81 | static inline CDF_STATUS __cdf_init_bh(cdf_handle_t hdl, |
| 82 | struct tasklet_struct *bh, |
| 83 | cdf_defer_fn_t func, void *arg) |
| 84 | { |
| 85 | tasklet_init(bh, (__cdf_bh_fn_t) func, (unsigned long)arg); |
| 86 | |
| 87 | return CDF_STATUS_SUCCESS; |
| 88 | } |
| 89 | |
| 90 | static inline CDF_STATUS |
| 91 | __cdf_sched_bh(cdf_handle_t hdl, struct tasklet_struct *bh) |
| 92 | { |
| 93 | tasklet_schedule(bh); |
| 94 | |
| 95 | return CDF_STATUS_SUCCESS; |
| 96 | } |
| 97 | |
| 98 | static inline CDF_STATUS |
| 99 | __cdf_disable_bh(cdf_handle_t hdl, struct tasklet_struct *bh) |
| 100 | { |
| 101 | tasklet_kill(bh); |
| 102 | |
| 103 | return CDF_STATUS_SUCCESS; |
| 104 | } |
| 105 | |
| 106 | #endif /*_I_CDF_DEFER_H*/ |