Merge branch 'pm-cpufreq'
[cascardo/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 MALLOC_WILC_BUFFER(name, size)  \
12         exported_ ## name = kmalloc(size, GFP_KERNEL);    \
13         if (!exported_ ## name) {   \
14                 printk("fail to alloc: %s memory\n", exported_ ## name);  \
15                 return -ENOBUFS;        \
16         }
17
18 #define FREE_WILC_BUFFER(name)  \
19         kfree(exported_ ## name);
20
21 /*
22  * Add necessary buffer pointers
23  */
24 void *exported_g_tx_buf;
25 void *exported_g_rx_buf;
26 void *exported_g_fw_buf;
27
28 void *get_tx_buffer(void)
29 {
30         return exported_g_tx_buf;
31 }
32 EXPORT_SYMBOL(get_tx_buffer);
33
34 void *get_rx_buffer(void)
35 {
36         return exported_g_rx_buf;
37 }
38 EXPORT_SYMBOL(get_rx_buffer);
39
40 void *get_fw_buffer(void)
41 {
42         return exported_g_fw_buf;
43 }
44 EXPORT_SYMBOL(get_fw_buffer);
45
46 static int __init wilc_module_init(void)
47 {
48         printk("wilc_module_init\n");
49         /*
50          * alloc necessary memory
51          */
52         MALLOC_WILC_BUFFER(g_tx_buf, LINUX_TX_SIZE)
53         MALLOC_WILC_BUFFER(g_rx_buf, LINUX_RX_SIZE)
54         MALLOC_WILC_BUFFER(g_fw_buf, WILC1000_FW_SIZE)
55
56         return 0;
57 }
58
59 static void __exit wilc_module_deinit(void)
60 {
61         printk("wilc_module_deinit\n");
62         FREE_WILC_BUFFER(g_tx_buf)
63         FREE_WILC_BUFFER(g_rx_buf)
64         FREE_WILC_BUFFER(g_fw_buf)
65 }
66
67 MODULE_LICENSE("Dual BSD/GPL");
68 MODULE_AUTHOR("Tony Cho");
69 MODULE_DESCRIPTION("WILC1xxx Memory Manager");
70 pure_initcall(wilc_module_init);
71 module_exit(wilc_module_deinit);