diff options
author | Holger Waechtler <devnull@localhost> | 2003-06-21 10:25:54 +0000 |
---|---|---|
committer | Holger Waechtler <devnull@localhost> | 2003-06-21 10:25:54 +0000 |
commit | b7df7335fc0cd7132912b1148c602cd757b50353 (patch) | |
tree | 1a415503f65f209bd2161959fec6645e55e3a239 | |
parent | bea08fc6a395ec2e21e3ef3c11c3feb3ff1db811 (diff) | |
download | mediapointer-dvb-s2-b7df7335fc0cd7132912b1148c602cd757b50353.tar.gz mediapointer-dvb-s2-b7df7335fc0cd7132912b1148c602cd757b50353.tar.bz2 |
2.5 portability code to task queues
-rw-r--r-- | linux/drivers/media/dvb/dvb-core/dvb_compat.h | 28 | ||||
-rw-r--r-- | linux/drivers/media/dvb/dvb-core/dvb_functions.h | 1 | ||||
-rw-r--r-- | linux/drivers/media/dvb/dvb-core/dvb_net.c | 16 |
3 files changed, 29 insertions, 16 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_compat.h b/linux/drivers/media/dvb/dvb-core/dvb_compat.h index 0cd86638a..b867f09ff 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_compat.h +++ b/linux/drivers/media/dvb/dvb-core/dvb_compat.h @@ -92,20 +92,40 @@ extern struct page * vmalloc_to_page(void *addr); #define BUG_ON(condition) do { if (unlikely((condition)!=0)) BUG(); } while(0) #endif + +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) +#include <linux/tqueue.h> +#define work_struct tq_struct +#define INIT_WORK(wq,routine,data) INIT_TQUEUE(wq,routine,data) +#define schedule_work(wq) schedule_task(wq) +static inline +void flush_workqueue(struct tq_struct *wq) +{ + unsigned long flags; + /** + * we take the simple approach and just remove wq from the list of + * scheduled tasks -- should work for us + */ + spin_lock_irqsave(&tqueue_lock, flags); + if (test_bit(0, &wq->sync)) + list_del(&wq->list); + spin_unlock_irqrestore(&tqueue_lock, flags); +} +#else +#include <linux/workqueue.h> +#endif + + /* USB compatibility */ #include <linux/usb.h> #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0) - typedef struct iso_packet_descriptor usb_iso_packet_descriptor; #define URB_ISO_ASAP USB_ISO_ASAP #define URB_MEM_FLAG - #else - #define URB_MEM_FLAG , GFP_KERNEL - #endif #endif diff --git a/linux/drivers/media/dvb/dvb-core/dvb_functions.h b/linux/drivers/media/dvb/dvb-core/dvb_functions.h index 9bb8053d2..b49fdb818 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_functions.h +++ b/linux/drivers/media/dvb/dvb-core/dvb_functions.h @@ -25,6 +25,7 @@ extern int dvb_usercopy(struct inode *inode, struct file *file, extern void dvb_kernel_thread_setup (const char *thread_name); + #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) #include "dvb_compat.h" #endif diff --git a/linux/drivers/media/dvb/dvb-core/dvb_net.c b/linux/drivers/media/dvb/dvb-core/dvb_net.c index 9717da34d..69f3545fc 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_net.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_net.c @@ -45,7 +45,7 @@ struct dvb_net_priv { struct dmx_section_filter *multi_secfilter[DVB_NET_MULTICAST_MAX]; unsigned char multi_macs[DVB_NET_MULTICAST_MAX][6]; int mode; - struct tq_struct tq; + struct work_struct wq; }; @@ -347,7 +347,7 @@ static void dvb_net_set_multicast_list (struct net_device *dev) { struct dvb_net_priv *priv = (struct dvb_net_priv*) dev->priv; - schedule_task(&priv->tq); + schedule_work(&priv->wq); } @@ -473,7 +473,7 @@ int dvb_net_add_if(struct dvb_net *dvbnet, u16 pid) priv->pid = pid; priv->mode = 0; - PREPARE_TQUEUE(&priv->tq, tq_set_multicast_list, net); + INIT_WORK(&priv->wq, tq_set_multicast_list, net); net->base_addr = pid; @@ -489,20 +489,12 @@ static int dvb_net_remove_if(struct dvb_net *dvbnet, int num) { struct dvb_net_priv *priv = dvbnet->device[num].priv; - unsigned long flags; if (!dvbnet->state[num]) return -EINVAL; - /** - * remove tq from task queue if it was scheduled before... - */ - spin_lock_irqsave(&tqueue_lock, flags); - if (test_bit(0, &priv->tq.sync)) - list_del(&priv->tq.list); - spin_unlock_irqrestore(&tqueue_lock, flags); - dvb_net_stop(&dvbnet->device[num]); + flush_workqueue(&priv->wq); kfree(priv); unregister_netdev(&dvbnet->device[num]); dvbnet->state[num]=0; |