diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-09-06 06:54:00 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-18 23:19:34 -0400 |
commit | 6b5270d21202fcf6ae16a6266fed83a30ccece7a (patch) | |
tree | 54036a74de819e7d6a63f7572ecf37b0a00ac94c /drivers/media/video/v4l2-dev.c | |
parent | 5062cb70c828bd7b2a8223390ae836c5baa250b9 (diff) |
V4L/DVB (12725): v4l: warn when desired devnodenr is in use & add _no_warn function
Warn when the desired device node number is already in use, except when
the new video_register_device_no_warn function is called since in some
use-cases that warning is not relevant.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/v4l2-dev.c')
-rw-r--r-- | drivers/media/video/v4l2-dev.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index 4715f08157bc..500cbe9891ac 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c | |||
@@ -382,6 +382,8 @@ static int get_index(struct video_device *vdev) | |||
382 | * @type: type of device to register | 382 | * @type: type of device to register |
383 | * @nr: which device node number (0 == /dev/video0, 1 == /dev/video1, ... | 383 | * @nr: which device node number (0 == /dev/video0, 1 == /dev/video1, ... |
384 | * -1 == first free) | 384 | * -1 == first free) |
385 | * @warn_if_nr_in_use: warn if the desired device node number | ||
386 | * was already in use and another number was chosen instead. | ||
385 | * | 387 | * |
386 | * The registration code assigns minor numbers and device node numbers | 388 | * The registration code assigns minor numbers and device node numbers |
387 | * based on the requested type and registers the new device node with | 389 | * based on the requested type and registers the new device node with |
@@ -401,7 +403,8 @@ static int get_index(struct video_device *vdev) | |||
401 | * | 403 | * |
402 | * %VFL_TYPE_RADIO - A radio card | 404 | * %VFL_TYPE_RADIO - A radio card |
403 | */ | 405 | */ |
404 | int video_register_device(struct video_device *vdev, int type, int nr) | 406 | static int __video_register_device(struct video_device *vdev, int type, int nr, |
407 | int warn_if_nr_in_use) | ||
405 | { | 408 | { |
406 | int i = 0; | 409 | int i = 0; |
407 | int ret; | 410 | int ret; |
@@ -547,6 +550,10 @@ int video_register_device(struct video_device *vdev, int type, int nr) | |||
547 | reference to the device goes away. */ | 550 | reference to the device goes away. */ |
548 | vdev->dev.release = v4l2_device_release; | 551 | vdev->dev.release = v4l2_device_release; |
549 | 552 | ||
553 | if (nr != -1 && nr != vdev->num && warn_if_nr_in_use) | ||
554 | printk(KERN_WARNING "%s: requested %s%d, got %s%d\n", | ||
555 | __func__, name_base, nr, name_base, vdev->num); | ||
556 | |||
550 | /* Part 5: Activate this minor. The char device can now be used. */ | 557 | /* Part 5: Activate this minor. The char device can now be used. */ |
551 | mutex_lock(&videodev_lock); | 558 | mutex_lock(&videodev_lock); |
552 | video_device[vdev->minor] = vdev; | 559 | video_device[vdev->minor] = vdev; |
@@ -563,8 +570,19 @@ cleanup: | |||
563 | vdev->minor = -1; | 570 | vdev->minor = -1; |
564 | return ret; | 571 | return ret; |
565 | } | 572 | } |
573 | |||
574 | int video_register_device(struct video_device *vdev, int type, int nr) | ||
575 | { | ||
576 | return __video_register_device(vdev, type, nr, 1); | ||
577 | } | ||
566 | EXPORT_SYMBOL(video_register_device); | 578 | EXPORT_SYMBOL(video_register_device); |
567 | 579 | ||
580 | int video_register_device_no_warn(struct video_device *vdev, int type, int nr) | ||
581 | { | ||
582 | return __video_register_device(vdev, type, nr, 0); | ||
583 | } | ||
584 | EXPORT_SYMBOL(video_register_device_no_warn); | ||
585 | |||
568 | /** | 586 | /** |
569 | * video_unregister_device - unregister a video4linux device | 587 | * video_unregister_device - unregister a video4linux device |
570 | * @vdev: the device to unregister | 588 | * @vdev: the device to unregister |