Эх сурвалжийг харах

[media] saa7164: Removed use of the BKL

Remove usage of the BKL and instead used video_set_drvdata() during
open fops.

Signed-off-by: Steven Toth <stoth@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Steven Toth 14 жил өмнө
parent
commit
214ce3faac

+ 9 - 39
drivers/media/video/saa7164/saa7164-encoder.c

@@ -1054,57 +1054,26 @@ out:
 
 
 static int fops_open(struct file *file)
 static int fops_open(struct file *file)
 {
 {
-	struct saa7164_dev *h, *dev = NULL;
-	struct saa7164_port *port = NULL;
-	struct saa7164_port *portc = NULL;
-	struct saa7164_port *portd = NULL;
+	struct saa7164_dev *dev;
+	struct saa7164_port *port;
 	struct saa7164_encoder_fh *fh;
 	struct saa7164_encoder_fh *fh;
-	struct list_head *list;
-	int minor = video_devdata(file)->minor;
 
 
-	dprintk(DBGLVL_ENC, "%s()\n", __func__);
-
-	/* TODO: Really, the BKL? - remove this */
-	lock_kernel();
-	list_for_each(list, &saa7164_devlist) {
-		h = list_entry(list, struct saa7164_dev, devlist);
-
-		portc = &h->ports[SAA7164_PORT_ENC1];
-		portd = &h->ports[SAA7164_PORT_ENC2];
-
-		if (portc->v4l_device &&
-		    portc->v4l_device->minor == minor) {
-			dev = h;
-			port = portc;
-			break;
-		}
-
-		if (portd->v4l_device &&
-		    portd->v4l_device->minor == minor) {
-			dev = h;
-			port = portd;
-			break;
-		}
+	port = (struct saa7164_port *)video_get_drvdata(video_devdata(file));
+	if (!port)
+		return -ENODEV;
 
 
-	}
+	dev = port->dev;
 
 
-	if (port == NULL) {
-		unlock_kernel();
-		return -ENODEV;
-	}
+	dprintk(DBGLVL_ENC, "%s()\n", __func__);
 
 
 	/* allocate + initialize per filehandle data */
 	/* allocate + initialize per filehandle data */
 	fh = kzalloc(sizeof(*fh), GFP_KERNEL);
 	fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-	if (NULL == fh) {
-		unlock_kernel();
+	if (NULL == fh)
 		return -ENOMEM;
 		return -ENOMEM;
-	}
 
 
 	file->private_data = fh;
 	file->private_data = fh;
 	fh->port = port;
 	fh->port = port;
 
 
-	unlock_kernel();
-
 	return 0;
 	return 0;
 }
 }
 
 
@@ -1474,6 +1443,7 @@ int saa7164_encoder_register(struct saa7164_port *port)
 		goto failed;
 		goto failed;
 	}
 	}
 
 
+	video_set_drvdata(port->v4l_device, port);
 	result = video_register_device(port->v4l_device,
 	result = video_register_device(port->v4l_device,
 		VFL_TYPE_GRABBER, -1);
 		VFL_TYPE_GRABBER, -1);
 	if (result < 0) {
 	if (result < 0) {

+ 9 - 39
drivers/media/video/saa7164/saa7164-vbi.c

@@ -1001,57 +1001,26 @@ int saa7164_vbi_fmt(struct file *file, void *priv, struct v4l2_format *f)
 
 
 static int fops_open(struct file *file)
 static int fops_open(struct file *file)
 {
 {
-	struct saa7164_dev *h, *dev = NULL;
-	struct saa7164_port *port = NULL;
-	struct saa7164_port *porte = NULL;
-	struct saa7164_port *portf = NULL;
+	struct saa7164_dev *dev;
+	struct saa7164_port *port;
 	struct saa7164_vbi_fh *fh;
 	struct saa7164_vbi_fh *fh;
-	struct list_head *list;
-	int minor = video_devdata(file)->minor;
 
 
-	dprintk(DBGLVL_VBI, "%s()\n", __func__);
-
-	/* TODO: Really, the BKL? - remove this */
-	lock_kernel();
-	list_for_each(list, &saa7164_devlist) {
-		h = list_entry(list, struct saa7164_dev, devlist);
-
-		porte = &h->ports[SAA7164_PORT_VBI1];
-		portf = &h->ports[SAA7164_PORT_VBI2];
-
-		if (porte->v4l_device &&
-		    porte->v4l_device->minor == minor) {
-			dev = h;
-			port = porte;
-			break;
-		}
-
-		if (portf->v4l_device &&
-		    portf->v4l_device->minor == minor) {
-			dev = h;
-			port = portf;
-			break;
-		}
+	port = (struct saa7164_port *)video_get_drvdata(video_devdata(file));
+	if (!port)
+		return -ENODEV;
 
 
-	}
+	dev = port->dev;
 
 
-	if (port == NULL) {
-		unlock_kernel();
-		return -ENODEV;
-	}
+	dprintk(DBGLVL_VBI, "%s()\n", __func__);
 
 
 	/* allocate + initialize per filehandle data */
 	/* allocate + initialize per filehandle data */
 	fh = kzalloc(sizeof(*fh), GFP_KERNEL);
 	fh = kzalloc(sizeof(*fh), GFP_KERNEL);
-	if (NULL == fh) {
-		unlock_kernel();
+	if (NULL == fh)
 		return -ENOMEM;
 		return -ENOMEM;
-	}
 
 
 	file->private_data = fh;
 	file->private_data = fh;
 	fh->port = port;
 	fh->port = port;
 
 
-	unlock_kernel();
-
 	return 0;
 	return 0;
 }
 }
 
 
@@ -1363,6 +1332,7 @@ int saa7164_vbi_register(struct saa7164_port *port)
 		goto failed;
 		goto failed;
 	}
 	}
 
 
+	video_set_drvdata(port->v4l_device, port);
 	result = video_register_device(port->v4l_device,
 	result = video_register_device(port->v4l_device,
 		VFL_TYPE_VBI, -1);
 		VFL_TYPE_VBI, -1);
 	if (result < 0) {
 	if (result < 0) {