diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-05-02 09:12:50 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-06-16 17:20:50 -0400 |
commit | 102e78136446faca7d7d241b628c5bd0e0d61d5d (patch) | |
tree | 17f26a5fc1aa4bab59d38a80c2684af21e37d53e /drivers | |
parent | 416a7aa88300601d6630736836f9798c4079bc16 (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')
-rw-r--r-- | drivers/media/video/v4l2-device.c | 16 |
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) | |||
49 | } | 49 | } |
50 | EXPORT_SYMBOL_GPL(v4l2_device_register); | 50 | EXPORT_SYMBOL_GPL(v4l2_device_register); |
51 | 51 | ||
52 | int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename, | ||
53 | atomic_t *instance) | ||
54 | { | ||
55 | int num = atomic_inc_return(instance) - 1; | ||
56 | int len = strlen(basename); | ||
57 | |||
58 | if (basename[len - 1] >= '0' && basename[len - 1] <= '9') | ||
59 | snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), | ||
60 | "%s-%d", basename, num); | ||
61 | else | ||
62 | snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), | ||
63 | "%s%d", basename, num); | ||
64 | return num; | ||
65 | } | ||
66 | EXPORT_SYMBOL_GPL(v4l2_device_set_name); | ||
67 | |||
52 | void v4l2_device_disconnect(struct v4l2_device *v4l2_dev) | 68 | void v4l2_device_disconnect(struct v4l2_device *v4l2_dev) |
53 | { | 69 | { |
54 | if (v4l2_dev->dev) { | 70 | if (v4l2_dev->dev) { |