diff options
Diffstat (limited to 'drivers/media/video/cx18/cx18-fileops.c')
| -rw-r--r-- | drivers/media/video/cx18/cx18-fileops.c | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/drivers/media/video/cx18/cx18-fileops.c b/drivers/media/video/cx18/cx18-fileops.c index 14cb961c22bd..4bfd865a4106 100644 --- a/drivers/media/video/cx18/cx18-fileops.c +++ b/drivers/media/video/cx18/cx18-fileops.c | |||
| @@ -751,20 +751,10 @@ int cx18_v4l2_close(struct file *filp) | |||
| 751 | 751 | ||
| 752 | CX18_DEBUG_IOCTL("close() of %s\n", s->name); | 752 | CX18_DEBUG_IOCTL("close() of %s\n", s->name); |
| 753 | 753 | ||
| 754 | v4l2_fh_del(fh); | ||
| 755 | v4l2_fh_exit(fh); | ||
| 756 | |||
| 757 | /* Easy case first: this stream was never claimed by us */ | ||
| 758 | if (s->id != id->open_id) { | ||
| 759 | kfree(id); | ||
| 760 | return 0; | ||
| 761 | } | ||
| 762 | |||
| 763 | /* 'Unclaim' this stream */ | ||
| 764 | |||
| 765 | /* Stop radio */ | ||
| 766 | mutex_lock(&cx->serialize_lock); | 754 | mutex_lock(&cx->serialize_lock); |
| 767 | if (id->type == CX18_ENC_STREAM_TYPE_RAD) { | 755 | /* Stop radio */ |
| 756 | if (id->type == CX18_ENC_STREAM_TYPE_RAD && | ||
| 757 | v4l2_fh_is_singular_file(filp)) { | ||
| 768 | /* Closing radio device, return to TV mode */ | 758 | /* Closing radio device, return to TV mode */ |
| 769 | cx18_mute(cx); | 759 | cx18_mute(cx); |
| 770 | /* Mark that the radio is no longer in use */ | 760 | /* Mark that the radio is no longer in use */ |
| @@ -781,10 +771,14 @@ int cx18_v4l2_close(struct file *filp) | |||
| 781 | } | 771 | } |
| 782 | /* Done! Unmute and continue. */ | 772 | /* Done! Unmute and continue. */ |
| 783 | cx18_unmute(cx); | 773 | cx18_unmute(cx); |
| 784 | cx18_release_stream(s); | ||
| 785 | } else { | ||
| 786 | cx18_stop_capture(id, 0); | ||
| 787 | } | 774 | } |
| 775 | |||
| 776 | v4l2_fh_del(fh); | ||
| 777 | v4l2_fh_exit(fh); | ||
| 778 | |||
| 779 | /* 'Unclaim' this stream */ | ||
| 780 | if (s->id == id->open_id) | ||
| 781 | cx18_stop_capture(id, 0); | ||
| 788 | kfree(id); | 782 | kfree(id); |
| 789 | mutex_unlock(&cx->serialize_lock); | 783 | mutex_unlock(&cx->serialize_lock); |
| 790 | return 0; | 784 | return 0; |
| @@ -810,21 +804,15 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp) | |||
| 810 | 804 | ||
| 811 | item->open_id = cx->open_id++; | 805 | item->open_id = cx->open_id++; |
| 812 | filp->private_data = &item->fh; | 806 | filp->private_data = &item->fh; |
| 807 | v4l2_fh_add(&item->fh); | ||
| 813 | 808 | ||
| 814 | if (item->type == CX18_ENC_STREAM_TYPE_RAD) { | 809 | if (item->type == CX18_ENC_STREAM_TYPE_RAD && |
| 815 | /* Try to claim this stream */ | 810 | v4l2_fh_is_singular_file(filp)) { |
| 816 | if (cx18_claim_stream(item, item->type)) { | ||
| 817 | /* No, it's already in use */ | ||
| 818 | v4l2_fh_exit(&item->fh); | ||
| 819 | kfree(item); | ||
| 820 | return -EBUSY; | ||
| 821 | } | ||
| 822 | |||
| 823 | if (!test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) { | 811 | if (!test_bit(CX18_F_I_RADIO_USER, &cx->i_flags)) { |
| 824 | if (atomic_read(&cx->ana_capturing) > 0) { | 812 | if (atomic_read(&cx->ana_capturing) > 0) { |
| 825 | /* switching to radio while capture is | 813 | /* switching to radio while capture is |
| 826 | in progress is not polite */ | 814 | in progress is not polite */ |
| 827 | cx18_release_stream(s); | 815 | v4l2_fh_del(&item->fh); |
| 828 | v4l2_fh_exit(&item->fh); | 816 | v4l2_fh_exit(&item->fh); |
| 829 | kfree(item); | 817 | kfree(item); |
| 830 | return -EBUSY; | 818 | return -EBUSY; |
| @@ -842,7 +830,6 @@ static int cx18_serialized_open(struct cx18_stream *s, struct file *filp) | |||
| 842 | /* Done! Unmute and continue. */ | 830 | /* Done! Unmute and continue. */ |
| 843 | cx18_unmute(cx); | 831 | cx18_unmute(cx); |
| 844 | } | 832 | } |
| 845 | v4l2_fh_add(&item->fh); | ||
| 846 | return 0; | 833 | return 0; |
| 847 | } | 834 | } |
| 848 | 835 | ||
