From 8c9150ca2220706abb9f7642fdc26f779800b3b7 Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Tue, 8 Apr 2008 18:04:39 +0000 Subject: * added kernel version check to module source * removed branch for old kernels git-svn-id: http://svn.openslx.org/svn/openslx/contrib/dnbd2/trunk@1731 95ad53e4-c205-0410-b2fa-d234c58c8868 --- kernel/devices.c | 15 ++++++++++++--- kernel/dnbd2.h | 1 + kernel/servers.c | 34 ++++++++++++++++++++++++++++------ 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/kernel/devices.c b/kernel/devices.c index ccc6db1..7c1102b 100644 --- a/kernel/devices.c +++ b/kernel/devices.c @@ -106,8 +106,13 @@ int add_device(dnbd2_device_t *dev, int minor) * Prepare dnbd2_device_t. Please use the * same order as in dnbd2.h. */ - INIT_WORK(&dev->work, NULL); //, NULL); - /* Change in //include/linux/workqueue.h */ + + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) + INIT_WORK(&dev->work, NULL, NULL); + #else + INIT_WORK(&dev->work, NULL); + #endif + spin_lock_init(&dev->kmap_lock); for (i=0 ; iinfo_pool[i].cnt = -1; @@ -145,7 +150,11 @@ int add_device(dnbd2_device_t *dev, int minor) init_completion(&srv_info->rx_start); init_completion(&srv_info->rx_stop); init_waitqueue_head(&srv_info->wq); - INIT_WORK(&srv_info->work, NULL); //, NULL); + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) + INIT_WORK(&srv_info->work, NULL, NULL); + #else + INIT_WORK(&srv_info->work, NULL); + #endif /* Change in //include/linux/workqueue.h */ srv_info->dev = dev; } diff --git a/kernel/dnbd2.h b/kernel/dnbd2.h index cf693d9..c49c9b9 100644 --- a/kernel/dnbd2.h +++ b/kernel/dnbd2.h @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include "../include/dnbd2.h" diff --git a/kernel/servers.c b/kernel/servers.c index 7d5c229..52d565b 100644 --- a/kernel/servers.c +++ b/kernel/servers.c @@ -60,9 +60,17 @@ struct srv_info *fastest_server(uint16_t *srtt, dnbd2_device_t *dev) * This function can be enqueued in a workqueue. It removes srv_info * from the list of servers. */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) +void del_server_work(void *data) +#else void del_server_work(struct work_struct *work) +#endif { - struct srv_info *srv_info = container_of(work, struct srv_info, work); + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) + struct srv_info *srv_info = data; + #else + struct srv_info *srv_info = container_of(work, struct srv_info, work); + #endif dnbd2_device_t *dev = srv_info->dev; down(&dev->servers_mutex); @@ -80,9 +88,17 @@ void del_server_work(struct work_struct *work) * This function can be enqueued in a workqueue. Read comment on * schedule_activate_fastest in servers.h */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) +void activate_fastest_work(void *data) +#else void activate_fastest_work(struct work_struct *work) +#endif { - dnbd2_device_t *dev = container_of(work, dnbd2_device_t, work); + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) + dnbd2_device_t *dev = data; + #else + dnbd2_device_t *dev = container_of(work, dnbd2_device_t, work); + #endif struct srv_info *alt_srv, *next_srv; uint16_t min, srtt; int newsrv = 0; @@ -341,15 +357,21 @@ void enqueue_hb(struct srv_info *srv_info) void schedule_del_server(struct srv_info *srv_info) { - PREPARE_WORK(&srv_info->work, del_server_work); //, srv_info); - /* Change in //include/linux/workqueue.h */ + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) + PREPARE_WORK(&srv_info->work, del_server_work, srv_info); + #else + PREPARE_WORK(&srv_info->work, del_server_work); + #endif schedule_work(&srv_info->work); } void schedule_activate_fastest(dnbd2_device_t *dev) { - PREPARE_WORK(&dev->work, activate_fastest_work); //, dev); - /* Change in //include/linux/workqueue.h */ + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,20)) + PREPARE_WORK(&dev->work, activate_fastest_work, dev); + #else + PREPARE_WORK(&dev->work, activate_fastest_work); + #endif schedule_work(&dev->work); } -- cgit v1.2.3-55-g7522