Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 223377
b: refs/heads/master
c: 1cccee0
h: refs/heads/master
i:
  223375: beefce2
v: v3
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Dec 1, 2010
1 parent 6d162e9 commit ffbb7bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 32958fdd1663aeaa23b5edbfbb0db684ffd4e20e
refs/heads/master: 1cccee0b84e3445a142d0e9edcbf66b677b2e7e5
12 changes: 9 additions & 3 deletions trunk/drivers/media/radio/radio-cadet.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,24 +328,26 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
unsigned char readbuf[RDS_BUFFER];
int i = 0;

mutex_lock(&dev->lock);
if (dev->rdsstat == 0) {
mutex_lock(&dev->lock);
dev->rdsstat = 1;
outb(0x80, dev->io); /* Select RDS fifo */
mutex_unlock(&dev->lock);
init_timer(&dev->readtimer);
dev->readtimer.function = cadet_handler;
dev->readtimer.data = (unsigned long)dev;
dev->readtimer.expires = jiffies + msecs_to_jiffies(50);
add_timer(&dev->readtimer);
}
if (dev->rdsin == dev->rdsout) {
mutex_unlock(&dev->lock);
if (file->f_flags & O_NONBLOCK)
return -EWOULDBLOCK;
interruptible_sleep_on(&dev->read_queue);
mutex_lock(&dev->lock);
}
while (i < count && dev->rdsin != dev->rdsout)
readbuf[i++] = dev->rdsbuf[dev->rdsout++];
mutex_unlock(&dev->lock);

if (copy_to_user(data, readbuf, i))
return -EFAULT;
Expand Down Expand Up @@ -525,21 +527,25 @@ static int cadet_open(struct file *file)
{
struct cadet *dev = video_drvdata(file);

mutex_lock(&dev->lock);
dev->users++;
if (1 == dev->users)
init_waitqueue_head(&dev->read_queue);
mutex_unlock(&dev->lock);
return 0;
}

static int cadet_release(struct file *file)
{
struct cadet *dev = video_drvdata(file);

mutex_lock(&dev->lock);
dev->users--;
if (0 == dev->users) {
del_timer_sync(&dev->readtimer);
dev->rdsstat = 0;
}
mutex_unlock(&dev->lock);
return 0;
}

Expand All @@ -559,7 +565,7 @@ static const struct v4l2_file_operations cadet_fops = {
.open = cadet_open,
.release = cadet_release,
.read = cadet_read,
.ioctl = video_ioctl2,
.unlocked_ioctl = video_ioctl2,
.poll = cadet_poll,
};

Expand Down

0 comments on commit ffbb7bf

Please sign in to comment.