summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app-emulation/qemu-softmmu/files/kqemu-sysfs.patch')
-rw-r--r--app-emulation/qemu-softmmu/files/kqemu-sysfs.patch77
1 files changed, 77 insertions, 0 deletions
diff --git a/app-emulation/qemu-softmmu/files/kqemu-sysfs.patch b/app-emulation/qemu-softmmu/files/kqemu-sysfs.patch
new file mode 100644
index 000000000000..05c49ca67898
--- /dev/null
+++ b/app-emulation/qemu-softmmu/files/kqemu-sysfs.patch
@@ -0,0 +1,77 @@
+--- kqemu/kmod.c 2005-02-10 23:09:09.000000000 +0100
++++ kqemu/kmod-sysfs.c 2005-02-22 19:46:44.000000000 +0100
+@@ -15,7 +15,10 @@
+ #include <asm/processor.h>
+ #include <asm/uaccess.h>
+ #include <asm/io.h>
+-
++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
++#include <linux/device.h>
++#endif
++#include <linux/devfs_fs_kernel.h>
+ #include "kqemu.h"
+
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19)
+@@ -34,6 +37,10 @@
+ int page_alloc_count;
+ #endif
+
++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
++static struct class_simple *kqemu_class;
++#endif
++
+ /* lock the page at virtual address 'user_addr' and return its
+ page index. Return -1 if error */
+ unsigned long CDECL kqemu_lock_user_page(unsigned long user_addr)
+@@ -296,17 +303,51 @@
+ max_locked_pages = 32768;
+
+ ret = register_chrdev(KQEMU_MAJOR, "kqemu", &kqemu_fops);
++
+ if (ret < 0) {
+ printk("kqemu: could not get major %d\n", KQEMU_MAJOR);
+ return ret;
+ }
++
++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
++ kqemu_class = class_simple_create(THIS_MODULE, "kqemu");
++
++ if (IS_ERR(kqemu_class)) {
++ unregister_chrdev(KQEMU_MAJOR, "kqemu");
++ ret = PTR_ERR(kqemu_class);
++ goto out_chrdev;
++ }
++
++ class_simple_device_add(kqemu_class, MKDEV(KQEMU_MAJOR, 0), NULL, "kqemu");
++#endif
++
++ ret = devfs_mk_cdev(MKDEV(KQEMU_MAJOR, 0),
++ S_IFCHR|S_IRUSR|S_IWUSR, "kqemu");
++ if (ret)
++ goto out_class;
++
+ printk("KQEMU installed, max_instances=%d max_locked_mem=%dkB.\n",
+ KQEMU_MAX_INSTANCES,
+ max_locked_pages * 4);
+ return 0;
++
++out_class:
++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
++ class_simple_device_remove(MKDEV(KQEMU_MAJOR,0));
++ class_simple_destroy(kqemu_class);
++#endif
++out_chrdev:
++ unregister_chrdev(KQEMU_MAJOR, "kqemu");
++
++ return ret;
+ }
+
+ void cleanup_module(void)
+ {
+ unregister_chrdev(KQEMU_MAJOR, "kqemu");
++ devfs_remove("kqemu");
++#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,0)
++ class_simple_device_remove(MKDEV(KQEMU_MAJOR, 0));
++ class_simple_destroy(kqemu_class);
++#endif
+ }