summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--v4l/compat.h19
-rwxr-xr-xv4l/scripts/make_config_compat.pl60
2 files changed, 72 insertions, 7 deletions
diff --git a/v4l/compat.h b/v4l/compat.h
index 253b3387a..1d042d96c 100644
--- a/v4l/compat.h
+++ b/v4l/compat.h
@@ -163,7 +163,8 @@ do { \
#define put_unaligned_le64(r, a) \
put_unaligned(cpu_to_le64(r), ((u64 *)(a)))
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
+
+#ifdef NEED_PROC_CREATE
#ifdef CONFIG_PROC_FS
static inline struct proc_dir_entry *proc_create(const char *a,
mode_t b, struct proc_dir_entry *c, const struct file_operations *d)
@@ -215,19 +216,23 @@ static inline struct proc_dir_entry *proc_create_data(const char *a,
typedef unsigned long uintptr_t;
#endif
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
-#define div64_u64(a,b) div64_64(a,b)
+#ifdef NEED_IS_SINGULAR
+static inline int list_is_singular(const struct list_head *head)
+{
+ return !list_empty(head) && (head->next == head->prev);
+}
+#endif
+#ifdef NEED_CLAMP
#define clamp( x, l, h ) max_t( __typeof__( x ), \
( l ), \
min_t( __typeof__( x ), \
( h ), \
( x ) ) )
+#endif
-static inline int list_is_singular(const struct list_head *head)
-{
- return !list_empty(head) && (head->next == head->prev);
-}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26)
+#define div64_u64(a,b) div64_64(a,b)
#define dev_name(dev) ((dev)->bus_id)
diff --git a/v4l/scripts/make_config_compat.pl b/v4l/scripts/make_config_compat.pl
index bd34e7193..f681baf3e 100755
--- a/v4l/scripts/make_config_compat.pl
+++ b/v4l/scripts/make_config_compat.pl
@@ -102,6 +102,63 @@ sub check_bool()
close INDEP;
}
+sub check_is_singular()
+{
+ my $file = "$kdir/include/linux/list.h";
+ my $need_compat = 1;
+
+ open INNET, "<$file" or die "File not found: $file";
+ while (<INNET>) {
+ if (m/list_is_singular/) {
+ $need_compat = 0;
+ last;
+ }
+ }
+
+ if ($need_compat) {
+ $out.= "\n#define NEED_IS_SINGULAR 1\n";
+ }
+ close INNET;
+}
+
+sub check_clamp()
+{
+ my $file = "$kdir/include/linux/kernel.h";
+ my $need_compat = 1;
+
+ open INNET, "<$file" or die "File not found: $file";
+ while (<INNET>) {
+ if (m/define\s+clamp/) {
+ $need_compat = 0;
+ last;
+ }
+ }
+
+ if ($need_compat) {
+ $out.= "\n#define NEED_CLAMP 1\n";
+ }
+ close INNET;
+}
+
+sub check_proc_create()
+{
+ my $file = "$kdir/include/linux/proc_fs.h";
+ my $need_compat = 1;
+
+ open INNET, "<$file" or die "File not found: $file";
+ while (<INNET>) {
+ if (m/proc_create/) {
+ $need_compat = 0;
+ last;
+ }
+ }
+
+ if ($need_compat) {
+ $out.= "\n#define NEED_PROC_FS 1\n";
+ }
+ close INNET;
+}
+
sub check_other_dependencies()
{
check_spin_lock();
@@ -109,6 +166,9 @@ sub check_other_dependencies()
check_snd_ctl_boolean_mono_info();
check_snd_pcm_rate_to_rate_bit();
check_bool();
+ check_is_singular();
+ check_clamp();
+ check_proc_create();
}
# Do the basic rules