diff options
Diffstat (limited to 'drivers/media/video/cx88/cx88-video.c')
-rw-r--r-- | drivers/media/video/cx88/cx88-video.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/drivers/media/video/cx88/cx88-video.c b/drivers/media/video/cx88/cx88-video.c index ef4d56ea0027..be45955dff68 100644 --- a/drivers/media/video/cx88/cx88-video.c +++ b/drivers/media/video/cx88/cx88-video.c | |||
@@ -773,6 +773,7 @@ static int video_open(struct inode *inode, struct file *file) | |||
773 | enum v4l2_buf_type type = 0; | 773 | enum v4l2_buf_type type = 0; |
774 | int radio = 0; | 774 | int radio = 0; |
775 | 775 | ||
776 | lock_kernel(); | ||
776 | list_for_each_entry(h, &cx8800_devlist, devlist) { | 777 | list_for_each_entry(h, &cx8800_devlist, devlist) { |
777 | if (h->video_dev->minor == minor) { | 778 | if (h->video_dev->minor == minor) { |
778 | dev = h; | 779 | dev = h; |
@@ -788,8 +789,10 @@ static int video_open(struct inode *inode, struct file *file) | |||
788 | dev = h; | 789 | dev = h; |
789 | } | 790 | } |
790 | } | 791 | } |
791 | if (NULL == dev) | 792 | if (NULL == dev) { |
793 | unlock_kernel(); | ||
792 | return -ENODEV; | 794 | return -ENODEV; |
795 | } | ||
793 | 796 | ||
794 | core = dev->core; | 797 | core = dev->core; |
795 | 798 | ||
@@ -798,8 +801,10 @@ static int video_open(struct inode *inode, struct file *file) | |||
798 | 801 | ||
799 | /* allocate + initialize per filehandle data */ | 802 | /* allocate + initialize per filehandle data */ |
800 | fh = kzalloc(sizeof(*fh),GFP_KERNEL); | 803 | fh = kzalloc(sizeof(*fh),GFP_KERNEL); |
801 | if (NULL == fh) | 804 | if (NULL == fh) { |
805 | unlock_kernel(); | ||
802 | return -ENOMEM; | 806 | return -ENOMEM; |
807 | } | ||
803 | file->private_data = fh; | 808 | file->private_data = fh; |
804 | fh->dev = dev; | 809 | fh->dev = dev; |
805 | fh->radio = radio; | 810 | fh->radio = radio; |
@@ -832,6 +837,9 @@ static int video_open(struct inode *inode, struct file *file) | |||
832 | cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); | 837 | cx88_set_stereo(core,V4L2_TUNER_MODE_STEREO,1); |
833 | cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL); | 838 | cx88_call_i2c_clients(core,AUDC_SET_RADIO,NULL); |
834 | } | 839 | } |
840 | unlock_kernel(); | ||
841 | |||
842 | atomic_inc(&core->users); | ||
835 | 843 | ||
836 | return 0; | 844 | return 0; |
837 | } | 845 | } |
@@ -920,7 +928,8 @@ static int video_release(struct inode *inode, struct file *file) | |||
920 | file->private_data = NULL; | 928 | file->private_data = NULL; |
921 | kfree(fh); | 929 | kfree(fh); |
922 | 930 | ||
923 | cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); | 931 | if(atomic_dec_and_test(&dev->core->users)) |
932 | cx88_call_i2c_clients (dev->core, TUNER_SET_STANDBY, NULL); | ||
924 | 933 | ||
925 | return 0; | 934 | return 0; |
926 | } | 935 | } |