From 5673904df7d5dd00df35988fd6fda922b4000398 Mon Sep 17 00:00:00 2001 From: Holger Waechtler Date: Fri, 21 Mar 2003 11:02:16 +0000 Subject: - more portability changes, move ddelay() into compat.h - introduce kernel_thread_setup() function to encapsulate linux process model related stuff --- linux/drivers/media/dvb/dvb-core/compat.h | 38 +++++++++++++++++++++++++ linux/drivers/media/dvb/dvb-core/dvb_frontend.c | 32 +++++---------------- linux/drivers/media/dvb/frontends/alps_tdmb7.c | 9 +----- linux/drivers/media/dvb/frontends/ves1820.c | 8 +----- linux/drivers/media/dvb/ttpci/av7110.c | 37 +++++------------------- linux/drivers/media/dvb/ttpci/budget-av.c | 13 ++------- linux/drivers/media/dvb/ttpci/budget-core.c | 13 --------- linux/drivers/media/dvb/ttpci/budget.c | 12 +------- 8 files changed, 58 insertions(+), 104 deletions(-) (limited to 'linux') diff --git a/linux/drivers/media/dvb/dvb-core/compat.h b/linux/drivers/media/dvb/dvb-core/compat.h index 92ba960a0..292d6c958 100644 --- a/linux/drivers/media/dvb/dvb-core/compat.h +++ b/linux/drivers/media/dvb/dvb-core/compat.h @@ -1,10 +1,48 @@ #ifndef __CRAP_H #define __CRAP_H +#include #include +#include #include #include + +/** + * a sleeping delay function, waits i ms + * + */ +static +inline void ddelay(int i) +{ + current->state=TASK_INTERRUPTIBLE; + schedule_timeout((HZ*i)/1000); +} + + +static inline +void kernel_thread_setup (const char *thread_name) +{ + lock_kernel (); + +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,61)) + daemonize (); + strncpy (current->comm, thread_name, sizeof(current->comm)); +#else + daemonize (thread_name); +#endif + +/* not needed anymore in 2.5.x, done in daemonize() */ +#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) + reparent_to_init (); +#endif + + sigfillset (¤t->blocked); + unlock_kernel (); +} + + + /** * compatibility crap for old kernels. No guarantee for a working driver * even when everything compiles. diff --git a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c index 6049dbf44..3cdbbe71a 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_frontend.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_frontend.c @@ -25,10 +25,10 @@ #include #include #include +#include #include #include #include -#include #include #include #include @@ -36,6 +36,7 @@ #include "dvb_frontend.h" #include "dvbdev.h" +#include "compat.h" static int dvb_frontend_debug = 0; @@ -102,14 +103,6 @@ static LIST_HEAD(frontend_notifier_list); static DECLARE_MUTEX(frontend_mutex); -static -inline void ddelay (int ms) -{ - current->state=TASK_INTERRUPTIBLE; - schedule_timeout((HZ*ms)/1000); -} - - static int dvb_frontend_internal_ioctl (struct dvb_frontend *frontend, unsigned int cmd, void *arg) @@ -433,33 +426,22 @@ static int dvb_frontend_thread (void *data) { struct dvb_frontend_data *fe = (struct dvb_frontend_data *) data; + char name [15]; int quality = 0, delay = 3*HZ; fe_status_t s; dprintk ("%s\n", __FUNCTION__); - lock_kernel (); -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,61)) - daemonize (); -#else - daemonize ("dvb fe"); -#endif -/* not needed anymore in 2.5.x, done in daemonize() */ -#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)) - reparent_to_init (); -#endif + snprintf (name, sizeof(name), "kdvb-fe-%i:%i", + fe->frontend.i2c->adapter->num, fe->frontend.i2c->id); - sigfillset (¤t->blocked); + kernel_thread_setup (name); fe->thread = current; - snprintf (current->comm, sizeof (current->comm), "kdvb-fe-%i:%i", - fe->frontend.i2c->adapter->num, fe->frontend.i2c->id); - unlock_kernel (); + fe->lost_sync_count = -1; dvb_call_frontend_notifiers (fe, 0); dvb_frontend_init (fe); - fe->lost_sync_count = -1; - while (!dvb_frontend_is_exiting (fe)) { up (&fe->sem); /* is locked when we enter the thread... */ diff --git a/linux/drivers/media/dvb/frontends/alps_tdmb7.c b/linux/drivers/media/dvb/frontends/alps_tdmb7.c index 65bccfed1..7776e1137 100644 --- a/linux/drivers/media/dvb/frontends/alps_tdmb7.c +++ b/linux/drivers/media/dvb/frontends/alps_tdmb7.c @@ -24,6 +24,7 @@ #include #include "dvb_frontend.h" +#include "compat.h" static int debug = 0; @@ -51,14 +52,6 @@ struct dvb_frontend_info tdmb7_info = { }; -static -inline void ddelay (int timeout) -{ - current->state=TASK_INTERRUPTIBLE; - schedule_timeout(timeout); -} - - static u8 init_tab [] = { 0x04, 0x10, diff --git a/linux/drivers/media/dvb/frontends/ves1820.c b/linux/drivers/media/dvb/frontends/ves1820.c index e5cf4465c..10e9d59b5 100644 --- a/linux/drivers/media/dvb/frontends/ves1820.c +++ b/linux/drivers/media/dvb/frontends/ves1820.c @@ -24,6 +24,7 @@ #include #include "dvb_frontend.h" +#include "compat.h" #if 0 @@ -64,13 +65,6 @@ #define GET_DEMOD_ADDR(data) ((u8) (((int) data >> 24) & 0xff)) -static inline -void ddelay (int ms) -{ - current->state=TASK_INTERRUPTIBLE; - schedule_timeout((HZ*ms)/1000); -} - static struct dvb_frontend_info ves1820_info = { diff --git a/linux/drivers/media/dvb/ttpci/av7110.c b/linux/drivers/media/dvb/ttpci/av7110.c index 39ef32abe..a5ce92cc4 100644 --- a/linux/drivers/media/dvb/ttpci/av7110.c +++ b/linux/drivers/media/dvb/ttpci/av7110.c @@ -75,6 +75,8 @@ #include "dvb_i2c.h" #include "dvb_frontend.h" +#include "compat.h" + #if 1 #define DEBUG_VARIABLE av7110_debug @@ -107,20 +109,6 @@ static int hw_sections = 1; int av7110_num = 0; -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51) - #define KBUILD_MODNAME av7110 -#endif - -/**************************************************************************** - * General helper functions - ****************************************************************************/ - -static inline void ddelay(int i) -{ - current->state=TASK_INTERRUPTIBLE; - schedule_timeout((HZ*i)/100); -} - /**************************************************************************** * DEBI functions @@ -326,7 +314,8 @@ recover_arm(av7110_t *av7110) printk("OOPS, no current->files\n"); reset_arm(av7110); } - ddelay(10); + + ddelay(100); restart_feeds(av7110); } @@ -346,21 +335,9 @@ static int arm_thread(void *data) u16 newloops = 0; DEB_EE(("av7110: %p\n",av7110)); - - lock_kernel(); -#if 0 - daemonize(); -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51) - reparent_to_init (); -#endif -#else - exit_mm(current); - current->session=current->pgrp=1; -#endif - sigfillset(¤t->blocked); - strcpy(current->comm, "arm_mon"); + + kernel_thread_setup ("arm_mon"); av7110->arm_thread = current; - unlock_kernel(); while (!av7110->arm_rmmod && !signal_pending(current)) { interruptible_sleep_on_timeout(&av7110->arm_wait, 5*HZ); @@ -4143,7 +4120,7 @@ int av7110_attach (struct saa7146_dev* dev, struct saa7146_pci_extension_data *p i2c_writereg(av7110, 0x80, 0x0, 0); printk ("av7110: DVB-C analog module detected, " "initializing MSP3400\n"); - ddelay(10); + ddelay(100); msp_writereg(av7110, 0x12, 0x0013, 0x0c00); msp_writereg(av7110, 0x12, 0x0000, 0x7f00); // loudspeaker + headphone msp_writereg(av7110, 0x12, 0x0008, 0x0220); // loudspeaker source diff --git a/linux/drivers/media/dvb/ttpci/budget-av.c b/linux/drivers/media/dvb/ttpci/budget-av.c index 8d6be0828..2fa7ab6aa 100644 --- a/linux/drivers/media/dvb/ttpci/budget-av.c +++ b/linux/drivers/media/dvb/ttpci/budget-av.c @@ -48,13 +48,6 @@ struct budget_av { * INITIALIZATION ****************************************************************************/ -static inline -void ddelay(int i) -{ - current->state=TASK_INTERRUPTIBLE; - schedule_timeout((HZ*i)/100); -} - static u8 i2c_readreg (struct dvb_i2c_bus *i2c, u8 id, u8 reg) @@ -175,7 +168,7 @@ int budget_av_detach (struct saa7146_dev *dev) saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO); - ddelay(20); + ddelay(200); saa7146_unregister_device (&budget_av->vd, dev); @@ -221,7 +214,7 @@ int budget_av_attach (struct saa7146_dev* dev, //test_knc_ci(av7110); saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTHI); - ddelay(50); + ddelay(500); if ((err = saa7113_init (budget_av))) { budget_av_detach(dev); @@ -246,7 +239,7 @@ int budget_av_attach (struct saa7146_dev* dev, /* what is this? since we don't support open()/close() notifications, we simply put this into the release handler... */ // saa7146_setgpio(dev, 0, SAA7146_GPIO_OUTLO); - ddelay(20); + ddelay(200); /* fixme: find some sane values here... */ saa7146_write(dev, PCI_BT_V1, 0x1c00101f); diff --git a/linux/drivers/media/dvb/ttpci/budget-core.c b/linux/drivers/media/dvb/ttpci/budget-core.c index 71cbcfffd..bdf81a82e 100644 --- a/linux/drivers/media/dvb/ttpci/budget-core.c +++ b/linux/drivers/media/dvb/ttpci/budget-core.c @@ -1,20 +1,7 @@ #include "budget.h" -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51) - #define KBUILD_MODNAME budget -#endif int budget_debug = 0; -/**************************************************************************** - * General helper functions - ****************************************************************************/ - -static inline void ddelay(int i) -{ - current->state=TASK_INTERRUPTIBLE; - schedule_timeout((HZ*i)/100); -} - /**************************************************************************** * TT budget / WinTV Nova ****************************************************************************/ diff --git a/linux/drivers/media/dvb/ttpci/budget.c b/linux/drivers/media/dvb/ttpci/budget.c index 545101f44..d4f9f7640 100644 --- a/linux/drivers/media/dvb/ttpci/budget.c +++ b/linux/drivers/media/dvb/ttpci/budget.c @@ -30,19 +30,9 @@ */ #include "budget.h" -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,51) - #define KBUILD_MODNAME budget -#endif -static inline void ddelay(int i) -{ - current->state=TASK_INTERRUPTIBLE; - schedule_timeout((HZ*i)/100); -} - - static void Set22K (struct budget *budget, int state) { @@ -110,7 +100,7 @@ int SendDiSEqCMsg (struct budget *budget, int len, u8 *msg, int burst) udelay(12500); saa7146_setgpio(dev, 3, SAA7146_GPIO_OUTLO); } - ddelay(2); + ddelay(20); } return 0; -- cgit v1.2.3