From 1f035accaf4bde77cc6a3382d0340304f86665ec Mon Sep 17 00:00:00 2001
From: Frank Mori Hess <fmhess@speakeasy.net>
Date: Mon, 4 Aug 2003 01:06:40 +0000
Subject: [PATCH] more 2.6 compatibility

---
 include/asm/pgtable.h           | 33 ++++++++++++++++++++++++++++++++
 include/linux/comedidev.h       |  1 +
 include/linux/devfs_fs_kernel.h |  2 +-
 include/linux/interrupt.h       | 34 +++++++++++++++++++++++++++++++++
 include/linux/module.h          |  6 ++++++
 include/linux/pci.h             |  8 ++++++++
 include/linux/wrapper.h         | 32 +++++++++++++++++++++++++++++++
 7 files changed, 115 insertions(+), 1 deletion(-)
 create mode 100644 include/asm/pgtable.h
 create mode 100644 include/linux/interrupt.h
 create mode 100644 include/linux/wrapper.h

diff --git a/include/asm/pgtable.h b/include/asm/pgtable.h
new file mode 100644
index 00000000..84017b2f
--- /dev/null
+++ b/include/asm/pgtable.h
@@ -0,0 +1,33 @@
+/*
+    asm/pgtable.h compatibility header
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __COMPAT_ASM_PGTABLE_H_
+#define __COMPAT_ASM_PGTABLE_H_
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+
+#define pte_offset_kernel(dir,address) pte_offset(dir,address)
+
+#endif
+
+#include_next <asm/pgtable.h>
+
+#endif /* __COMPAT_ASM_PGTABLE_H_ */
+
diff --git a/include/linux/comedidev.h b/include/linux/comedidev.h
index 1ebd1ad6..ee4b2b13 100644
--- a/include/linux/comedidev.h
+++ b/include/linux/comedidev.h
@@ -37,6 +37,7 @@
 #include <linux/init.h>
 #include <linux/vmalloc.h>
 #include <linux/mm.h>
+#include <linux/interrupt.h>
 
 #include <asm/uaccess.h>
 #include <asm/io.h>
diff --git a/include/linux/devfs_fs_kernel.h b/include/linux/devfs_fs_kernel.h
index 54ad13ef..b3fe6e3c 100644
--- a/include/linux/devfs_fs_kernel.h
+++ b/include/linux/devfs_fs_kernel.h
@@ -7,7 +7,7 @@
 
 #include <linux/version.h>
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 18)
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 2, 18) || LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 0)
 
 #define DEVFS_FL_DEFAULT 0
 #define DEVFS_SPECIAL_CHR 0
diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
new file mode 100644
index 00000000..8daf83c6
--- /dev/null
+++ b/include/linux/interrupt.h
@@ -0,0 +1,34 @@
+/*
+    linux/interrupt.h compatibility header
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __COMPAT_LINUX_INTERRUPT_H_
+#define __COMPAT_LINUX_INTERRUPT_H_
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
+typedef void irqreturn_t;
+#define IRQ_NONE
+#define IRQ_HANDLED
+#define IRQ_RETVAL(x)
+#endif
+
+#include_next <linux/interrupt.h>
+
+#endif
+
diff --git a/include/linux/module.h b/include/linux/module.h
index 51693371..308de36b 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -7,6 +7,12 @@
 
 #include <linux/version.h>
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#define __MOD_INC_USE_COUNT(x)
+#define __MOD_DEC_USE_COUNT(x)
+#define MOD_IN_USE (0)
+#endif
+
 #if LINUX_VERSION_CODE < 0x020115
 #define MODULE_AUTHOR(a)
 #define MODULE_DESCRIPTION(a)
diff --git a/include/linux/pci.h b/include/linux/pci.h
index efe742d8..bbf1d33a 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -15,6 +15,14 @@
 #include_next <linux/pci.h>
 #define PCI_SUPPORT_VER2
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+/* we should get rid of this, as it has been dropped from 2.6 */
+#define pci_for_each_dev(x)	\
+	for((x) = pci_dev_g(pci_devices.next), prefetch((x)->global_list.next); \
+		x->global_list.next != &pci_devices; (x) = pci_dev_g((x)->global_list.next), \
+		prefetch((x)->global_list.next))
+#endif
+
 #if LINUX_VERSION_CODE < 0x020300 /* XXX */
 
 #define pci_for_each_dev(x)	\
diff --git a/include/linux/wrapper.h b/include/linux/wrapper.h
new file mode 100644
index 00000000..235d107a
--- /dev/null
+++ b/include/linux/wrapper.h
@@ -0,0 +1,32 @@
+/*
+    linux/wrapper.h compatibility header
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef __COMPAT_LINUX_WRAPPER_H_
+#define __COMPAT_LINUX_WRAPPER_H_
+
+#include <linux/version.h>
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+#define mem_map_reserve(p)      set_bit(PG_reserved, &((p)->flags))
+#define mem_map_unreserve(p)    clear_bit(PG_reserved, &((p)->flags))
+#else
+#include_next <linux/wrapper.h>
+#endif
+
+#endif /* __COMPAT_LINUX_WRAPPER_H_ */
+
-- 
2.26.2