aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIan Abbott <abbotti@mev.co.uk>2013-01-28 12:07:39 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-01-30 05:47:47 -0500
commit682b911938f8c0e88c8204bb1178c2c7728d5661 (patch)
tree127e6384cb988bc9a3588ebdf53264d32bb160cf
parent754ab5c0e55dd118273ca2c217c4d95e9fbc8259 (diff)
staging: comedi: cleanup all board minors on module exit
The comedi core module optionally allocates some legacy board minor devices on module load and cleans these up on module exit. These are used for manual configuration of comedi boards (for those low-level comedi drivers that support manual configuration - mainly for ISA boards). Other board minor devices are created and destroyed dynamically in response to bus device probe and remove requests. The ioctl used for manual configuration (attachment) and removal (detachment) of devices is COMEDI_DEVCONFIG, but that works for any board minor device, including those that were originally created dynamically. If the COMEDI_DEVCONFIG ioctl is used to manually detach an automatically created and attached device, commit 7d3135af399e92cf4c9bbc5f86b6c140aab3b88c ("staging: comedi: prevent auto-unconfig of manually configured devices") ensures that the board minor will no longer be automatically detached and destroyed by a bus device remove request. From that point on the board minor behaves more like one of the comedi "legacy" board minors. (There would be some justification for destroying the board minor instead, but I'd rather leave that decision until removal of board minors has been made safer than it currently is.) Although the board minor behaves more like a legacy board minor, it is not currently cleaned up on module exit. In fact, the module exit code will bug out because this board minor has not been cleaned up. Change comedi_cleanup_legacy_minors() (called from the module exit code, and from the module init code on error) to clean up all board minors. Rename the function to comedi_cleanup_board_minors() to reflect the change in functionality. Signed-off-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/comedi/comedi_fops.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c
index 38e4fcb418c0..c7377d012a6d 100644
--- a/drivers/staging/comedi/comedi_fops.c
+++ b/drivers/staging/comedi/comedi_fops.c
@@ -2415,11 +2415,11 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s)
2415 kfree(info); 2415 kfree(info);
2416} 2416}
2417 2417
2418static void comedi_cleanup_legacy_minors(void) 2418static void comedi_cleanup_board_minors(void)
2419{ 2419{
2420 unsigned i; 2420 unsigned i;
2421 2421
2422 for (i = 0; i < comedi_num_legacy_minors; i++) 2422 for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++)
2423 comedi_free_board_minor(i); 2423 comedi_free_board_minor(i);
2424} 2424}
2425 2425
@@ -2479,7 +2479,7 @@ static int __init comedi_init(void)
2479 int minor; 2479 int minor;
2480 minor = comedi_alloc_board_minor(NULL); 2480 minor = comedi_alloc_board_minor(NULL);
2481 if (minor < 0) { 2481 if (minor < 0) {
2482 comedi_cleanup_legacy_minors(); 2482 comedi_cleanup_board_minors();
2483 cdev_del(&comedi_cdev); 2483 cdev_del(&comedi_cdev);
2484 unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0), 2484 unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
2485 COMEDI_NUM_MINORS); 2485 COMEDI_NUM_MINORS);
@@ -2495,7 +2495,7 @@ static void __exit comedi_cleanup(void)
2495{ 2495{
2496 int i; 2496 int i;
2497 2497
2498 comedi_cleanup_legacy_minors(); 2498 comedi_cleanup_board_minors();
2499 for (i = 0; i < COMEDI_NUM_MINORS; ++i) 2499 for (i = 0; i < COMEDI_NUM_MINORS; ++i)
2500 BUG_ON(comedi_file_info_table[i]); 2500 BUG_ON(comedi_file_info_table[i]);
2501 2501