diff options
-rw-r--r-- | drivers/media/video/w9968cf.c | 20 | ||||
-rw-r--r-- | drivers/media/video/w9968cf.h | 16 |
2 files changed, 21 insertions, 15 deletions
diff --git a/drivers/media/video/w9968cf.c b/drivers/media/video/w9968cf.c index 105a832531f2..3318be5688c9 100644 --- a/drivers/media/video/w9968cf.c +++ b/drivers/media/video/w9968cf.c | |||
@@ -3495,12 +3495,14 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
3495 | if (!cam) | 3495 | if (!cam) |
3496 | return -ENOMEM; | 3496 | return -ENOMEM; |
3497 | 3497 | ||
3498 | err = v4l2_device_register(&udev->dev, &cam->v4l2_dev); | ||
3499 | if (err) | ||
3500 | goto fail0; | ||
3501 | |||
3498 | mutex_init(&cam->dev_mutex); | 3502 | mutex_init(&cam->dev_mutex); |
3499 | mutex_lock(&cam->dev_mutex); | 3503 | mutex_lock(&cam->dev_mutex); |
3500 | 3504 | ||
3501 | cam->usbdev = udev; | 3505 | cam->usbdev = udev; |
3502 | /* NOTE: a local copy is used to avoid possible race conditions */ | ||
3503 | memcpy(&cam->dev, &udev->dev, sizeof(struct device)); | ||
3504 | 3506 | ||
3505 | DBG(2, "%s detected", symbolic(camlist, mod_id)) | 3507 | DBG(2, "%s detected", symbolic(camlist, mod_id)) |
3506 | 3508 | ||
@@ -3549,7 +3551,7 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
3549 | cam->v4ldev->minor = video_nr[dev_nr]; | 3551 | cam->v4ldev->minor = video_nr[dev_nr]; |
3550 | cam->v4ldev->release = video_device_release; | 3552 | cam->v4ldev->release = video_device_release; |
3551 | video_set_drvdata(cam->v4ldev, cam); | 3553 | video_set_drvdata(cam->v4ldev, cam); |
3552 | cam->v4ldev->parent = &cam->dev; | 3554 | cam->v4ldev->v4l2_dev = &cam->v4l2_dev; |
3553 | 3555 | ||
3554 | err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, | 3556 | err = video_register_device(cam->v4ldev, VFL_TYPE_GRABBER, |
3555 | video_nr[dev_nr]); | 3557 | video_nr[dev_nr]); |
@@ -3579,6 +3581,9 @@ w9968cf_usb_probe(struct usb_interface* intf, const struct usb_device_id* id) | |||
3579 | 3581 | ||
3580 | usb_set_intfdata(intf, cam); | 3582 | usb_set_intfdata(intf, cam); |
3581 | mutex_unlock(&cam->dev_mutex); | 3583 | mutex_unlock(&cam->dev_mutex); |
3584 | |||
3585 | if (ovmod_load) | ||
3586 | request_module("ovcamchip"); | ||
3582 | return 0; | 3587 | return 0; |
3583 | 3588 | ||
3584 | fail: /* Free unused memory */ | 3589 | fail: /* Free unused memory */ |
@@ -3587,6 +3592,8 @@ fail: /* Free unused memory */ | |||
3587 | if (cam->v4ldev) | 3592 | if (cam->v4ldev) |
3588 | video_device_release(cam->v4ldev); | 3593 | video_device_release(cam->v4ldev); |
3589 | mutex_unlock(&cam->dev_mutex); | 3594 | mutex_unlock(&cam->dev_mutex); |
3595 | v4l2_device_unregister(&cam->v4l2_dev); | ||
3596 | fail0: | ||
3590 | kfree(cam); | 3597 | kfree(cam); |
3591 | return err; | 3598 | return err; |
3592 | } | 3599 | } |
@@ -3622,8 +3629,10 @@ static void w9968cf_usb_disconnect(struct usb_interface* intf) | |||
3622 | 3629 | ||
3623 | mutex_unlock(&cam->dev_mutex); | 3630 | mutex_unlock(&cam->dev_mutex); |
3624 | 3631 | ||
3625 | if (!cam->users) | 3632 | if (!cam->users) { |
3633 | v4l2_device_unregister(&cam->v4l2_dev); | ||
3626 | kfree(cam); | 3634 | kfree(cam); |
3635 | } | ||
3627 | } | 3636 | } |
3628 | 3637 | ||
3629 | up_write(&w9968cf_disconnect); | 3638 | up_write(&w9968cf_disconnect); |
@@ -3650,9 +3659,6 @@ static int __init w9968cf_module_init(void) | |||
3650 | KDBG(2, W9968CF_MODULE_NAME" "W9968CF_MODULE_VERSION) | 3659 | KDBG(2, W9968CF_MODULE_NAME" "W9968CF_MODULE_VERSION) |
3651 | KDBG(3, W9968CF_MODULE_AUTHOR) | 3660 | KDBG(3, W9968CF_MODULE_AUTHOR) |
3652 | 3661 | ||
3653 | if (ovmod_load) | ||
3654 | request_module("ovcamchip"); | ||
3655 | |||
3656 | if ((err = usb_register(&w9968cf_usb_driver))) | 3662 | if ((err = usb_register(&w9968cf_usb_driver))) |
3657 | return err; | 3663 | return err; |
3658 | 3664 | ||
diff --git a/drivers/media/video/w9968cf.h b/drivers/media/video/w9968cf.h index 30032e15e23c..c59883552545 100644 --- a/drivers/media/video/w9968cf.h +++ b/drivers/media/video/w9968cf.h | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/rwsem.h> | 33 | #include <linux/rwsem.h> |
34 | #include <linux/mutex.h> | 34 | #include <linux/mutex.h> |
35 | 35 | ||
36 | #include <media/v4l2-device.h> | ||
36 | #include <media/ovcamchip.h> | 37 | #include <media/ovcamchip.h> |
37 | 38 | ||
38 | #include "w9968cf_vpp.h" | 39 | #include "w9968cf_vpp.h" |
@@ -195,10 +196,9 @@ enum w9968cf_vpp_flag { | |||
195 | 196 | ||
196 | /* Main device driver structure */ | 197 | /* Main device driver structure */ |
197 | struct w9968cf_device { | 198 | struct w9968cf_device { |
198 | struct device dev; /* device structure */ | ||
199 | |||
200 | enum w9968cf_model_id id; /* private device identifier */ | 199 | enum w9968cf_model_id id; /* private device identifier */ |
201 | 200 | ||
201 | struct v4l2_device v4l2_dev; | ||
202 | struct video_device* v4ldev; /* -> V4L structure */ | 202 | struct video_device* v4ldev; /* -> V4L structure */ |
203 | struct list_head v4llist; /* entry of the list of V4L cameras */ | 203 | struct list_head v4llist; /* entry of the list of V4L cameras */ |
204 | 204 | ||
@@ -291,14 +291,14 @@ struct w9968cf_device { | |||
291 | if ( ((specific_debug) && (debug == (level))) || \ | 291 | if ( ((specific_debug) && (debug == (level))) || \ |
292 | ((!specific_debug) && (debug >= (level))) ) { \ | 292 | ((!specific_debug) && (debug >= (level))) ) { \ |
293 | if ((level) == 1) \ | 293 | if ((level) == 1) \ |
294 | dev_err(&cam->dev, fmt "\n", ## args); \ | 294 | v4l2_err(&cam->v4l2_dev, fmt "\n", ## args); \ |
295 | else if ((level) == 2 || (level) == 3) \ | 295 | else if ((level) == 2 || (level) == 3) \ |
296 | dev_info(&cam->dev, fmt "\n", ## args); \ | 296 | v4l2_info(&cam->v4l2_dev, fmt "\n", ## args); \ |
297 | else if ((level) == 4) \ | 297 | else if ((level) == 4) \ |
298 | dev_warn(&cam->dev, fmt "\n", ## args); \ | 298 | v4l2_warn(&cam->v4l2_dev, fmt "\n", ## args); \ |
299 | else if ((level) >= 5) \ | 299 | else if ((level) >= 5) \ |
300 | dev_info(&cam->dev, "[%s:%d] " fmt "\n", \ | 300 | v4l2_info(&cam->v4l2_dev, "[%s:%d] " fmt "\n", \ |
301 | __func__, __LINE__ , ## args); \ | 301 | __func__, __LINE__ , ## args); \ |
302 | } \ | 302 | } \ |
303 | } | 303 | } |
304 | /* For generic kernel (not device specific) messages */ | 304 | /* For generic kernel (not device specific) messages */ |
@@ -321,7 +321,7 @@ struct w9968cf_device { | |||
321 | 321 | ||
322 | #undef PDBG | 322 | #undef PDBG |
323 | #define PDBG(fmt, args...) \ | 323 | #define PDBG(fmt, args...) \ |
324 | dev_info(&cam->dev, "[%s:%d] " fmt "\n", __func__, __LINE__ , ## args); | 324 | v4l2_info(&cam->v4l2_dev, "[%s:%d] " fmt "\n", __func__, __LINE__ , ## args); |
325 | 325 | ||
326 | #undef PDBGG | 326 | #undef PDBGG |
327 | #define PDBGG(fmt, args...) do {;} while(0); /* nothing: it's a placeholder */ | 327 | #define PDBGG(fmt, args...) do {;} while(0); /* nothing: it's a placeholder */ |