aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/sound/tea575x-tuner.h1
-rw-r--r--sound/i2c/other/tea575x-tuner.c22
2 files changed, 21 insertions, 2 deletions
diff --git a/include/sound/tea575x-tuner.h b/include/sound/tea575x-tuner.h
index b62ce3e077f9..b6870cbaf2b3 100644
--- a/include/sound/tea575x-tuner.h
+++ b/include/sound/tea575x-tuner.h
@@ -43,6 +43,7 @@ struct snd_tea575x {
43 unsigned int freq_fixup; /* crystal onboard */ 43 unsigned int freq_fixup; /* crystal onboard */
44 unsigned int val; /* hw value */ 44 unsigned int val; /* hw value */
45 unsigned long freq; /* frequency */ 45 unsigned long freq; /* frequency */
46 unsigned long in_use; /* set if the device is in use */
46 struct snd_tea575x_ops *ops; 47 struct snd_tea575x_ops *ops;
47 void *private_data; 48 void *private_data;
48}; 49};
diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c
index 83e90057270e..621d7fe3074b 100644
--- a/sound/i2c/other/tea575x-tuner.c
+++ b/sound/i2c/other/tea575x-tuner.c
@@ -175,6 +175,23 @@ static void snd_tea575x_release(struct video_device *vfd)
175{ 175{
176} 176}
177 177
178static int snd_tea575x_exclusive_open(struct inode *inode, struct file *file)
179{
180 struct video_device *dev = video_devdata(file);
181 struct snd_tea575x *tea = video_get_drvdata(dev);
182
183 return test_and_set_bit(0, &tea->in_use) ? -EBUSY : 0;
184}
185
186static int snd_tea575x_exclusive_release(struct inode *inode, struct file *file)
187{
188 struct video_device *dev = video_devdata(file);
189 struct snd_tea575x *tea = video_get_drvdata(dev);
190
191 clear_bit(0, &tea->in_use);
192 return 0;
193}
194
178/* 195/*
179 * initialize all the tea575x chips 196 * initialize all the tea575x chips
180 */ 197 */
@@ -193,9 +210,10 @@ void snd_tea575x_init(struct snd_tea575x *tea)
193 tea->vd.release = snd_tea575x_release; 210 tea->vd.release = snd_tea575x_release;
194 video_set_drvdata(&tea->vd, tea); 211 video_set_drvdata(&tea->vd, tea);
195 tea->vd.fops = &tea->fops; 212 tea->vd.fops = &tea->fops;
213 tea->in_use = 0;
196 tea->fops.owner = tea->card->module; 214 tea->fops.owner = tea->card->module;
197 tea->fops.open = video_exclusive_open; 215 tea->fops.open = snd_tea575x_exclusive_open;
198 tea->fops.release = video_exclusive_release; 216 tea->fops.release = snd_tea575x_exclusive_release;
199 tea->fops.ioctl = snd_tea575x_ioctl; 217 tea->fops.ioctl = snd_tea575x_ioctl;
200 if (video_register_device(&tea->vd, VFL_TYPE_RADIO, tea->dev_nr - 1) < 0) { 218 if (video_register_device(&tea->vd, VFL_TYPE_RADIO, tea->dev_nr - 1) < 0) {
201 snd_printk(KERN_ERR "unable to register tea575x tuner\n"); 219 snd_printk(KERN_ERR "unable to register tea575x tuner\n");