提交 24a8f7b5 编写于 作者: H Hans Verkuil 提交者: Mauro Carvalho Chehab

[media] cx23885: use core locking, switch to unlocked_ioctl

Enable core locking which allows us to safely switch to unlocked_ioctl.
Signed-off-by: NHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: NMauro Carvalho Chehab <m.chehab@samsung.com>
上级 86dd9831
...@@ -1235,9 +1235,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id) ...@@ -1235,9 +1235,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id id)
dev->encodernorm = cx23885_tvnorms[i]; dev->encodernorm = cx23885_tvnorms[i];
/* Have the drier core notify the subdevices */ /* Have the drier core notify the subdevices */
mutex_lock(&dev->lock);
cx23885_set_tvnorm(dev, id); cx23885_set_tvnorm(dev, id);
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -1661,7 +1659,7 @@ static struct v4l2_file_operations mpeg_fops = { ...@@ -1661,7 +1659,7 @@ static struct v4l2_file_operations mpeg_fops = {
.read = mpeg_read, .read = mpeg_read,
.poll = mpeg_poll, .poll = mpeg_poll,
.mmap = mpeg_mmap, .mmap = mpeg_mmap,
.ioctl = video_ioctl2, .unlocked_ioctl = video_ioctl2,
}; };
static const struct v4l2_ioctl_ops mpeg_ioctl_ops = { static const struct v4l2_ioctl_ops mpeg_ioctl_ops = {
...@@ -1770,6 +1768,7 @@ int cx23885_417_register(struct cx23885_dev *dev) ...@@ -1770,6 +1768,7 @@ int cx23885_417_register(struct cx23885_dev *dev)
dev->v4l_device = cx23885_video_dev_alloc(tsport, dev->v4l_device = cx23885_video_dev_alloc(tsport,
dev->pci, &cx23885_mpeg_template, "mpeg"); dev->pci, &cx23885_mpeg_template, "mpeg");
video_set_drvdata(dev->v4l_device, dev); video_set_drvdata(dev->v4l_device, dev);
dev->v4l_device->lock = &dev->lock;
err = video_register_device(dev->v4l_device, err = video_register_device(dev->v4l_device,
VFL_TYPE_GRABBER, -1); VFL_TYPE_GRABBER, -1);
if (err < 0) { if (err < 0) {
......
...@@ -345,6 +345,7 @@ static struct video_device *cx23885_vdev_init(struct cx23885_dev *dev, ...@@ -345,6 +345,7 @@ static struct video_device *cx23885_vdev_init(struct cx23885_dev *dev,
*vfd = *template; *vfd = *template;
vfd->v4l2_dev = &dev->v4l2_dev; vfd->v4l2_dev = &dev->v4l2_dev;
vfd->release = video_device_release; vfd->release = video_device_release;
vfd->lock = &dev->lock;
snprintf(vfd->name, sizeof(vfd->name), "%s (%s)", snprintf(vfd->name, sizeof(vfd->name), "%s (%s)",
cx23885_boards[dev->board].name, type); cx23885_boards[dev->board].name, type);
video_set_drvdata(vfd, dev); video_set_drvdata(vfd, dev);
...@@ -381,17 +382,14 @@ static int res_get(struct cx23885_dev *dev, struct cx23885_fh *fh, ...@@ -381,17 +382,14 @@ static int res_get(struct cx23885_dev *dev, struct cx23885_fh *fh,
return 1; return 1;
/* is it free? */ /* is it free? */
mutex_lock(&dev->lock);
if (dev->resources & bit) { if (dev->resources & bit) {
/* no, someone else uses it */ /* no, someone else uses it */
mutex_unlock(&dev->lock);
return 0; return 0;
} }
/* it's free, grab it */ /* it's free, grab it */
fh->resources |= bit; fh->resources |= bit;
dev->resources |= bit; dev->resources |= bit;
dprintk(1, "res: get %d\n", bit); dprintk(1, "res: get %d\n", bit);
mutex_unlock(&dev->lock);
return 1; return 1;
} }
...@@ -411,11 +409,9 @@ static void res_free(struct cx23885_dev *dev, struct cx23885_fh *fh, ...@@ -411,11 +409,9 @@ static void res_free(struct cx23885_dev *dev, struct cx23885_fh *fh,
BUG_ON((fh->resources & bits) != bits); BUG_ON((fh->resources & bits) != bits);
dprintk(1, "%s()\n", __func__); dprintk(1, "%s()\n", __func__);
mutex_lock(&dev->lock);
fh->resources &= ~bits; fh->resources &= ~bits;
dev->resources &= ~bits; dev->resources &= ~bits;
dprintk(1, "res: put %d\n", bits); dprintk(1, "res: put %d\n", bits);
mutex_unlock(&dev->lock);
} }
int cx23885_flatiron_write(struct cx23885_dev *dev, u8 reg, u8 data) int cx23885_flatiron_write(struct cx23885_dev *dev, u8 reg, u8 data)
...@@ -1272,9 +1268,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id tvnorms) ...@@ -1272,9 +1268,7 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id tvnorms)
struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev; struct cx23885_dev *dev = ((struct cx23885_fh *)priv)->dev;
dprintk(1, "%s()\n", __func__); dprintk(1, "%s()\n", __func__);
mutex_lock(&dev->lock);
cx23885_set_tvnorm(dev, tvnorms); cx23885_set_tvnorm(dev, tvnorms);
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -1364,13 +1358,11 @@ int cx23885_set_input(struct file *file, void *priv, unsigned int i) ...@@ -1364,13 +1358,11 @@ int cx23885_set_input(struct file *file, void *priv, unsigned int i)
if (INPUT(i)->type == 0) if (INPUT(i)->type == 0)
return -EINVAL; return -EINVAL;
mutex_lock(&dev->lock);
cx23885_video_mux(dev, i); cx23885_video_mux(dev, i);
/* By default establish the default audio input for the card also */ /* By default establish the default audio input for the card also */
/* Caller is free to use VIDIOC_S_AUDIO to override afterwards */ /* Caller is free to use VIDIOC_S_AUDIO to override afterwards */
cx23885_audio_mux(dev, i); cx23885_audio_mux(dev, i);
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -1544,7 +1536,6 @@ static int cx23885_set_freq(struct cx23885_dev *dev, const struct v4l2_frequency ...@@ -1544,7 +1536,6 @@ static int cx23885_set_freq(struct cx23885_dev *dev, const struct v4l2_frequency
if (unlikely(f->tuner != 0)) if (unlikely(f->tuner != 0))
return -EINVAL; return -EINVAL;
mutex_lock(&dev->lock);
dev->freq = f->frequency; dev->freq = f->frequency;
/* I need to mute audio here */ /* I need to mute audio here */
...@@ -1561,8 +1552,6 @@ static int cx23885_set_freq(struct cx23885_dev *dev, const struct v4l2_frequency ...@@ -1561,8 +1552,6 @@ static int cx23885_set_freq(struct cx23885_dev *dev, const struct v4l2_frequency
ctrl.value = 0; ctrl.value = 0;
cx23885_set_control(dev, &ctrl); cx23885_set_control(dev, &ctrl);
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -1580,7 +1569,6 @@ static int cx23885_set_freq_via_ops(struct cx23885_dev *dev, ...@@ -1580,7 +1569,6 @@ static int cx23885_set_freq_via_ops(struct cx23885_dev *dev,
.frequency = f->frequency .frequency = f->frequency
}; };
mutex_lock(&dev->lock);
dev->freq = f->frequency; dev->freq = f->frequency;
/* I need to mute audio here */ /* I need to mute audio here */
...@@ -1594,7 +1582,6 @@ static int cx23885_set_freq_via_ops(struct cx23885_dev *dev, ...@@ -1594,7 +1582,6 @@ static int cx23885_set_freq_via_ops(struct cx23885_dev *dev,
vfe = videobuf_dvb_get_frontend(&dev->ts2.frontends, 1); vfe = videobuf_dvb_get_frontend(&dev->ts2.frontends, 1);
if (!vfe) { if (!vfe) {
mutex_unlock(&dev->lock);
return -EINVAL; return -EINVAL;
} }
...@@ -1619,8 +1606,6 @@ static int cx23885_set_freq_via_ops(struct cx23885_dev *dev, ...@@ -1619,8 +1606,6 @@ static int cx23885_set_freq_via_ops(struct cx23885_dev *dev,
ctrl.value = 0; ctrl.value = 0;
cx23885_set_control(dev, &ctrl); cx23885_set_control(dev, &ctrl);
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -1742,7 +1727,7 @@ static const struct v4l2_file_operations video_fops = { ...@@ -1742,7 +1727,7 @@ static const struct v4l2_file_operations video_fops = {
.read = video_read, .read = video_read,
.poll = video_poll, .poll = video_poll,
.mmap = video_mmap, .mmap = video_mmap,
.ioctl = video_ioctl2, .unlocked_ioctl = video_ioctl2,
}; };
static const struct v4l2_ioctl_ops video_ioctl_ops = { static const struct v4l2_ioctl_ops video_ioctl_ops = {
...@@ -1791,14 +1776,6 @@ static struct video_device cx23885_video_template = { ...@@ -1791,14 +1776,6 @@ static struct video_device cx23885_video_template = {
.tvnorms = CX23885_NORMS, .tvnorms = CX23885_NORMS,
}; };
static const struct v4l2_file_operations radio_fops = {
.owner = THIS_MODULE,
.open = video_open,
.release = video_release,
.ioctl = video_ioctl2,
};
void cx23885_video_unregister(struct cx23885_dev *dev) void cx23885_video_unregister(struct cx23885_dev *dev)
{ {
dprintk(1, "%s()\n", __func__); dprintk(1, "%s()\n", __func__);
...@@ -1909,6 +1886,14 @@ int cx23885_video_register(struct cx23885_dev *dev) ...@@ -1909,6 +1886,14 @@ int cx23885_video_register(struct cx23885_dev *dev)
} }
} }
/* initial device configuration */
mutex_lock(&dev->lock);
cx23885_set_tvnorm(dev, dev->tvnorm);
init_controls(dev);
cx23885_video_mux(dev, 0);
cx23885_audio_mux(dev, 0);
mutex_unlock(&dev->lock);
/* register Video device */ /* register Video device */
dev->video_dev = cx23885_vdev_init(dev, dev->pci, dev->video_dev = cx23885_vdev_init(dev, dev->pci,
&cx23885_video_template, "video"); &cx23885_video_template, "video");
...@@ -1938,14 +1923,6 @@ int cx23885_video_register(struct cx23885_dev *dev) ...@@ -1938,14 +1923,6 @@ int cx23885_video_register(struct cx23885_dev *dev)
/* Register ALSA audio device */ /* Register ALSA audio device */
dev->audio_dev = cx23885_audio_register(dev); dev->audio_dev = cx23885_audio_register(dev);
/* initial device configuration */
mutex_lock(&dev->lock);
cx23885_set_tvnorm(dev, dev->tvnorm);
init_controls(dev);
cx23885_video_mux(dev, 0);
cx23885_audio_mux(dev, 0);
mutex_unlock(&dev->lock);
return 0; return 0;
fail_unreg: fail_unreg:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册