lirc (0.8.3-5) 20_kcompat-2.6.26.patch

Summary

 drivers/kcompat.h           |   38 +++++++++++++++++++++++++++++---------
 drivers/lirc_dev/lirc_dev.c |   12 +++++++-----
 2 files changed, 36 insertions(+), 14 deletions(-)

    
download this patch

Patch contents

Kernel 2.6.26 removes an API previously used by lirc:
  - http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=c3b19ff06e0808555403491d61e8f0cbbb53e933

* add compatibility patch for kernels >= 2.6.26, based on upstream CVS.
  - http://lirc.cvs.sourceforge.net/lirc/lirc/drivers/kcompat.h?r1=5.34&r2=5.36
  - http://lirc.cvs.sourceforge.net/lirc/lirc/drivers/lirc_dev/lirc_dev.c?r1=1.57&r2=1.58

Copyright: © 2008 Christoph Bartelmus <lirc@bartelmus.de>

--- a/drivers/kcompat.h
+++ b/drivers/kcompat.h
@@ -36,10 +36,10 @@ static inline void class_destroy(lirc_cl
 	class_simple_destroy(cls);
 }
 
-#define lirc_class_device_create(cs, parent, dev, device, fmt, args...) \
-	class_simple_device_add(cs, dev, device, fmt, ## args)
+#define lirc_device_create(cs, parent, dev, fmt, args...) \
+	class_simple_device_add(cs, dev, parent, fmt, ## args)
 
-static inline void class_device_destroy(lirc_class_t *cls, dev_t devt)
+static inline void lirc_device_destroy(lirc_class_t *cls, dev_t devt)
 {
 	class_simple_device_remove(devt);
 }
@@ -48,20 +48,40 @@ static inline void class_device_destroy(
 
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 15)
 
-#define lirc_class_device_create(cs, parent, dev, device, fmt, args...) \
-	class_device_create(cs, dev, device, fmt, ## args)
+#define lirc_device_create(cs, parent, dev, fmt, args...) \
+	class_device_create(cs, dev, parent, fmt, ## args)
 
 #else /* >= 2.6.15 */
 
-#define lirc_class_device_create class_device_create
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
+
+#define lirc_device_create(cs, parent, dev, fmt, args...) \
+	class_device_create(cs, NULL, dev, parent, fmt, ## args)
+
+#else /* >= 2.6.26 */
+
+#define lirc_device_create device_create
+
+#endif /* >= 2.6.26 */
+
 #define LIRC_DEVFS_PREFIX
 
-#endif
+#endif /* >= 2.6.15 */
 
 typedef struct class lirc_class_t;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
+
+#define lirc_device_destroy class_device_destroy
+
+#else
+
+#define lirc_device_destroy device_destroy
+
 #endif
 
+#endif /* >= 2.6.13 */
+
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 0)
 #define LIRC_HAVE_DEVFS
 #define LIRC_HAVE_DEVFS_24
@@ -133,8 +153,8 @@ static inline void del_timer_sync(struct
 #ifndef LIRC_HAVE_SYSFS
 #define class_destroy(x) do { } while (0)
 #define class_create(x, y) NULL
-#define class_device_destroy(x, y) do { } while (0)
-#define lirc_class_device_create(x, y, z, xx, yy, zz) 0
+#define lirc_class_destroy(x, y) do { } while (0)
+#define lirc_class_create(x, y, z, xx, yy, zz) 0
 #define IS_ERR(x) 0
 typedef struct class_simple
 {
--- a/drivers/lirc_dev/lirc_dev.c
+++ b/drivers/lirc_dev/lirc_dev.c
@@ -145,7 +145,8 @@ static void cleanup(struct irctl *ir)
 #ifdef LIRC_HAVE_DEVFS_26
 	devfs_remove(DEV_LIRC "/%u", ir->p.minor);
 #endif
-	class_device_destroy(lirc_class, MKDEV(IRCTL_DEV_MAJOR, ir->p.minor));
+	lirc_device_destroy(lirc_class,
+			    MKDEV(IRCTL_DEV_MAJOR, ir->p.minor));
 
 	if (ir->buf != ir->p.rbuf) {
 		lirc_buffer_free(ir->buf);
@@ -400,9 +401,9 @@ int lirc_register_plugin(struct lirc_plu
 			S_IFCHR|S_IRUSR|S_IWUSR,
 			DEV_LIRC "/%u", ir->p.minor);
 #endif
-	(void) lirc_class_device_create(lirc_class, NULL,
-					MKDEV(IRCTL_DEV_MAJOR, ir->p.minor),
-					ir->p.dev, "lirc%u", ir->p.minor);
+	(void) lirc_device_create(lirc_class, ir->p.dev,
+				  MKDEV(IRCTL_DEV_MAJOR, ir->p.minor),
+				  "lirc%u", ir->p.minor);
 
 	if (p->sample_rate || p->get_queue) {
 		/* try to fire up polling thread */
@@ -441,7 +442,8 @@ int lirc_register_plugin(struct lirc_plu
 	return minor;
 
 out_sysfs:
-	class_device_destroy(lirc_class, MKDEV(IRCTL_DEV_MAJOR, ir->p.minor));
+	lirc_device_destroy(lirc_class,
+			    MKDEV(IRCTL_DEV_MAJOR, ir->p.minor));
 #ifdef LIRC_HAVE_DEVFS_24
 	devfs_unregister(ir->devfs_handle);
 #endif