diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2008-08-23 06:48:38 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2008-10-12 07:36:54 -0400 |
commit | bfa8a273bb91078ea193ab94c717889928f3b925 (patch) | |
tree | 3be9718a35023adec6e87343dc1efce3e60778a8 /drivers | |
parent | 601e9444f249d219009ec05674268d90f6f1cdcb (diff) |
V4L/DVB (8787): v4l2-dev: cleanups and add video_drvdata helper function
Cleanup v4l2-dev.[ch], add/improve comments and add a new helper
function: video_drvdata() that can get the private driver data from
a file struct.
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-dev.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index ff219df4b72..1ec0a1a8fb7 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c | |||
@@ -42,6 +42,7 @@ static ssize_t show_index(struct device *cd, | |||
42 | struct device_attribute *attr, char *buf) | 42 | struct device_attribute *attr, char *buf) |
43 | { | 43 | { |
44 | struct video_device *vfd = container_of(cd, struct video_device, dev); | 44 | struct video_device *vfd = container_of(cd, struct video_device, dev); |
45 | |||
45 | return sprintf(buf, "%i\n", vfd->index); | 46 | return sprintf(buf, "%i\n", vfd->index); |
46 | } | 47 | } |
47 | 48 | ||
@@ -49,6 +50,7 @@ static ssize_t show_name(struct device *cd, | |||
49 | struct device_attribute *attr, char *buf) | 50 | struct device_attribute *attr, char *buf) |
50 | { | 51 | { |
51 | struct video_device *vfd = container_of(cd, struct video_device, dev); | 52 | struct video_device *vfd = container_of(cd, struct video_device, dev); |
53 | |||
52 | return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name); | 54 | return sprintf(buf, "%.*s\n", (int)sizeof(vfd->name), vfd->name); |
53 | } | 55 | } |
54 | 56 | ||
@@ -60,10 +62,7 @@ static struct device_attribute video_device_attrs[] = { | |||
60 | 62 | ||
61 | struct video_device *video_device_alloc(void) | 63 | struct video_device *video_device_alloc(void) |
62 | { | 64 | { |
63 | struct video_device *vfd; | 65 | return kzalloc(sizeof(struct video_device), GFP_KERNEL); |
64 | |||
65 | vfd = kzalloc(sizeof(*vfd), GFP_KERNEL); | ||
66 | return vfd; | ||
67 | } | 66 | } |
68 | EXPORT_SYMBOL(video_device_alloc); | 67 | EXPORT_SYMBOL(video_device_alloc); |
69 | 68 | ||
@@ -263,7 +262,7 @@ int video_register_device_index(struct video_device *vfd, int type, int nr, | |||
263 | 262 | ||
264 | /* pick a minor number */ | 263 | /* pick a minor number */ |
265 | mutex_lock(&videodev_lock); | 264 | mutex_lock(&videodev_lock); |
266 | if (nr >= 0 && nr < end-base) { | 265 | if (nr >= 0 && nr < end-base) { |
267 | /* use the one the driver asked for */ | 266 | /* use the one the driver asked for */ |
268 | i = base + nr; | 267 | i = base + nr; |
269 | if (NULL != video_device[i]) { | 268 | if (NULL != video_device[i]) { |
@@ -295,7 +294,7 @@ int video_register_device_index(struct video_device *vfd, int type, int nr, | |||
295 | } | 294 | } |
296 | 295 | ||
297 | /* sysfs class */ | 296 | /* sysfs class */ |
298 | memset(&vfd->dev, 0x00, sizeof(vfd->dev)); | 297 | memset(&vfd->dev, 0, sizeof(vfd->dev)); |
299 | vfd->dev.class = &video_class; | 298 | vfd->dev.class = &video_class; |
300 | vfd->dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor); | 299 | vfd->dev.devt = MKDEV(VIDEO_MAJOR, vfd->minor); |
301 | if (vfd->parent) | 300 | if (vfd->parent) |
@@ -312,8 +311,8 @@ int video_register_device_index(struct video_device *vfd, int type, int nr, | |||
312 | fail_minor: | 311 | fail_minor: |
313 | mutex_lock(&videodev_lock); | 312 | mutex_lock(&videodev_lock); |
314 | video_device[vfd->minor] = NULL; | 313 | video_device[vfd->minor] = NULL; |
315 | vfd->minor = -1; | ||
316 | mutex_unlock(&videodev_lock); | 314 | mutex_unlock(&videodev_lock); |
315 | vfd->minor = -1; | ||
317 | return ret; | 316 | return ret; |
318 | } | 317 | } |
319 | EXPORT_SYMBOL(video_register_device_index); | 318 | EXPORT_SYMBOL(video_register_device_index); |