summaryrefslogtreecommitdiff
path: root/linux/drivers/media/dvb/dvb-core/dvbdev.h
diff options
context:
space:
mode:
Diffstat (limited to 'linux/drivers/media/dvb/dvb-core/dvbdev.h')
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvbdev.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvbdev.h b/linux/drivers/media/dvb/dvb-core/dvbdev.h
index 1e7c036d5..1375d3a8e 100644
--- a/linux/drivers/media/dvb/dvb-core/dvbdev.h
+++ b/linux/drivers/media/dvb/dvb-core/dvbdev.h
@@ -103,4 +103,58 @@ extern int dvb_usercopy(struct inode *inode, struct file *file,
int (*func)(struct inode *inode, struct file *file,
unsigned int cmd, void *arg));
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,17))
+
+/** generic DVB attach function. */
+#ifdef CONFIG_DVB_CORE_ATTACH
+#define dvb_attach(FUNCTION, ARGS...) ({ \
+ void *__r = NULL; \
+ typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
+ if (__a) { \
+ __r = (void *) __a(ARGS); \
+ if (__r == NULL) \
+ symbol_put(FUNCTION); \
+ } else { \
+ printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \
+ } \
+ __r; \
+})
+
+#define dvb_detach(FUNCPTR, ARGS...) ({ \
+ typeof((FUNCPTR)) __funcptrtmp = FUNCPTR; \
+ if (__funcptrtmp) { \
+ __funcptrtmp(ARGS); \
+ symbol_put_addr(__funcptrtmp); \
+ } \
+ FUNCPTR = NULL; \
+})
+
+#else
+#define dvb_attach(FUNCTION, ARGS...) ({ \
+ FUNCTION(ARGS); \
+})
+
+#define dvb_detach(FUNCPTR, ARGS...) \
+do { \
+ if (FUNCPTR) \
+ FUNCPTR(ARGS); \
+ FUNCPTR = NULL; \
+} while(0)
+
+#endif
+
+#else
+#define dvb_attach(FUNCTION, ARGS...) ({ \
+ FUNCTION(ARGS); \
+})
+
+#define dvb_detach(FUNCPTR, ARGS...) \
+do { \
+ if (FUNCPTR) \
+ FUNCPTR(ARGS); \
+ FUNCPTR = NULL; \
+} while(0)
+
+#endif
+
#endif /* #ifndef _DVBDEV_H_ */