diff options
Diffstat (limited to 'drivers/media/video/usbvision/usbvision-i2c.c')
-rw-r--r-- | drivers/media/video/usbvision/usbvision-i2c.c | 15 |
1 files changed, 12 insertions, 3 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) | |||
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 | ||
@@ -248,7 +251,7 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision) | |||
248 | hit-and-miss. */ | 251 | hit-and-miss. */ |
249 | mdelay(10); | 252 | mdelay(10); |
250 | v4l2_i2c_new_subdev(&usbvision->v4l2_dev, | 253 | v4l2_i2c_new_subdev(&usbvision->v4l2_dev, |
251 | &usbvision->i2c_adap, "saa7115", | 254 | &usbvision->i2c_adap, NULL, |
252 | "saa7115_auto", 0, saa711x_addrs); | 255 | "saa7115_auto", 0, saa711x_addrs); |
253 | break; | 256 | break; |
254 | } | 257 | } |
@@ -258,16 +261,18 @@ int usbvision_i2c_register(struct usb_usbvision *usbvision) | |||
258 | struct tuner_setup tun_setup; | 261 | struct tuner_setup tun_setup; |
259 | 262 | ||
260 | sd = v4l2_i2c_new_subdev(&usbvision->v4l2_dev, | 263 | sd = v4l2_i2c_new_subdev(&usbvision->v4l2_dev, |
261 | &usbvision->i2c_adap, "tuner", | 264 | &usbvision->i2c_adap, NULL, |
262 | "tuner", 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); | 265 | "tuner", 0, v4l2_i2c_tuner_addrs(ADDRS_DEMOD)); |
263 | /* depending on whether we found a demod or not, select | 266 | /* depending on whether we found a demod or not, select |
264 | the tuner type. */ | 267 | the tuner type. */ |
265 | type = sd ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; | 268 | type = sd ? ADDRS_TV_WITH_DEMOD : ADDRS_TV; |
266 | 269 | ||
267 | sd = v4l2_i2c_new_subdev(&usbvision->v4l2_dev, | 270 | sd = v4l2_i2c_new_subdev(&usbvision->v4l2_dev, |
268 | &usbvision->i2c_adap, "tuner", | 271 | &usbvision->i2c_adap, NULL, |
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 | ||
282 | int usbvision_i2c_unregister(struct usb_usbvision *usbvision) | 288 | int 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 | ||