Re: [PATCH] fixes for compiling against kernel 2.6.14

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 16 Jan 2007, Mark Buechler wrote:
> In kernel 2.6.14, method input_register_device returns void, whereas in the
> latest hg we're expecting int. Also, use of __GFP_DMA32 should be changed to
> __GFP_DMA for 2.6.14 and below. From what I understand, use of __GFP_DMA32
> isn't necessary anyway. Please see attached patch.

Generally, we try to keep the compat code inside compat.h if it's at all
possible.  For the input_register_device() change it's a little tricky, but
this can be done with:

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
#define input_register_device(x) (input_register_device(x), 0)
#endif

That will make input_register_device(x) appear to always return 0, and no
#if's are needed for any code that calls it.

The other things, setup_timer() and __GFP_DMA32, were easy to handle in
compat.h

Here is a patch which does all this.  I've tested that everything that is
supposed to compiles ok with 2.6.14, but I'm not actually using that
kernel.  Can you tell me if this patch works ok for you?  There was another
bit of code added Jan 21st to cinergyT2.c that needed some compat stuff for
2.6.14 as well.
# HG changeset patch
# User Trent Piepho <xyzzy@xxxxxxxxxxxxx>
# Node ID 5160ae04f246461051dbf18c4704d6a51ef467b7
# Parent  7b438c3c6a2e1bbdee793a68be9bd243fa0858a6
compat: Handle input_register_device() change and some others

From: Trent Piepho <xyzzy@xxxxxxxxxxxxx>

input_register_device() was changed to return an error code instead of
being void in 2.6.15.  Handle it with a macro wrapper in config.h.  For
this to work, linux/input.h must be included before config.h.  This
required some trivial header re-ordering in budget-ci.c and ttusb_dec.c.

In kernel 2.6.15-rc1 a helper function called setup_timer() was added to
linux/timer.h.  Add to compat.h, but require that linux/timer.h be
included first to give the definition of struct timer_list.

A new 4GB DMA zone, __GFP_DMA32, was added in 2.6.15-rc2.  Alias it to
__GFP_DMA on older kernels.

Handle another 2.6.15 "input_dev->dev to input_dev->cdev.dev" change for
some recently added code in cinergyT2.c.

Signed-off-by: Trent Piepho <xyzzy@xxxxxxxxxxxxx>

