git: 5ad42f80559c - main - smapi: Use devclass_find to lookup smapi devclass in unload handler.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 05 May 2022 23:42:25 UTC
The branch main has been updated by jhb:
URL: https://cgit.FreeBSD.org/src/commit/?id=5ad42f80559cd37fbd2897df4f6462fb43330608
commit 5ad42f80559cd37fbd2897df4f6462fb43330608
Author: John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-05-05 23:35:40 +0000
Commit: John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-05-05 23:35:40 +0000
smapi: Use devclass_find to lookup smapi devclass in unload handler.
Move smapi_modevent below the declaration of smapi_driver so that
smapi_driver's name member can be used rather than hardcoding the
device class name.
Differential Revision: https://reviews.freebsd.org/D35064
---
sys/i386/bios/smapi.c | 33 +++++++++++++++++----------------
1 file changed, 17 insertions(+), 16 deletions(-)
diff --git a/sys/i386/bios/smapi.c b/sys/i386/bios/smapi.c
index 653399e1ca58..719d9b9558dc 100644
--- a/sys/i386/bios/smapi.c
+++ b/sys/i386/bios/smapi.c
@@ -278,6 +278,21 @@ smapi_detach (device_t dev)
return (0);
}
+static device_method_t smapi_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_identify, smapi_identify),
+ DEVMETHOD(device_probe, smapi_probe),
+ DEVMETHOD(device_attach, smapi_attach),
+ DEVMETHOD(device_detach, smapi_detach),
+ { 0, 0 }
+};
+
+static driver_t smapi_driver = {
+ "smapi",
+ smapi_methods,
+ sizeof(struct smapi_softc),
+};
+
static int
smapi_modevent (module_t mod, int what, void *arg)
{
@@ -289,7 +304,8 @@ smapi_modevent (module_t mod, int what, void *arg)
case MOD_LOAD:
break;
case MOD_UNLOAD:
- devclass_get_devices(smapi_devclass, &devs, &count);
+ devclass_get_devices(devclass_find(smapi_driver.name), &devs,
+ &count);
for (i = 0; i < count; i++) {
device_delete_child(device_get_parent(devs[i]), devs[i]);
}
@@ -302,20 +318,5 @@ smapi_modevent (module_t mod, int what, void *arg)
return (0);
}
-static device_method_t smapi_methods[] = {
- /* Device interface */
- DEVMETHOD(device_identify, smapi_identify),
- DEVMETHOD(device_probe, smapi_probe),
- DEVMETHOD(device_attach, smapi_attach),
- DEVMETHOD(device_detach, smapi_detach),
- { 0, 0 }
-};
-
-static driver_t smapi_driver = {
- "smapi",
- smapi_methods,
- sizeof(struct smapi_softc),
-};
-
DRIVER_MODULE(smapi, nexus, smapi_driver, smapi_devclass, smapi_modevent, 0);
MODULE_VERSION(smapi, 1);