From fd3d95608dc1745d714c2422ad72a0f19ce7dc82 Mon Sep 17 00:00:00 2001 From: Hans Verkuil Date: Sat, 23 Aug 2008 04:52:00 -0300 Subject: [PATCH] --- yaml --- r: 113860 b: refs/heads/master c: 2f3d00250ae5b1d2727e2723da805290ec408503 h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/include/sound/tea575x-tuner.h | 1 + trunk/sound/i2c/other/tea575x-tuner.c | 22 ++++++++++++++++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index 953b99fa2bd8..503578a35d3e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 3ca685aae04960eaa8b2c97baf384996c20cf9ac +refs/heads/master: 2f3d00250ae5b1d2727e2723da805290ec408503 diff --git a/trunk/include/sound/tea575x-tuner.h b/trunk/include/sound/tea575x-tuner.h index b62ce3e077f9..b6870cbaf2b3 100644 --- a/trunk/include/sound/tea575x-tuner.h +++ b/trunk/include/sound/tea575x-tuner.h @@ -43,6 +43,7 @@ struct snd_tea575x { unsigned int freq_fixup; /* crystal onboard */ unsigned int val; /* hw value */ unsigned long freq; /* frequency */ + unsigned long in_use; /* set if the device is in use */ struct snd_tea575x_ops *ops; void *private_data; }; diff --git a/trunk/sound/i2c/other/tea575x-tuner.c b/trunk/sound/i2c/other/tea575x-tuner.c index 83e90057270e..621d7fe3074b 100644 --- a/trunk/sound/i2c/other/tea575x-tuner.c +++ b/trunk/sound/i2c/other/tea575x-tuner.c @@ -175,6 +175,23 @@ static void snd_tea575x_release(struct video_device *vfd) { } +static int snd_tea575x_exclusive_open(struct inode *inode, struct file *file) +{ + struct video_device *dev = video_devdata(file); + struct snd_tea575x *tea = video_get_drvdata(dev); + + return test_and_set_bit(0, &tea->in_use) ? -EBUSY : 0; +} + +static int snd_tea575x_exclusive_release(struct inode *inode, struct file *file) +{ + struct video_device *dev = video_devdata(file); + struct snd_tea575x *tea = video_get_drvdata(dev); + + clear_bit(0, &tea->in_use); + return 0; +} + /* * initialize all the tea575x chips */ @@ -193,9 +210,10 @@ void snd_tea575x_init(struct snd_tea575x *tea) tea->vd.release = snd_tea575x_release; video_set_drvdata(&tea->vd, tea); tea->vd.fops = &tea->fops; + tea->in_use = 0; tea->fops.owner = tea->card->module; - tea->fops.open = video_exclusive_open; - tea->fops.release = video_exclusive_release; + tea->fops.open = snd_tea575x_exclusive_open; + tea->fops.release = snd_tea575x_exclusive_release; tea->fops.ioctl = snd_tea575x_ioctl; if (video_register_device(&tea->vd, VFL_TYPE_RADIO, tea->dev_nr - 1) < 0) { snd_printk(KERN_ERR "unable to register tea575x tuner\n");