mirror of https://gitee.com/openkylin/linux.git
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
7d3135af39
("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>
This commit is contained in:
parent
754ab5c0e5
commit
682b911938
|
@ -2415,11 +2415,11 @@ void comedi_free_subdevice_minor(struct comedi_subdevice *s)
|
||||||
kfree(info);
|
kfree(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void comedi_cleanup_legacy_minors(void)
|
static void comedi_cleanup_board_minors(void)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < comedi_num_legacy_minors; i++)
|
for (i = 0; i < COMEDI_NUM_BOARD_MINORS; i++)
|
||||||
comedi_free_board_minor(i);
|
comedi_free_board_minor(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2479,7 +2479,7 @@ static int __init comedi_init(void)
|
||||||
int minor;
|
int minor;
|
||||||
minor = comedi_alloc_board_minor(NULL);
|
minor = comedi_alloc_board_minor(NULL);
|
||||||
if (minor < 0) {
|
if (minor < 0) {
|
||||||
comedi_cleanup_legacy_minors();
|
comedi_cleanup_board_minors();
|
||||||
cdev_del(&comedi_cdev);
|
cdev_del(&comedi_cdev);
|
||||||
unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
|
unregister_chrdev_region(MKDEV(COMEDI_MAJOR, 0),
|
||||||
COMEDI_NUM_MINORS);
|
COMEDI_NUM_MINORS);
|
||||||
|
@ -2495,7 +2495,7 @@ static void __exit comedi_cleanup(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
comedi_cleanup_legacy_minors();
|
comedi_cleanup_board_minors();
|
||||||
for (i = 0; i < COMEDI_NUM_MINORS; ++i)
|
for (i = 0; i < COMEDI_NUM_MINORS; ++i)
|
||||||
BUG_ON(comedi_file_info_table[i]);
|
BUG_ON(comedi_file_info_table[i]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue