summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/zoran/zoran_driver.c
diff options
context:
space:
mode:
authorTrent Piepho <xyzzy@speakeasy.org>2009-01-12 08:09:46 -0800
committerTrent Piepho <xyzzy@speakeasy.org>2009-01-12 08:09:46 -0800
commit3bb4728d5f8d659362a60e10f4d8d64df7418940 (patch)
treeb532df52a46091cf696ae8cea07559072b427f3d /linux/drivers/media/video/zoran/zoran_driver.c
parentceaf74899f3331f9197ac119f58d9a4de61e65b7 (diff)
downloadmediapointer-dvb-s2-3bb4728d5f8d659362a60e10f4d8d64df7418940.tar.gz
mediapointer-dvb-s2-3bb4728d5f8d659362a60e10f4d8d64df7418940.tar.bz2
zoran: Remove global device array
From: Trent Piepho <xyzzy@speakeasy.org> The driver was keeping a global array with an entry for each zoran device probed. It was a leftover from when the driver didn't dynamically allocate the driver data for each device. There was only one use left, in the video device's ->open() method, looking up the struct zoran for the opened device from the minor number. This can be done better with video_get_drvdata(). Since zoran_num is now only used in the pci driver's ->probe() method, it doesn't need to be an atomic_t and be static. There is a race if multiple zoran cards could be probed at the same time, but currently the probe method for a given driver is single threaded. Priority: normal Signed-off-by: Trent Piepho <xyzzy@speakeasy.org> Acked-by: Jean Delvare <khali@linux-fr.org>
Diffstat (limited to 'linux/drivers/media/video/zoran/zoran_driver.c')
-rw-r--r--linux/drivers/media/video/zoran/zoran_driver.c25
1 files changed, 3 insertions, 22 deletions
diff --git a/linux/drivers/media/video/zoran/zoran_driver.c b/linux/drivers/media/video/zoran/zoran_driver.c
index 6803ca326..c6a200504 100644
--- a/linux/drivers/media/video/zoran/zoran_driver.c
+++ b/linux/drivers/media/video/zoran/zoran_driver.c
@@ -1261,28 +1261,13 @@ zoran_close_end_session (struct file *file)
* Open a zoran card. Right now the flags stuff is just playing
*/
-static int
-zoran_open(struct file *file)
+static int zoran_open(struct file *file)
{
- unsigned int minor = video_devdata(file)->minor;
- struct zoran *zr = NULL;
+ struct zoran *zr = video_drvdata(file);
struct zoran_fh *fh;
- int i, res, first_open = 0, have_module_locks = 0;
+ int res, first_open = 0, have_module_locks = 0;
lock_kernel();
- /* find the device */
- for (i = 0; i < atomic_read(&zoran_num); i++) {
- if (zoran[i]->video_dev->minor == minor) {
- zr = zoran[i];
- break;
- }
- }
-
- if (!zr) {
- dprintk(1, KERN_ERR "%s: device not found!\n", ZORAN_NAME);
- res = -ENODEV;
- goto open_unlock_and_return;
- }
/* see fs/device.c - the kernel already locks during open(),
* so locking ourselves only causes deadlocks */
@@ -1394,10 +1379,6 @@ open_unlock_and_return:
module_put(THIS_MODULE);
}
- /* if there's no device found, we didn't obtain the lock either */
- if (zr) {
- /*mutex_unlock(&zr->resource_lock);*/
- }
unlock_kernel();
return res;