summaryrefslogtreecommitdiff
path: root/linux/drivers
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2009-05-02 15:12:50 +0200
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-05-02 15:12:50 +0200
commit79d2addf97397ee580b80f71343cf72b03da65a2 (patch)
tree3659369523acd92f172a36132f559078d2800a74 /linux/drivers
parent83d87c0c4e7849713db298cea21c964f85313f3b (diff)
downloadmediapointer-dvb-s2-79d2addf97397ee580b80f71343cf72b03da65a2.tar.gz
mediapointer-dvb-s2-79d2addf97397ee580b80f71343cf72b03da65a2.tar.bz2
v4l2: add v4l2_device_set_name()
From: Hans Verkuil <hverkuil@xs4all.nl> Add a utility function that can be used to setup the v4l2_device's name field in a standard manner. Priority: normal Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'linux/drivers')
-rw-r--r--linux/drivers/media/video/v4l2-device.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/linux/drivers/media/video/v4l2-device.c b/linux/drivers/media/video/v4l2-device.c
index 2cb81c210..143f69614 100644
--- a/linux/drivers/media/video/v4l2-device.c
+++ b/linux/drivers/media/video/v4l2-device.c
@@ -50,6 +50,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) {