diff options
Diffstat (limited to 'drivers/media/video/arv.c')
-rw-r--r-- | drivers/media/video/arv.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/drivers/media/video/arv.c b/drivers/media/video/arv.c index 9e436ad3d34b..218754b4906a 100644 --- a/drivers/media/video/arv.c +++ b/drivers/media/video/arv.c | |||
@@ -116,6 +116,7 @@ struct ar_device { | |||
116 | int width, height; | 116 | int width, height; |
117 | int frame_bytes, line_bytes; | 117 | int frame_bytes, line_bytes; |
118 | wait_queue_head_t wait; | 118 | wait_queue_head_t wait; |
119 | unsigned long in_use; | ||
119 | struct mutex lock; | 120 | struct mutex lock; |
120 | }; | 121 | }; |
121 | 122 | ||
@@ -269,7 +270,7 @@ static inline void wait_for_vertical_sync(int exp_line) | |||
269 | static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos) | 270 | static ssize_t ar_read(struct file *file, char *buf, size_t count, loff_t *ppos) |
270 | { | 271 | { |
271 | struct video_device *v = video_devdata(file); | 272 | struct video_device *v = video_devdata(file); |
272 | struct ar_device *ar = v->priv; | 273 | struct ar_device *ar = video_get_drvdata(v); |
273 | long ret = ar->frame_bytes; /* return read bytes */ | 274 | long ret = ar->frame_bytes; /* return read bytes */ |
274 | unsigned long arvcr1 = 0; | 275 | unsigned long arvcr1 = 0; |
275 | unsigned long flags; | 276 | unsigned long flags; |
@@ -399,7 +400,7 @@ static int ar_do_ioctl(struct inode *inode, struct file *file, | |||
399 | unsigned int cmd, void *arg) | 400 | unsigned int cmd, void *arg) |
400 | { | 401 | { |
401 | struct video_device *dev = video_devdata(file); | 402 | struct video_device *dev = video_devdata(file); |
402 | struct ar_device *ar = dev->priv; | 403 | struct ar_device *ar = video_get_drvdata(dev); |
403 | 404 | ||
404 | DEBUG(1, "ar_ioctl()\n"); | 405 | DEBUG(1, "ar_ioctl()\n"); |
405 | switch(cmd) { | 406 | switch(cmd) { |
@@ -625,7 +626,7 @@ static void ar_interrupt(int irq, void *dev) | |||
625 | */ | 626 | */ |
626 | static int ar_initialize(struct video_device *dev) | 627 | static int ar_initialize(struct video_device *dev) |
627 | { | 628 | { |
628 | struct ar_device *ar = dev->priv; | 629 | struct ar_device *ar = video_get_drvdata(dev); |
629 | unsigned long cr = 0; | 630 | unsigned long cr = 0; |
630 | int i,found=0; | 631 | int i,found=0; |
631 | 632 | ||
@@ -732,7 +733,7 @@ static int ar_initialize(struct video_device *dev) | |||
732 | 733 | ||
733 | void ar_release(struct video_device *vfd) | 734 | void ar_release(struct video_device *vfd) |
734 | { | 735 | { |
735 | struct ar_device *ar = vfd->priv; | 736 | struct ar_device *ar = video_get_drvdata(vfd); |
736 | mutex_lock(&ar->lock); | 737 | mutex_lock(&ar->lock); |
737 | video_device_release(vfd); | 738 | video_device_release(vfd); |
738 | } | 739 | } |
@@ -742,10 +743,23 @@ void ar_release(struct video_device *vfd) | |||
742 | * Video4Linux Module functions | 743 | * Video4Linux Module functions |
743 | * | 744 | * |
744 | ****************************************************************************/ | 745 | ****************************************************************************/ |
746 | static struct ar_device ardev; | ||
747 | |||
748 | static int ar_exclusive_open(struct inode *inode, struct file *file) | ||
749 | { | ||
750 | return test_and_set_bit(0, &ardev.in_use) ? -EBUSY : 0; | ||
751 | } | ||
752 | |||
753 | static int ar_exclusive_release(struct inode *inode, struct file *file) | ||
754 | { | ||
755 | clear_bit(0, &ardev.in_use); | ||
756 | return 0; | ||
757 | } | ||
758 | |||
745 | static const struct file_operations ar_fops = { | 759 | static const struct file_operations ar_fops = { |
746 | .owner = THIS_MODULE, | 760 | .owner = THIS_MODULE, |
747 | .open = video_exclusive_open, | 761 | .open = ar_exclusive_open, |
748 | .release = video_exclusive_release, | 762 | .release = ar_exclusive_release, |
749 | .read = ar_read, | 763 | .read = ar_read, |
750 | .ioctl = ar_ioctl, | 764 | .ioctl = ar_ioctl, |
751 | #ifdef CONFIG_COMPAT | 765 | #ifdef CONFIG_COMPAT |
@@ -762,7 +776,6 @@ static struct video_device ar_template = { | |||
762 | }; | 776 | }; |
763 | 777 | ||
764 | #define ALIGN4(x) ((((int)(x)) & 0x3) == 0) | 778 | #define ALIGN4(x) ((((int)(x)) & 0x3) == 0) |
765 | static struct ar_device ardev; | ||
766 | 779 | ||
767 | static int __init ar_init(void) | 780 | static int __init ar_init(void) |
768 | { | 781 | { |
@@ -802,7 +815,7 @@ static int __init ar_init(void) | |||
802 | return -ENOMEM; | 815 | return -ENOMEM; |
803 | } | 816 | } |
804 | memcpy(ar->vdev, &ar_template, sizeof(ar_template)); | 817 | memcpy(ar->vdev, &ar_template, sizeof(ar_template)); |
805 | ar->vdev->priv = ar; | 818 | video_set_drvdata(ar->vdev, ar); |
806 | 819 | ||
807 | if (vga) { | 820 | if (vga) { |
808 | ar->width = AR_WIDTH_VGA; | 821 | ar->width = AR_WIDTH_VGA; |