mirror of
https://github.com/adulau/aha.git
synced 2024-12-27 19:26:25 +00:00
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>
This commit is contained in:
parent
53dacb1570
commit
7ae0cd9bc7
3 changed files with 20 additions and 54 deletions
|
@ -500,17 +500,11 @@ first free number.
|
|||
Whenever a device node is created some attributes are also created for you.
|
||||
If you look in /sys/class/video4linux you see the devices. Go into e.g.
|
||||
video0 and you will see 'name' and 'index' attributes. The 'name' attribute
|
||||
is the 'name' field of the video_device struct. The 'index' attribute is
|
||||
a device node index that can be assigned by the driver, or that is calculated
|
||||
for you.
|
||||
is the 'name' field of the video_device struct.
|
||||
|
||||
If you call video_register_device(), then the index is just increased by
|
||||
1 for each device node you register. The first video device node you register
|
||||
always starts off with 0.
|
||||
|
||||
Alternatively you can call video_register_device_index() which is identical
|
||||
to video_register_device(), but with an extra index argument. Here you can
|
||||
pass a specific index value (between 0 and 31) that should be used.
|
||||
The 'index' attribute is the index of the device node: for each call to
|
||||
video_register_device() the index is just increased by 1. The first video
|
||||
device node you register always starts with index 0.
|
||||
|
||||
Users can setup udev rules that utilize the index attribute to make fancy
|
||||
device names (e.g. 'mpegX' for MPEG video capture device nodes).
|
||||
|
@ -520,8 +514,7 @@ After the device was successfully registered, then you can use these fields:
|
|||
- vfl_type: the device type passed to video_register_device.
|
||||
- minor: the assigned device minor number.
|
||||
- num: the device kernel number (i.e. the X in videoX).
|
||||
- index: the device index number (calculated or set explicitly using
|
||||
video_register_device_index).
|
||||
- index: the device index number.
|
||||
|
||||
If the registration failed, then you need to call video_device_release()
|
||||
to free the allocated video_device struct, or free your own struct if the
|
||||
|
|
|
@ -299,32 +299,28 @@ static const struct file_operations v4l2_fops = {
|
|||
};
|
||||
|
||||
/**
|
||||
* get_index - assign stream number based on parent device
|
||||
* get_index - assign stream index number based on parent device
|
||||
* @vdev: video_device to assign index number to, vdev->parent should be assigned
|
||||
* @num: -1 if auto assign, requested number otherwise
|
||||
*
|
||||
* Note that when this is called the new device has not yet been registered
|
||||
* in the video_device array.
|
||||
* in the video_device array, but it was able to obtain a minor number.
|
||||
*
|
||||
* Returns -ENFILE if num is already in use, a free index number if
|
||||
* successful.
|
||||
* This means that we can always obtain a free stream index number since
|
||||
* the worst case scenario is that there are VIDEO_NUM_DEVICES - 1 slots in
|
||||
* use of the video_device array.
|
||||
*
|
||||
* Returns a free index number.
|
||||
*/
|
||||
static int get_index(struct video_device *vdev, int num)
|
||||
static int get_index(struct video_device *vdev)
|
||||
{
|
||||
/* This can be static since this function is called with the global
|
||||
videodev_lock held. */
|
||||
static DECLARE_BITMAP(used, VIDEO_NUM_DEVICES);
|
||||
int i;
|
||||
|
||||
if (num >= VIDEO_NUM_DEVICES) {
|
||||
printk(KERN_ERR "videodev: %s num is too large\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Some drivers do not set the parent. In that case always return
|
||||
num or 0. */
|
||||
/* Some drivers do not set the parent. In that case always return 0. */
|
||||
if (vdev->parent == NULL)
|
||||
return num >= 0 ? num : 0;
|
||||
return 0;
|
||||
|
||||
bitmap_zero(used, VIDEO_NUM_DEVICES);
|
||||
|
||||
|
@ -335,30 +331,15 @@ static int get_index(struct video_device *vdev, int num)
|
|||
}
|
||||
}
|
||||
|
||||
if (num >= 0) {
|
||||
if (test_bit(num, used))
|
||||
return -ENFILE;
|
||||
return num;
|
||||
}
|
||||
|
||||
i = find_first_zero_bit(used, VIDEO_NUM_DEVICES);
|
||||
return i == VIDEO_NUM_DEVICES ? -ENFILE : i;
|
||||
return find_first_zero_bit(used, VIDEO_NUM_DEVICES);
|
||||
}
|
||||
|
||||
int video_register_device(struct video_device *vdev, int type, int nr)
|
||||
{
|
||||
return video_register_device_index(vdev, type, nr, -1);
|
||||
}
|
||||
EXPORT_SYMBOL(video_register_device);
|
||||
|
||||
/**
|
||||
* video_register_device_index - register video4linux devices
|
||||
* video_register_device - register video4linux devices
|
||||
* @vdev: video device structure we want to register
|
||||
* @type: type of device to register
|
||||
* @nr: which device number (0 == /dev/video0, 1 == /dev/video1, ...
|
||||
* -1 == first free)
|
||||
* @index: stream number based on parent device;
|
||||
* -1 if auto assign, requested number otherwise
|
||||
*
|
||||
* The registration code assigns minor numbers based on the type
|
||||
* requested. -ENFILE is returned in all the device slots for this
|
||||
|
@ -377,8 +358,7 @@ EXPORT_SYMBOL(video_register_device);
|
|||
*
|
||||
* %VFL_TYPE_RADIO - A radio card
|
||||
*/
|
||||
int video_register_device_index(struct video_device *vdev, int type, int nr,
|
||||
int index)
|
||||
int video_register_device(struct video_device *vdev, int type, int nr)
|
||||
{
|
||||
int i = 0;
|
||||
int ret;
|
||||
|
@ -481,14 +461,9 @@ int video_register_device_index(struct video_device *vdev, int type, int nr,
|
|||
set_bit(nr, video_nums[type]);
|
||||
/* Should not happen since we thought this minor was free */
|
||||
WARN_ON(video_device[vdev->minor] != NULL);
|
||||
ret = vdev->index = get_index(vdev, index);
|
||||
vdev->index = get_index(vdev);
|
||||
mutex_unlock(&videodev_lock);
|
||||
|
||||
if (ret < 0) {
|
||||
printk(KERN_ERR "%s: get_index failed\n", __func__);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Part 3: Initialize the character device */
|
||||
vdev->cdev = cdev_alloc();
|
||||
if (vdev->cdev == NULL) {
|
||||
|
@ -543,7 +518,7 @@ cleanup:
|
|||
vdev->minor = -1;
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(video_register_device_index);
|
||||
EXPORT_SYMBOL(video_register_device);
|
||||
|
||||
/**
|
||||
* video_unregister_device - unregister a video4linux device
|
||||
|
|
|
@ -100,8 +100,6 @@ struct video_device
|
|||
|
||||
Also note that vdev->minor is set to -1 if the registration failed. */
|
||||
int __must_check video_register_device(struct video_device *vdev, int type, int nr);
|
||||
int __must_check video_register_device_index(struct video_device *vdev,
|
||||
int type, int nr, int index);
|
||||
|
||||
/* Unregister video devices. Will do nothing if vdev == NULL or
|
||||
vdev->minor < 0. */
|
||||
|
|
Loading…
Reference in a new issue