aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/v4l2-dev.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2009-09-06 06:13:14 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2009-09-18 23:19:27 -0400
commit22e221258b56cc1a4dc5a9fb2c26f4d6ed9dde81 (patch)
tree0e07015c3b78211491594f000b77aa8a7e48d8fc /drivers/media/video/v4l2-dev.c
parent7ae0cd9bc793e16d8d68df3c17c601732cc1d3c7 (diff)
V4L/DVB (12722): v4l2-dev: replace 'kernel number' by 'device node number'.
The term 'kernel number' is very vague, so replace it with the somewhat more descriptive term 'device node number'. In one place the local variable 'nr' was used to create the device node number of the new device name. This has been replaced with the vdev->num field to more clearly mark this as being the device node number and not the minor number. 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.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/drivers/media/video/v4l2-dev.c b/drivers/media/video/v4l2-dev.c
index 1219721894a1..4e61c77b7634 100644
--- a/drivers/media/video/v4l2-dev.c
+++ b/drivers/media/video/v4l2-dev.c
@@ -66,7 +66,7 @@ static struct device_attribute video_device_attrs[] = {
66 */ 66 */
67static struct video_device *video_device[VIDEO_NUM_DEVICES]; 67static struct video_device *video_device[VIDEO_NUM_DEVICES];
68static DEFINE_MUTEX(videodev_lock); 68static DEFINE_MUTEX(videodev_lock);
69static DECLARE_BITMAP(video_nums[VFL_TYPE_MAX], VIDEO_NUM_DEVICES); 69static DECLARE_BITMAP(devnode_nums[VFL_TYPE_MAX], VIDEO_NUM_DEVICES);
70 70
71struct video_device *video_device_alloc(void) 71struct video_device *video_device_alloc(void)
72{ 72{
@@ -119,8 +119,8 @@ static void v4l2_device_release(struct device *cd)
119 the release() callback. */ 119 the release() callback. */
120 vdev->cdev = NULL; 120 vdev->cdev = NULL;
121 121
122 /* Mark minor as free */ 122 /* Mark device node number as free */
123 clear_bit(vdev->num, video_nums[vdev->vfl_type]); 123 clear_bit(vdev->num, devnode_nums[vdev->vfl_type]);
124 124
125 mutex_unlock(&videodev_lock); 125 mutex_unlock(&videodev_lock);
126 126
@@ -338,13 +338,14 @@ static int get_index(struct video_device *vdev)
338 * video_register_device - register video4linux devices 338 * video_register_device - register video4linux devices
339 * @vdev: video device structure we want to register 339 * @vdev: video device structure we want to register
340 * @type: type of device to register 340 * @type: type of device to register
341 * @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ... 341 * @nr: which device node number (0 == /dev/video0, 1 == /dev/video1, ...
342 * -1 == first free) 342 * -1 == first free)
343 * 343 *
344 * The registration code assigns minor numbers based on the type 344 * The registration code assigns minor numbers and device node numbers
345 * requested. -ENFILE is returned in all the device slots for this 345 * based on the requested type and registers the new device node with
346 * category are full. If not then the minor field is set and the 346 * the kernel.
347 * driver initialize function is called (if non %NULL). 347 * An error is returned if no free minor or device node number could be
348 * found, or if the registration of the device node failed.
348 * 349 *
349 * Zero is returned on success. 350 * Zero is returned on success.
350 * 351 *
@@ -401,7 +402,7 @@ int video_register_device(struct video_device *vdev, int type, int nr)
401 if (vdev->v4l2_dev && vdev->v4l2_dev->dev) 402 if (vdev->v4l2_dev && vdev->v4l2_dev->dev)
402 vdev->parent = vdev->v4l2_dev->dev; 403 vdev->parent = vdev->v4l2_dev->dev;
403 404
404 /* Part 2: find a free minor, kernel number and device index. */ 405 /* Part 2: find a free minor, device node number and device index. */
405#ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES 406#ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES
406 /* Keep the ranges for the first four types for historical 407 /* Keep the ranges for the first four types for historical
407 * reasons. 408 * reasons.
@@ -432,21 +433,22 @@ int video_register_device(struct video_device *vdev, int type, int nr)
432 } 433 }
433#endif 434#endif
434 435
435 /* Pick a minor number */ 436 /* Pick a device node number */
436 mutex_lock(&videodev_lock); 437 mutex_lock(&videodev_lock);
437 nr = find_next_zero_bit(video_nums[type], minor_cnt, nr == -1 ? 0 : nr); 438 nr = find_next_zero_bit(devnode_nums[type], minor_cnt, nr == -1 ? 0 : nr);
438 if (nr == minor_cnt) 439 if (nr == minor_cnt)
439 nr = find_first_zero_bit(video_nums[type], minor_cnt); 440 nr = find_first_zero_bit(devnode_nums[type], minor_cnt);
440 if (nr == minor_cnt) { 441 if (nr == minor_cnt) {
441 printk(KERN_ERR "could not get a free kernel number\n"); 442 printk(KERN_ERR "could not get a free device node number\n");
442 mutex_unlock(&videodev_lock); 443 mutex_unlock(&videodev_lock);
443 return -ENFILE; 444 return -ENFILE;
444 } 445 }
445#ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES 446#ifdef CONFIG_VIDEO_FIXED_MINOR_RANGES
446 /* 1-on-1 mapping of kernel number to minor number */ 447 /* 1-on-1 mapping of device node number to minor number */
447 i = nr; 448 i = nr;
448#else 449#else
449 /* The kernel number and minor numbers are independent */ 450 /* The device node number and minor numbers are independent, so
451 we just find the first free minor number. */
450 for (i = 0; i < VIDEO_NUM_DEVICES; i++) 452 for (i = 0; i < VIDEO_NUM_DEVICES; i++)
451 if (video_device[i] == NULL) 453 if (video_device[i] == NULL)
452 break; 454 break;
@@ -458,7 +460,7 @@ int video_register_device(struct video_device *vdev, int type, int nr)
458#endif 460#endif
459 vdev->minor = i + minor_offset; 461 vdev->minor = i + minor_offset;
460 vdev->num = nr; 462 vdev->num = nr;
461 set_bit(nr, video_nums[type]); 463 set_bit(nr, devnode_nums[type]);
462 /* Should not happen since we thought this minor was free */ 464 /* Should not happen since we thought this minor was free */
463 WARN_ON(video_device[vdev->minor] != NULL); 465 WARN_ON(video_device[vdev->minor] != NULL);
464 vdev->index = get_index(vdev); 466 vdev->index = get_index(vdev);
@@ -492,7 +494,7 @@ int video_register_device(struct video_device *vdev, int type, int nr)
492 vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor); 494 vdev->dev.devt = MKDEV(VIDEO_MAJOR, vdev->minor);
493 if (vdev->parent) 495 if (vdev->parent)
494 vdev->dev.parent = vdev->parent; 496 vdev->dev.parent = vdev->parent;
495 dev_set_name(&vdev->dev, "%s%d", name_base, nr); 497 dev_set_name(&vdev->dev, "%s%d", name_base, vdev->num);
496 ret = device_register(&vdev->dev); 498 ret = device_register(&vdev->dev);
497 if (ret < 0) { 499 if (ret < 0) {
498 printk(KERN_ERR "%s: device_register failed\n", __func__); 500 printk(KERN_ERR "%s: device_register failed\n", __func__);
@@ -512,7 +514,7 @@ cleanup:
512 mutex_lock(&videodev_lock); 514 mutex_lock(&videodev_lock);
513 if (vdev->cdev) 515 if (vdev->cdev)
514 cdev_del(vdev->cdev); 516 cdev_del(vdev->cdev);
515 clear_bit(vdev->num, video_nums[type]); 517 clear_bit(vdev->num, devnode_nums[type]);
516 mutex_unlock(&videodev_lock); 518 mutex_unlock(&videodev_lock);
517 /* Mark this video device as never having been registered. */ 519 /* Mark this video device as never having been registered. */
518 vdev->minor = -1; 520 vdev->minor = -1;