Skip to content

Commit

Permalink
V4L/DVB (8390): videodev: add comment and remove magic number.
Browse files Browse the repository at this point in the history
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
  • Loading branch information
Hans Verkuil authored and Mauro Carvalho Chehab committed Jul 20, 2008
1 parent 8373a3e commit c3fb62b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/media/video/videodev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2023,9 +2023,13 @@ EXPORT_SYMBOL(video_ioctl2);
static int get_index(struct video_device *vdev, int num)
{
u32 used = 0;
const unsigned max_index = sizeof(used) * 8 - 1;
int i;

if (num >= 32) {
/* Currently a single v4l driver instance cannot create more than
32 devices.
Increase to u64 or an array of u32 if more are needed. */
if (num > max_index) {
printk(KERN_ERR "videodev: %s num is too large\n", __func__);
return -EINVAL;
}
Expand All @@ -2045,7 +2049,7 @@ static int get_index(struct video_device *vdev, int num)
}

i = ffz(used);
return i >= 32 ? -ENFILE : i;
return i > max_index ? -ENFILE : i;
}

static const struct file_operations video_fops;
Expand Down

0 comments on commit c3fb62b

Please sign in to comment.