diff -r 7b438c3c6a2e -r 5160ae04f246 linux/drivers/media/dvb/cinergyT2/cinergyT2.c
--- a/linux/drivers/media/dvb/cinergyT2/cinergyT2.c	Thu Jan 25 22:17:52 2007 -0800
+++ b/linux/drivers/media/dvb/cinergyT2/cinergyT2.c	Fri Jan 26 21:24:34 2007 -0800
@@ -868,7 +868,11 @@ static int cinergyt2_register_rc(struct 
 	input_dev->id.vendor = cinergyt2->udev->descriptor.idVendor;
 	input_dev->id.product = cinergyt2->udev->descriptor.idProduct;
 	input_dev->id.version = 1;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
 	input_dev->cdev.dev = &cinergyt2->udev->dev;
+#else
+	input_dev->dev = &cinergyt2->udev->dev;
+#endif
 
 	err = input_register_device(input_dev);
 	if (err) {
diff -r 7b438c3c6a2e -r 5160ae04f246 linux/drivers/media/dvb/ttpci/budget-ci.c
--- a/linux/drivers/media/dvb/ttpci/budget-ci.c	Thu Jan 25 22:17:52 2007 -0800
+++ b/linux/drivers/media/dvb/ttpci/budget-ci.c	Fri Jan 26 21:24:34 2007 -0800
@@ -29,8 +29,6 @@
  * the project's page is at http://www.linuxtv.org/dvb/
  */
 
-#include "budget.h"
-
 #include <linux/module.h>
 #include <linux/errno.h>
 #include <linux/slab.h>
@@ -38,6 +36,8 @@
 #include <linux/input.h>
 #include <linux/spinlock.h>
 #include <media/ir-common.h>
+
+#include "budget.h"
 
 #include "dvb_ca_en50221.h"
 #include "stv0299.h"
@@ -267,15 +267,11 @@ static int msp430_ir_init(struct budget_
 	input_dev->timer.function = msp430_ir_keyup;
 	input_dev->timer.data = (unsigned long) &budget_ci->ir;
 
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,15)
 	error = input_register_device(input_dev);
 	if (error) {
 		printk(KERN_ERR "budget_ci: could not init driver for IR device (code %d)\n", error);
 		goto out2;
 	}
-#else
-	input_register_device(input_dev);
-#endif
 
 	tasklet_init(&budget_ci->ir.msp430_irq_tasklet, msp430_ir_interrupt,
 		     (unsigned long) budget_ci);
diff -r 7b438c3c6a2e -r 5160ae04f246 linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c
--- a/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c	Thu Jan 25 22:17:52 2007 -0800
+++ b/linux/drivers/media/dvb/ttusb-dec/ttusb_dec.c	Fri Jan 26 21:24:34 2007 -0800
@@ -20,11 +20,6 @@
  *
  */
 
-#include "compat.h"
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
-#include <linux/mutex.h>
-#endif
-
 #include <linux/list.h>
 #include <linux/module.h>
 #include <linux/moduleparam.h>
@@ -37,6 +32,11 @@
 #include <linux/crc32.h>
 #include <linux/init.h>
 #include <linux/input.h>
+
+#include "compat.h"
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,15)
+#include <linux/mutex.h>
+#endif
 
 #include "dmxdev.h"
 #include "dvb_demux.h"
diff -r 7b438c3c6a2e -r 5160ae04f246 linux/drivers/media/video/ir-kbd-i2c.c
--- a/linux/drivers/media/video/ir-kbd-i2c.c	Thu Jan 25 22:17:52 2007 -0800
+++ b/linux/drivers/media/video/ir-kbd-i2c.c	Fri Jan 26 21:24:34 2007 -0800
@@ -41,9 +41,9 @@
 #include <linux/workqueue.h>
 #include <asm/semaphore.h>
 
-#include "compat.h"
 #include <media/ir-common.h>
 #include <media/ir-kbd-i2c.h>
+#include "compat.h"
 
 /* ----------------------------------------------------------------------- */
 /* insmod parameters                                                       */
diff -r 7b438c3c6a2e -r 5160ae04f246 v4l/compat.h
--- a/v4l/compat.h	Thu Jan 25 22:17:52 2007 -0800
+++ b/v4l/compat.h	Fri Jan 26 21:24:34 2007 -0800
@@ -268,6 +268,10 @@ static inline unsigned long vmalloc_to_p
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
 # define input_allocate_device() kzalloc(sizeof(struct input_dev),GFP_KERNEL);
 # define input_free_device(input_dev) kfree(input_dev)
+# ifdef _INPUT_H  /* input.h must be included _before_ compat.h for this to work */
+   /* input_register_device() was changed to return an error code in 2.6.15 */
+#  define input_register_device(x) (input_register_device(x), 0)
+# endif
 #endif
 
 #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,15)
@@ -285,6 +289,24 @@ schedule_timeout_interruptible(signed lo
 {
 	__set_current_state(TASK_INTERRUPTIBLE);
 	return schedule_timeout(timeout);
+}
+#endif
+
+/* New 4GB DMA zone was added in 2.6.15-rc2 */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
+#  define __GFP_DMA32	__GFP_DMA
+#endif
+
+/* setup_timer() helper added 10/31/05, 2.6.15-rc1 */
+/* Need linux/timer.h to be included for struct timer_list */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15) && defined(_LINUX_TIMER_H)
+static inline void setup_timer(struct timer_list * timer,
+			       void (*function)(unsigned long),
+			       unsigned long data)
+{
+	timer->function = function;
+	timer->data = data;
+	init_timer(timer);
 }
 #endif
 
_______________________________________________
linux-dvb mailing list
linux-dvb@xxxxxxxxxxx
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linux-dvb

[Index of Archives]     [Linux Media]     [Video 4 Linux]     [Asterisk]     [Samba]     [Xorg]     [Xfree86]     [Linux USB]

  Powered by Linux