[media] tea5764: convert to unlocked_ioctl
Convert from ioctl to unlocked_ioctl using the v4l2 core lock. Also removed the 'exclusive access' limitation. There was no need for it and it violates the v4l2 spec as well. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
1cccee0b84
commit
ee71e42321
@ -142,7 +142,6 @@ struct tea5764_device {
|
|||||||
struct video_device *videodev;
|
struct video_device *videodev;
|
||||||
struct tea5764_regs regs;
|
struct tea5764_regs regs;
|
||||||
struct mutex mutex;
|
struct mutex mutex;
|
||||||
int users;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* I2C code related */
|
/* I2C code related */
|
||||||
@ -458,41 +457,10 @@ static int vidioc_s_audio(struct file *file, void *priv,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int tea5764_open(struct file *file)
|
|
||||||
{
|
|
||||||
/* Currently we support only one device */
|
|
||||||
struct tea5764_device *radio = video_drvdata(file);
|
|
||||||
|
|
||||||
mutex_lock(&radio->mutex);
|
|
||||||
/* Only exclusive access */
|
|
||||||
if (radio->users) {
|
|
||||||
mutex_unlock(&radio->mutex);
|
|
||||||
return -EBUSY;
|
|
||||||
}
|
|
||||||
radio->users++;
|
|
||||||
mutex_unlock(&radio->mutex);
|
|
||||||
file->private_data = radio;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int tea5764_close(struct file *file)
|
|
||||||
{
|
|
||||||
struct tea5764_device *radio = video_drvdata(file);
|
|
||||||
|
|
||||||
if (!radio)
|
|
||||||
return -ENODEV;
|
|
||||||
mutex_lock(&radio->mutex);
|
|
||||||
radio->users--;
|
|
||||||
mutex_unlock(&radio->mutex);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* File system interface */
|
/* File system interface */
|
||||||
static const struct v4l2_file_operations tea5764_fops = {
|
static const struct v4l2_file_operations tea5764_fops = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.open = tea5764_open,
|
.unlocked_ioctl = video_ioctl2,
|
||||||
.release = tea5764_close,
|
|
||||||
.ioctl = video_ioctl2,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct v4l2_ioctl_ops tea5764_ioctl_ops = {
|
static const struct v4l2_ioctl_ops tea5764_ioctl_ops = {
|
||||||
@ -527,7 +495,7 @@ static int __devinit tea5764_i2c_probe(struct i2c_client *client,
|
|||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
PDEBUG("probe");
|
PDEBUG("probe");
|
||||||
radio = kmalloc(sizeof(struct tea5764_device), GFP_KERNEL);
|
radio = kzalloc(sizeof(struct tea5764_device), GFP_KERNEL);
|
||||||
if (!radio)
|
if (!radio)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -555,12 +523,7 @@ static int __devinit tea5764_i2c_probe(struct i2c_client *client,
|
|||||||
|
|
||||||
i2c_set_clientdata(client, radio);
|
i2c_set_clientdata(client, radio);
|
||||||
video_set_drvdata(radio->videodev, radio);
|
video_set_drvdata(radio->videodev, radio);
|
||||||
|
radio->videodev->lock = &radio->mutex;
|
||||||
ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr);
|
|
||||||
if (ret < 0) {
|
|
||||||
PWARN("Could not register video device!");
|
|
||||||
goto errrel;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* initialize and power off the chip */
|
/* initialize and power off the chip */
|
||||||
tea5764_i2c_read(radio);
|
tea5764_i2c_read(radio);
|
||||||
@ -568,6 +531,12 @@ static int __devinit tea5764_i2c_probe(struct i2c_client *client,
|
|||||||
tea5764_mute(radio, 1);
|
tea5764_mute(radio, 1);
|
||||||
tea5764_power_down(radio);
|
tea5764_power_down(radio);
|
||||||
|
|
||||||
|
ret = video_register_device(radio->videodev, VFL_TYPE_RADIO, radio_nr);
|
||||||
|
if (ret < 0) {
|
||||||
|
PWARN("Could not register video device!");
|
||||||
|
goto errrel;
|
||||||
|
}
|
||||||
|
|
||||||
PINFO("registered.");
|
PINFO("registered.");
|
||||||
return 0;
|
return 0;
|
||||||
errrel:
|
errrel:
|
||||||
|
Loading…
Reference in New Issue
Block a user