From 6414245c8fb95b7664678c441f8d84ef047d6489 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Mon, 19 Feb 2007 15:57:38 -0800 Subject: compat: Add code to compat.h for try_to_sleep() From: Trent Piepho Compat.h used to have an argument, now it doesn't. There was also some code: if (current->flags & PF_FREEZE) { refrigerator(PF_FREEZE); } which is the same as try_to_freeze(), and so can be replaced by it. Signed-off-by: Trent Piepho --- v4l/compat.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'v4l/compat.h') diff --git a/v4l/compat.h b/v4l/compat.h index 6ba49e825..ffe4e97a5 100644 --- a/v4l/compat.h +++ b/v4l/compat.h @@ -236,6 +236,15 @@ static inline unsigned long vmalloc_to_pfn(void * vmalloc_addr) #endif #endif +/* try_to_freeze() lost its argument. Must appear after linux/sched.h */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13) && defined(_LINUX_SCHED_H) +# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0) +# define try_to_freeze() try_to_freeze(PF_FREEZE) +# else +# define try_to_freeze() (0) +# endif +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) #ifndef kzalloc #define kzalloc(size, flags) \ -- cgit v1.2.3 From fda56953d09325bd00e7edc0292d5034e494218e Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Mon, 19 Feb 2007 16:50:52 -0800 Subject: compat: Add -include linux/version.h to cflags From: Trent Piepho Add -include linux/version.h to the cflags. Now code can have backward compatibility test without including compat.h first. Linux headers included from compat.h are removed, so that code will get the same headers when compiling in v4l-dvb as it does in the kernel. Many drivers have compat.h moved to the end of their include list, as this lets compat.h do things it can't do at the beginning. Such as test of something is defined to include compat code, or to put a wrapper around a function without changing the function's name. Signed-off-by: Trent Piepho --- v4l/compat.h | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'v4l/compat.h') diff --git a/v4l/compat.h b/v4l/compat.h index ffe4e97a5..bdad519e9 100644 --- a/v4l/compat.h +++ b/v4l/compat.h @@ -5,23 +5,14 @@ #ifndef _COMPAT_H #define _COMPAT_H -#include -#include -#include -#include -#include - #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,18) # define minor(x) MINOR(x) #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) -#include +# include # define need_resched() (current->need_resched) - -#define work_struct tq_struct -#else -#include +# define work_struct tq_struct #endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19) @@ -58,6 +49,10 @@ # define PCI_D0 (0) # define assert_spin_locked(foobar) #endif + +/* Since v4l-dvb now includes it's own copy of linux/i2c-id.h these + are no longer necessary */ +/* #if !defined(I2C_ALGO_SAA7134) #define I2C_ALGO_SAA7134 I2C_HW_B_BT848 #endif @@ -70,10 +65,10 @@ #if !defined(I2C_HW_SAA7146) # define I2C_HW_SAA7146 I2C_ALGO_SAA7146 #endif - #if !defined(I2C_HW_B_EM2820) #define I2C_HW_B_EM2820 0x99 #endif +*/ #ifndef I2C_M_IGNORE_NAK # define I2C_M_IGNORE_NAK 0x1000 @@ -291,7 +286,7 @@ static inline unsigned long vmalloc_to_pfn(void * vmalloc_addr) #define mutex_trylock(a) down_trylock(a) #endif -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) && defined(_LINUX_SCHED_H) static inline signed long __sched schedule_timeout_interruptible(signed long timeout) { @@ -327,7 +322,8 @@ static inline void setup_timer(struct timer_list * timer, turned on. We can not just include usb.h here, because there is a lot of code which will not compile if it has usb.h included, due to conflicts with symbol names. */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13) && defined(__LINUX_USB_H) +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13) && \ + defined(__LINUX_USB_H) && defined(_INPUT_H) #include /* Found in linux/usb_input.h in 2.6.13 */ /* Moved to linux/usb/input.h in 2.6.18 */ -- cgit v1.2.3 From 13aac084f52613baf79f047bdac0b0decc2b37d2 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Mon, 19 Feb 2007 19:01:09 -0800 Subject: compat: Fix compat stuff for usbvision and zr364xx From: Trent Piepho compat.h was missing from usbvideo-i2c.c and zr364xx.c zr364xx.c needed the struct semaphore -> struct mutex compat check. Added an old i2c id to compat.h. These could be added to the Hg copy of linux/i2c-id.h instead? There's just this one so far. zr364xx needs 2.6.15 because of vm_insert_page(), so add to versions.txt Signed-off-by: Trent Piepho --- v4l/compat.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'v4l/compat.h') diff --git a/v4l/compat.h b/v4l/compat.h index bdad519e9..25c11f460 100644 --- a/v4l/compat.h +++ b/v4l/compat.h @@ -74,6 +74,12 @@ # define I2C_M_IGNORE_NAK 0x1000 #endif +/* v4l-dvb uses an out of kernel copy of i2c-id.h, which does not have + some stuff that previous versions of i2c-id.h defined. */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) && defined(LINUX_I2C_ID_H) +# define I2C_ALGO_BIT 0x010000 +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9) #define __le32 __u32 #endif -- cgit v1.2.3 From 98901e271eeb3ffc496d67ebe1f30c744d7e63cd Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Mon, 19 Feb 2007 19:57:36 -0800 Subject: compat: Add compat code for vm_insert_page() From: Trent Piepho Add an inline versin of vm_insert_page() that uses remap_pfn_range() to compat.h. Remove compat code from em28xx-video.c, sn9c102_core.c, and usbvision-video.c since compat.h is now doing the same thing. USB_ZC0301, USB_ET61X251, and USB_ZR364XX will now compile under 2.6.12. Signed-off-by: Trent Piepho --- v4l/compat.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'v4l/compat.h') diff --git a/v4l/compat.h b/v4l/compat.h index 25c11f460..2b2de93a7 100644 --- a/v4l/compat.h +++ b/v4l/compat.h @@ -224,6 +224,16 @@ static inline unsigned long vmalloc_to_pfn(void * vmalloc_addr) #endif +/* vm_insert_page() was added in 2.6.15 */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15) && defined(_LINUX_MM_H) +static inline int vm_insert_page(struct vm_area_struct *vma, + unsigned long addr, struct page *page) +{ + return remap_pfn_range(vma, addr, page_to_pfn(page), PAGE_SIZE, + vma->vm_page_prot); +} +#endif + #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9) #ifndef kcalloc #define kcalloc(n,size,flags) \ -- cgit v1.2.3