V4L/DVB (13549): v4l: Add video_device_node_name function
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Fri, 27 Nov 2009 16:56:50 +0000 (13:56 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Wed, 16 Dec 2009 02:17:54 +0000 (00:17 -0200)
Many drivers access the device number (video_device::v4l2_devnode::num)
in order to print the video device node name. Add and use a helper
function to retrieve the video_device node name.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Documentation/video4linux/v4l2-framework.txt
drivers/media/video/v4l2-dev.c
include/media/v4l2-dev.h

index b806eda..74d677c 100644 (file)
@@ -561,6 +561,8 @@ video_device helper functions
 
 There are a few useful helper functions:
 
+- file/video_device private data
+
 You can set/get driver private data in the video_device struct using:
 
 void *video_get_drvdata(struct video_device *vdev);
@@ -575,8 +577,7 @@ struct video_device *video_devdata(struct file *file);
 
 returns the video_device belonging to the file struct.
 
-The final helper function combines video_get_drvdata with
-video_devdata:
+The video_drvdata function combines video_get_drvdata with video_devdata:
 
 void *video_drvdata(struct file *file);
 
@@ -584,6 +585,17 @@ You can go from a video_device struct to the v4l2_device struct using:
 
 struct v4l2_device *v4l2_dev = vdev->v4l2_dev;
 
+- Device node name
+
+The video_device node kernel name can be retrieved using
+
+const char *video_device_node_name(struct video_device *vdev);
+
+The name is used as a hint by userspace tools such as udev. The function
+should be used where possible instead of accessing the video_device::num and
+video_device::minor fields.
+
+
 video buffer helper functions
 -----------------------------
 
index 500cbe9..aa3e0f9 100644 (file)
@@ -551,8 +551,8 @@ static int __video_register_device(struct video_device *vdev, int type, int nr,
        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);
+               printk(KERN_WARNING "%s: requested %s%d, got %s\n", __func__,
+                       name_base, nr, video_device_node_name(vdev));
 
        /* Part 5: Activate this minor. The char device can now be used. */
        mutex_lock(&videodev_lock);
index 73c9867..9135f57 100644 (file)
@@ -141,6 +141,11 @@ static inline void *video_drvdata(struct file *file)
        return video_get_drvdata(video_devdata(file));
 }
 
+static inline const char *video_device_node_name(struct video_device *vdev)
+{
+       return dev_name(&vdev->dev);
+}
+
 static inline int video_is_unregistered(struct video_device *vdev)
 {
        return test_bit(V4L2_FL_UNREGISTERED, &vdev->flags);