Skip to contentSkip to conversation

build: Add support for timer_setup

PATCH New Matthias Schwarzott 1 participant 1 message Nov 4, 2017 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: Add support for timer_setup

Literally copied the implementation from kernel
commit 686fef928bba6be13 (timer: Prepare to change timer callback argument type)

---
 v4l/compat.h                      | 17 +++++++++++++++++
 v4l/scripts/make_config_compat.pl |  1 +
 2 files changed, 18 insertions(+)
v4l/compat.h +17 -0
index 3504288..f788e79 100644
@@ -2195,4 +2195,21 @@ static inline void *bsearch(const void *key, const void *base, size_t num, size_
 }
 #endif
 
+#ifdef NEED_TIMER_SETUP
+#define TIMER_DATA_TYPE                unsigned long
+#define TIMER_FUNC_TYPE                void (*)(TIMER_DATA_TYPE)
+
+static inline void timer_setup(struct timer_list *timer,
+                              void (*callback)(struct timer_list *),
+                              unsigned int flags)
+{
+       __setup_timer(timer, (TIMER_FUNC_TYPE)callback,
+                     (TIMER_DATA_TYPE)timer, flags);
+}
+
+#define from_timer(var, callback_timer, timer_fieldname) \
+       container_of(callback_timer, typeof(*var), timer_fieldname)
+
+#endif
+
 #endif /*  _COMPAT_H */
v4l/scripts/make_config_compat.pl +1 -0
index 8ebeea3..62eb6b9 100644
@@ -706,6 +706,7 @@ sub check_other_dependencies()
 	check_files_for_func("annotate_reachable", "NEED_ANNOTATE_REACHABLE", "include/linux/compiler.h");
 	check_files_for_func("U32_MAX", "NEED_U32_MAX", "include/linux/kernel.h");
 	check_files_for_func("bsearch", "NEED_BSEARCH", "include/linux/bsearch.h");
+	check_files_for_func("timer_setup", "NEED_TIMER_SETUP", "include/linux/timer.h");
 
 	# For tests for uapi-dependent logic
 	check_files_for_func_uapi("usb_endpoint_maxp", "NEED_USB_ENDPOINT_MAXP", "usb/ch9.h");
Signature · 1 line
2.15.0