diff options
author | Hans Verkuil <hverkuil@xs4all.nl> | 2009-06-19 10:32:56 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-09-18 23:19:26 -0400 |
commit | 7ae0cd9bc793e16d8d68df3c17c601732cc1d3c7 (patch) | |
tree | 6e95700b260955b91793bbc58a7d20c486e5d358 /drivers/media/video/v4l2-dev.c | |
parent | 53dacb15705901e14b03dcba27e40364fedd9d09 (diff) |
V4L/DVB (12541): v4l: remove video_register_device_index
video_register_device_index is never actually called, instead the
stream index number is always calculated automatically.
This patch removes this function and simplifies the internal get_index
function since that can now always just return the first free index.
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/v4l2-dev.c')
-rw-r--r-- | drivers/media/video/v4l2-dev.c | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c index a7f1b69a7dab..1219721894a1 100644 --- a/drivers/media/video/v4l2-dev.c +++ b/drivers/media/video/v4l2-dev.c | |||
@@ -299,32 +299,28 @@ static const struct file_operations v4l2_fops = { | |||
299 | }; | 299 | }; |
300 | 300 | ||
301 | /** | 301 | /** |
302 | * get_index - assign stream number based on parent device | 302 | * get_index - assign stream index number based on parent device |
303 | * @vdev: video_device to assign index number to, vdev->parent should be assigned | 303 | * @vdev: video_device to assign index number to, vdev->parent should be assigned |
304 | * @num: -1 if auto assign, requested number otherwise | ||
305 | * | 304 | * |
306 | * Note that when this is called the new device has not yet been registered | 305 | * Note that when this is called the new device has not yet been registered |
307 | * in the video_device array. | 306 | * in the video_device array, but it was able to obtain a minor number. |
308 | * | 307 | * |
309 | * Returns -ENFILE if num is already in use, a free index number if | 308 | * This means that we can always obtain a free stream index number since |
310 | * successful. | 309 | * the worst case scenario is that there are VIDEO_NUM_DEVICES - 1 slots in |
310 | * use of the video_device array. | ||
311 | * | ||
312 | * Returns a free index number. | ||
311 | */ | 313 | */ |
312 | static int get_index(struct video_device *vdev, int num) | 314 | static int get_index(struct video_device *vdev) |
313 | { | 315 | { |
314 | /* This can be static since this function is called with the global | 316 | /* This can be static since this function is called with the global |
315 | videodev_lock held. */ | 317 | videodev_lock held. */ |
316 | static DECLARE_BITMAP(used, VIDEO_NUM_DEVICES); | 318 | static DECLARE_BITMAP(used, VIDEO_NUM_DEVICES); |
317 | int i; | 319 | int i; |
318 | 320 | ||
319 | if (num >= VIDEO_NUM_DEVICES) { | 321 | /* Some drivers do not set the parent. In that case always return 0. */ |
320 | printk(KERN_ERR "videodev: %s num is too large\n", __func__); | ||
321 | return -EINVAL; | ||
322 | } | ||
323 | |||
324 | /* Some drivers do not set the parent. In that case always return | ||
325 | num or 0. */ | ||
326 | if (vdev->parent == NULL) | 322 | if (vdev->parent == NULL) |
327 | return num >= 0 ? num : 0; | 323 | return 0; |
328 | 324 | ||
329 | bitmap_zero(used, VIDEO_NUM_DEVICES); | 325 | bitmap_zero(used, VIDEO_NUM_DEVICES); |
330 | 326 | ||
@@ -335,30 +331,15 @@ static int get_index(struct video_device *vdev, int num) | |||
335 | } | 331 | } |
336 | } | 332 | } |
337 | 333 | ||
338 | if (num >= 0) { | 334 | return find_first_zero_bit(used, VIDEO_NUM_DEVICES); |
339 | if (test_bit(num, used)) | ||
340 | return -ENFILE; | ||
341 | return num; | ||
342 | } | ||
343 | |||
344 | i = find_first_zero_bit(used, VIDEO_NUM_DEVICES); | ||
345 | return i == VIDEO_NUM_DEVICES ? -ENFILE : i; | ||
346 | } | 335 | } |
347 | 336 | ||
348 | int video_register_device(struct video_device *vdev, int type, int nr) | ||
349 | { | ||
350 | return video_register_device_index(vdev, type, nr, -1); | ||
351 | } | ||
352 | EXPORT_SYMBOL(video_register_device); | ||
353 | |||
354 | /** | 337 | /** |
355 | * video_register_device_index - register video4linux devices | 338 | * video_register_device - register video4linux devices |
356 | * @vdev: video device structure we want to register | 339 | * @vdev: video device structure we want to register |
357 | * @type: type of device to register | 340 | * @type: type of device to register |
358 | * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ... | 341 | * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ... |
359 | * -1 == first free) | 342 | * -1 == first free) |
360 | * @index: stream number based on parent device; | ||
361 | * -1 if auto assign, requested number otherwise | ||
362 | * | 343 | * |
363 | * The registration code assigns minor numbers based on the type | 344 | * The registration code assigns minor numbers based on the type |
364 | * requested. -ENFILE is returned in all the device slots for this | 345 | * requested. -ENFILE is returned in all the device slots for this |
@@ -377,8 +358,7 @@ EXPORT_SYMBOL(video_register_device); | |||
377 | * | 358 | * |
378 | * %VFL_TYPE_RADIO - A radio card | 359 | * %VFL_TYPE_RADIO - A radio card |
379 | */ | 360 | */ |
380 | int video_register_device_index(struct video_device *vdev, int type, int nr, | 361 | int video_register_device(struct video_device *vdev, int type, int nr) |
381 | int index) | ||
382 | { | 362 | { |
383 | int i = 0; | 363 | int i = 0; |
384 | int ret; | 364 | int ret; |
@@ -481,14 +461,9 @@ int video_register_device_index(struct video_device *vdev, int type, int nr, | |||
481 | set_bit(nr, video_nums[type]); | 461 | set_bit(nr, video_nums[type]); |
482 | /* Should not happen since we thought this minor was free */ | 462 | /* Should not happen since we thought this minor was free */ |
483 | WARN_ON(video_device[vdev->minor] != NULL); | 463 | WARN_ON(video_device[vdev->minor] != NULL); |
484 | ret = vdev->index = get_index(vdev, index); | 464 | vdev->index = get_index(vdev); |
485 | mutex_unlock(&videodev_lock); | 465 | mutex_unlock(&videodev_lock); |
486 | 466 | ||
487 | if (ret < 0) { | ||
488 | printk(KERN_ERR "%s: get_index failed\n", __func__); | ||
489 | goto cleanup; | ||
490 | } | ||
491 | |||
492 | /* Part 3: Initialize the character device */ | 467 | /* Part 3: Initialize the character device */ |
493 | vdev->cdev = cdev_alloc(); | 468 | vdev->cdev = cdev_alloc(); |
494 | if (vdev->cdev == NULL) { | 469 | if (vdev->cdev == NULL) { |
@@ -543,7 +518,7 @@ cleanup: | |||
543 | vdev->minor = -1; | 518 | vdev->minor = -1; |
544 | return ret; | 519 | return ret; |
545 | } | 520 | } |
546 | EXPORT_SYMBOL(video_register_device_index); | 521 | EXPORT_SYMBOL(video_register_device); |
547 | 522 | ||
548 | /** | 523 | /** |
549 | * video_unregister_device - unregister a video4linux device | 524 | * video_unregister_device - unregister a video4linux device |