aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2010-09-17 14:07:28 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2010-10-20 23:06:06 -0400
commit8403472f19fea7e7cec7899e998f38b899e59604 (patch)
treef23180ec9f6610bd3b416590beabc896798ec7fa
parent1f2052539666bd8b43ed26c9b1c3687628c49ecc (diff)
V4L/DVB: usbvision: remove BKL from usbvision
Removed the BKL from usbvision. There was an initialization bug as well where the i2c bus was registered twice. Although when the BKL was present no oops was generated, I did run into other i2c problems. Now that I protect against duplicate i2c registration that bug is now gone as well. But trying to disconnect the USB cable while someone is still using the device still leads to a crash. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/video/usbvision/usbvision-i2c.c9
-rw-r--r--drivers/media/video/usbvision/usbvision-video.c8
-rw-r--r--drivers/media/video/usbvision/usbvision.h1
3 files changed, 13 insertions, 5 deletions
diff --git a/drivers/media/video/usbvision/usbvision-i2c.c b/drivers/media/video/usbvision/usbvision-i2c.c
index 42ba28785750..a5fd2aa3646e 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)
211 0x42 >> 1, 0x40 >> 1, /* SAA7114, SAA7115 and SAA7118 */ 211 0x42 >> 1, 0x40 >> 1, /* SAA7114, SAA7115 and SAA7118 */
212 I2C_CLIENT_END }; 212 I2C_CLIENT_END };
213 213
214 if (usbvision->registered_i2c)
215 return 0;
216
214 memcpy(&usbvision->i2c_adap, &i2c_adap_template, 217 memcpy(&usbvision->i2c_adap, &i2c_adap_template,
215 sizeof(struct i2c_adapter)); 218 sizeof(struct i2c_adapter));
216 219
@@ -268,6 +271,8 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision)
268 &usbvision->i2c_adap, "tuner", 271 &usbvision->i2c_adap, "tuner",
269 "tuner", 0, v4l2_i2c_tuner_addrs(type)); 272 "tuner", 0, v4l2_i2c_tuner_addrs(type));
270 273
274 if (sd == NULL)
275 return -ENODEV;
271 if (usbvision->tuner_type != -1) { 276 if (usbvision->tuner_type != -1) {
272 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO; 277 tun_setup.mode_mask = T_ANALOG_TV | T_RADIO;
273 tun_setup.type = usbvision->tuner_type; 278 tun_setup.type = usbvision->tuner_type;
@@ -275,14 +280,18 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision)
275 call_all(usbvision, tuner, s_type_addr, &tun_setup); 280 call_all(usbvision, tuner, s_type_addr, &tun_setup);
276 } 281 }
277 } 282 }
283 usbvision->registered_i2c = 1;
278 284
279 return 0; 285 return 0;
280} 286}
281 287
282int usbvision_i2c_unregister(struct usb_usbvision *usbvision) 288int usbvision_i2c_unregister(struct usb_usbvision *usbvision)
283{ 289{
290 if (!usbvision->registered_i2c)
291 return 0;
284 292
285 i2c_del_adapter(&(usbvision->i2c_adap)); 293 i2c_del_adapter(&(usbvision->i2c_adap));
294 usbvision->registered_i2c = 0;
286 295
287 PDEBUG(DBG_I2C,"i2c bus for %s unregistered", usbvision->i2c_adap.name); 296 PDEBUG(DBG_I2C,"i2c bus for %s unregistered", usbvision->i2c_adap.name);
288 297
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)
357 357
358 PDEBUG(DBG_IO, "open"); 358 PDEBUG(DBG_IO, "open");
359 359
360 lock_kernel(); 360 mutex_lock(&usbvision->lock);
361 usbvision_reset_powerOffTimer(usbvision); 361 usbvision_reset_powerOffTimer(usbvision);
362 362
363 if (usbvision->user) 363 if (usbvision->user)
@@ -379,7 +379,6 @@ static int usbvision_v4l2_open(struct file *file)
379 379
380 /* If so far no errors then we shall start the camera */ 380 /* If so far no errors then we shall start the camera */
381 if (!errCode) { 381 if (!errCode) {
382 mutex_lock(&usbvision->lock);
383 if (usbvision->power == 0) { 382 if (usbvision->power == 0) {
384 usbvision_power_on(usbvision); 383 usbvision_power_on(usbvision);
385 usbvision_i2c_register(usbvision); 384 usbvision_i2c_register(usbvision);
@@ -408,14 +407,13 @@ static int usbvision_v4l2_open(struct file *file)
408 usbvision->initialized = 0; 407 usbvision->initialized = 0;
409 } 408 }
410 } 409 }
411 mutex_unlock(&usbvision->lock);
412 } 410 }
413 411
414 /* prepare queues */ 412 /* prepare queues */
415 usbvision_empty_framequeues(usbvision); 413 usbvision_empty_framequeues(usbvision);
416 414
417 PDEBUG(DBG_IO, "success"); 415 PDEBUG(DBG_IO, "success");
418 unlock_kernel(); 416 mutex_unlock(&usbvision->lock);
419 return errCode; 417 return errCode;
420} 418}
421 419
@@ -1645,8 +1643,8 @@ static int __devinit usbvision_probe(struct usb_interface *intf,
1645 usbvision->usb_bandwidth = 0; 1643 usbvision->usb_bandwidth = 0;
1646 usbvision->user = 0; 1644 usbvision->user = 0;
1647 usbvision->streaming = Stream_Off; 1645 usbvision->streaming = Stream_Off;
1648 usbvision_register_video(usbvision);
1649 usbvision_configure_video(usbvision); 1646 usbvision_configure_video(usbvision);
1647 usbvision_register_video(usbvision);
1650 mutex_unlock(&usbvision->lock); 1648 mutex_unlock(&usbvision->lock);
1651 1649
1652 usbvision_create_sysfs(usbvision->vdev); 1650 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 {
363 363
364 /* i2c Declaration Section*/ 364 /* i2c Declaration Section*/
365 struct i2c_adapter i2c_adap; 365 struct i2c_adapter i2c_adap;
366 int registered_i2c;
366 367
367 struct urb *ctrlUrb; 368 struct urb *ctrlUrb;
368 unsigned char ctrlUrbBuffer[8]; 369 unsigned char ctrlUrbBuffer[8];