]> git.karo-electronics.de Git - karo-tx-linux.git/blob - drivers/staging/wilc1000/wilc_exported_buf.c
Merge tag 'sound-4.2-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai...
[karo-tx-linux.git] / drivers / staging / wilc1000 / wilc_exported_buf.c
1 #include <linux/module.h>
2 #include <linux/moduleparam.h>
3 #include <linux/init.h>
4 #include <linux/kernel.h>
5 #include <linux/slab.h>
6
7 #define LINUX_RX_SIZE   (96 * 1024)
8 #define LINUX_TX_SIZE   (64 * 1024)
9 #define WILC1000_FW_SIZE (4 * 1024)
10
11 #define DECLARE_WILC_BUFFER(name)       \
12         void *exported_ ## name = NULL;
13
14 #define MALLOC_WILC_BUFFER(name, size)  \
15         exported_ ## name = kmalloc(size, GFP_KERNEL);    \
16         if (!exported_ ## name) {   \
17                 printk("fail to alloc: %s memory\n", exported_ ## name);  \
18                 return -ENOBUFS;        \
19         }
20
21 #define FREE_WILC_BUFFER(name)  \
22         kfree(exported_ ## name);
23
24 /*
25  * Add necessary buffer pointers
26  */
27 DECLARE_WILC_BUFFER(g_tx_buf)
28 DECLARE_WILC_BUFFER(g_rx_buf)
29 DECLARE_WILC_BUFFER(g_fw_buf)
30
31 void *get_tx_buffer(void)
32 {
33         return exported_g_tx_buf;
34 }
35 EXPORT_SYMBOL(get_tx_buffer);
36
37 void *get_rx_buffer(void)
38 {
39         return exported_g_rx_buf;
40 }
41 EXPORT_SYMBOL(get_rx_buffer);
42
43 void *get_fw_buffer(void)
44 {
45         return exported_g_fw_buf;
46 }
47 EXPORT_SYMBOL(get_fw_buffer);
48
49 static int __init wilc_module_init(void)
50 {
51         printk("wilc_module_init\n");
52         /*
53          * alloc necessary memory
54          */
55         MALLOC_WILC_BUFFER(g_tx_buf, LINUX_TX_SIZE)
56         MALLOC_WILC_BUFFER(g_rx_buf, LINUX_RX_SIZE)
57         MALLOC_WILC_BUFFER(g_fw_buf, WILC1000_FW_SIZE)
58
59         return 0;
60 }
61
62 static void __exit wilc_module_deinit(void)
63 {
64         printk("wilc_module_deinit\n");
65         FREE_WILC_BUFFER(g_tx_buf)
66         FREE_WILC_BUFFER(g_rx_buf)
67         FREE_WILC_BUFFER(g_fw_buf)
68
69         return;
70 }
71
72 MODULE_LICENSE("Dual BSD/GPL");
73 MODULE_AUTHOR("Tony Cho");
74 MODULE_DESCRIPTION("WILC1xxx Memory Manager");
75 pure_initcall(wilc_module_init);
76 module_exit(wilc_module_deinit);