summaryrefslogtreecommitdiff
path: root/linux/drivers
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-09-06 13:54:00 +0300
committerHans Verkuil <hverkuil@xs4all.nl>2009-09-06 13:54:00 +0300
commit856378592a1b9be61e28092caf5e87446bae4694 (patch)
treee9d775f64e0893ce1c89aa61e59e0e3ca8a4cde8 /linux/drivers
parent026fbaf9a959eb5b7770b075a604999f704640cb (diff)
downloadmediapointer-dvb-s2-856378592a1b9be61e28092caf5e87446bae4694.tar.gz
mediapointer-dvb-s2-856378592a1b9be61e28092caf5e87446bae4694.tar.bz2
v4l: warn when desired devnodenr is in use & add _no_warn function
From: Hans Verkuil <hverkuil@xs4all.nl> 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. Priority: normal Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Diffstat (limited to 'linux/drivers')
-rw-r--r--linux/drivers/media/video/cx18/cx18-streams.c2
-rw-r--r--linux/drivers/media/video/ivtv/ivtv-streams.c2
-rw-r--r--linux/drivers/media/video/v4l2-dev.c20
3 files changed, 21 insertions, 3 deletions
diff --git a/linux/drivers/media/video/cx18/cx18-streams.c b/linux/drivers/media/video/cx18/cx18-streams.c
index 816d70cc2..dabe3fadc 100644
--- a/linux/drivers/media/video/cx18/cx18-streams.c
+++ b/linux/drivers/media/video/cx18/cx18-streams.c
@@ -250,7 +250,7 @@ static int cx18_reg_dev(struct cx18 *cx, int type)
video_set_drvdata(s->video_dev, s);
/* Register device. First try the desired minor, then any free one. */
- ret = video_register_device(s->video_dev, vfl_type, num);
+ ret = video_register_device_no_warn(s->video_dev, vfl_type, num);
if (ret < 0) {
CX18_ERR("Couldn't register v4l2 device for %s (device node number %d)\n",
s->name, num);
diff --git a/linux/drivers/media/video/ivtv/ivtv-streams.c b/linux/drivers/media/video/ivtv/ivtv-streams.c
index 234000352..67699e3f2 100644
--- a/linux/drivers/media/video/ivtv/ivtv-streams.c
+++ b/linux/drivers/media/video/ivtv/ivtv-streams.c
@@ -261,7 +261,7 @@ static int ivtv_reg_dev(struct ivtv *itv, int type)
video_set_drvdata(s->vdev, s);
/* Register device. First try the desired minor, then any free one. */
- if (video_register_device(s->vdev, vfl_type, num)) {
+ if (video_register_device_no_warn(s->vdev, vfl_type, num)) {
IVTV_ERR("Couldn't register v4l2 device for %s (device node number %d)\n",
s->name, num);
video_device_release(s->vdev);
diff --git a/linux/drivers/media/video/v4l2-dev.c b/linux/drivers/media/video/v4l2-dev.c
index 9a9fc1c83..a6d761dec 100644
--- a/linux/drivers/media/video/v4l2-dev.c
+++ b/linux/drivers/media/video/v4l2-dev.c
@@ -420,6 +420,8 @@ static int get_index(struct video_device *vdev)
* @type: type of device to register
* @nr: which device node number (0 == /dev/video0, 1 == /dev/video1, ...
* -1 == first free)
+ * @warn_if_nr_in_use: warn if the desired device node number
+ * was already in use and another number was chosen instead.
*
* The registration code assigns minor numbers and device node numbers
* based on the requested type and registers the new device node with
@@ -439,7 +441,8 @@ static int get_index(struct video_device *vdev)
*
* %VFL_TYPE_RADIO - A radio card
*/
-int video_register_device(struct video_device *vdev, int type, int nr)
+static int __video_register_device(struct video_device *vdev, int type, int nr,
+ int warn_if_nr_in_use)
{
int i = 0;
int ret;
@@ -615,6 +618,10 @@ int video_register_device(struct video_device *vdev, int type, int nr)
reference to the device goes away. */
vdev->dev.release = v4l2_device_release;
+ if (nr != -1 && nr != vdev->num && warn_if_nr_in_use)
+ printk(KERN_WARNING "%s: requested %s%d, got %s%d\n",
+ __func__, name_base, nr, name_base, vdev->num);
+
/* Part 5: Activate this minor. The char device can now be used. */
mutex_lock(&videodev_lock);
video_device[vdev->minor] = vdev;
@@ -631,8 +638,19 @@ cleanup:
vdev->minor = -1;
return ret;
}
+
+int video_register_device(struct video_device *vdev, int type, int nr)
+{
+ return __video_register_device(vdev, type, nr, 1);
+}
EXPORT_SYMBOL(video_register_device);
+int video_register_device_no_warn(struct video_device *vdev, int type, int nr)
+{
+ return __video_register_device(vdev, type, nr, 0);
+}
+EXPORT_SYMBOL(video_register_device_no_warn);
+
/**
* video_unregister_device - unregister a video4linux device
* @vdev: the device to unregister