提交 0499a5aa 编写于 作者: H Hans Verkuil 提交者: Mauro Carvalho Chehab

V4L/DVB: em28xx: remove BKL

Signed-off-by: NHans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: NMauro Carvalho Chehab <mchehab@redhat.com>
上级 fedc6c81
...@@ -863,17 +863,14 @@ static int res_get(struct em28xx_fh *fh, unsigned int bit) ...@@ -863,17 +863,14 @@ static int res_get(struct em28xx_fh *fh, unsigned int bit)
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;
em28xx_videodbg("res: get %d\n", bit); em28xx_videodbg("res: get %d\n", bit);
mutex_unlock(&dev->lock);
return 1; return 1;
} }
...@@ -893,11 +890,9 @@ static void res_free(struct em28xx_fh *fh, unsigned int bits) ...@@ -893,11 +890,9 @@ static void res_free(struct em28xx_fh *fh, unsigned int bits)
BUG_ON((fh->resources & bits) != bits); BUG_ON((fh->resources & bits) != bits);
mutex_lock(&dev->lock);
fh->resources &= ~bits; fh->resources &= ~bits;
dev->resources &= ~bits; dev->resources &= ~bits;
em28xx_videodbg("res: put %d\n", bits); em28xx_videodbg("res: put %d\n", bits);
mutex_unlock(&dev->lock);
} }
static int get_ressource(struct em28xx_fh *fh) static int get_ressource(struct em28xx_fh *fh)
...@@ -1024,8 +1019,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, ...@@ -1024,8 +1019,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
struct em28xx_fh *fh = priv; struct em28xx_fh *fh = priv;
struct em28xx *dev = fh->dev; struct em28xx *dev = fh->dev;
mutex_lock(&dev->lock);
f->fmt.pix.width = dev->width; f->fmt.pix.width = dev->width;
f->fmt.pix.height = dev->height; f->fmt.pix.height = dev->height;
f->fmt.pix.pixelformat = dev->format->fourcc; f->fmt.pix.pixelformat = dev->format->fourcc;
...@@ -1039,8 +1032,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv, ...@@ -1039,8 +1032,6 @@ static int vidioc_g_fmt_vid_cap(struct file *file, void *priv,
else else
f->fmt.pix.field = dev->interlaced ? f->fmt.pix.field = dev->interlaced ?
V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP; V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP;
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -1138,22 +1129,15 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv, ...@@ -1138,22 +1129,15 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
if (rc < 0) if (rc < 0)
return rc; return rc;
mutex_lock(&dev->lock);
vidioc_try_fmt_vid_cap(file, priv, f); vidioc_try_fmt_vid_cap(file, priv, f);
if (videobuf_queue_is_busy(&fh->vb_vidq)) { if (videobuf_queue_is_busy(&fh->vb_vidq)) {
em28xx_errdev("%s queue busy\n", __func__); em28xx_errdev("%s queue busy\n", __func__);
rc = -EBUSY; return -EBUSY;
goto out;
} }
rc = em28xx_set_video_format(dev, f->fmt.pix.pixelformat, return em28xx_set_video_format(dev, f->fmt.pix.pixelformat,
f->fmt.pix.width, f->fmt.pix.height); f->fmt.pix.width, f->fmt.pix.height);
out:
mutex_unlock(&dev->lock);
return rc;
} }
static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *norm) static int vidioc_g_std(struct file *file, void *priv, v4l2_std_id *norm)
...@@ -1182,7 +1166,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) ...@@ -1182,7 +1166,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm)
if (rc < 0) if (rc < 0)
return rc; return rc;
mutex_lock(&dev->lock);
dev->norm = *norm; dev->norm = *norm;
/* Adjusts width/height, if needed */ /* Adjusts width/height, if needed */
...@@ -1198,7 +1181,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm) ...@@ -1198,7 +1181,6 @@ static int vidioc_s_std(struct file *file, void *priv, v4l2_std_id *norm)
em28xx_resolution_set(dev); em28xx_resolution_set(dev);
v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, dev->norm); v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_std, dev->norm);
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -1303,9 +1285,7 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i) ...@@ -1303,9 +1285,7 @@ static int vidioc_s_input(struct file *file, void *priv, unsigned int i)
dev->ctl_input = i; dev->ctl_input = i;
mutex_lock(&dev->lock);
video_mux(dev, dev->ctl_input); video_mux(dev, dev->ctl_input);
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -1366,15 +1346,12 @@ static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a) ...@@ -1366,15 +1346,12 @@ static int vidioc_s_audio(struct file *file, void *priv, struct v4l2_audio *a)
if (0 == INPUT(a->index)->type) if (0 == INPUT(a->index)->type)
return -EINVAL; return -EINVAL;
mutex_lock(&dev->lock);
dev->ctl_ainput = INPUT(a->index)->amux; dev->ctl_ainput = INPUT(a->index)->amux;
dev->ctl_aoutput = INPUT(a->index)->aout; dev->ctl_aoutput = INPUT(a->index)->aout;
if (!dev->ctl_aoutput) if (!dev->ctl_aoutput)
dev->ctl_aoutput = EM28XX_AOUT_MASTER; dev->ctl_aoutput = EM28XX_AOUT_MASTER;
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -1394,17 +1371,15 @@ static int vidioc_queryctrl(struct file *file, void *priv, ...@@ -1394,17 +1371,15 @@ static int vidioc_queryctrl(struct file *file, void *priv,
qc->id = id; qc->id = id;
/* enumberate AC97 controls */ /* enumerate AC97 controls */
if (dev->audio_mode.ac97 != EM28XX_NO_AC97) { if (dev->audio_mode.ac97 != EM28XX_NO_AC97) {
rc = ac97_queryctrl(qc); rc = ac97_queryctrl(qc);
if (!rc) if (!rc)
return 0; return 0;
} }
/* enumberate V4L2 device controls */ /* enumerate V4L2 device controls */
mutex_lock(&dev->lock);
v4l2_device_call_all(&dev->v4l2_dev, 0, core, queryctrl, qc); v4l2_device_call_all(&dev->v4l2_dev, 0, core, queryctrl, qc);
mutex_unlock(&dev->lock);
if (qc->type) if (qc->type)
return 0; return 0;
...@@ -1424,7 +1399,6 @@ static int vidioc_g_ctrl(struct file *file, void *priv, ...@@ -1424,7 +1399,6 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
return rc; return rc;
rc = 0; rc = 0;
mutex_lock(&dev->lock);
/* Set an AC97 control */ /* Set an AC97 control */
if (dev->audio_mode.ac97 != EM28XX_NO_AC97) if (dev->audio_mode.ac97 != EM28XX_NO_AC97)
...@@ -1438,7 +1412,6 @@ static int vidioc_g_ctrl(struct file *file, void *priv, ...@@ -1438,7 +1412,6 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
rc = 0; rc = 0;
} }
mutex_unlock(&dev->lock);
return rc; return rc;
} }
...@@ -1453,8 +1426,6 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -1453,8 +1426,6 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
if (rc < 0) if (rc < 0)
return rc; return rc;
mutex_lock(&dev->lock);
/* Set an AC97 control */ /* Set an AC97 control */
if (dev->audio_mode.ac97 != EM28XX_NO_AC97) if (dev->audio_mode.ac97 != EM28XX_NO_AC97)
rc = ac97_set_ctrl(dev, ctrl); rc = ac97_set_ctrl(dev, ctrl);
...@@ -1481,8 +1452,6 @@ static int vidioc_s_ctrl(struct file *file, void *priv, ...@@ -1481,8 +1452,6 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
rc = em28xx_audio_analog_set(dev); rc = em28xx_audio_analog_set(dev);
} }
} }
mutex_unlock(&dev->lock);
return rc; return rc;
} }
...@@ -1503,10 +1472,7 @@ static int vidioc_g_tuner(struct file *file, void *priv, ...@@ -1503,10 +1472,7 @@ static int vidioc_g_tuner(struct file *file, void *priv,
strcpy(t->name, "Tuner"); strcpy(t->name, "Tuner");
t->type = V4L2_TUNER_ANALOG_TV; t->type = V4L2_TUNER_ANALOG_TV;
mutex_lock(&dev->lock);
v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t); v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t);
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -1524,10 +1490,7 @@ static int vidioc_s_tuner(struct file *file, void *priv, ...@@ -1524,10 +1490,7 @@ static int vidioc_s_tuner(struct file *file, void *priv,
if (0 != t->index) if (0 != t->index)
return -EINVAL; return -EINVAL;
mutex_lock(&dev->lock);
v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t); v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t);
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -1537,11 +1500,8 @@ static int vidioc_g_frequency(struct file *file, void *priv, ...@@ -1537,11 +1500,8 @@ static int vidioc_g_frequency(struct file *file, void *priv,
struct em28xx_fh *fh = priv; struct em28xx_fh *fh = priv;
struct em28xx *dev = fh->dev; struct em28xx *dev = fh->dev;
mutex_lock(&dev->lock);
f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; f->type = fh->radio ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV;
f->frequency = dev->ctl_freq; f->frequency = dev->ctl_freq;
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -1564,13 +1524,9 @@ static int vidioc_s_frequency(struct file *file, void *priv, ...@@ -1564,13 +1524,9 @@ static int vidioc_s_frequency(struct file *file, void *priv,
if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO)) if (unlikely(1 == fh->radio && f->type != V4L2_TUNER_RADIO))
return -EINVAL; return -EINVAL;
mutex_lock(&dev->lock);
dev->ctl_freq = f->frequency; dev->ctl_freq = f->frequency;
v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, f); v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_frequency, f);
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -1611,9 +1567,7 @@ static int vidioc_g_register(struct file *file, void *priv, ...@@ -1611,9 +1567,7 @@ static int vidioc_g_register(struct file *file, void *priv,
switch (reg->match.type) { switch (reg->match.type) {
case V4L2_CHIP_MATCH_AC97: case V4L2_CHIP_MATCH_AC97:
mutex_lock(&dev->lock);
ret = em28xx_read_ac97(dev, reg->reg); ret = em28xx_read_ac97(dev, reg->reg);
mutex_unlock(&dev->lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1635,9 +1589,7 @@ static int vidioc_g_register(struct file *file, void *priv, ...@@ -1635,9 +1589,7 @@ static int vidioc_g_register(struct file *file, void *priv,
/* Match host */ /* Match host */
reg->size = em28xx_reg_len(reg->reg); reg->size = em28xx_reg_len(reg->reg);
if (reg->size == 1) { if (reg->size == 1) {
mutex_lock(&dev->lock);
ret = em28xx_read_reg(dev, reg->reg); ret = em28xx_read_reg(dev, reg->reg);
mutex_unlock(&dev->lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1645,10 +1597,8 @@ static int vidioc_g_register(struct file *file, void *priv, ...@@ -1645,10 +1597,8 @@ static int vidioc_g_register(struct file *file, void *priv,
reg->val = ret; reg->val = ret;
} else { } else {
__le16 val = 0; __le16 val = 0;
mutex_lock(&dev->lock);
ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS, ret = em28xx_read_reg_req_len(dev, USB_REQ_GET_STATUS,
reg->reg, (char *)&val, 2); reg->reg, (char *)&val, 2);
mutex_unlock(&dev->lock);
if (ret < 0) if (ret < 0)
return ret; return ret;
...@@ -1668,11 +1618,7 @@ static int vidioc_s_register(struct file *file, void *priv, ...@@ -1668,11 +1618,7 @@ static int vidioc_s_register(struct file *file, void *priv,
switch (reg->match.type) { switch (reg->match.type) {
case V4L2_CHIP_MATCH_AC97: case V4L2_CHIP_MATCH_AC97:
mutex_lock(&dev->lock); return em28xx_write_ac97(dev, reg->reg, reg->val);
rc = em28xx_write_ac97(dev, reg->reg, reg->val);
mutex_unlock(&dev->lock);
return rc;
case V4L2_CHIP_MATCH_I2C_DRIVER: case V4L2_CHIP_MATCH_I2C_DRIVER:
v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_register, reg); v4l2_device_call_all(&dev->v4l2_dev, 0, core, s_register, reg);
return 0; return 0;
...@@ -1688,12 +1634,8 @@ static int vidioc_s_register(struct file *file, void *priv, ...@@ -1688,12 +1634,8 @@ static int vidioc_s_register(struct file *file, void *priv,
/* Match host */ /* Match host */
buf = cpu_to_le16(reg->val); buf = cpu_to_le16(reg->val);
mutex_lock(&dev->lock); return em28xx_write_regs(dev, reg->reg, (char *)&buf,
rc = em28xx_write_regs(dev, reg->reg, (char *)&buf,
em28xx_reg_len(reg->reg)); em28xx_reg_len(reg->reg));
mutex_unlock(&dev->lock);
return rc;
} }
#endif #endif
...@@ -1830,16 +1772,12 @@ static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv, ...@@ -1830,16 +1772,12 @@ static int vidioc_g_fmt_sliced_vbi_cap(struct file *file, void *priv,
if (rc < 0) if (rc < 0)
return rc; return rc;
mutex_lock(&dev->lock);
f->fmt.sliced.service_set = 0; f->fmt.sliced.service_set = 0;
v4l2_device_call_all(&dev->v4l2_dev, 0, vbi, g_sliced_fmt, &f->fmt.sliced); v4l2_device_call_all(&dev->v4l2_dev, 0, vbi, g_sliced_fmt, &f->fmt.sliced);
if (f->fmt.sliced.service_set == 0) if (f->fmt.sliced.service_set == 0)
rc = -EINVAL; rc = -EINVAL;
mutex_unlock(&dev->lock);
return rc; return rc;
} }
...@@ -1854,9 +1792,7 @@ static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv, ...@@ -1854,9 +1792,7 @@ static int vidioc_try_set_sliced_vbi_cap(struct file *file, void *priv,
if (rc < 0) if (rc < 0)
return rc; return rc;
mutex_lock(&dev->lock);
v4l2_device_call_all(&dev->v4l2_dev, 0, vbi, g_sliced_fmt, &f->fmt.sliced); v4l2_device_call_all(&dev->v4l2_dev, 0, vbi, g_sliced_fmt, &f->fmt.sliced);
mutex_unlock(&dev->lock);
if (f->fmt.sliced.service_set == 0) if (f->fmt.sliced.service_set == 0)
return -EINVAL; return -EINVAL;
...@@ -2041,9 +1977,7 @@ static int radio_g_tuner(struct file *file, void *priv, ...@@ -2041,9 +1977,7 @@ static int radio_g_tuner(struct file *file, void *priv,
strcpy(t->name, "Radio"); strcpy(t->name, "Radio");
t->type = V4L2_TUNER_RADIO; t->type = V4L2_TUNER_RADIO;
mutex_lock(&dev->lock);
v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t); v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, g_tuner, t);
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -2076,9 +2010,7 @@ static int radio_s_tuner(struct file *file, void *priv, ...@@ -2076,9 +2010,7 @@ static int radio_s_tuner(struct file *file, void *priv,
if (0 != t->index) if (0 != t->index)
return -EINVAL; return -EINVAL;
mutex_lock(&dev->lock);
v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t); v4l2_device_call_all(&dev->v4l2_dev, 0, tuner, s_tuner, t);
mutex_unlock(&dev->lock);
return 0; return 0;
} }
...@@ -2138,8 +2070,6 @@ static int em28xx_v4l2_open(struct file *filp) ...@@ -2138,8 +2070,6 @@ static int em28xx_v4l2_open(struct file *filp)
break; break;
} }
mutex_lock(&dev->lock);
em28xx_videodbg("open dev=%s type=%s users=%d\n", em28xx_videodbg("open dev=%s type=%s users=%d\n",
video_device_node_name(vdev), v4l2_type_names[fh_type], video_device_node_name(vdev), v4l2_type_names[fh_type],
dev->users); dev->users);
...@@ -2148,7 +2078,6 @@ static int em28xx_v4l2_open(struct file *filp) ...@@ -2148,7 +2078,6 @@ static int em28xx_v4l2_open(struct file *filp)
fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL); fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL);
if (!fh) { if (!fh) {
em28xx_errdev("em28xx-video.c: Out of memory?!\n"); em28xx_errdev("em28xx-video.c: Out of memory?!\n");
mutex_unlock(&dev->lock);
return -ENOMEM; return -ENOMEM;
} }
fh->dev = dev; fh->dev = dev;
...@@ -2182,15 +2111,13 @@ static int em28xx_v4l2_open(struct file *filp) ...@@ -2182,15 +2111,13 @@ static int em28xx_v4l2_open(struct file *filp)
videobuf_queue_vmalloc_init(&fh->vb_vidq, &em28xx_video_qops, videobuf_queue_vmalloc_init(&fh->vb_vidq, &em28xx_video_qops,
NULL, &dev->slock, NULL, &dev->slock,
V4L2_BUF_TYPE_VIDEO_CAPTURE, field, V4L2_BUF_TYPE_VIDEO_CAPTURE, field,
sizeof(struct em28xx_buffer), fh, NULL); sizeof(struct em28xx_buffer), fh, &dev->lock);
videobuf_queue_vmalloc_init(&fh->vb_vbiq, &em28xx_vbi_qops, videobuf_queue_vmalloc_init(&fh->vb_vbiq, &em28xx_vbi_qops,
NULL, &dev->slock, NULL, &dev->slock,
V4L2_BUF_TYPE_VBI_CAPTURE, V4L2_BUF_TYPE_VBI_CAPTURE,
V4L2_FIELD_SEQ_TB, V4L2_FIELD_SEQ_TB,
sizeof(struct em28xx_buffer), fh, NULL); sizeof(struct em28xx_buffer), fh, &dev->lock);
mutex_unlock(&dev->lock);
return errCode; return errCode;
} }
...@@ -2389,7 +2316,7 @@ static const struct v4l2_file_operations em28xx_v4l_fops = { ...@@ -2389,7 +2316,7 @@ static const struct v4l2_file_operations em28xx_v4l_fops = {
.read = em28xx_v4l2_read, .read = em28xx_v4l2_read,
.poll = em28xx_v4l2_poll, .poll = em28xx_v4l2_poll,
.mmap = em28xx_v4l2_mmap, .mmap = em28xx_v4l2_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 = {
...@@ -2497,6 +2424,7 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev, ...@@ -2497,6 +2424,7 @@ static struct video_device *em28xx_vdev_init(struct em28xx *dev,
vfd->v4l2_dev = &dev->v4l2_dev; vfd->v4l2_dev = &dev->v4l2_dev;
vfd->release = video_device_release; vfd->release = video_device_release;
vfd->debug = video_debug; vfd->debug = video_debug;
vfd->lock = &dev->lock;
snprintf(vfd->name, sizeof(vfd->name), "%s %s", snprintf(vfd->name, sizeof(vfd->name), "%s %s",
dev->name, type_name); dev->name, type_name);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册