b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven.eckelmann@gmx.de>
To: b.a.t.m.a.n@open-mesh.net
Subject: [B.A.T.M.A.N.] [PATCHv2] Move more linux 2.6 compat stuff to compat26.h
Date: Thu, 25 Sep 2008 16:49:17 +0200	[thread overview]
Message-ID: <20080925144917.GA9330@sven-desktop.lazhur.ath.cx> (raw)

---
 batman/linux/modules/compat26.h   |   12 ++++++++++++
 batman/linux/modules/gateway.c    |    8 --------
 batman/linux/modules/mod_batman.c |   22 ++--------------------
 3 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/batman/linux/modules/compat26.h b/batman/linux/modules/compat26.h
index a95b229..f1fdc67 100644
--- a/batman/linux/modules/compat26.h
+++ b/batman/linux/modules/compat26.h
@@ -31,6 +31,7 @@ static inline struct iphdr *ip_hdr(const struct sk_buff *skb)
 {
 	return (struct iphdr *)skb_network_header(skb);
 }
+
 #endif /* KERNEL_VERSION(2, 6, 22) */
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
@@ -39,4 +40,15 @@ static inline int kernel_bind(struct socket *sock, struct sockaddr *addr, int ad
 {
 	return sock->ops->bind(sock, addr, addrlen);
 }
+
 #endif /* KERNEL_VERSION(2, 6, 19) */
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,26)
+
+#define device_create_drvdata \
+	class_device_create
+
+#define device_destroy \
+	class_device_destroy
+
+#endif /* KERNEL_VERSION(2,6,26) */
diff --git a/batman/linux/modules/gateway.c b/batman/linux/modules/gateway.c
index 965f87b..154497e 100644
--- a/batman/linux/modules/gateway.c
+++ b/batman/linux/modules/gateway.c
@@ -91,11 +91,7 @@ int init_module()
 	if ( IS_ERR( batman_class ) )
 		DBG( "could not register class 'batgat'" );
 	else
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)
 		device_create_drvdata(batman_class, NULL, MKDEV(Major, 0), NULL, "batgat");
-#else
-		class_device_create(batman_class, NULL, MKDEV(Major, 0), NULL, "batgat");
-#endif
 
 
 	DBG( "batgat loaded %s", strlen(REVISION_VERSION) > 3 ? REVISION_VERSION : "" );
@@ -120,11 +116,7 @@ void cleanup_module()
 	struct free_client_data *entry, *next;
 	struct gw_client *gw_client;
 
-#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 );
 
 	/* Unregister the device */
diff --git a/batman/linux/modules/mod_batman.c b/batman/linux/modules/mod_batman.c
index d34b05e..1b9ecda 100644
--- a/batman/linux/modules/mod_batman.c
+++ b/batman/linux/modules/mod_batman.c
@@ -50,6 +50,8 @@
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 	#include <linux/devfs_fs_kernel.h>
 #else
+#include "compat26.h"
+
 	static struct class *batman_class;
 #endif
 
@@ -117,11 +119,7 @@ int init_module( void ) {
 	if ( IS_ERR(batman_class) )
 		printk( "B.A.T.M.A.N.: Could not register class 'batman' \n" );
 	else
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)  
 		device_create_drvdata( batman_class, NULL, MKDEV( Major, 0 ), NULL, "batman" );
-#else
-		class_device_create( batman_class, NULL, MKDEV( Major, 0 ), NULL, "batman" );
-#endif
 #endif
 
 	for ( i = 0; i < 255; i++ ) {
@@ -143,11 +141,7 @@ void cleanup_module( void ) {
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 	devfs_remove( "batman", 0 );
 #else
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)  
 	device_destroy_drvdata( batman_class, MKDEV( Major, 0 ) );
-#else
-	class_device_destroy( batman_class, MKDEV( Major, 0 ) );
-#endif
 	class_destroy( batman_class );
 #endif
 
@@ -247,11 +241,7 @@ static int device_release( struct inode *inode, struct file *file ) {
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 		devfs_remove( "batman", minor_num );
 #else
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)  
 		device_destroy(minor->minor_class, MKDEV(Major, minor_num));
-#else
-		class_device_destroy( minor->minor_class, MKDEV( Major, minor_num ) );
-#endif
 		class_destroy( minor->minor_class );
 #endif
 		sock_release( minor->raw_sock );
@@ -367,11 +357,7 @@ static int device_ioctl( struct inode *inode, struct file *file, unsigned int cm
 			if ( IS_ERR(minor->minor_class) )
 				printk( "B.A.T.M.A.N.: Could not register class '%s' \n", filename );
 			else
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)  
 				device_create_drvdata( minor->minor_class, NULL, MKDEV( Major, minor_num ), NULL, "batman%d", minor_num );
-#else
-				class_device_create( minor->minor_class, NULL, MKDEV( Major, minor_num ), NULL, "batman%d", minor_num );
-#endif
 #endif
 			/* let udev create the device file */
 			set_current_state(TASK_INTERRUPTIBLE);
@@ -395,11 +381,7 @@ static int device_ioctl( struct inode *inode, struct file *file, unsigned int cm
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 					devfs_remove( "batman", minor_num );
 #else
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,25)  
 					device_destroy( minor->minor_class, MKDEV(Major, minor_num ));
-#else
-					class_device_destroy( minor->minor_class, MKDEV(Major, minor_num ));
-#endif
 					class_destroy( minor->minor_class );
 #endif
 					kfree( minor );
-- 
1.6.0.1



                 reply	other threads:[~2008-09-25 14:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080925144917.GA9330@sven-desktop.lazhur.ath.cx \
    --to=sven.eckelmann@gmx.de \
    --cc=b.a.t.m.a.n@open-mesh.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).