staging: comedi: add comedi_release_hardware_device()
authorIan Abbott <abbotti@mev.co.uk>
Thu, 4 Apr 2013 13:58:47 +0000 (14:58 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 5 Apr 2013 21:33:17 +0000 (14:33 -0700)
Add `comedi_release_hardware_device()` as a replacement for the call
sequence `comedi_find_board_minor()`, `comedi_free_board_minor()`.  This
is slightly safer as we can make sure nothing funny happens to the found
`comedi_file_info_table[]` entry in the middle of the sequence.  Change
`comedi_auto_unconfig()` to call the new function instead of the old
sequence.  Remove `comedi_find_board_minor()` as it has no other
callers.

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>
drivers/staging/comedi/comedi_fops.c
drivers/staging/comedi/comedi_internal.h
drivers/staging/comedi/drivers.c

index 8b5fa2fc9a821bede95d2580c2944f071a6a81ef..ce050e4ba1070dc25280bbaf5558ae0ed36eee02 100644 (file)
@@ -2348,7 +2348,7 @@ void comedi_free_board_minor(unsigned minor)
        comedi_free_board_file_info(comedi_clear_minor(minor));
 }
 
-int comedi_find_board_minor(struct device *hardware_device)
+void comedi_release_hardware_device(struct device *hardware_device)
 {
        int minor;
        struct comedi_file_info *info;
@@ -2357,12 +2357,13 @@ int comedi_find_board_minor(struct device *hardware_device)
                spin_lock(&comedi_file_info_table_lock);
                info = comedi_file_info_table[minor];
                if (info && info->hardware_device == hardware_device) {
+                       comedi_file_info_table[minor] = NULL;
                        spin_unlock(&comedi_file_info_table_lock);
-                       return minor;
+                       comedi_free_board_file_info(info);
+                       break;
                }
                spin_unlock(&comedi_file_info_table_lock);
        }
-       return -ENODEV;
 }
 
 int comedi_alloc_subdevice_minor(struct comedi_subdevice *s)
index b3743135f4aa8e4e26c73ef63be24c1e13d0271b..fd14de662e8f0d418af727b7d948b9e50dda8e1f 100644 (file)
@@ -10,7 +10,7 @@ int do_rangeinfo_ioctl(struct comedi_device *dev,
                       struct comedi_rangeinfo __user *arg);
 int comedi_alloc_board_minor(struct device *hardware_device);
 void comedi_free_board_minor(unsigned minor);
-int comedi_find_board_minor(struct device *hardware_device);
+void comedi_release_hardware_device(struct device *hardware_device);
 int comedi_alloc_subdevice_minor(struct comedi_subdevice *s);
 void comedi_free_subdevice_minor(struct comedi_subdevice *s);
 
index 4460814d5344c4e0289bd7d13495ecccd8b29ad4..29c8f5037065f390b9b0325446ef27d8e65ef43a 100644 (file)
@@ -459,14 +459,9 @@ EXPORT_SYMBOL_GPL(comedi_auto_config);
 
 void comedi_auto_unconfig(struct device *hardware_device)
 {
-       int minor;
-
        if (hardware_device == NULL)
                return;
-       minor = comedi_find_board_minor(hardware_device);
-       if (minor < 0)
-               return;
-       comedi_free_board_minor(minor);
+       comedi_release_hardware_device(hardware_device);
 }
 EXPORT_SYMBOL_GPL(comedi_auto_unconfig);