updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / fusd-kor-svn / fusd-kor-2.6.33-kernel.patch
blobf7249d7a010d96266993195e756bead9af5f9b2b
1 diff -Naur fusd-kor.old/include/kfusd.h fusd-kor.new/include/kfusd.h
2 --- fusd-kor.old/include/kfusd.h 2010-05-16 21:11:25.000000000 +0200
3 +++ fusd-kor.new/include/kfusd.h 2010-05-16 17:00:40.000000000 +0200
4 @@ -44,6 +44,7 @@
5 #define __KFUSD_H__
7 #include "fusd_msg.h"
8 +#include <linux/version.h>
10 /* magic numbers for structure checking; unique w.r.t
11 * /usr/src/linux/Documentation/magic-number.txt */
12 @@ -125,7 +126,11 @@
13 char *dev_name;
14 struct CLASS *clazz;
15 int owns_class;
16 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
17 struct class_device *class_device;
18 +#else
19 + struct device *class_device;
20 +#endif
22 void *private_data; /* User's private data */
23 struct cdev* handle;
24 diff -Naur fusd-kor.old/kfusd/kfusd.c fusd-kor.new/kfusd/kfusd.c
25 --- fusd-kor.old/kfusd/kfusd.c 2010-05-16 21:11:30.000000000 +0200
26 +++ fusd-kor.new/kfusd/kfusd.c 2010-05-16 18:04:45.000000000 +0200
27 @@ -58,7 +58,6 @@
28 #include <linux/modversions.h>
29 #endif
31 -//#include <linux/config.h>
32 #include <linux/stddef.h>
33 #include <linux/kernel.h>
34 #include <linux/module.h>
35 @@ -68,7 +67,6 @@
36 #include <linux/mm.h>
37 #include <linux/slab.h>
38 #include <linux/vmalloc.h>
39 -//#include <linux/devfs_fs_kernel.h>
40 #include <linux/poll.h>
41 #include <linux/version.h>
42 #include <linux/major.h>
43 @@ -86,7 +84,7 @@
44 #define STATIC
46 /* Define this if you want to emit debug messages (adds ~8K) */
47 -#define CONFIG_FUSD_DEBUG
48 +/*#define CONFIG_FUSD_DEBUG*/
50 /* Default debug level for FUSD messages. Has no effect unless
51 * CONFIG_FUSD_DEBUG is defined. */
52 @@ -121,23 +119,37 @@
53 #define CLASS_DEVICE_CREATE(a, b, c, d, e) class_device_create(a, c, d, e)
55 #else
56 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
58 #define CLASS_DEVICE_CREATE(a, b, c, d, e) class_device_create(a, b, c, d, e)
60 +#else
62 +#define CLASS_DEVICE_CREATE(a, b, c, d, e) device_create(a, b, c, d, e)
63 +#define class_device_destroy(a, b) device_destroy(a, b)
65 +#endif
67 #endif
69 #endif
71 static inline struct kobject * to_kobj(struct dentry * dentry)
73 - struct sysfs_dirent * sd = dentry->d_fsdata;
74 - if(sd)
75 - return ((struct kobject *) sd->s_element);
76 + struct kobject * penis = {0};
77 + penis->sd = (struct sysfs_dirent *) dentry->d_fsdata;
78 + if(penis->sd)
79 + return (penis);
80 else
81 return NULL;
84 -#define to_class(obj) container_of(obj, struct class, subsys.kset.kobj)
85 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
86 +# define to_class(obj) container_of(obj, struct class, subsys.kset.kobj)
87 +#else
88 +# define to_class(obj) container_of(obj, struct class, dev_kobj)
89 +#endif
92 /**************************************************************************/
94 @@ -157,8 +169,13 @@
96 static struct CLASS *fusd_class;
98 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
99 static struct class_device *fusd_control_class_device;
100 static struct class_device *fusd_status_class_device;
101 +#else
102 +static struct device *fusd_control_class_device;
103 +static struct device *fusd_status_class_device;
104 +#endif
106 extern struct CLASS *sound_class;
108 @@ -175,10 +192,8 @@
109 LIST_HEAD(fusd_devlist_head);
110 DECLARE_MUTEX(fusd_devlist_sem);
112 -//#ifdef MODULE_LICENSE
113 MODULE_AUTHOR("Jeremy Elson <jelson@acm.org> (c)2001");
114 MODULE_LICENSE("GPL");
115 -//#endif
117 /***************************Debugging Support*****************************/
119 @@ -739,8 +754,10 @@
121 /* fill the rest of the structure */
122 fusd_msg->parm.fops_msg.pid = current->pid;
123 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
124 fusd_msg->parm.fops_msg.uid = current->uid;
125 fusd_msg->parm.fops_msg.gid = current->gid;
126 +#endif
127 fusd_msg->parm.fops_msg.flags = fusd_file->file->f_flags;
128 fusd_msg->parm.fops_msg.offset = fusd_file->file->f_pos;
129 fusd_msg->parm.fops_msg.device_info = fusd_dev->private_data;
130 @@ -1562,6 +1579,7 @@
132 static void fusd_client_mm_open(struct vm_area_struct * vma);
133 static void fusd_client_mm_close(struct vm_area_struct * vma);
134 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
135 static struct page* fusd_client_nopage(struct vm_area_struct* vma, unsigned long address, int* type);
136 static struct vm_operations_struct fusd_remap_vm_ops =
138 @@ -1569,6 +1587,15 @@
139 close: fusd_client_mm_close,
140 nopage: fusd_client_nopage,
142 +#else
143 +static int fusd_client_fault(struct vm_area_struct* vma, struct vm_fault *vmf, int* type);
144 +static struct vm_operations_struct fusd_remap_vm_ops =
146 + .fault = fusd_client_fault,
147 + .open = fusd_client_mm_open,
148 + .close = fusd_client_mm_close,
150 +#endif
152 struct fusd_mmap_instance
154 @@ -1665,6 +1692,7 @@
155 return -EPIPE;
158 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
159 static struct page* fusd_client_nopage(struct vm_area_struct* vma, unsigned long address,
160 int* type)
162 @@ -1697,8 +1725,44 @@
163 out:
164 return page;
168 +#else
170 +static int fusd_client_fault(struct vm_area_struct* vma, struct vm_fault *vmf,
171 + int* type)
173 + struct fusd_mmap_instance* mmap_instance = (struct fusd_mmap_instance*) vma->vm_private_data;
174 + unsigned long offset;
175 + int result;
176 + struct page *page = NULL;
177 + offset = ((unsigned long)vmf->virtual_address - vma->vm_start) + (vma->vm_pgoff << PAGE_SHIFT);
178 + // todo: worry about size
179 + if(offset > mmap_instance->size)
180 + goto out;
182 + down_read(&mmap_instance->fusd_dev->task->mm->mmap_sem);
183 + result = get_user_pages(mmap_instance->fusd_dev->task, mmap_instance->fusd_dev->task->mm, mmap_instance->addr + offset, 1, 1, 0, &page, NULL);
184 + up_read(&mmap_instance->fusd_dev->task->mm->mmap_sem);
187 + if(PageAnon(page))
189 + RDEBUG(2, "Cannot mmap anonymous pages. Be sure to allocate your shared buffer with MAP_SHARED | MAP_ANONYMOUS");
190 + return VM_FAULT_SIGBUS;
193 + if(result > 0)
195 + get_page(page);
196 + vmf->page = page;
197 + if (type)
198 + *type = VM_FAULT_MINOR;
200 +out:
201 + return 0;
203 +#endif
207 @@ -2596,13 +2660,17 @@
210 STATIC struct file_operations fusd_fops = {
211 - owner: THIS_MODULE,
212 - open: fusd_open,
213 - read: fusd_read,
214 - write: fusd_write,
215 - writev: fusd_writev,
216 - release: fusd_release,
217 - poll: fusd_poll,
218 + owner: THIS_MODULE,
219 + open: fusd_open,
220 + read: fusd_read,
221 + write: fusd_write,
222 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
223 + writev: fusd_writev,
224 +#else
225 + aio_write: fusd_writev,
226 +#endif
227 + release: fusd_release,
228 + poll: fusd_poll,
232 diff -Naur fusd-kor.old/kfusd/Makefile fusd-kor.new/kfusd/Makefile
233 --- fusd-kor.old/kfusd/Makefile 2010-05-16 21:11:30.000000000 +0200
234 +++ fusd-kor.new/kfusd/Makefile 2010-05-16 14:36:54.000000000 +0200
235 @@ -1,15 +1,16 @@
236 ifneq ($(KERNELRELEASE),)
237 obj-m := kfusd.o
238 else
239 -KDIR ?= /lib/modules/$(shell uname -r)/build
240 -PWD := $(shell pwd)
241 +KREL := $(shell uname -r)
242 +KDIR ?= /lib/modules/$(KREL)/build
243 +PWD := $(shell pwd)
245 default:
246 $(MAKE) -C $(KDIR) SUBDIRS=$(PWD) EXTRA_CFLAGS=-I$(PWD)/../include modules
248 install:
249 - $(INSTALL) -d -m 0755 /lib/modules/$(shell uname -r)/kernel/drivers/misc
250 - $(INSTALL) -m 0755 kfusd.ko /lib/modules/$(shell uname -r)/kernel/drivers/misc
251 + $(INSTALL) -d -m 0755 /lib/modules/$(KREL)/kernel/drivers/misc
252 + $(INSTALL) -m 0755 kfusd.ko /lib/modules/$(KREL)/kernel/drivers/misc
253 /sbin/depmod -a
255 clean: