summaryrefslogtreecommitdiff
path: root/drivers/media/video/v4l2-device.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-05-02 10:12:50 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-06-16 18:20:50 -0300
commit102e78136446faca7d7d241b628c5bd0e0d61d5d (patch)
tree17f26a5fc1aa4bab59d38a80c2684af21e37d53e /drivers/media/video/v4l2-device.c
parent416a7aa88300601d6630736836f9798c4079bc16 (diff)
V4L/DVB (11671): v4l2: add v4l2_device_set_name()
Add a utility function that can be used to setup the v4l2_device's name field in a standard manner. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/v4l2-device.c')
-rw-r--r--drivers/media/video/v4l2-device.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/media/video/v4l2-device.c b/drivers/media/video/v4l2-device.c
index 94aa485ade52..ffb425f7c24c 100644
--- a/drivers/media/video/v4l2-device.c
+++ b/drivers/media/video/v4l2-device.c
@@ -49,6 +49,22 @@ int v4l2_device_register(struct device *dev, struct v4l2_device *v4l2_dev)
}
EXPORT_SYMBOL_GPL(v4l2_device_register);
+int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
+ atomic_t *instance)
+{
+ int num = atomic_inc_return(instance) - 1;
+ int len = strlen(basename);
+
+ if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
+ snprintf(v4l2_dev->name, sizeof(v4l2_dev->name),
+ "%s-%d", basename, num);
+ else
+ snprintf(v4l2_dev->name, sizeof(v4l2_dev->name),
+ "%s%d", basename, num);
+ return num;
+}
+EXPORT_SYMBOL_GPL(v4l2_device_set_name);
+
void v4l2_device_disconnect(struct v4l2_device *v4l2_dev)
{
if (v4l2_dev->dev) {