diff options
Diffstat (limited to 'drivers/usb/media/sn9c102_core.c')
-rw-r--r-- | drivers/usb/media/sn9c102_core.c | 326 |
1 files changed, 178 insertions, 148 deletions
diff --git a/drivers/usb/media/sn9c102_core.c b/drivers/usb/media/sn9c102_core.c index c81397e4714..4c6cc639572 100644 --- a/drivers/usb/media/sn9c102_core.c +++ b/drivers/usb/media/sn9c102_core.c | |||
@@ -25,11 +25,9 @@ | |||
25 | #include <linux/moduleparam.h> | 25 | #include <linux/moduleparam.h> |
26 | #include <linux/errno.h> | 26 | #include <linux/errno.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/string.h> | ||
29 | #include <linux/device.h> | 28 | #include <linux/device.h> |
30 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
31 | #include <linux/delay.h> | 30 | #include <linux/delay.h> |
32 | #include <linux/stddef.h> | ||
33 | #include <linux/compiler.h> | 31 | #include <linux/compiler.h> |
34 | #include <linux/ioctl.h> | 32 | #include <linux/ioctl.h> |
35 | #include <linux/poll.h> | 33 | #include <linux/poll.h> |
@@ -49,8 +47,8 @@ | |||
49 | #define SN9C102_MODULE_AUTHOR "(C) 2004-2006 Luca Risolia" | 47 | #define SN9C102_MODULE_AUTHOR "(C) 2004-2006 Luca Risolia" |
50 | #define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" | 48 | #define SN9C102_AUTHOR_EMAIL "<luca.risolia@studio.unibo.it>" |
51 | #define SN9C102_MODULE_LICENSE "GPL" | 49 | #define SN9C102_MODULE_LICENSE "GPL" |
52 | #define SN9C102_MODULE_VERSION "1:1.26" | 50 | #define SN9C102_MODULE_VERSION "1:1.27" |
53 | #define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 26) | 51 | #define SN9C102_MODULE_VERSION_CODE KERNEL_VERSION(1, 0, 27) |
54 | 52 | ||
55 | /*****************************************************************************/ | 53 | /*****************************************************************************/ |
56 | 54 | ||
@@ -89,6 +87,15 @@ MODULE_PARM_DESC(force_munmap, | |||
89 | "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"." | 87 | "\nDefault value is "__MODULE_STRING(SN9C102_FORCE_MUNMAP)"." |
90 | "\n"); | 88 | "\n"); |
91 | 89 | ||
90 | static unsigned int frame_timeout[] = {[0 ... SN9C102_MAX_DEVICES-1] = | ||
91 | SN9C102_FRAME_TIMEOUT}; | ||
92 | module_param_array(frame_timeout, uint, NULL, 0644); | ||
93 | MODULE_PARM_DESC(frame_timeout, | ||
94 | "\n<n[,...]> Timeout for a video frame in seconds." | ||
95 | "\nThis parameter is specific for each detected camera." | ||
96 | "\nDefault value is "__MODULE_STRING(SN9C102_FRAME_TIMEOUT)"." | ||
97 | "\n"); | ||
98 | |||
92 | #ifdef SN9C102_DEBUG | 99 | #ifdef SN9C102_DEBUG |
93 | static unsigned short debug = SN9C102_DEBUG_LEVEL; | 100 | static unsigned short debug = SN9C102_DEBUG_LEVEL; |
94 | module_param(debug, ushort, 0644); | 101 | module_param(debug, ushort, 0644); |
@@ -128,8 +135,8 @@ static u32 | |||
128 | sn9c102_request_buffers(struct sn9c102_device* cam, u32 count, | 135 | sn9c102_request_buffers(struct sn9c102_device* cam, u32 count, |
129 | enum sn9c102_io_method io) | 136 | enum sn9c102_io_method io) |
130 | { | 137 | { |
131 | struct v4l2_pix_format* p = &(cam->sensor->pix_format); | 138 | struct v4l2_pix_format* p = &(cam->sensor.pix_format); |
132 | struct v4l2_rect* r = &(cam->sensor->cropcap.bounds); | 139 | struct v4l2_rect* r = &(cam->sensor.cropcap.bounds); |
133 | const size_t imagesize = cam->module_param.force_munmap || | 140 | const size_t imagesize = cam->module_param.force_munmap || |
134 | io == IO_READ ? | 141 | io == IO_READ ? |
135 | (p->width * p->height * p->priv) / 8 : | 142 | (p->width * p->height * p->priv) / 8 : |
@@ -449,19 +456,13 @@ sn9c102_i2c_try_write(struct sn9c102_device* cam, | |||
449 | 456 | ||
450 | int sn9c102_i2c_read(struct sn9c102_device* cam, u8 address) | 457 | int sn9c102_i2c_read(struct sn9c102_device* cam, u8 address) |
451 | { | 458 | { |
452 | if (!cam->sensor) | 459 | return sn9c102_i2c_try_read(cam, &cam->sensor, address); |
453 | return -1; | ||
454 | |||
455 | return sn9c102_i2c_try_read(cam, cam->sensor, address); | ||
456 | } | 460 | } |
457 | 461 | ||
458 | 462 | ||
459 | int sn9c102_i2c_write(struct sn9c102_device* cam, u8 address, u8 value) | 463 | int sn9c102_i2c_write(struct sn9c102_device* cam, u8 address, u8 value) |
460 | { | 464 | { |
461 | if (!cam->sensor) | 465 | return sn9c102_i2c_try_write(cam, &cam->sensor, address, value); |
462 | return -1; | ||
463 | |||
464 | return sn9c102_i2c_try_write(cam, cam->sensor, address, value); | ||
465 | } | 466 | } |
466 | 467 | ||
467 | /*****************************************************************************/ | 468 | /*****************************************************************************/ |
@@ -505,7 +506,7 @@ sn9c102_find_eof_header(struct sn9c102_device* cam, void* mem, size_t len) | |||
505 | size_t eoflen = sizeof(sn9c102_eof_header_t), i; | 506 | size_t eoflen = sizeof(sn9c102_eof_header_t), i; |
506 | unsigned j, n = sizeof(sn9c102_eof_header) / eoflen; | 507 | unsigned j, n = sizeof(sn9c102_eof_header) / eoflen; |
507 | 508 | ||
508 | if (cam->sensor->pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X) | 509 | if (cam->sensor.pix_format.pixelformat == V4L2_PIX_FMT_SN9C10X) |
509 | return NULL; /* EOF header does not exist in compressed data */ | 510 | return NULL; /* EOF header does not exist in compressed data */ |
510 | 511 | ||
511 | for (i = 0; (len >= eoflen) && (i <= len - eoflen); i++) | 512 | for (i = 0; (len >= eoflen) && (i <= len - eoflen); i++) |
@@ -535,7 +536,7 @@ static void sn9c102_urb_complete(struct urb *urb, struct pt_regs* regs) | |||
535 | if ((*f)) | 536 | if ((*f)) |
536 | (*f)->state = F_QUEUED; | 537 | (*f)->state = F_QUEUED; |
537 | DBG(3, "Stream interrupted"); | 538 | DBG(3, "Stream interrupted"); |
538 | wake_up_interruptible(&cam->wait_stream); | 539 | wake_up(&cam->wait_stream); |
539 | } | 540 | } |
540 | 541 | ||
541 | if (cam->state & DEV_DISCONNECTED) | 542 | if (cam->state & DEV_DISCONNECTED) |
@@ -553,9 +554,9 @@ static void sn9c102_urb_complete(struct urb *urb, struct pt_regs* regs) | |||
553 | (*f) = list_entry(cam->inqueue.next, struct sn9c102_frame_t, | 554 | (*f) = list_entry(cam->inqueue.next, struct sn9c102_frame_t, |
554 | frame); | 555 | frame); |
555 | 556 | ||
556 | imagesize = (cam->sensor->pix_format.width * | 557 | imagesize = (cam->sensor.pix_format.width * |
557 | cam->sensor->pix_format.height * | 558 | cam->sensor.pix_format.height * |
558 | cam->sensor->pix_format.priv) / 8; | 559 | cam->sensor.pix_format.priv) / 8; |
559 | 560 | ||
560 | soflen = (cam->bridge) == BRIDGE_SN9C103 ? | 561 | soflen = (cam->bridge) == BRIDGE_SN9C103 ? |
561 | sizeof(sn9c103_sof_header_t) : | 562 | sizeof(sn9c103_sof_header_t) : |
@@ -579,7 +580,7 @@ static void sn9c102_urb_complete(struct urb *urb, struct pt_regs* regs) | |||
579 | 580 | ||
580 | redo: | 581 | redo: |
581 | sof = sn9c102_find_sof_header(cam, pos, len); | 582 | sof = sn9c102_find_sof_header(cam, pos, len); |
582 | if (!sof) { | 583 | if (likely(!sof)) { |
583 | eof = sn9c102_find_eof_header(cam, pos, len); | 584 | eof = sn9c102_find_eof_header(cam, pos, len); |
584 | if ((*f)->state == F_GRABBING) { | 585 | if ((*f)->state == F_GRABBING) { |
585 | end_of_frame: | 586 | end_of_frame: |
@@ -589,8 +590,9 @@ end_of_frame: | |||
589 | img = (eof > pos) ? eof - pos - 1 : 0; | 590 | img = (eof > pos) ? eof - pos - 1 : 0; |
590 | 591 | ||
591 | if ((*f)->buf.bytesused+img > imagesize) { | 592 | if ((*f)->buf.bytesused+img > imagesize) { |
592 | u32 b = (*f)->buf.bytesused + img - | 593 | u32 b; |
593 | imagesize; | 594 | b = (*f)->buf.bytesused + img - |
595 | imagesize; | ||
594 | img = imagesize - (*f)->buf.bytesused; | 596 | img = imagesize - (*f)->buf.bytesused; |
595 | DBG(3, "Expected EOF not found: " | 597 | DBG(3, "Expected EOF not found: " |
596 | "video frame cut"); | 598 | "video frame cut"); |
@@ -608,9 +610,10 @@ end_of_frame: | |||
608 | (*f)->buf.bytesused += img; | 610 | (*f)->buf.bytesused += img; |
609 | 611 | ||
610 | if ((*f)->buf.bytesused == imagesize || | 612 | if ((*f)->buf.bytesused == imagesize || |
611 | (cam->sensor->pix_format.pixelformat == | 613 | (cam->sensor.pix_format.pixelformat == |
612 | V4L2_PIX_FMT_SN9C10X && eof)) { | 614 | V4L2_PIX_FMT_SN9C10X && eof)) { |
613 | u32 b = (*f)->buf.bytesused; | 615 | u32 b; |
616 | b = (*f)->buf.bytesused; | ||
614 | (*f)->state = F_DONE; | 617 | (*f)->state = F_DONE; |
615 | (*f)->buf.sequence= ++cam->frame_count; | 618 | (*f)->buf.sequence= ++cam->frame_count; |
616 | spin_lock(&cam->queue_lock); | 619 | spin_lock(&cam->queue_lock); |
@@ -667,7 +670,7 @@ start_of_frame: | |||
667 | if (eof && eof < sof) | 670 | if (eof && eof < sof) |
668 | goto end_of_frame; /* (1) */ | 671 | goto end_of_frame; /* (1) */ |
669 | else { | 672 | else { |
670 | if (cam->sensor->pix_format.pixelformat == | 673 | if (cam->sensor.pix_format.pixelformat == |
671 | V4L2_PIX_FMT_SN9C10X) { | 674 | V4L2_PIX_FMT_SN9C10X) { |
672 | eof = sof - soflen; | 675 | eof = sof - soflen; |
673 | goto end_of_frame; | 676 | goto end_of_frame; |
@@ -808,20 +811,21 @@ static int sn9c102_stop_transfer(struct sn9c102_device* cam) | |||
808 | 811 | ||
809 | static int sn9c102_stream_interrupt(struct sn9c102_device* cam) | 812 | static int sn9c102_stream_interrupt(struct sn9c102_device* cam) |
810 | { | 813 | { |
811 | int err = 0; | 814 | long timeout; |
812 | 815 | ||
813 | cam->stream = STREAM_INTERRUPT; | 816 | cam->stream = STREAM_INTERRUPT; |
814 | err = wait_event_timeout(cam->wait_stream, | 817 | timeout = wait_event_timeout(cam->wait_stream, |
815 | (cam->stream == STREAM_OFF) || | 818 | (cam->stream == STREAM_OFF) || |
816 | (cam->state & DEV_DISCONNECTED), | 819 | (cam->state & DEV_DISCONNECTED), |
817 | SN9C102_URB_TIMEOUT); | 820 | SN9C102_URB_TIMEOUT); |
818 | if (cam->state & DEV_DISCONNECTED) | 821 | if (cam->state & DEV_DISCONNECTED) |
819 | return -ENODEV; | 822 | return -ENODEV; |
820 | else if (err) { | 823 | else if (cam->stream != STREAM_OFF) { |
821 | cam->state |= DEV_MISCONFIGURED; | 824 | cam->state |= DEV_MISCONFIGURED; |
822 | DBG(1, "The camera is misconfigured. To use it, close and " | 825 | DBG(1, "URB timeout reached. The camera is misconfigured. " |
823 | "open /dev/video%d again.", cam->v4ldev->minor); | 826 | "To use it, close and open /dev/video%d again.", |
824 | return err; | 827 | cam->v4ldev->minor); |
828 | return -EIO; | ||
825 | } | 829 | } |
826 | 830 | ||
827 | return 0; | 831 | return 0; |
@@ -866,18 +870,18 @@ static ssize_t sn9c102_show_reg(struct class_device* cd, char* buf) | |||
866 | struct sn9c102_device* cam; | 870 | struct sn9c102_device* cam; |
867 | ssize_t count; | 871 | ssize_t count; |
868 | 872 | ||
869 | if (down_interruptible(&sn9c102_sysfs_lock)) | 873 | if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) |
870 | return -ERESTARTSYS; | 874 | return -ERESTARTSYS; |
871 | 875 | ||
872 | cam = video_get_drvdata(to_video_device(cd)); | 876 | cam = video_get_drvdata(to_video_device(cd)); |
873 | if (!cam) { | 877 | if (!cam) { |
874 | up(&sn9c102_sysfs_lock); | 878 | mutex_unlock(&sn9c102_sysfs_lock); |
875 | return -ENODEV; | 879 | return -ENODEV; |
876 | } | 880 | } |
877 | 881 | ||
878 | count = sprintf(buf, "%u\n", cam->sysfs.reg); | 882 | count = sprintf(buf, "%u\n", cam->sysfs.reg); |
879 | 883 | ||
880 | up(&sn9c102_sysfs_lock); | 884 | mutex_unlock(&sn9c102_sysfs_lock); |
881 | 885 | ||
882 | return count; | 886 | return count; |
883 | } | 887 | } |
@@ -890,18 +894,18 @@ sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len) | |||
890 | u8 index; | 894 | u8 index; |
891 | ssize_t count; | 895 | ssize_t count; |
892 | 896 | ||
893 | if (down_interruptible(&sn9c102_sysfs_lock)) | 897 | if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) |
894 | return -ERESTARTSYS; | 898 | return -ERESTARTSYS; |
895 | 899 | ||
896 | cam = video_get_drvdata(to_video_device(cd)); | 900 | cam = video_get_drvdata(to_video_device(cd)); |
897 | if (!cam) { | 901 | if (!cam) { |
898 | up(&sn9c102_sysfs_lock); | 902 | mutex_unlock(&sn9c102_sysfs_lock); |
899 | return -ENODEV; | 903 | return -ENODEV; |
900 | } | 904 | } |
901 | 905 | ||
902 | index = sn9c102_strtou8(buf, len, &count); | 906 | index = sn9c102_strtou8(buf, len, &count); |
903 | if (index > 0x1f || !count) { | 907 | if (index > 0x1f || !count) { |
904 | up(&sn9c102_sysfs_lock); | 908 | mutex_unlock(&sn9c102_sysfs_lock); |
905 | return -EINVAL; | 909 | return -EINVAL; |
906 | } | 910 | } |
907 | 911 | ||
@@ -910,7 +914,7 @@ sn9c102_store_reg(struct class_device* cd, const char* buf, size_t len) | |||
910 | DBG(2, "Moved SN9C10X register index to 0x%02X", cam->sysfs.reg); | 914 | DBG(2, "Moved SN9C10X register index to 0x%02X", cam->sysfs.reg); |
911 | DBG(3, "Written bytes: %zd", count); | 915 | DBG(3, "Written bytes: %zd", count); |
912 | 916 | ||
913 | up(&sn9c102_sysfs_lock); | 917 | mutex_unlock(&sn9c102_sysfs_lock); |
914 | 918 | ||
915 | return count; | 919 | return count; |
916 | } | 920 | } |
@@ -922,17 +926,17 @@ static ssize_t sn9c102_show_val(struct class_device* cd, char* buf) | |||
922 | ssize_t count; | 926 | ssize_t count; |
923 | int val; | 927 | int val; |
924 | 928 | ||
925 | if (down_interruptible(&sn9c102_sysfs_lock)) | 929 | if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) |
926 | return -ERESTARTSYS; | 930 | return -ERESTARTSYS; |
927 | 931 | ||
928 | cam = video_get_drvdata(to_video_device(cd)); | 932 | cam = video_get_drvdata(to_video_device(cd)); |
929 | if (!cam) { | 933 | if (!cam) { |
930 | up(&sn9c102_sysfs_lock); | 934 | mutex_unlock(&sn9c102_sysfs_lock); |
931 | return -ENODEV; | 935 | return -ENODEV; |
932 | } | 936 | } |
933 | 937 | ||
934 | if ((val = sn9c102_read_reg(cam, cam->sysfs.reg)) < 0) { | 938 | if ((val = sn9c102_read_reg(cam, cam->sysfs.reg)) < 0) { |
935 | up(&sn9c102_sysfs_lock); | 939 | mutex_unlock(&sn9c102_sysfs_lock); |
936 | return -EIO; | 940 | return -EIO; |
937 | } | 941 | } |
938 | 942 | ||
@@ -940,7 +944,7 @@ static ssize_t sn9c102_show_val(struct class_device* cd, char* buf) | |||
940 | 944 | ||
941 | DBG(3, "Read bytes: %zd", count); | 945 | DBG(3, "Read bytes: %zd", count); |
942 | 946 | ||
943 | up(&sn9c102_sysfs_lock); | 947 | mutex_unlock(&sn9c102_sysfs_lock); |
944 | 948 | ||
945 | return count; | 949 | return count; |
946 | } | 950 | } |
@@ -954,24 +958,24 @@ sn9c102_store_val(struct class_device* cd, const char* buf, size_t len) | |||
954 | ssize_t count; | 958 | ssize_t count; |
955 | int err; | 959 | int err; |
956 | 960 | ||
957 | if (down_interruptible(&sn9c102_sysfs_lock)) | 961 | if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) |
958 | return -ERESTARTSYS; | 962 | return -ERESTARTSYS; |
959 | 963 | ||
960 | cam = video_get_drvdata(to_video_device(cd)); | 964 | cam = video_get_drvdata(to_video_device(cd)); |
961 | if (!cam) { | 965 | if (!cam) { |
962 | up(&sn9c102_sysfs_lock); | 966 | mutex_unlock(&sn9c102_sysfs_lock); |
963 | return -ENODEV; | 967 | return -ENODEV; |
964 | } | 968 | } |
965 | 969 | ||
966 | value = sn9c102_strtou8(buf, len, &count); | 970 | value = sn9c102_strtou8(buf, len, &count); |
967 | if (!count) { | 971 | if (!count) { |
968 | up(&sn9c102_sysfs_lock); | 972 | mutex_unlock(&sn9c102_sysfs_lock); |
969 | return -EINVAL; | 973 | return -EINVAL; |
970 | } | 974 | } |
971 | 975 | ||
972 | err = sn9c102_write_reg(cam, value, cam->sysfs.reg); | 976 | err = sn9c102_write_reg(cam, value, cam->sysfs.reg); |
973 | if (err) { | 977 | if (err) { |
974 | up(&sn9c102_sysfs_lock); | 978 | mutex_unlock(&sn9c102_sysfs_lock); |
975 | return -EIO; | 979 | return -EIO; |
976 | } | 980 | } |
977 | 981 | ||
@@ -979,7 +983,7 @@ sn9c102_store_val(struct class_device* cd, const char* buf, size_t len) | |||
979 | cam->sysfs.reg, value); | 983 | cam->sysfs.reg, value); |
980 | DBG(3, "Written bytes: %zd", count); | 984 | DBG(3, "Written bytes: %zd", count); |
981 | 985 | ||
982 | up(&sn9c102_sysfs_lock); | 986 | mutex_unlock(&sn9c102_sysfs_lock); |
983 | 987 | ||
984 | return count; | 988 | return count; |
985 | } | 989 | } |
@@ -990,12 +994,12 @@ static ssize_t sn9c102_show_i2c_reg(struct class_device* cd, char* buf) | |||
990 | struct sn9c102_device* cam; | 994 | struct sn9c102_device* cam; |
991 | ssize_t count; | 995 | ssize_t count; |
992 | 996 | ||
993 | if (down_interruptible(&sn9c102_sysfs_lock)) | 997 | if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) |
994 | return -ERESTARTSYS; | 998 | return -ERESTARTSYS; |
995 | 999 | ||
996 | cam = video_get_drvdata(to_video_device(cd)); | 1000 | cam = video_get_drvdata(to_video_device(cd)); |
997 | if (!cam) { | 1001 | if (!cam) { |
998 | up(&sn9c102_sysfs_lock); | 1002 | mutex_unlock(&sn9c102_sysfs_lock); |
999 | return -ENODEV; | 1003 | return -ENODEV; |
1000 | } | 1004 | } |
1001 | 1005 | ||
@@ -1003,7 +1007,7 @@ static ssize_t sn9c102_show_i2c_reg(struct class_device* cd, char* buf) | |||
1003 | 1007 | ||
1004 | DBG(3, "Read bytes: %zd", count); | 1008 | DBG(3, "Read bytes: %zd", count); |
1005 | 1009 | ||
1006 | up(&sn9c102_sysfs_lock); | 1010 | mutex_unlock(&sn9c102_sysfs_lock); |
1007 | 1011 | ||
1008 | return count; | 1012 | return count; |
1009 | } | 1013 | } |
@@ -1016,18 +1020,18 @@ sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len) | |||
1016 | u8 index; | 1020 | u8 index; |
1017 | ssize_t count; | 1021 | ssize_t count; |
1018 | 1022 | ||
1019 | if (down_interruptible(&sn9c102_sysfs_lock)) | 1023 | if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) |
1020 | return -ERESTARTSYS; | 1024 | return -ERESTARTSYS; |
1021 | 1025 | ||
1022 | cam = video_get_drvdata(to_video_device(cd)); | 1026 | cam = video_get_drvdata(to_video_device(cd)); |
1023 | if (!cam) { | 1027 | if (!cam) { |
1024 | up(&sn9c102_sysfs_lock); | 1028 | mutex_unlock(&sn9c102_sysfs_lock); |
1025 | return -ENODEV; | 1029 | return -ENODEV; |
1026 | } | 1030 | } |
1027 | 1031 | ||
1028 | index = sn9c102_strtou8(buf, len, &count); | 1032 | index = sn9c102_strtou8(buf, len, &count); |
1029 | if (!count) { | 1033 | if (!count) { |
1030 | up(&sn9c102_sysfs_lock); | 1034 | mutex_unlock(&sn9c102_sysfs_lock); |
1031 | return -EINVAL; | 1035 | return -EINVAL; |
1032 | } | 1036 | } |
1033 | 1037 | ||
@@ -1036,7 +1040,7 @@ sn9c102_store_i2c_reg(struct class_device* cd, const char* buf, size_t len) | |||
1036 | DBG(2, "Moved sensor register index to 0x%02X", cam->sysfs.i2c_reg); | 1040 | DBG(2, "Moved sensor register index to 0x%02X", cam->sysfs.i2c_reg); |
1037 | DBG(3, "Written bytes: %zd", count); | 1041 | DBG(3, "Written bytes: %zd", count); |
1038 | 1042 | ||
1039 | up(&sn9c102_sysfs_lock); | 1043 | mutex_unlock(&sn9c102_sysfs_lock); |
1040 | 1044 | ||
1041 | return count; | 1045 | return count; |
1042 | } | 1046 | } |
@@ -1048,22 +1052,22 @@ static ssize_t sn9c102_show_i2c_val(struct class_device* cd, char* buf) | |||
1048 | ssize_t count; | 1052 | ssize_t count; |
1049 | int val; | 1053 | int val; |
1050 | 1054 | ||
1051 | if (down_interruptible(&sn9c102_sysfs_lock)) | 1055 | if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) |
1052 | return -ERESTARTSYS; | 1056 | return -ERESTARTSYS; |
1053 | 1057 | ||
1054 | cam = video_get_drvdata(to_video_device(cd)); | 1058 | cam = video_get_drvdata(to_video_device(cd)); |
1055 | if (!cam) { | 1059 | if (!cam) { |
1056 | up(&sn9c102_sysfs_lock); | 1060 | mutex_unlock(&sn9c102_sysfs_lock); |
1057 | return -ENODEV; | 1061 | return -ENODEV; |
1058 | } | 1062 | } |
1059 | 1063 | ||
1060 | if (!(cam->sensor->sysfs_ops & SN9C102_I2C_READ)) { | 1064 | if (!(cam->sensor.sysfs_ops & SN9C102_I2C_READ)) { |
1061 | up(&sn9c102_sysfs_lock); | 1065 | mutex_unlock(&sn9c102_sysfs_lock); |
1062 | return -ENOSYS; | 1066 | return -ENOSYS; |
1063 | } | 1067 | } |
1064 | 1068 | ||
1065 | if ((val = sn9c102_i2c_read(cam, cam->sysfs.i2c_reg)) < 0) { | 1069 | if ((val = sn9c102_i2c_read(cam, cam->sysfs.i2c_reg)) < 0) { |
1066 | up(&sn9c102_sysfs_lock); | 1070 | mutex_unlock(&sn9c102_sysfs_lock); |
1067 | return -EIO; | 1071 | return -EIO; |
1068 | } | 1072 | } |
1069 | 1073 | ||
@@ -1071,7 +1075,7 @@ static ssize_t sn9c102_show_i2c_val(struct class_device* cd, char* buf) | |||
1071 | 1075 | ||
1072 | DBG(3, "Read bytes: %zd", count); | 1076 | DBG(3, "Read bytes: %zd", count); |
1073 | 1077 | ||
1074 | up(&sn9c102_sysfs_lock); | 1078 | mutex_unlock(&sn9c102_sysfs_lock); |
1075 | 1079 | ||
1076 | return count; | 1080 | return count; |
1077 | } | 1081 | } |
@@ -1085,29 +1089,29 @@ sn9c102_store_i2c_val(struct class_device* cd, const char* buf, size_t len) | |||
1085 | ssize_t count; | 1089 | ssize_t count; |
1086 | int err; | 1090 | int err; |
1087 | 1091 | ||
1088 | if (down_interruptible(&sn9c102_sysfs_lock)) | 1092 | if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) |
1089 | return -ERESTARTSYS; | 1093 | return -ERESTARTSYS; |
1090 | 1094 | ||
1091 | cam = video_get_drvdata(to_video_device(cd)); | 1095 | cam = video_get_drvdata(to_video_device(cd)); |
1092 | if (!cam) { | 1096 | if (!cam) { |
1093 | up(&sn9c102_sysfs_lock); | 1097 | mutex_unlock(&sn9c102_sysfs_lock); |
1094 | return -ENODEV; | 1098 | return -ENODEV; |
1095 | } | 1099 | } |
1096 | 1100 | ||
1097 | if (!(cam->sensor->sysfs_ops & SN9C102_I2C_WRITE)) { | 1101 | if (!(cam->sensor.sysfs_ops & SN9C102_I2C_WRITE)) { |
1098 | up(&sn9c102_sysfs_lock); | 1102 | mutex_unlock(&sn9c102_sysfs_lock); |
1099 | return -ENOSYS; | 1103 | return -ENOSYS; |
1100 | } | 1104 | } |
1101 | 1105 | ||
1102 | value = sn9c102_strtou8(buf, len, &count); | 1106 | value = sn9c102_strtou8(buf, len, &count); |
1103 | if (!count) { | 1107 | if (!count) { |
1104 | up(&sn9c102_sysfs_lock); | 1108 | mutex_unlock(&sn9c102_sysfs_lock); |
1105 | return -EINVAL; | 1109 | return -EINVAL; |
1106 | } | 1110 | } |
1107 | 1111 | ||
1108 | err = sn9c102_i2c_write(cam, cam->sysfs.i2c_reg, value); | 1112 | err = sn9c102_i2c_write(cam, cam->sysfs.i2c_reg, value); |
1109 | if (err) { | 1113 | if (err) { |
1110 | up(&sn9c102_sysfs_lock); | 1114 | mutex_unlock(&sn9c102_sysfs_lock); |
1111 | return -EIO; | 1115 | return -EIO; |
1112 | } | 1116 | } |
1113 | 1117 | ||
@@ -1115,7 +1119,7 @@ sn9c102_store_i2c_val(struct class_device* cd, const char* buf, size_t len) | |||
1115 | cam->sysfs.i2c_reg, value); | 1119 | cam->sysfs.i2c_reg, value); |
1116 | DBG(3, "Written bytes: %zd", count); | 1120 | DBG(3, "Written bytes: %zd", count); |
1117 | 1121 | ||
1118 | up(&sn9c102_sysfs_lock); | 1122 | mutex_unlock(&sn9c102_sysfs_lock); |
1119 | 1123 | ||
1120 | return count; | 1124 | return count; |
1121 | } | 1125 | } |
@@ -1130,18 +1134,18 @@ sn9c102_store_green(struct class_device* cd, const char* buf, size_t len) | |||
1130 | u8 value; | 1134 | u8 value; |
1131 | ssize_t count; | 1135 | ssize_t count; |
1132 | 1136 | ||
1133 | if (down_interruptible(&sn9c102_sysfs_lock)) | 1137 | if (mutex_lock_interruptible(&sn9c102_sysfs_lock)) |
1134 | return -ERESTARTSYS; | 1138 | return -ERESTARTSYS; |
1135 | 1139 | ||
1136 | cam = video_get_drvdata(to_video_device(cd)); | 1140 | cam = video_get_drvdata(to_video_device(cd)); |
1137 | if (!cam) { | 1141 | if (!cam) { |
1138 | up(&sn9c102_sysfs_lock); | 1142 | mutex_unlock(&sn9c102_sysfs_lock); |
1139 | return -ENODEV; | 1143 | return -ENODEV; |
1140 | } | 1144 | } |
1141 | 1145 | ||
1142 | bridge = cam->bridge; | 1146 | bridge = cam->bridge; |
1143 | 1147 | ||
1144 | up(&sn9c102_sysfs_lock); | 1148 | mutex_unlock(&sn9c102_sysfs_lock); |
1145 | 1149 | ||
1146 | value = sn9c102_strtou8(buf, len, &count); | 1150 | value = sn9c102_strtou8(buf, len, &count); |
1147 | if (!count) | 1151 | if (!count) |
@@ -1249,7 +1253,7 @@ static void sn9c102_create_sysfs(struct sn9c102_device* cam) | |||
1249 | video_device_create_file(v4ldev, &class_device_attr_blue); | 1253 | video_device_create_file(v4ldev, &class_device_attr_blue); |
1250 | video_device_create_file(v4ldev, &class_device_attr_red); | 1254 | video_device_create_file(v4ldev, &class_device_attr_red); |
1251 | } | 1255 | } |
1252 | if (cam->sensor && cam->sensor->sysfs_ops) { | 1256 | if (cam->sensor.sysfs_ops) { |
1253 | video_device_create_file(v4ldev, &class_device_attr_i2c_reg); | 1257 | video_device_create_file(v4ldev, &class_device_attr_i2c_reg); |
1254 | video_device_create_file(v4ldev, &class_device_attr_i2c_val); | 1258 | video_device_create_file(v4ldev, &class_device_attr_i2c_val); |
1255 | } | 1259 | } |
@@ -1312,7 +1316,7 @@ static int sn9c102_set_scale(struct sn9c102_device* cam, u8 scale) | |||
1312 | 1316 | ||
1313 | static int sn9c102_set_crop(struct sn9c102_device* cam, struct v4l2_rect* rect) | 1317 | static int sn9c102_set_crop(struct sn9c102_device* cam, struct v4l2_rect* rect) |
1314 | { | 1318 | { |
1315 | struct sn9c102_sensor* s = cam->sensor; | 1319 | struct sn9c102_sensor* s = &cam->sensor; |
1316 | u8 h_start = (u8)(rect->left - s->cropcap.bounds.left), | 1320 | u8 h_start = (u8)(rect->left - s->cropcap.bounds.left), |
1317 | v_start = (u8)(rect->top - s->cropcap.bounds.top), | 1321 | v_start = (u8)(rect->top - s->cropcap.bounds.top), |
1318 | h_size = (u8)(rect->width / 16), | 1322 | h_size = (u8)(rect->width / 16), |
@@ -1335,7 +1339,7 @@ static int sn9c102_set_crop(struct sn9c102_device* cam, struct v4l2_rect* rect) | |||
1335 | 1339 | ||
1336 | static int sn9c102_init(struct sn9c102_device* cam) | 1340 | static int sn9c102_init(struct sn9c102_device* cam) |
1337 | { | 1341 | { |
1338 | struct sn9c102_sensor* s = cam->sensor; | 1342 | struct sn9c102_sensor* s = &cam->sensor; |
1339 | struct v4l2_control ctrl; | 1343 | struct v4l2_control ctrl; |
1340 | struct v4l2_queryctrl *qctrl; | 1344 | struct v4l2_queryctrl *qctrl; |
1341 | struct v4l2_rect* rect; | 1345 | struct v4l2_rect* rect; |
@@ -1404,7 +1408,7 @@ static int sn9c102_init(struct sn9c102_device* cam) | |||
1404 | } | 1408 | } |
1405 | 1409 | ||
1406 | if (!(cam->state & DEV_INITIALIZED)) { | 1410 | if (!(cam->state & DEV_INITIALIZED)) { |
1407 | init_MUTEX(&cam->fileop_sem); | 1411 | mutex_init(&cam->fileop_mutex); |
1408 | spin_lock_init(&cam->queue_lock); | 1412 | spin_lock_init(&cam->queue_lock); |
1409 | init_waitqueue_head(&cam->wait_frame); | 1413 | init_waitqueue_head(&cam->wait_frame); |
1410 | init_waitqueue_head(&cam->wait_stream); | 1414 | init_waitqueue_head(&cam->wait_stream); |
@@ -1422,13 +1426,15 @@ static int sn9c102_init(struct sn9c102_device* cam) | |||
1422 | 1426 | ||
1423 | static void sn9c102_release_resources(struct sn9c102_device* cam) | 1427 | static void sn9c102_release_resources(struct sn9c102_device* cam) |
1424 | { | 1428 | { |
1425 | down(&sn9c102_sysfs_lock); | 1429 | mutex_lock(&sn9c102_sysfs_lock); |
1426 | 1430 | ||
1427 | DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->minor); | 1431 | DBG(2, "V4L2 device /dev/video%d deregistered", cam->v4ldev->minor); |
1428 | video_set_drvdata(cam->v4ldev, NULL); | 1432 | video_set_drvdata(cam->v4ldev, NULL); |
1429 | video_unregister_device(cam->v4ldev); | 1433 | video_unregister_device(cam->v4ldev); |
1430 | 1434 | ||
1431 | up(&sn9c102_sysfs_lock); | 1435 | usb_put_dev(cam->usbdev); |
1436 | |||
1437 | mutex_unlock(&sn9c102_sysfs_lock); | ||
1432 | 1438 | ||
1433 | kfree(cam->control_buffer); | 1439 | kfree(cam->control_buffer); |
1434 | } | 1440 | } |
@@ -1449,7 +1455,7 @@ static int sn9c102_open(struct inode* inode, struct file* filp) | |||
1449 | 1455 | ||
1450 | cam = video_get_drvdata(video_devdata(filp)); | 1456 | cam = video_get_drvdata(video_devdata(filp)); |
1451 | 1457 | ||
1452 | if (down_interruptible(&cam->dev_sem)) { | 1458 | if (mutex_lock_interruptible(&cam->dev_mutex)) { |
1453 | up_read(&sn9c102_disconnect); | 1459 | up_read(&sn9c102_disconnect); |
1454 | return -ERESTARTSYS; | 1460 | return -ERESTARTSYS; |
1455 | } | 1461 | } |
@@ -1461,7 +1467,7 @@ static int sn9c102_open(struct inode* inode, struct file* filp) | |||
1461 | err = -EWOULDBLOCK; | 1467 | err = -EWOULDBLOCK; |
1462 | goto out; | 1468 | goto out; |
1463 | } | 1469 | } |
1464 | up(&cam->dev_sem); | 1470 | mutex_unlock(&cam->dev_mutex); |
1465 | err = wait_event_interruptible_exclusive(cam->open, | 1471 | err = wait_event_interruptible_exclusive(cam->open, |
1466 | cam->state & DEV_DISCONNECTED | 1472 | cam->state & DEV_DISCONNECTED |
1467 | || !cam->users); | 1473 | || !cam->users); |
@@ -1473,7 +1479,7 @@ static int sn9c102_open(struct inode* inode, struct file* filp) | |||
1473 | up_read(&sn9c102_disconnect); | 1479 | up_read(&sn9c102_disconnect); |
1474 | return -ENODEV; | 1480 | return -ENODEV; |
1475 | } | 1481 | } |
1476 | down(&cam->dev_sem); | 1482 | mutex_lock(&cam->dev_mutex); |
1477 | } | 1483 | } |
1478 | 1484 | ||
1479 | 1485 | ||
@@ -1501,7 +1507,7 @@ static int sn9c102_open(struct inode* inode, struct file* filp) | |||
1501 | DBG(3, "Video device /dev/video%d is open", cam->v4ldev->minor); | 1507 | DBG(3, "Video device /dev/video%d is open", cam->v4ldev->minor); |
1502 | 1508 | ||
1503 | out: | 1509 | out: |
1504 | up(&cam->dev_sem); | 1510 | mutex_unlock(&cam->dev_mutex); |
1505 | up_read(&sn9c102_disconnect); | 1511 | up_read(&sn9c102_disconnect); |
1506 | return err; | 1512 | return err; |
1507 | } | 1513 | } |
@@ -1511,7 +1517,7 @@ static int sn9c102_release(struct inode* inode, struct file* filp) | |||
1511 | { | 1517 | { |
1512 | struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); | 1518 | struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); |
1513 | 1519 | ||
1514 | down(&cam->dev_sem); /* prevent disconnect() to be called */ | 1520 | mutex_lock(&cam->dev_mutex); /* prevent disconnect() to be called */ |
1515 | 1521 | ||
1516 | sn9c102_stop_transfer(cam); | 1522 | sn9c102_stop_transfer(cam); |
1517 | 1523 | ||
@@ -1519,7 +1525,7 @@ static int sn9c102_release(struct inode* inode, struct file* filp) | |||
1519 | 1525 | ||
1520 | if (cam->state & DEV_DISCONNECTED) { | 1526 | if (cam->state & DEV_DISCONNECTED) { |
1521 | sn9c102_release_resources(cam); | 1527 | sn9c102_release_resources(cam); |
1522 | up(&cam->dev_sem); | 1528 | mutex_unlock(&cam->dev_mutex); |
1523 | kfree(cam); | 1529 | kfree(cam); |
1524 | return 0; | 1530 | return 0; |
1525 | } | 1531 | } |
@@ -1529,7 +1535,7 @@ static int sn9c102_release(struct inode* inode, struct file* filp) | |||
1529 | 1535 | ||
1530 | DBG(3, "Video device /dev/video%d closed", cam->v4ldev->minor); | 1536 | DBG(3, "Video device /dev/video%d closed", cam->v4ldev->minor); |
1531 | 1537 | ||
1532 | up(&cam->dev_sem); | 1538 | mutex_unlock(&cam->dev_mutex); |
1533 | 1539 | ||
1534 | return 0; | 1540 | return 0; |
1535 | } | 1541 | } |
@@ -1541,35 +1547,36 @@ sn9c102_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos) | |||
1541 | struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); | 1547 | struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); |
1542 | struct sn9c102_frame_t* f, * i; | 1548 | struct sn9c102_frame_t* f, * i; |
1543 | unsigned long lock_flags; | 1549 | unsigned long lock_flags; |
1550 | long timeout; | ||
1544 | int err = 0; | 1551 | int err = 0; |
1545 | 1552 | ||
1546 | if (down_interruptible(&cam->fileop_sem)) | 1553 | if (mutex_lock_interruptible(&cam->fileop_mutex)) |
1547 | return -ERESTARTSYS; | 1554 | return -ERESTARTSYS; |
1548 | 1555 | ||
1549 | if (cam->state & DEV_DISCONNECTED) { | 1556 | if (cam->state & DEV_DISCONNECTED) { |
1550 | DBG(1, "Device not present"); | 1557 | DBG(1, "Device not present"); |
1551 | up(&cam->fileop_sem); | 1558 | mutex_unlock(&cam->fileop_mutex); |
1552 | return -ENODEV; | 1559 | return -ENODEV; |
1553 | } | 1560 | } |
1554 | 1561 | ||
1555 | if (cam->state & DEV_MISCONFIGURED) { | 1562 | if (cam->state & DEV_MISCONFIGURED) { |
1556 | DBG(1, "The camera is misconfigured. Close and open it " | 1563 | DBG(1, "The camera is misconfigured. Close and open it " |
1557 | "again."); | 1564 | "again."); |
1558 | up(&cam->fileop_sem); | 1565 | mutex_unlock(&cam->fileop_mutex); |
1559 | return -EIO; | 1566 | return -EIO; |
1560 | } | 1567 | } |
1561 | 1568 | ||
1562 | if (cam->io == IO_MMAP) { | 1569 | if (cam->io == IO_MMAP) { |
1563 | DBG(3, "Close and open the device again to choose " | 1570 | DBG(3, "Close and open the device again to choose " |
1564 | "the read method"); | 1571 | "the read method"); |
1565 | up(&cam->fileop_sem); | 1572 | mutex_unlock(&cam->fileop_mutex); |
1566 | return -EINVAL; | 1573 | return -EINVAL; |
1567 | } | 1574 | } |
1568 | 1575 | ||
1569 | if (cam->io == IO_NONE) { | 1576 | if (cam->io == IO_NONE) { |
1570 | if (!sn9c102_request_buffers(cam,cam->nreadbuffers, IO_READ)) { | 1577 | if (!sn9c102_request_buffers(cam,cam->nreadbuffers, IO_READ)) { |
1571 | DBG(1, "read() failed, not enough memory"); | 1578 | DBG(1, "read() failed, not enough memory"); |
1572 | up(&cam->fileop_sem); | 1579 | mutex_unlock(&cam->fileop_mutex); |
1573 | return -ENOMEM; | 1580 | return -ENOMEM; |
1574 | } | 1581 | } |
1575 | cam->io = IO_READ; | 1582 | cam->io = IO_READ; |
@@ -1583,30 +1590,32 @@ sn9c102_read(struct file* filp, char __user * buf, size_t count, loff_t* f_pos) | |||
1583 | } | 1590 | } |
1584 | 1591 | ||
1585 | if (!count) { | 1592 | if (!count) { |
1586 | up(&cam->fileop_sem); | 1593 | mutex_unlock(&cam->fileop_mutex); |
1587 | return 0; | 1594 | return 0; |
1588 | } | 1595 | } |
1589 | 1596 | ||
1590 | if (list_empty(&cam->outqueue)) { | 1597 | if (list_empty(&cam->outqueue)) { |
1591 | if (filp->f_flags & O_NONBLOCK) { | 1598 | if (filp->f_flags & O_NONBLOCK) { |
1592 | up(&cam->fileop_sem); | 1599 | mutex_unlock(&cam->fileop_mutex); |
1593 | return -EAGAIN; | 1600 | return -EAGAIN; |
1594 | } | 1601 | } |
1595 | err = wait_event_interruptible | 1602 | timeout = wait_event_interruptible_timeout |
1596 | ( cam->wait_frame, | 1603 | ( cam->wait_frame, |
1597 | (!list_empty(&cam->outqueue)) || | 1604 | (!list_empty(&cam->outqueue)) || |
1598 | (cam->state & DEV_DISCONNECTED) || | 1605 | (cam->state & DEV_DISCONNECTED) || |
1599 | (cam->state & DEV_MISCONFIGURED) ); | 1606 | (cam->state & DEV_MISCONFIGURED), |
1600 | if (err) { | 1607 | cam->module_param.frame_timeout * |
1601 | up(&cam->fileop_sem); | 1608 | 1000 * msecs_to_jiffies(1) ); |
1602 | return err; | 1609 | if (timeout < 0) { |
1610 | mutex_unlock(&cam->fileop_mutex); | ||
1611 | return timeout; | ||
1603 | } | 1612 | } |
1604 | if (cam->state & DEV_DISCONNECTED) { | 1613 | if (cam->state & DEV_DISCONNECTED) { |
1605 | up(&cam->fileop_sem); | 1614 | mutex_unlock(&cam->fileop_mutex); |
1606 | return -ENODEV; | 1615 | return -ENODEV; |
1607 | } | 1616 | } |
1608 | if (cam->state & DEV_MISCONFIGURED) { | 1617 | if (!timeout || (cam->state & DEV_MISCONFIGURED)) { |
1609 | up(&cam->fileop_sem); | 1618 | mutex_unlock(&cam->fileop_mutex); |
1610 | return -EIO; | 1619 | return -EIO; |
1611 | } | 1620 | } |
1612 | } | 1621 | } |
@@ -1634,7 +1643,7 @@ exit: | |||
1634 | PDBGG("Frame #%lu, bytes read: %zu", | 1643 | PDBGG("Frame #%lu, bytes read: %zu", |
1635 | (unsigned long)f->buf.index, count); | 1644 | (unsigned long)f->buf.index, count); |
1636 | 1645 | ||
1637 | up(&cam->fileop_sem); | 1646 | mutex_unlock(&cam->fileop_mutex); |
1638 | 1647 | ||
1639 | return count; | 1648 | return count; |
1640 | } | 1649 | } |
@@ -1647,7 +1656,7 @@ static unsigned int sn9c102_poll(struct file *filp, poll_table *wait) | |||
1647 | unsigned long lock_flags; | 1656 | unsigned long lock_flags; |
1648 | unsigned int mask = 0; | 1657 | unsigned int mask = 0; |
1649 | 1658 | ||
1650 | if (down_interruptible(&cam->fileop_sem)) | 1659 | if (mutex_lock_interruptible(&cam->fileop_mutex)) |
1651 | return POLLERR; | 1660 | return POLLERR; |
1652 | 1661 | ||
1653 | if (cam->state & DEV_DISCONNECTED) { | 1662 | if (cam->state & DEV_DISCONNECTED) { |
@@ -1685,12 +1694,12 @@ static unsigned int sn9c102_poll(struct file *filp, poll_table *wait) | |||
1685 | if (!list_empty(&cam->outqueue)) | 1694 | if (!list_empty(&cam->outqueue)) |
1686 | mask |= POLLIN | POLLRDNORM; | 1695 | mask |= POLLIN | POLLRDNORM; |
1687 | 1696 | ||
1688 | up(&cam->fileop_sem); | 1697 | mutex_unlock(&cam->fileop_mutex); |
1689 | 1698 | ||
1690 | return mask; | 1699 | return mask; |
1691 | 1700 | ||
1692 | error: | 1701 | error: |
1693 | up(&cam->fileop_sem); | 1702 | mutex_unlock(&cam->fileop_mutex); |
1694 | return POLLERR; | 1703 | return POLLERR; |
1695 | } | 1704 | } |
1696 | 1705 | ||
@@ -1724,25 +1733,25 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma) | |||
1724 | void *pos; | 1733 | void *pos; |
1725 | u32 i; | 1734 | u32 i; |
1726 | 1735 | ||
1727 | if (down_interruptible(&cam->fileop_sem)) | 1736 | if (mutex_lock_interruptible(&cam->fileop_mutex)) |
1728 | return -ERESTARTSYS; | 1737 | return -ERESTARTSYS; |
1729 | 1738 | ||
1730 | if (cam->state & DEV_DISCONNECTED) { | 1739 | if (cam->state & DEV_DISCONNECTED) { |
1731 | DBG(1, "Device not present"); | 1740 | DBG(1, "Device not present"); |
1732 | up(&cam->fileop_sem); | 1741 | mutex_unlock(&cam->fileop_mutex); |
1733 | return -ENODEV; | 1742 | return -ENODEV; |
1734 | } | 1743 | } |
1735 | 1744 | ||
1736 | if (cam->state & DEV_MISCONFIGURED) { | 1745 | if (cam->state & DEV_MISCONFIGURED) { |
1737 | DBG(1, "The camera is misconfigured. Close and open it " | 1746 | DBG(1, "The camera is misconfigured. Close and open it " |
1738 | "again."); | 1747 | "again."); |
1739 | up(&cam->fileop_sem); | 1748 | mutex_unlock(&cam->fileop_mutex); |
1740 | return -EIO; | 1749 | return -EIO; |
1741 | } | 1750 | } |
1742 | 1751 | ||
1743 | if (cam->io != IO_MMAP || !(vma->vm_flags & VM_WRITE) || | 1752 | if (cam->io != IO_MMAP || !(vma->vm_flags & VM_WRITE) || |
1744 | size != PAGE_ALIGN(cam->frame[0].buf.length)) { | 1753 | size != PAGE_ALIGN(cam->frame[0].buf.length)) { |
1745 | up(&cam->fileop_sem); | 1754 | mutex_unlock(&cam->fileop_mutex); |
1746 | return -EINVAL; | 1755 | return -EINVAL; |
1747 | } | 1756 | } |
1748 | 1757 | ||
@@ -1751,7 +1760,7 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma) | |||
1751 | break; | 1760 | break; |
1752 | } | 1761 | } |
1753 | if (i == cam->nbuffers) { | 1762 | if (i == cam->nbuffers) { |
1754 | up(&cam->fileop_sem); | 1763 | mutex_unlock(&cam->fileop_mutex); |
1755 | return -EINVAL; | 1764 | return -EINVAL; |
1756 | } | 1765 | } |
1757 | 1766 | ||
@@ -1761,7 +1770,7 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma) | |||
1761 | pos = cam->frame[i].bufmem; | 1770 | pos = cam->frame[i].bufmem; |
1762 | while (size > 0) { /* size is page-aligned */ | 1771 | while (size > 0) { /* size is page-aligned */ |
1763 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { | 1772 | if (vm_insert_page(vma, start, vmalloc_to_page(pos))) { |
1764 | up(&cam->fileop_sem); | 1773 | mutex_unlock(&cam->fileop_mutex); |
1765 | return -EAGAIN; | 1774 | return -EAGAIN; |
1766 | } | 1775 | } |
1767 | start += PAGE_SIZE; | 1776 | start += PAGE_SIZE; |
@@ -1774,7 +1783,7 @@ static int sn9c102_mmap(struct file* filp, struct vm_area_struct *vma) | |||
1774 | 1783 | ||
1775 | sn9c102_vm_open(vma); | 1784 | sn9c102_vm_open(vma); |
1776 | 1785 | ||
1777 | up(&cam->fileop_sem); | 1786 | mutex_unlock(&cam->fileop_mutex); |
1778 | 1787 | ||
1779 | return 0; | 1788 | return 0; |
1780 | } | 1789 | } |
@@ -1816,6 +1825,7 @@ sn9c102_vidioc_enuminput(struct sn9c102_device* cam, void __user * arg) | |||
1816 | 1825 | ||
1817 | memset(&i, 0, sizeof(i)); | 1826 | memset(&i, 0, sizeof(i)); |
1818 | strcpy(i.name, "Camera"); | 1827 | strcpy(i.name, "Camera"); |
1828 | i.type = V4L2_INPUT_TYPE_CAMERA; | ||
1819 | 1829 | ||
1820 | if (copy_to_user(arg, &i, sizeof(i))) | 1830 | if (copy_to_user(arg, &i, sizeof(i))) |
1821 | return -EFAULT; | 1831 | return -EFAULT; |
@@ -1825,7 +1835,19 @@ sn9c102_vidioc_enuminput(struct sn9c102_device* cam, void __user * arg) | |||
1825 | 1835 | ||
1826 | 1836 | ||
1827 | static int | 1837 | static int |
1828 | sn9c102_vidioc_gs_input(struct sn9c102_device* cam, void __user * arg) | 1838 | sn9c102_vidioc_g_input(struct sn9c102_device* cam, void __user * arg) |
1839 | { | ||
1840 | int index = 0; | ||
1841 | |||
1842 | if (copy_to_user(arg, &index, sizeof(index))) | ||
1843 | return -EFAULT; | ||
1844 | |||
1845 | return 0; | ||
1846 | } | ||
1847 | |||
1848 | |||
1849 | static int | ||
1850 | sn9c102_vidioc_s_input(struct sn9c102_device* cam, void __user * arg) | ||
1829 | { | 1851 | { |
1830 | int index; | 1852 | int index; |
1831 | 1853 | ||
@@ -1842,7 +1864,7 @@ sn9c102_vidioc_gs_input(struct sn9c102_device* cam, void __user * arg) | |||
1842 | static int | 1864 | static int |
1843 | sn9c102_vidioc_query_ctrl(struct sn9c102_device* cam, void __user * arg) | 1865 | sn9c102_vidioc_query_ctrl(struct sn9c102_device* cam, void __user * arg) |
1844 | { | 1866 | { |
1845 | struct sn9c102_sensor* s = cam->sensor; | 1867 | struct sn9c102_sensor* s = &cam->sensor; |
1846 | struct v4l2_queryctrl qc; | 1868 | struct v4l2_queryctrl qc; |
1847 | u8 i; | 1869 | u8 i; |
1848 | 1870 | ||
@@ -1864,7 +1886,7 @@ sn9c102_vidioc_query_ctrl(struct sn9c102_device* cam, void __user * arg) | |||
1864 | static int | 1886 | static int |
1865 | sn9c102_vidioc_g_ctrl(struct sn9c102_device* cam, void __user * arg) | 1887 | sn9c102_vidioc_g_ctrl(struct sn9c102_device* cam, void __user * arg) |
1866 | { | 1888 | { |
1867 | struct sn9c102_sensor* s = cam->sensor; | 1889 | struct sn9c102_sensor* s = &cam->sensor; |
1868 | struct v4l2_control ctrl; | 1890 | struct v4l2_control ctrl; |
1869 | int err = 0; | 1891 | int err = 0; |
1870 | u8 i; | 1892 | u8 i; |
@@ -1896,7 +1918,7 @@ exit: | |||
1896 | static int | 1918 | static int |
1897 | sn9c102_vidioc_s_ctrl(struct sn9c102_device* cam, void __user * arg) | 1919 | sn9c102_vidioc_s_ctrl(struct sn9c102_device* cam, void __user * arg) |
1898 | { | 1920 | { |
1899 | struct sn9c102_sensor* s = cam->sensor; | 1921 | struct sn9c102_sensor* s = &cam->sensor; |
1900 | struct v4l2_control ctrl; | 1922 | struct v4l2_control ctrl; |
1901 | u8 i; | 1923 | u8 i; |
1902 | int err = 0; | 1924 | int err = 0; |
@@ -1909,6 +1931,8 @@ sn9c102_vidioc_s_ctrl(struct sn9c102_device* cam, void __user * arg) | |||
1909 | 1931 | ||
1910 | for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) | 1932 | for (i = 0; i < ARRAY_SIZE(s->qctrl); i++) |
1911 | if (ctrl.id == s->qctrl[i].id) { | 1933 | if (ctrl.id == s->qctrl[i].id) { |
1934 | if (s->qctrl[i].flags & V4L2_CTRL_FLAG_DISABLED) | ||
1935 | return -EINVAL; | ||
1912 | if (ctrl.value < s->qctrl[i].minimum || | 1936 | if (ctrl.value < s->qctrl[i].minimum || |
1913 | ctrl.value > s->qctrl[i].maximum) | 1937 | ctrl.value > s->qctrl[i].maximum) |
1914 | return -ERANGE; | 1938 | return -ERANGE; |
@@ -1931,7 +1955,7 @@ sn9c102_vidioc_s_ctrl(struct sn9c102_device* cam, void __user * arg) | |||
1931 | static int | 1955 | static int |
1932 | sn9c102_vidioc_cropcap(struct sn9c102_device* cam, void __user * arg) | 1956 | sn9c102_vidioc_cropcap(struct sn9c102_device* cam, void __user * arg) |
1933 | { | 1957 | { |
1934 | struct v4l2_cropcap* cc = &(cam->sensor->cropcap); | 1958 | struct v4l2_cropcap* cc = &(cam->sensor.cropcap); |
1935 | 1959 | ||
1936 | cc->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; | 1960 | cc->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; |
1937 | cc->pixelaspect.numerator = 1; | 1961 | cc->pixelaspect.numerator = 1; |
@@ -1947,7 +1971,7 @@ sn9c102_vidioc_cropcap(struct sn9c102_device* cam, void __user * arg) | |||
1947 | static int | 1971 | static int |
1948 | sn9c102_vidioc_g_crop(struct sn9c102_device* cam, void __user * arg) | 1972 | sn9c102_vidioc_g_crop(struct sn9c102_device* cam, void __user * arg) |
1949 | { | 1973 | { |
1950 | struct sn9c102_sensor* s = cam->sensor; | 1974 | struct sn9c102_sensor* s = &cam->sensor; |
1951 | struct v4l2_crop crop = { | 1975 | struct v4l2_crop crop = { |
1952 | .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, | 1976 | .type = V4L2_BUF_TYPE_VIDEO_CAPTURE, |
1953 | }; | 1977 | }; |
@@ -1964,7 +1988,7 @@ sn9c102_vidioc_g_crop(struct sn9c102_device* cam, void __user * arg) | |||
1964 | static int | 1988 | static int |
1965 | sn9c102_vidioc_s_crop(struct sn9c102_device* cam, void __user * arg) | 1989 | sn9c102_vidioc_s_crop(struct sn9c102_device* cam, void __user * arg) |
1966 | { | 1990 | { |
1967 | struct sn9c102_sensor* s = cam->sensor; | 1991 | struct sn9c102_sensor* s = &cam->sensor; |
1968 | struct v4l2_crop crop; | 1992 | struct v4l2_crop crop; |
1969 | struct v4l2_rect* rect; | 1993 | struct v4l2_rect* rect; |
1970 | struct v4l2_rect* bounds = &(s->cropcap.bounds); | 1994 | struct v4l2_rect* bounds = &(s->cropcap.bounds); |
@@ -2105,7 +2129,7 @@ static int | |||
2105 | sn9c102_vidioc_g_fmt(struct sn9c102_device* cam, void __user * arg) | 2129 | sn9c102_vidioc_g_fmt(struct sn9c102_device* cam, void __user * arg) |
2106 | { | 2130 | { |
2107 | struct v4l2_format format; | 2131 | struct v4l2_format format; |
2108 | struct v4l2_pix_format* pfmt = &(cam->sensor->pix_format); | 2132 | struct v4l2_pix_format* pfmt = &(cam->sensor.pix_format); |
2109 | 2133 | ||
2110 | if (copy_from_user(&format, arg, sizeof(format))) | 2134 | if (copy_from_user(&format, arg, sizeof(format))) |
2111 | return -EFAULT; | 2135 | return -EFAULT; |
@@ -2130,7 +2154,7 @@ static int | |||
2130 | sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd, | 2154 | sn9c102_vidioc_try_s_fmt(struct sn9c102_device* cam, unsigned int cmd, |
2131 | void __user * arg) | 2155 | void __user * arg) |
2132 | { | 2156 | { |
2133 | struct sn9c102_sensor* s = cam->sensor; | 2157 | struct sn9c102_sensor* s = &cam->sensor; |
2134 | struct v4l2_format format; | 2158 | struct v4l2_format format; |
2135 | struct v4l2_pix_format* pix; | 2159 | struct v4l2_pix_format* pix; |
2136 | struct v4l2_pix_format* pfmt = &(s->pix_format); | 2160 | struct v4l2_pix_format* pfmt = &(s->pix_format); |
@@ -2417,7 +2441,7 @@ sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp, | |||
2417 | struct v4l2_buffer b; | 2441 | struct v4l2_buffer b; |
2418 | struct sn9c102_frame_t *f; | 2442 | struct sn9c102_frame_t *f; |
2419 | unsigned long lock_flags; | 2443 | unsigned long lock_flags; |
2420 | int err = 0; | 2444 | long timeout; |
2421 | 2445 | ||
2422 | if (copy_from_user(&b, arg, sizeof(b))) | 2446 | if (copy_from_user(&b, arg, sizeof(b))) |
2423 | return -EFAULT; | 2447 | return -EFAULT; |
@@ -2430,16 +2454,18 @@ sn9c102_vidioc_dqbuf(struct sn9c102_device* cam, struct file* filp, | |||
2430 | return -EINVAL; | 2454 | return -EINVAL; |
2431 | if (filp->f_flags & O_NONBLOCK) | 2455 | if (filp->f_flags & O_NONBLOCK) |
2432 | return -EAGAIN; | 2456 | return -EAGAIN; |
2433 | err = wait_event_interruptible | 2457 | timeout = wait_event_interruptible_timeout |
2434 | ( cam->wait_frame, | 2458 | ( cam->wait_frame, |
2435 | (!list_empty(&cam->outqueue)) || | 2459 | (!list_empty(&cam->outqueue)) || |
2436 | (cam->state & DEV_DISCONNECTED) || | 2460 | (cam->state & DEV_DISCONNECTED) || |
2437 | (cam->state & DEV_MISCONFIGURED) ); | 2461 | (cam->state & DEV_MISCONFIGURED), |
2438 | if (err) | 2462 | cam->module_param.frame_timeout * |
2439 | return err; | 2463 | 1000 * msecs_to_jiffies(1) ); |
2464 | if (timeout < 0) | ||
2465 | return timeout; | ||
2440 | if (cam->state & DEV_DISCONNECTED) | 2466 | if (cam->state & DEV_DISCONNECTED) |
2441 | return -ENODEV; | 2467 | return -ENODEV; |
2442 | if (cam->state & DEV_MISCONFIGURED) | 2468 | if (!timeout || (cam->state & DEV_MISCONFIGURED)) |
2443 | return -EIO; | 2469 | return -EIO; |
2444 | } | 2470 | } |
2445 | 2471 | ||
@@ -2571,8 +2597,10 @@ static int sn9c102_ioctl_v4l2(struct inode* inode, struct file* filp, | |||
2571 | return sn9c102_vidioc_enuminput(cam, arg); | 2597 | return sn9c102_vidioc_enuminput(cam, arg); |
2572 | 2598 | ||
2573 | case VIDIOC_G_INPUT: | 2599 | case VIDIOC_G_INPUT: |
2600 | return sn9c102_vidioc_g_input(cam, arg); | ||
2601 | |||
2574 | case VIDIOC_S_INPUT: | 2602 | case VIDIOC_S_INPUT: |
2575 | return sn9c102_vidioc_gs_input(cam, arg); | 2603 | return sn9c102_vidioc_s_input(cam, arg); |
2576 | 2604 | ||
2577 | case VIDIOC_QUERYCTRL: | 2605 | case VIDIOC_QUERYCTRL: |
2578 | return sn9c102_vidioc_query_ctrl(cam, arg); | 2606 | return sn9c102_vidioc_query_ctrl(cam, arg); |
@@ -2655,19 +2683,19 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp, | |||
2655 | struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); | 2683 | struct sn9c102_device* cam = video_get_drvdata(video_devdata(filp)); |
2656 | int err = 0; | 2684 | int err = 0; |
2657 | 2685 | ||
2658 | if (down_interruptible(&cam->fileop_sem)) | 2686 | if (mutex_lock_interruptible(&cam->fileop_mutex)) |
2659 | return -ERESTARTSYS; | 2687 | return -ERESTARTSYS; |
2660 | 2688 | ||
2661 | if (cam->state & DEV_DISCONNECTED) { | 2689 | if (cam->state & DEV_DISCONNECTED) { |
2662 | DBG(1, "Device not present"); | 2690 | DBG(1, "Device not present"); |
2663 | up(&cam->fileop_sem); | 2691 | mutex_unlock(&cam->fileop_mutex); |
2664 | return -ENODEV; | 2692 | return -ENODEV; |
2665 | } | 2693 | } |
2666 | 2694 | ||
2667 | if (cam->state & DEV_MISCONFIGURED) { | 2695 | if (cam->state & DEV_MISCONFIGURED) { |
2668 | DBG(1, "The camera is misconfigured. Close and open it " | 2696 | DBG(1, "The camera is misconfigured. Close and open it " |
2669 | "again."); | 2697 | "again."); |
2670 | up(&cam->fileop_sem); | 2698 | mutex_unlock(&cam->fileop_mutex); |
2671 | return -EIO; | 2699 | return -EIO; |
2672 | } | 2700 | } |
2673 | 2701 | ||
@@ -2675,7 +2703,7 @@ static int sn9c102_ioctl(struct inode* inode, struct file* filp, | |||
2675 | 2703 | ||
2676 | err = sn9c102_ioctl_v4l2(inode, filp, cmd, (void __user *)arg); | 2704 | err = sn9c102_ioctl_v4l2(inode, filp, cmd, (void __user *)arg); |
2677 | 2705 | ||
2678 | up(&cam->fileop_sem); | 2706 | mutex_unlock(&cam->fileop_mutex); |
2679 | 2707 | ||
2680 | return err; | 2708 | return err; |
2681 | } | 2709 | } |
@@ -2722,7 +2750,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
2722 | goto fail; | 2750 | goto fail; |
2723 | } | 2751 | } |
2724 | 2752 | ||
2725 | init_MUTEX(&cam->dev_sem); | 2753 | mutex_init(&cam->dev_mutex); |
2726 | 2754 | ||
2727 | r = sn9c102_read_reg(cam, 0x00); | 2755 | r = sn9c102_read_reg(cam, 0x00); |
2728 | if (r < 0 || r != 0x10) { | 2756 | if (r < 0 || r != 0x10) { |
@@ -2752,10 +2780,10 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
2752 | break; | 2780 | break; |
2753 | } | 2781 | } |
2754 | 2782 | ||
2755 | if (!err && cam->sensor) { | 2783 | if (!err) { |
2756 | DBG(2, "%s image sensor detected", cam->sensor->name); | 2784 | DBG(2, "%s image sensor detected", cam->sensor.name); |
2757 | DBG(3, "Support for %s maintained by %s", | 2785 | DBG(3, "Support for %s maintained by %s", |
2758 | cam->sensor->name, cam->sensor->maintainer); | 2786 | cam->sensor.name, cam->sensor.maintainer); |
2759 | } else { | 2787 | } else { |
2760 | DBG(1, "No supported image sensor detected"); | 2788 | DBG(1, "No supported image sensor detected"); |
2761 | err = -ENODEV; | 2789 | err = -ENODEV; |
@@ -2776,7 +2804,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
2776 | cam->v4ldev->release = video_device_release; | 2804 | cam->v4ldev->release = video_device_release; |
2777 | video_set_drvdata(cam->v4ldev, cam); | 2805 | video_set_drvdata(cam->v4ldev, cam); |
2778 | 2806 | ||
2779 | down(&cam->dev_sem); | 2807 | mutex_lock(&cam->dev_mutex); |
2780 | 2808 | ||
2781 | err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, | 2809 | err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, |
2782 | video_nr[dev_nr]); | 2810 | video_nr[dev_nr]); |
@@ -2786,13 +2814,14 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
2786 | DBG(1, "Free /dev/videoX node not found"); | 2814 | DBG(1, "Free /dev/videoX node not found"); |
2787 | video_nr[dev_nr] = -1; | 2815 | video_nr[dev_nr] = -1; |
2788 | dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0; | 2816 | dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0; |
2789 | up(&cam->dev_sem); | 2817 | mutex_unlock(&cam->dev_mutex); |
2790 | goto fail; | 2818 | goto fail; |
2791 | } | 2819 | } |
2792 | 2820 | ||
2793 | DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor); | 2821 | DBG(2, "V4L2 device registered as /dev/video%d", cam->v4ldev->minor); |
2794 | 2822 | ||
2795 | cam->module_param.force_munmap = force_munmap[dev_nr]; | 2823 | cam->module_param.force_munmap = force_munmap[dev_nr]; |
2824 | cam->module_param.frame_timeout = frame_timeout[dev_nr]; | ||
2796 | 2825 | ||
2797 | dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0; | 2826 | dev_nr = (dev_nr < SN9C102_MAX_DEVICES-1) ? dev_nr+1 : 0; |
2798 | 2827 | ||
@@ -2803,7 +2832,7 @@ sn9c102_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
2803 | 2832 | ||
2804 | usb_set_intfdata(intf, cam); | 2833 | usb_set_intfdata(intf, cam); |
2805 | 2834 | ||
2806 | up(&cam->dev_sem); | 2835 | mutex_unlock(&cam->dev_mutex); |
2807 | 2836 | ||
2808 | return 0; | 2837 | return 0; |
2809 | 2838 | ||
@@ -2827,7 +2856,7 @@ static void sn9c102_usb_disconnect(struct usb_interface* intf) | |||
2827 | 2856 | ||
2828 | down_write(&sn9c102_disconnect); | 2857 | down_write(&sn9c102_disconnect); |
2829 | 2858 | ||
2830 | down(&cam->dev_sem); | 2859 | mutex_lock(&cam->dev_mutex); |
2831 | 2860 | ||
2832 | DBG(2, "Disconnecting %s...", cam->v4ldev->name); | 2861 | DBG(2, "Disconnecting %s...", cam->v4ldev->name); |
2833 | 2862 | ||
@@ -2841,13 +2870,14 @@ static void sn9c102_usb_disconnect(struct usb_interface* intf) | |||
2841 | sn9c102_stop_transfer(cam); | 2870 | sn9c102_stop_transfer(cam); |
2842 | cam->state |= DEV_DISCONNECTED; | 2871 | cam->state |= DEV_DISCONNECTED; |
2843 | wake_up_interruptible(&cam->wait_frame); | 2872 | wake_up_interruptible(&cam->wait_frame); |
2844 | wake_up_interruptible(&cam->wait_stream); | 2873 | wake_up(&cam->wait_stream); |
2874 | usb_get_dev(cam->usbdev); | ||
2845 | } else { | 2875 | } else { |
2846 | cam->state |= DEV_DISCONNECTED; | 2876 | cam->state |= DEV_DISCONNECTED; |
2847 | sn9c102_release_resources(cam); | 2877 | sn9c102_release_resources(cam); |
2848 | } | 2878 | } |
2849 | 2879 | ||
2850 | up(&cam->dev_sem); | 2880 | mutex_unlock(&cam->dev_mutex); |
2851 | 2881 | ||
2852 | if (!cam->users) | 2882 | if (!cam->users) |
2853 | kfree(cam); | 2883 | kfree(cam); |