aboutsummaryrefslogtreecommitdiffstats
path: root/sound/i2c
diff options
context:
space:
mode:
authorOndrej Zary <linux@rainbow-software.org>2011-06-11 09:28:59 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2011-07-27 16:53:07 -0400
commit6a529c1a4a87e0f5d143ad3bc0d37179332f210e (patch)
tree50b293832428289f8d8bcea7effabaee3be0b6d6 /sound/i2c
parent9cd49719fda38613e9d7c712b11a54ea4ea005dc (diff)
[media] tea575x: allow multiple opens
Change locking to allow tea575x-radio device to be opened multiple times. Signed-off-by: Ondrej Zary <linux@rainbow-software.org> Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'sound/i2c')
-rw-r--r--sound/i2c/other/tea575x-tuner.c22
1 files changed, 3 insertions, 19 deletions
diff --git a/sound/i2c/other/tea575x-tuner.c b/sound/i2c/other/tea575x-tuner.c
index 0d7a659c494c..beb0e86537cd 100644
--- a/sound/i2c/other/tea575x-tuner.c
+++ b/sound/i2c/other/tea575x-tuner.c
@@ -282,26 +282,9 @@ static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
282 return 0; 282 return 0;
283} 283}
284 284
285static int snd_tea575x_exclusive_open(struct file *file)
286{
287 struct snd_tea575x *tea = video_drvdata(file);
288
289 return test_and_set_bit(0, &tea->in_use) ? -EBUSY : 0;
290}
291
292static int snd_tea575x_exclusive_release(struct file *file)
293{
294 struct snd_tea575x *tea = video_drvdata(file);
295
296 clear_bit(0, &tea->in_use);
297 return 0;
298}
299
300static const struct v4l2_file_operations tea575x_fops = { 285static const struct v4l2_file_operations tea575x_fops = {
301 .owner = THIS_MODULE, 286 .owner = THIS_MODULE,
302 .open = snd_tea575x_exclusive_open, 287 .unlocked_ioctl = video_ioctl2,
303 .release = snd_tea575x_exclusive_release,
304 .ioctl = video_ioctl2,
305}; 288};
306 289
307static const struct v4l2_ioctl_ops tea575x_ioctl_ops = { 290static const struct v4l2_ioctl_ops tea575x_ioctl_ops = {
@@ -340,13 +323,14 @@ int snd_tea575x_init(struct snd_tea575x *tea)
340 if (snd_tea575x_read(tea) != 0x55AA) 323 if (snd_tea575x_read(tea) != 0x55AA)
341 return -ENODEV; 324 return -ENODEV;
342 325
343 tea->in_use = 0;
344 tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_10_40; 326 tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_10_40;
345 tea->freq = 90500 * 16; /* 90.5Mhz default */ 327 tea->freq = 90500 * 16; /* 90.5Mhz default */
346 snd_tea575x_set_freq(tea); 328 snd_tea575x_set_freq(tea);
347 329
348 tea->vd = tea575x_radio; 330 tea->vd = tea575x_radio;
349 video_set_drvdata(&tea->vd, tea); 331 video_set_drvdata(&tea->vd, tea);
332 mutex_init(&tea->mutex);
333 tea->vd.lock = &tea->mutex;
350 334
351 v4l2_ctrl_handler_init(&tea->ctrl_handler, 1); 335 v4l2_ctrl_handler_init(&tea->ctrl_handler, 1);
352 tea->vd.ctrl_handler = &tea->ctrl_handler; 336 tea->vd.ctrl_handler = &tea->ctrl_handler;