summaryrefslogtreecommitdiffstats
path: root/drivers/staging/comedi/comedi_fops.c
diff options
context:
space:
mode:
authorIan Abbott2013-04-04 15:58:52 +0200
committerGreg Kroah-Hartman2013-04-05 23:33:17 +0200
commit38b9722a4414c395c6c1e82cd5f8ee64a23313b8 (patch)
tree36150235af2fd5525d78f081d7b6f34f34ae5e1b /drivers/staging/comedi/comedi_fops.c
parentstaging: comedi: pre-lock mutex on creation of comedi device (diff)
downloadkernel-qcow2-linux-38b9722a4414c395c6c1e82cd5f8ee64a23313b8.tar.gz
kernel-qcow2-linux-38b9722a4414c395c6c1e82cd5f8ee64a23313b8.tar.xz
kernel-qcow2-linux-38b9722a4414c395c6c1e82cd5f8ee64a23313b8.zip
staging: comedi: avoid releasing legacy minors automatically
`comedi_alloc_board_minor()` is called for both reserved "legacy" devices created during module initialization, and for dynamically created devices (via `comedi_auto_config()`). All the minor device numbers from 0 to `comedi_num_legacy_minors - 1` are for legacy devices and all those from `comedi_num_legacy_minors` to `COMEDI_NUM_BOARD_MINORS - 1` are for dynamically created devices. `comedi_release_hardware_device()` is called (via `comedi_auto_unconfig()`) when a dynamically created device is being removed. It needs to search the table of minor device numbers to see which one is associated with the hardware device. It currently starts the search at minor device number 0. Change it to start from `comedi_num_legacy_minors` to skip over those belonging to legacy devices. Also change `comedi_alloc_board_minor()` to skip the legacy devices when searching for a free minor device number for the dynamically created device. (The validity of the `hardware_device` parameter is used to distinguish the legacy devices from the dynamically created ones.) Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Reviewed-by: H Hartley Sweeten <hsweeten@visionengravers.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/comedi_fops.c')
-rw-r--r--drivers/staging/comedi/comedi_fops.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 061b55b48383..ffa64228c3cf 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -2295,7 +2295,8 @@ struct comedi_device *comedi_alloc_board_minor(struct device *hardware_device)
comedi_device_init(dev);
mutex_lock(&dev->mutex);
spin_lock(&comedi_file_info_table_lock);
- for (i = 0; i < COMEDI_NUM_BOARD_MINORS; ++i) {
+ for (i = hardware_device ? comedi_num_legacy_minors : 0;
+ i < COMEDI_NUM_BOARD_MINORS; ++i) {
if (comedi_file_info_table[i] == NULL) {
comedi_file_info_table[i] = info;
break;
@@ -2359,7 +2360,8 @@ void comedi_release_hardware_device(struct device *hardware_device)
int minor;
struct comedi_file_info *info;
- for (minor = 0; minor < COMEDI_NUM_BOARD_MINORS; minor++) {
+ for (minor = comedi_num_legacy_minors; minor < COMEDI_NUM_BOARD_MINORS;
+ minor++) {
spin_lock(&comedi_file_info_table_lock);
info = comedi_file_info_table[minor];
if (info && info->hardware_device == hardware_device) {