aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/usbvision/usbvision-i2c.c
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 /drivers/media/video/usbvision/usbvision-i2c.c
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>
Diffstat (limited to 'drivers/media/video/usbvision/usbvision-i2c.c')
-rw-r--r--drivers/media/video/usbvision/usbvision-i2c.c9
1 files changed, 9 insertions, 0 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