[v2] Move more linux 2.6 compat stuff to compat26.h

Message ID 20080925144917.GA9330@sven-desktop.lazhur.ath.cx (mailing list archive)
State Accepted, archived
Headers

Commit Message

Sven Eckelmann Sept. 25, 2008, 2:49 p.m. UTC
  ---
 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(-)
  

Patch

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 );