patch-2.4.7 linux/drivers/media/video/saa5249.c

Next file: linux/drivers/media/video/zoran.h
Previous file: linux/drivers/media/video/meye.h
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.4.6/linux/drivers/media/video/saa5249.c linux/drivers/media/video/saa5249.c
@@ -102,6 +102,7 @@
 	int disp_mode;
 	int virtual_mode;
 	struct i2c_client *client;
+	struct semaphore lock;
 };
 
 
@@ -175,6 +176,7 @@
 	}
 	memset(t, 0, sizeof(*t));
 	strcpy(client->name, IF_NAME);
+	init_MUTEX(&t->lock);
 	
 	/*
 	 *	Now create a video4linux device
@@ -188,7 +190,7 @@
 		return -ENOMEM;
 	}
 	memcpy(vd, &saa_template, sizeof(*vd));
-	
+		
 	for (pgbuf = 0; pgbuf < NUM_DAUS; pgbuf++) 
 	{
 		memset(t->vdau[pgbuf].pgbuf, ' ', sizeof(t->vdau[0].pgbuf));
@@ -199,7 +201,8 @@
 		t->vdau[pgbuf].stopped = TRUE;
 		t->is_searching[pgbuf] = FALSE;
 	}
-	vd->priv=t;		 
+	vd->priv=t;	
+	 
 	
 	/*
 	 *	Register it
@@ -342,9 +345,8 @@
  *	Standard character-device-driver functions
  */
 
-static int saa5249_ioctl(struct video_device *vd, unsigned int cmd, void *arg) 
+static int do_saa5249_ioctl(struct saa5249_device *t, unsigned int cmd, void *arg) 
 {
-	struct saa5249_device *t=vd->priv;
 	static int virtual_mode = FALSE;
 
 	switch(cmd) 
@@ -602,6 +604,21 @@
 	return -EINVAL;
 }
 
+/*
+ *	Handle the locking
+ */
+ 
+static int saa5249_ioctl(struct video_device *vd, unsigned int cmd, void *arg) 
+{
+	struct saa5249_device *t=vd->priv;
+	int err;
+	
+	down(&t->lock);
+	err = do_saa5249_ioctl(t, cmd, arg);
+	up(&t->lock);
+
+	return err;
+}
 
 static int saa5249_open(struct video_device *vd, int nb) 
 {
@@ -632,7 +649,6 @@
 		t->is_searching[pgbuf] = FALSE;
 	}
 	t->virtual_mode=FALSE;
-	MOD_INC_USE_COUNT;
 	return 0;
 }
 
@@ -643,7 +659,6 @@
 	struct saa5249_device *t=vd->priv;
 	i2c_senddata(t, 1, 0x20, -1);		/* Turn off CCT */
 	i2c_senddata(t, 5, 3, 3, -1);		/* Turn off TV-display */
-	MOD_DEC_USE_COUNT;
 	return;
 }
 
@@ -669,6 +684,7 @@
 
 static struct video_device saa_template =
 {
+	owner:		THIS_MODULE,
 	name:		IF_NAME,
 	type:		VID_TYPE_TELETEXT,	/*| VID_TYPE_TUNER ?? */
 	hardware:	VID_HARDWARE_SAA5249,

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)