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>
7 #define LINUX_RX_SIZE (96 * 1024)
8 #define LINUX_TX_SIZE (64 * 1024)
9 #define WILC1000_FW_SIZE (4 * 1024)
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); \
18 #define FREE_WILC_BUFFER(name) \
19 kfree(exported_ ## name);
22 * Add necessary buffer pointers
24 void *exported_g_tx_buf;
25 void *exported_g_rx_buf;
26 void *exported_g_fw_buf;
28 void *get_tx_buffer(void)
30 return exported_g_tx_buf;
32 EXPORT_SYMBOL(get_tx_buffer);
34 void *get_rx_buffer(void)
36 return exported_g_rx_buf;
38 EXPORT_SYMBOL(get_rx_buffer);
40 void *get_fw_buffer(void)
42 return exported_g_fw_buf;
44 EXPORT_SYMBOL(get_fw_buffer);
46 static int __init wilc_module_init(void)
48 printk("wilc_module_init\n");
50 * alloc necessary memory
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)
59 static void __exit wilc_module_deinit(void)
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)
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);