EXTRA_CFLAGS := $(extra_cflags)
obj-m := swap_driver_new.o
-swap_driver_new-y := swap_driver_module.o \
- device_driver.o \
+swap_driver_new-y := device_driver.o \
driver_to_buffer.o
static splice_shrink_spd_p_t splice_shrink_spd_p = NULL;
static splice_grow_spd_p_t splice_grow_spd_p = NULL;
-/* Typedef for swap_message_parser handler func */
-typedef int(*swap_message_parser_handler_t)(unsigned int cmd, void __user * arg);
-
-static swap_message_parser_handler_t swap_message_parser_handler = NULL;
+static msg_handler_t msg_handler = NULL;
/* Device numbers */
static dev_t swap_device_no = 0;
}
default:
{
- if (swap_message_parser_handler) {
- result = swap_message_parser_handler(cmd, (void __user *) arg);
+ if (msg_handler) {
+ result = msg_handler((void __user *)arg);
} else {
// print_warn("Unknown command %d\n", cmd);
result = -EINVAL;
wake_up_interruptible(&swap_device_wait);
}
-int register_message_handler(void *s_m_p_h)
+void set_msg_handler(msg_handler_t mh)
{
- print_debug("Register message handler\n");
+ msg_handler = mh;
+}
+EXPORT_SYMBOL_GPL(set_msg_handler);
- swap_message_parser_handler = s_m_p_h;
- return E_SD_SUCCESS;
+static int __init swap_driver_init(void)
+{
+ swap_device_init();
+
+ return 0;
}
+
+static void __exit swap_driver_exit(void)
+{
+ swap_device_exit();
+}
+
+module_init(swap_driver_init);
+module_exit(swap_driver_exit);
+
+MODULE_LICENSE("GPL");
#ifndef __SWAP_DRIVER_DEVICE_DRIVER__
#define __SWAP_DRIVER_DEVICE_DRIVER__
-/* Create and register device */
-int swap_device_init(void);
+typedef int (*msg_handler_t)(void __user *data);
-/* Delete device */
-void swap_device_exit(void);
-
-/* Register swap_message_parser handler */
-int register_message_handler(void *s_m_p_h);
+/* Set the message handler */
+void set_msg_handler(msg_handler_t mh);
#endif /* __SWAP_DRIVER_DEVICE_DRIVER__ */
+++ /dev/null
-#include <linux/module.h>
-
-#include "driver_defs.h"
-#include "device_driver.h"
-
-int register_swap_message_parser_handler(void *s_m_p_h)
-{
- return register_message_handler(s_m_p_h);
-}
-EXPORT_SYMBOL_GPL(register_swap_message_parser_handler);
-
-static int __init swap_driver_init(void)
-{
- print_msg("Module init\n");
-
-#ifdef TEST_MODE
- print_msg("Test mode on\n");
-#endif
-
- swap_device_init();
-
- return 0;
-}
-
-static void __exit swap_driver_exit(void)
-{
- //TODO Kill userspace daemon process
- swap_device_exit();
- print_msg("Module exit\n");
-}
-
-module_init(swap_driver_init);
-module_exit(swap_driver_exit);
-
-MODULE_LICENSE("GPL");
+++ /dev/null
-/* SWAP Device Driver interface module */
-
-#ifndef __SWAP_DRIVER_MODULE_H__
-#define __SWAP_DRIVER_MODULE_H__
-
-/* Register swap_message_parser messages handler */
-int register_swap_message_parser_handler(void *s_m_p_h);
-
-#endif /* __SWAP_DRIVER_MODULE_H__ */