[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>
This commit is contained in:
parent
9cd49719fd
commit
6a529c1a4a
2 changed files with 4 additions and 20 deletions
|
@ -49,7 +49,7 @@ struct snd_tea575x {
|
||||||
bool tuned; /* tuned to a station */
|
bool tuned; /* tuned to a station */
|
||||||
unsigned int val; /* hw value */
|
unsigned int val; /* hw value */
|
||||||
unsigned long freq; /* frequency */
|
unsigned long freq; /* frequency */
|
||||||
unsigned long in_use; /* set if the device is in use */
|
struct mutex mutex;
|
||||||
struct snd_tea575x_ops *ops;
|
struct snd_tea575x_ops *ops;
|
||||||
void *private_data;
|
void *private_data;
|
||||||
u8 card[32];
|
u8 card[32];
|
||||||
|
|
|
@ -282,26 +282,9 @@ static int vidioc_s_input(struct file *filp, void *priv, unsigned int i)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int snd_tea575x_exclusive_open(struct file *file)
|
|
||||||
{
|
|
||||||
struct snd_tea575x *tea = video_drvdata(file);
|
|
||||||
|
|
||||||
return test_and_set_bit(0, &tea->in_use) ? -EBUSY : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int snd_tea575x_exclusive_release(struct file *file)
|
|
||||||
{
|
|
||||||
struct snd_tea575x *tea = video_drvdata(file);
|
|
||||||
|
|
||||||
clear_bit(0, &tea->in_use);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const struct v4l2_file_operations tea575x_fops = {
|
static const struct v4l2_file_operations tea575x_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.open = snd_tea575x_exclusive_open,
|
.unlocked_ioctl = video_ioctl2,
|
||||||
.release = snd_tea575x_exclusive_release,
|
|
||||||
.ioctl = video_ioctl2,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct v4l2_ioctl_ops tea575x_ioctl_ops = {
|
static const struct v4l2_ioctl_ops tea575x_ioctl_ops = {
|
||||||
|
@ -340,13 +323,14 @@ int snd_tea575x_init(struct snd_tea575x *tea)
|
||||||
if (snd_tea575x_read(tea) != 0x55AA)
|
if (snd_tea575x_read(tea) != 0x55AA)
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
tea->in_use = 0;
|
|
||||||
tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_10_40;
|
tea->val = TEA575X_BIT_BAND_FM | TEA575X_BIT_SEARCH_10_40;
|
||||||
tea->freq = 90500 * 16; /* 90.5Mhz default */
|
tea->freq = 90500 * 16; /* 90.5Mhz default */
|
||||||
snd_tea575x_set_freq(tea);
|
snd_tea575x_set_freq(tea);
|
||||||
|
|
||||||
tea->vd = tea575x_radio;
|
tea->vd = tea575x_radio;
|
||||||
video_set_drvdata(&tea->vd, tea);
|
video_set_drvdata(&tea->vd, tea);
|
||||||
|
mutex_init(&tea->mutex);
|
||||||
|
tea->vd.lock = &tea->mutex;
|
||||||
|
|
||||||
v4l2_ctrl_handler_init(&tea->ctrl_handler, 1);
|
v4l2_ctrl_handler_init(&tea->ctrl_handler, 1);
|
||||||
tea->vd.ctrl_handler = &tea->ctrl_handler;
|
tea->vd.ctrl_handler = &tea->ctrl_handler;
|
||||||
|
|
Loading…
Add table
Reference in a new issue