Fix lirc compilation on 2.6.26
[openwrt/svn-archive/archive.git] / utils / lirc / patches / 001-class_kcompat.patch
1 Kernel 2.6.26 removes an API previously used by lirc:
2 - http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c3b19ff06e0808555403491d61e8f0cbbb53e933
3
4 * add compatibility patch for kernels >= 2.6.26, based on upstream CVS.
5 - http://lirc.cvs.sourceforge.net/lirc/lirc/drivers/kcompat.h?r1=5.34&r2=5.36
6 - http://lirc.cvs.sourceforge.net/lirc/lirc/drivers/lirc_dev/lirc_dev.c?r1=1.57&r2=1.58
7
8 Copyright: (C) 2008 Christoph Bartelmus <lirc@bartelmus.de>
9
10 --- a/drivers/kcompat.h
11 +++ b/drivers/kcompat.h
12 @@ -36,10 +36,10 @@
13 class_simple_destroy(cls);
14 }
15
16 -#define lirc_class_device_create(cs, parent, dev, device, fmt, args...) \
17 - class_simple_device_add(cs, dev, device, fmt, ## args)
18 +#define lirc_device_create(cs, parent, dev, fmt, args...) \
19 + class_simple_device_add(cs, dev, parent, fmt, ## args)
20
21 -static inline void class_device_destroy(lirc_class_t *cls, dev_t devt)
22 +static inline void lirc_device_destroy(lirc_class_t *cls, dev_t devt)
23 {
24 class_simple_device_remove(devt);
25 }
26 @@ -48,20 +48,40 @@
27
28 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 15)
29
30 -#define lirc_class_device_create(cs, parent, dev, device, fmt, args...) \
31 - class_device_create(cs, dev, device, fmt, ## args)
32 +#define lirc_device_create(cs, parent, dev, fmt, args...) \
33 + class_device_create(cs, dev, parent, fmt, ## args)
34
35 #else /* >= 2.6.15 */
36
37 -#define lirc_class_device_create class_device_create
38 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
39 +
40 +#define lirc_device_create(cs, parent, dev, fmt, args...) \
41 + class_device_create(cs, NULL, dev, parent, fmt, ## args)
42 +
43 +#else /* >= 2.6.26 */
44 +
45 +#define lirc_device_create device_create
46 +
47 +#endif /* >= 2.6.26 */
48 +
49 #define LIRC_DEVFS_PREFIX
50
51 -#endif
52 +#endif /* >= 2.6.15 */
53
54 typedef struct class lirc_class_t;
55
56 +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
57 +
58 +#define lirc_device_destroy class_device_destroy
59 +
60 +#else
61 +
62 +#define lirc_device_destroy device_destroy
63 +
64 #endif
65
66 +#endif /* >= 2.6.13 */
67 +
68 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
69 #define LIRC_HAVE_DEVFS
70 #define LIRC_HAVE_DEVFS_24
71 @@ -133,8 +153,8 @@
72 #ifndef LIRC_HAVE_SYSFS
73 #define class_destroy(x) do { } while (0)
74 #define class_create(x, y) NULL
75 -#define class_device_destroy(x, y) do { } while (0)
76 -#define lirc_class_device_create(x, y, z, xx, yy, zz) 0
77 +#define lirc_class_destroy(x, y) do { } while (0)
78 +#define lirc_class_create(x, y, z, xx, yy, zz) 0
79 #define IS_ERR(x) 0
80 typedef struct class_simple
81 {
82 --- a/drivers/lirc_dev/lirc_dev.c
83 +++ b/drivers/lirc_dev/lirc_dev.c
84 @@ -145,7 +145,8 @@
85 #ifdef LIRC_HAVE_DEVFS_26
86 devfs_remove(DEV_LIRC "/%u", ir->p.minor);
87 #endif
88 - class_device_destroy(lirc_class, MKDEV(IRCTL_DEV_MAJOR, ir->p.minor));
89 + lirc_device_destroy(lirc_class,
90 + MKDEV(IRCTL_DEV_MAJOR, ir->p.minor));
91
92 if (ir->buf != ir->p.rbuf) {
93 lirc_buffer_free(ir->buf);
94 @@ -400,9 +401,9 @@
95 S_IFCHR|S_IRUSR|S_IWUSR,
96 DEV_LIRC "/%u", ir->p.minor);
97 #endif
98 - (void) lirc_class_device_create(lirc_class, NULL,
99 - MKDEV(IRCTL_DEV_MAJOR, ir->p.minor),
100 - ir->p.dev, "lirc%u", ir->p.minor);
101 + (void) lirc_device_create(lirc_class, ir->p.dev,
102 + MKDEV(IRCTL_DEV_MAJOR, ir->p.minor),
103 + "lirc%u", ir->p.minor);
104
105 if (p->sample_rate || p->get_queue) {
106 /* try to fire up polling thread */
107 @@ -441,7 +442,8 @@
108 return minor;
109
110 out_sysfs:
111 - class_device_destroy(lirc_class, MKDEV(IRCTL_DEV_MAJOR, ir->p.minor));
112 + lirc_device_destroy(lirc_class,
113 + MKDEV(IRCTL_DEV_MAJOR, ir->p.minor));
114 #ifdef LIRC_HAVE_DEVFS_24
115 devfs_unregister(ir->devfs_handle);
116 #endif