From 52eaaa8dff6907aae78b53fc2944769bf03cddc8 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 28 Jul 2006 23:10:17 +0100 Subject: Add dvb_attach() macro and supporting routines From: Andrew de Quincey Add dvb_attach() macro and supporting routines Signed-off-by: Andrew de Quincey Acked-by: Michael Krufky Acked-by: Trent Piepho --- linux/drivers/media/dvb/dvb-core/dvbdev.h | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'linux/drivers/media/dvb/dvb-core/dvbdev.h') 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_ */ -- cgit v1.2.3 From 401232ba8026e33a71183d3c80a83b53b3ef6ee4 Mon Sep 17 00:00:00 2001 From: Andrew de Quincey Date: Fri, 28 Jul 2006 23:10:41 +0100 Subject: Refactor dvb_detach calls into a single dvb_frontend_detach function. From: Andrew de Quincey Remove buggy dvb_detach() macro and replace with unified dvb_frontend_detach() call. Signed-off-by: Andrew de Quincey Acked-by: Trent Piepho --- linux/drivers/media/dvb/dvb-core/dvbdev.h | 32 ------------------------------- 1 file changed, 32 deletions(-) (limited to 'linux/drivers/media/dvb/dvb-core/dvbdev.h') diff --git a/linux/drivers/media/dvb/dvb-core/dvbdev.h b/linux/drivers/media/dvb/dvb-core/dvbdev.h index 1375d3a8e..26e4a9135 100644 --- a/linux/drivers/media/dvb/dvb-core/dvbdev.h +++ b/linux/drivers/media/dvb/dvb-core/dvbdev.h @@ -103,8 +103,6 @@ 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...) ({ \ @@ -120,41 +118,11 @@ extern int dvb_usercopy(struct inode *inode, struct file *file, __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_ */ -- cgit v1.2.3