diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-03-08 05:56:19 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:43:11 -0400 |
commit | 4e06839fc7221872d7868855c05659f08d1c9f3d (patch) | |
tree | e41d15ad4995e26bd1258827c03c55c9e828f625 /drivers/media/video/w9968cf.c | |
parent | 78175bf2c5e4beb0874aee27dcfce58c4c7d4fb4 (diff) |
V4L/DVB (10873): w9968cf: add v4l2_device.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/w9968cf.c')
-rw-r--r-- | drivers/media/video/w9968cf.c | 20 |
1 files changed, 13 insertions, 7 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 | ||