svn commit: r356092 - head/sys/dev/kbdmux
Kyle Evans
kevans at FreeBSD.org
Thu Dec 26 17:25:52 UTC 2019
Author: kevans
Date: Thu Dec 26 17:25:51 2019
New Revision: 356092
URL: https://svnweb.freebsd.org/changeset/base/356092
Log:
kbdmux: simplify modevent handler
In the event of a MOD_LOAD failure, MOD_UNLOAD will be invoked to unwind
module load. Most of the reversion in MOD_LOAD can just be deferred to
normal MOD_UNLOAD cleanup, rather than duplicating the effort.
A NULL return of kbd_get_switch in the MOD_UNLOAD handler has been
downgraded from a panic to a successful return, as that certainly just means
that kbd_add_driver failed (not possible at the moment) and we have no work
to do.
Modified:
head/sys/dev/kbdmux/kbdmux.c
Modified: head/sys/dev/kbdmux/kbdmux.c
==============================================================================
--- head/sys/dev/kbdmux/kbdmux.c Thu Dec 26 17:09:36 2019 (r356091)
+++ head/sys/dev/kbdmux/kbdmux.c Thu Dec 26 17:25:51 2019 (r356092)
@@ -1427,7 +1427,6 @@ kbdmux_modevent(module_t mod, int type, void *data)
break;
if ((sw = kbd_get_switch(KEYBOARD_NAME)) == NULL) {
- kbd_delete_driver(&kbdmux_kbd_driver);
error = ENXIO;
break;
}
@@ -1435,33 +1434,25 @@ kbdmux_modevent(module_t mod, int type, void *data)
kbd = NULL;
if ((error = (*sw->probe)(0, NULL, 0)) != 0 ||
- (error = (*sw->init)(0, &kbd, NULL, 0)) != 0) {
- kbd_delete_driver(&kbdmux_kbd_driver);
+ (error = (*sw->init)(0, &kbd, NULL, 0)) != 0)
break;
- }
#ifdef KBD_INSTALL_CDEV
if ((error = kbd_attach(kbd)) != 0) {
(*sw->term)(kbd);
- kbd_delete_driver(&kbdmux_kbd_driver);
break;
}
#endif
- if ((error = (*sw->enable)(kbd)) != 0) {
- (*sw->disable)(kbd);
-#ifdef KBD_INSTALL_CDEV
- kbd_detach(kbd);
-#endif
- (*sw->term)(kbd);
- kbd_delete_driver(&kbdmux_kbd_driver);
+ if ((error = (*sw->enable)(kbd)) != 0)
break;
- }
break;
case MOD_UNLOAD:
- if ((sw = kbd_get_switch(KEYBOARD_NAME)) == NULL)
- panic("kbd_get_switch(" KEYBOARD_NAME ") == NULL");
+ if ((sw = kbd_get_switch(KEYBOARD_NAME)) == NULL) {
+ error = 0;
+ break;
+ }
kbd = kbd_get_keyboard(kbd_find_keyboard(KEYBOARD_NAME, 0));
if (kbd != NULL) {
@@ -1470,8 +1461,8 @@ kbdmux_modevent(module_t mod, int type, void *data)
kbd_detach(kbd);
#endif
(*sw->term)(kbd);
- kbd_delete_driver(&kbdmux_kbd_driver);
}
+ kbd_delete_driver(&kbdmux_kbd_driver);
error = 0;
break;
More information about the svn-src-head
mailing list