[PATCH 06/37] staging: comedi: add comedi_release_hardware_device()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 drivers/staging/comedi/comedi_fops.c     | 7 ++++---
 drivers/staging/comedi/comedi_internal.h | 2 +-
 drivers/staging/comedi/drivers.c         | 7 +------
 3 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 8b5fa2f..ce050e4 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -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)
diff --git a/drivers/staging/comedi/comedi_internal.h b/drivers/staging/comedi/comedi_internal.h
index b374313..fd14de6 100644
--- a/drivers/staging/comedi/comedi_internal.h
+++ b/drivers/staging/comedi/comedi_internal.h
@@ -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);
 
diff --git a/drivers/staging/comedi/drivers.c b/drivers/staging/comedi/drivers.c
index 4460814..29c8f50 100644
--- a/drivers/staging/comedi/drivers.c
+++ b/drivers/staging/comedi/drivers.c
@@ -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);
 
-- 
1.8.1.5

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux