aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/em28xx/em28xx-video.c
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-10-14 20:31:54 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-10-14 20:31:54 -0400
commit6dc6472581f693b5fc95aebedf67b4960fb85cf0 (patch)
tree06a5a9a08519950575505273eabced331ed51405 /drivers/media/video/em28xx/em28xx-video.c
parentee673eaa72d8d185012b1027a05e25aba18c267f (diff)
parent8acd3a60bcca17c6d89c73cee3ad6057eb83ba1e (diff)
Merge commit 'origin'
Manual fixup of conflicts on: arch/powerpc/include/asm/dcr-regs.h drivers/net/ibm_newemac/core.h
Diffstat (limited to 'drivers/media/video/em28xx/em28xx-video.c')
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c60
1 files changed, 48 insertions, 12 deletions
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 49ab0629702e..c53649e5315b 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -513,10 +513,17 @@ static struct videobuf_queue_ops em28xx_video_qops = {
513 */ 513 */
514static int em28xx_config(struct em28xx *dev) 514static int em28xx_config(struct em28xx *dev)
515{ 515{
516 int retval;
516 517
517 /* Sets I2C speed to 100 KHz */ 518 /* Sets I2C speed to 100 KHz */
518 if (!dev->is_em2800) 519 if (!dev->is_em2800) {
519 em28xx_write_regs_req(dev, 0x00, 0x06, "\x40", 1); 520 retval = em28xx_write_regs_req(dev, 0x00, 0x06, "\x40", 1);
521 if (retval < 0) {
522 em28xx_errdev("%s: em28xx_write_regs_req failed! retval [%d]\n",
523 __func__, retval);
524 return retval;
525 }
526 }
520 527
521 /* enable vbi capturing */ 528 /* enable vbi capturing */
522 529
@@ -1512,6 +1519,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1512 struct em28xx_fh *fh; 1519 struct em28xx_fh *fh;
1513 enum v4l2_buf_type fh_type = 0; 1520 enum v4l2_buf_type fh_type = 0;
1514 1521
1522 lock_kernel();
1515 list_for_each_entry(h, &em28xx_devlist, devlist) { 1523 list_for_each_entry(h, &em28xx_devlist, devlist) {
1516 if (h->vdev->minor == minor) { 1524 if (h->vdev->minor == minor) {
1517 dev = h; 1525 dev = h;
@@ -1527,8 +1535,10 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1527 dev = h; 1535 dev = h;
1528 } 1536 }
1529 } 1537 }
1530 if (NULL == dev) 1538 if (NULL == dev) {
1539 unlock_kernel();
1531 return -ENODEV; 1540 return -ENODEV;
1541 }
1532 1542
1533 em28xx_videodbg("open minor=%d type=%s users=%d\n", 1543 em28xx_videodbg("open minor=%d type=%s users=%d\n",
1534 minor, v4l2_type_names[fh_type], dev->users); 1544 minor, v4l2_type_names[fh_type], dev->users);
@@ -1537,6 +1547,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1537 fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL); 1547 fh = kzalloc(sizeof(struct em28xx_fh), GFP_KERNEL);
1538 if (!fh) { 1548 if (!fh) {
1539 em28xx_errdev("em28xx-video.c: Out of memory?!\n"); 1549 em28xx_errdev("em28xx-video.c: Out of memory?!\n");
1550 unlock_kernel();
1540 return -ENOMEM; 1551 return -ENOMEM;
1541 } 1552 }
1542 mutex_lock(&dev->lock); 1553 mutex_lock(&dev->lock);
@@ -1573,6 +1584,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
1573 sizeof(struct em28xx_buffer), fh); 1584 sizeof(struct em28xx_buffer), fh);
1574 1585
1575 mutex_unlock(&dev->lock); 1586 mutex_unlock(&dev->lock);
1587 unlock_kernel();
1576 1588
1577 return errCode; 1589 return errCode;
1578} 1590}
@@ -1588,8 +1600,7 @@ static void em28xx_release_resources(struct em28xx *dev)
1588 /*FIXME: I2C IR should be disconnected */ 1600 /*FIXME: I2C IR should be disconnected */
1589 1601
1590 em28xx_info("V4L2 devices /dev/video%d and /dev/vbi%d deregistered\n", 1602 em28xx_info("V4L2 devices /dev/video%d and /dev/vbi%d deregistered\n",
1591 dev->vdev->minor-MINOR_VFL_TYPE_GRABBER_MIN, 1603 dev->vdev->num, dev->vbi_dev->num);
1592 dev->vbi_dev->minor-MINOR_VFL_TYPE_VBI_MIN);
1593 list_del(&dev->devlist); 1604 list_del(&dev->devlist);
1594 if (dev->sbutton_input_dev) 1605 if (dev->sbutton_input_dev)
1595 em28xx_deregister_snapshot_button(dev); 1606 em28xx_deregister_snapshot_button(dev);
@@ -1948,13 +1959,23 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1948 } 1959 }
1949 1960
1950 /* register i2c bus */ 1961 /* register i2c bus */
1951 em28xx_i2c_register(dev); 1962 errCode = em28xx_i2c_register(dev);
1963 if (errCode < 0) {
1964 em28xx_errdev("%s: em28xx_i2c_register - errCode [%d]!\n",
1965 __func__, errCode);
1966 return errCode;
1967 }
1952 1968
1953 /* Do board specific init and eeprom reading */ 1969 /* Do board specific init and eeprom reading */
1954 em28xx_card_setup(dev); 1970 em28xx_card_setup(dev);
1955 1971
1956 /* Configure audio */ 1972 /* Configure audio */
1957 em28xx_audio_analog_set(dev); 1973 errCode = em28xx_audio_analog_set(dev);
1974 if (errCode < 0) {
1975 em28xx_errdev("%s: em28xx_audio_analog_set - errCode [%d]!\n",
1976 __func__, errCode);
1977 return errCode;
1978 }
1958 1979
1959 /* configure the device */ 1980 /* configure the device */
1960 em28xx_config_i2c(dev); 1981 em28xx_config_i2c(dev);
@@ -1974,6 +1995,11 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
1974 dev->ctl_input = 2; 1995 dev->ctl_input = 2;
1975 1996
1976 errCode = em28xx_config(dev); 1997 errCode = em28xx_config(dev);
1998 if (errCode < 0) {
1999 em28xx_errdev("%s: em28xx_config - errCode [%d]!\n",
2000 __func__, errCode);
2001 return errCode;
2002 }
1977 2003
1978 list_add_tail(&dev->devlist, &em28xx_devlist); 2004 list_add_tail(&dev->devlist, &em28xx_devlist);
1979 2005
@@ -2026,17 +2052,27 @@ static int em28xx_init_dev(struct em28xx **devhandle, struct usb_device *udev,
2026 2052
2027 if (dev->has_msp34xx) { 2053 if (dev->has_msp34xx) {
2028 /* Send a reset to other chips via gpio */ 2054 /* Send a reset to other chips via gpio */
2029 em28xx_write_regs_req(dev, 0x00, 0x08, "\xf7", 1); 2055 errCode = em28xx_write_regs_req(dev, 0x00, 0x08, "\xf7", 1);
2056 if (errCode < 0) {
2057 em28xx_errdev("%s: em28xx_write_regs_req - msp34xx(1) failed! errCode [%d]\n",
2058 __func__, errCode);
2059 return errCode;
2060 }
2030 msleep(3); 2061 msleep(3);
2031 em28xx_write_regs_req(dev, 0x00, 0x08, "\xff", 1); 2062
2063 errCode = em28xx_write_regs_req(dev, 0x00, 0x08, "\xff", 1);
2064 if (errCode < 0) {
2065 em28xx_errdev("%s: em28xx_write_regs_req - msp34xx(2) failed! errCode [%d]\n",
2066 __func__, errCode);
2067 return errCode;
2068 }
2032 msleep(3); 2069 msleep(3);
2033 } 2070 }
2034 2071
2035 video_mux(dev, 0); 2072 video_mux(dev, 0);
2036 2073
2037 em28xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n", 2074 em28xx_info("V4L2 device registered as /dev/video%d and /dev/vbi%d\n",
2038 dev->vdev->minor-MINOR_VFL_TYPE_GRABBER_MIN, 2075 dev->vdev->num, dev->vbi_dev->num);
2039 dev->vbi_dev->minor-MINOR_VFL_TYPE_VBI_MIN);
2040 2076
2041 mutex_lock(&em28xx_extension_devlist_lock); 2077 mutex_lock(&em28xx_extension_devlist_lock);
2042 if (!list_empty(&em28xx_extension_devlist)) { 2078 if (!list_empty(&em28xx_extension_devlist)) {
@@ -2236,7 +2272,7 @@ static void em28xx_usb_disconnect(struct usb_interface *interface)
2236 em28xx_warn 2272 em28xx_warn
2237 ("device /dev/video%d is open! Deregistration and memory " 2273 ("device /dev/video%d is open! Deregistration and memory "
2238 "deallocation are deferred on close.\n", 2274 "deallocation are deferred on close.\n",
2239 dev->vdev->minor-MINOR_VFL_TYPE_GRABBER_MIN); 2275 dev->vdev->num);
2240 2276
2241 dev->state |= DEV_MISCONFIGURED; 2277 dev->state |= DEV_MISCONFIGURED;
2242 em28xx_uninit_isoc(dev); 2278 em28xx_uninit_isoc(dev);