From patchwork Fri Jul 18 11:18:09 2008 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sven Eckelmann X-Patchwork-Id: 5331 Received: from john.hrz.tu-chemnitz.de (john.hrz.tu-chemnitz.de [134.109.132.2]) by open-mesh.net (8.13.4/8.13.4/Debian-3sarge3) with ESMTP id m6IBKDsF009533 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT) for ; Fri, 18 Jul 2008 13:20:14 +0200 Received: from galba.hrz.tu-chemnitz.de ([134.109.133.156] helo=mailbox.hrz.tu-chemnitz.de) by john.hrz.tu-chemnitz.de with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1KJnx7-0004du-Ob for b.a.t.m.a.n@open-mesh.net; Fri, 18 Jul 2008 13:16:45 +0200 Received: from vpnclient-003.hrz.tu-chemnitz.de ([134.109.232.3] helo=sven-desktop) by mailbox.hrz.tu-chemnitz.de with smtp (Exim 4.69) (envelope-from ) id 1KJnx7-0000Yi-Cw for b.a.t.m.a.n@open-mesh.net; Fri, 18 Jul 2008 13:16:45 +0200 Received: by sven-desktop (nbSMTP-1.00) for uid 1000 sven.eckelmann@gmx.de; Fri, 18 Jul 2008 13:18:10 +0200 (CEST) Date: Fri, 18 Jul 2008 13:18:09 +0200 From: Sven Eckelmann To: b.a.t.m.a.n@open-mesh.net Message-ID: <20080718111809.GA30576@sven-desktop.lazhur.ath.cx> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) X-Scan-Signature: ee1b6ace4177ba37ace38764881c5012 Subject: [B.A.T.M.A.N.] [PATCH] Move more compatibility code to compat.h X-BeenThere: b.a.t.m.a.n@open-mesh.net X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Jul 2008 11:20:15 -0000 Use the madwifi-like compat.h to keep as much of the #ifLINUX_VERSION.. stuff out of the code to increase the readability. Parts which weren't moved are the device creation/deletion, which is to different to move it to compat.h, and the module count. Signed-off-by: Sven Eckelmann --- batman-adv-kernelland/batman-core/compat.h | 16 ++++++++++++++-- batman-adv-kernelland/batman-core/device.c | 12 +----------- batman-adv-kernelland/batman-core/main.c | 1 + batman-adv-kernelland/batman-core/main.h | 1 - 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/batman-adv-kernelland/batman-core/compat.h b/batman-adv-kernelland/batman-core/compat.h index cb94665..5f58f8f 100644 --- a/batman-adv-kernelland/batman-core/compat.h +++ b/batman-adv-kernelland/batman-core/compat.h @@ -20,8 +20,9 @@ * of the Linux kernel. */ +#include /* LINUX_VERSION_CODE */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,22) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) #define skb_set_network_header(_skb, _offset) \ do { (_skb)->nh.raw = (_skb)->data + (_offset); } while (0) @@ -32,4 +33,15 @@ #define list_first_entry(ptr, type, member) \ list_entry((ptr)->next, type, member) -#endif +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) */ + + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) + +#define device_create_drvdata(_cls, _parent, _devt, _device, _fmt) \ + class_device_create(_cls, _parent, _devt, _device, _fmt) + +#define device_destroy(_cls, _device) \ + class_device_destroy(_cls, _device) + +#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) */ diff --git a/batman-adv-kernelland/batman-core/device.c b/batman-adv-kernelland/batman-core/device.c index 18b026a..6608f13 100644 --- a/batman-adv-kernelland/batman-core/device.c +++ b/batman-adv-kernelland/batman-core/device.c @@ -30,9 +30,7 @@ #include "compat.h" -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) -#include -#else +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 0) static struct class *batman_class; #endif @@ -85,11 +83,7 @@ void bat_device_setup(void) debug_log(LOG_TYPE_WARN, "Could not register class 'batman-adv' \n"); return; } else { -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25) device_create_drvdata(batman_class, NULL, MKDEV(tmp_major, 0), NULL, "batman-adv"); -#else - class_device_create(batman_class, NULL, MKDEV(tmp_major, 0), NULL, "batman-adv"); -#endif } #endif @@ -106,11 +100,7 @@ void bat_device_destroy(void) #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0) devfs_remove("batman-adv", 0); #else -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25) device_destroy(batman_class, MKDEV(Major, 0)); -#else - class_device_destroy(batman_class, MKDEV(Major, 0)); -#endif class_destroy(batman_class); #endif diff --git a/batman-adv-kernelland/batman-core/main.c b/batman-adv-kernelland/batman-core/main.c index bf2a52c..7628865 100644 --- a/batman-adv-kernelland/batman-core/main.c +++ b/batman-adv-kernelland/batman-core/main.c @@ -30,6 +30,7 @@ #include "vis.h" #include "types.h" #include "hash.h" +#include "compat.h" diff --git a/batman-adv-kernelland/batman-core/main.h b/batman-adv-kernelland/batman-core/main.h index 517fbc6..4208ae5 100644 --- a/batman-adv-kernelland/batman-core/main.h +++ b/batman-adv-kernelland/batman-core/main.h @@ -78,7 +78,6 @@ #include /* mutex */ #include /* needed by all modules */ -#include /* LINUX_VERSION_CODE */ #include /* netdevice */ #include /* timer */ #include /* ethernet header */