summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/msp3400-driver.c
diff options
context:
space:
mode:
authorHans Verkuil <devnull@localhost>2005-12-04 16:33:19 +0000
committerHans Verkuil <devnull@localhost>2005-12-04 16:33:19 +0000
commitc5c68bc2b8f184d2507facc7f627821cae1c80d2 (patch)
tree8e1d0634ce8f83ad9e4d052065dda08aede56f8c /linux/drivers/media/video/msp3400-driver.c
parent3763b37eaab7f4ce367aacd5262330afe92f4dde (diff)
downloadmediapointer-dvb-s2-c5c68bc2b8f184d2507facc7f627821cae1c80d2.tar.gz
mediapointer-dvb-s2-c5c68bc2b8f184d2507facc7f627821cae1c80d2.tar.bz2
Restore 2.4 support for msp3400.c
Restore 2.4 support for msp3400.c. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Diffstat (limited to 'linux/drivers/media/video/msp3400-driver.c')
-rw-r--r--linux/drivers/media/video/msp3400-driver.c84
1 files changed, 83 insertions, 1 deletions
diff --git a/linux/drivers/media/video/msp3400-driver.c b/linux/drivers/media/video/msp3400-driver.c
index b4e425828..a7a43d748 100644
--- a/linux/drivers/media/video/msp3400-driver.c
+++ b/linux/drivers/media/video/msp3400-driver.c
@@ -168,6 +168,10 @@ struct msp3400c {
/* thread */
struct task_struct *kthread;
wait_queue_head_t wq;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ struct semaphore *notify;
+ int rmmod:1;
+#endif
int restart:1;
int watch_stereo:1;
};
@@ -859,7 +863,11 @@ static int msp34xx_sleep(struct msp3400c *msp, int timeout)
DECLARE_WAITQUEUE(wait, current);
add_wait_queue(&msp->wq, &wait);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ if (!(msp->rmmod || signal_pending(current))) {
+#else
if (!kthread_should_stop()) {
+#endif
if (timeout < 0) {
set_current_state(TASK_INTERRUPTIBLE);
schedule();
@@ -904,6 +912,24 @@ static void watch_stereo(struct i2c_client *client)
msp->watch_stereo = 0;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+static void msp3400_setup_thread(struct msp3400c *msp)
+{
+ daemonize();
+ exit_files(current);
+ reparent_to_init();
+
+ spin_lock_irq(SIGMASK_LOCK(current));
+ sigfillset(&current->blocked);
+ spin_unlock_irq(SIGMASK_LOCK(current));
+ strcpy(current->comm, "msp3400");
+
+ msp->kthread = current;
+ if (msp->notify != NULL)
+ up(msp->notify);
+}
+#endif
+
static int msp3400c_thread(void *data)
{
struct i2c_client *client = data;
@@ -911,6 +937,10 @@ static int msp3400c_thread(void *data)
struct CARRIER_DETECT *cd;
int count, max1,max2,val1,val2, val,this;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ msp3400_setup_thread(msp);
+#endif
+
msp3400_info("msp3400 daemon started\n");
for (;;) {
msp3400_dbg_mediumvol("msp3400 thread: sleep\n");
@@ -920,7 +950,11 @@ static int msp3400c_thread(void *data)
restart:
msp3400_dbg("thread: restart scan\n");
msp->restart = 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ if (msp->rmmod || signal_pending(current))
+#else
if (kthread_should_stop())
+#endif
break;
if (VIDEO_MODE_RADIO == msp->norm ||
@@ -1088,6 +1122,12 @@ static int msp3400c_thread(void *data)
}
}
msp3400_dbg("thread: exit\n");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ msp->kthread = NULL;
+
+ if (msp->notify != NULL)
+ up(msp->notify);
+#endif
return 0;
}
@@ -1183,7 +1223,11 @@ static int msp3410d_thread(void *data)
struct msp3400c *msp = i2c_get_clientdata(client);
int mode,val,i,std;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ msp3400_setup_thread(msp);
+#endif
msp3400_info("msp3410 daemon started\n");
+
for (;;) {
msp3400_dbg_mediumvol("msp3410 thread: sleep\n");
msp34xx_sleep(msp,-1);
@@ -1192,7 +1236,11 @@ static int msp3410d_thread(void *data)
restart:
msp3400_dbg("thread: restart scan\n");
msp->restart = 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ if (msp->rmmod || signal_pending(current))
+#else
if (kthread_should_stop())
+#endif
break;
if (msp->mode == MSP_MODE_EXTERN) {
@@ -1340,6 +1388,12 @@ static int msp3410d_thread(void *data)
}
}
msp3400_dbg("thread: exit\n");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ msp->kthread = NULL;
+
+ if (msp->notify != NULL)
+ up(msp->notify);
+#endif
return 0;
}
@@ -1412,7 +1466,11 @@ static int msp34xxg_thread(void *data)
struct msp3400c *msp = i2c_get_clientdata(client);
int val, std, i;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ msp3400_setup_thread(msp);
+#endif
msp3400_info("msp34xxg daemon started\n");
+
msp->source = 1; /* default */
for (;;) {
msp3400_dbg_mediumvol("msp34xxg thread: sleep\n");
@@ -1422,7 +1480,11 @@ static int msp34xxg_thread(void *data)
restart:
msp3400_dbg("thread: restart scan\n");
msp->restart = 0;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ if (msp->rmmod || signal_pending(current))
+#else
if (kthread_should_stop())
+#endif
break;
/* setup the chip*/
@@ -1471,6 +1533,12 @@ static int msp34xxg_thread(void *data)
msp3400c_write(client,I2C_MSP3400C_DEM, 0x40, msp->i2s_mode);
}
msp3400_dbg("thread: exit\n");
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ msp->kthread = NULL;
+
+ if (msp->notify != NULL)
+ up(msp->notify);
+#endif
return 0;
}
@@ -2212,6 +2280,7 @@ static int msp_resume(struct device * dev, u32 level)
return 0;
}
#endif /* LINUX_VERSION_CODE */
+
/* ----------------------------------------------------------------------- */
static int msp_probe(struct i2c_adapter *adap);
@@ -2359,10 +2428,13 @@ static int msp_attach(struct i2c_adapter *adap, int addr, unsigned short flags,
if (NULL == msp->kthread)
msp3400_warn("kernel_thread() failed\n");
#else
- /*FIXME: Not sure if this will work */
+ DECLARE_MUTEX_LOCKED(sem);
msp->kthread = NULL;
+ msp->notify = &sem;
kernel_thread (thread_func, client, 0);
+ down(&sem);
+ msp->notify = NULL;
#endif
msp_wake_thread(client);
}
@@ -2383,7 +2455,17 @@ static int msp_detach(struct i2c_client *client)
/* shutdown control thread */
if (msp->kthread) {
msp->restart = 1;
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
+ DECLARE_MUTEX_LOCKED(sem);
+ /* shutdown control thread */
+ msp->notify = &sem;
+ msp->rmmod = 1;
+ wake_up_interruptible(&msp->wq);
+ down(&sem);
+ msp->notify = NULL;
+#else
kthread_stop(msp->kthread);
+#endif
}
msp3400c_reset(client);