diff options
Diffstat (limited to 'drivers/media/video/usbvision')
-rw-r--r-- | drivers/media/video/usbvision/usbvision-i2c.c | 15 | ||||
-rw-r--r-- | drivers/media/video/usbvision/usbvision-video.c | 8 | ||||
-rw-r--r-- | drivers/media/video/usbvision/usbvision.h | 1 |
3 files changed, 16 insertions, 8 deletions
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c index 42ba28785750..e3bbae26e3ce 100644 --- a/drivers/media/video/usbvision/usbvision-i2c.c +++ b/drivers/media/video/usbvision/usbvision-i2c.c @@ -211,6 +211,9 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision) 0x42 >> 1, 0x40 >> 1, /* SAA7114, SAA7115 and SAA7118 */ I2C_CLIENT_END }; + if (usbvision->registered_i2c) + return 0; + memcpy(&usbvision->i2c_adap, &i2c_adap_template, sizeof(struct i2c_adapter)); @@ -248,7 +251,7 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision) hit-and-miss. */ mdelay(10); v4l2_i2c_new_subdev(&usbvision->v4l2_dev, - &usbvision->i2c_adap, "saa7115", + &usbvision->i2c_adap, NULL, "saa7115_auto", 0, saa711x_addrs); break; } @@ -258,16 +261,18 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision) struct tuner_setup tun_setup; sd = v4l2_i2c_new_subdev(&usbvision->v4l2_dev, - &usbvision->i2c_adap, "tuner", + &usbvision->i2c_adap, NULL, "tuner", 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); /* depending on whether we found a demod or not, select the tuner type. */ type = sd ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; sd = v4l2_i2c_new_subdev(&usbvision->v4l2_dev, - &usbvision->i2c_adap, "tuner", + &usbvision->i2c_adap, NULL, "tuner", 0, v4l2_i2c_tuner_addrs(type)); + if (sd == NULL) + return -ENODEV; if (usbvision->tuner_type != -1) { tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; tun_setup.type = usbvision->tuner_type; @@ -275,14 +280,18 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision) call_all(usbvision, tuner, s_type_addr, &tun_setup); } } + usbvision->registered_i2c = 1; return 0; } int usbvision_i2c_unregister(struct usb_usbvision *usbvision) { + if (!usbvision->registered_i2c) + return 0; i2c_del_adapter(&(usbvision->i2c_adap)); + usbvision->registered_i2c = 0; PDEBUG(DBG_I2C,"i2c bus for %s unregistered", usbvision->i2c_adap.name); diff --git a/drivers/media/video/usbvision/usbvision-video.c b/drivers/media/video/usbvision/usbvision-video.c index c2690df33438..db6b828594f5 100644 --- a/drivers/media/video/usbvision/usbvision-video.c +++ b/drivers/media/video/usbvision/usbvision-video.c @@ -357,7 +357,7 @@ static int usbvision_v4l2_open(struct file *file) PDEBUG(DBG_IO, "open"); - lock_kernel(); + mutex_lock(&usbvision->lock); usbvision_reset_powerOffTimer(usbvision); if (usbvision->user) @@ -379,7 +379,6 @@ static int usbvision_v4l2_open(struct file *file) /* If so far no errors then we shall start the camera */ if (!errCode) { - mutex_lock(&usbvision->lock); if (usbvision->power == 0) { usbvision_power_on(usbvision); usbvision_i2c_register(usbvision); @@ -408,14 +407,13 @@ static int usbvision_v4l2_open(struct file *file) usbvision->initialized = 0; } } - mutex_unlock(&usbvision->lock); } /* prepare queues */ usbvision_empty_framequeues(usbvision); PDEBUG(DBG_IO, "success"); - unlock_kernel(); + mutex_unlock(&usbvision->lock); return errCode; } @@ -1645,8 +1643,8 @@ static int __devinit usbvision_probe(struct usb_interface *intf, usbvision->usb_bandwidth = 0; usbvision->user = 0; usbvision->streaming = Stream_Off; - usbvision_register_video(usbvision); usbvision_configure_video(usbvision); + usbvision_register_video(usbvision); mutex_unlock(&usbvision->lock); usbvision_create_sysfs(usbvision->vdev); diff --git a/drivers/media/video/usbvision/usbvision.h b/drivers/media/video/usbvision/usbvision.h index d1b3cc0cd87f..cc4e96c8cd6c 100644 --- a/drivers/media/video/usbvision/usbvision.h +++ b/drivers/media/video/usbvision/usbvision.h @@ -363,6 +363,7 @@ struct usb_usbvision { /* i2c Declaration Section*/ struct i2c_adapter i2c_adap; + int registered_i2c; struct urb *ctrlUrb; unsigned char ctrlUrbBuffer[8]; |