Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/nvmm Only detach the cfdriver if we just attached it.



details:   https://anonhg.NetBSD.org/src/rev/5eed9e3d2074
branches:  trunk
changeset: 368372:5eed9e3d2074
user:      pgoyette <pgoyette%NetBSD.org@localhost>
date:      Thu Jul 07 23:50:33 2022 +0000

description:
Only detach the cfdriver if we just attached it.

Report errno in message when fail to attach cdevsw

diffstat:

 sys/dev/nvmm/nvmm.c |  14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diffs (59 lines):

diff -r 5dda089538a2 -r 5eed9e3d2074 sys/dev/nvmm/nvmm.c
--- a/sys/dev/nvmm/nvmm.c       Thu Jul 07 20:22:03 2022 +0000
+++ b/sys/dev/nvmm/nvmm.c       Thu Jul 07 23:50:33 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nvmm.c,v 1.45 2022/07/06 13:10:49 riastradh Exp $      */
+/*     $NetBSD: nvmm.c,v 1.46 2022/07/07 23:50:33 pgoyette Exp $       */
 
 /*
  * Copyright (c) 2018-2020 Maxime Villard, m00nbsd.net
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.45 2022/07/06 13:10:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm.c,v 1.46 2022/07/07 23:50:33 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1255,7 +1255,9 @@
 #endif
                error = config_cfattach_attach(nvmm_cd.cd_name, &nvmm_ca);
                if (error) {
+#if defined(_MODULE)
                        config_cfdriver_detach(&nvmm_cd);
+#endif
                        aprint_error("%s: config_cfattach_attach failed\n",
                            nvmm_cd.cd_name);
                        return error;
@@ -1264,7 +1266,9 @@
                error = config_cfdata_attach(nvmm_cfdata, 1);
                if (error) {
                        config_cfattach_detach(nvmm_cd.cd_name, &nvmm_ca);
+#if defined(_MODULE)
                        config_cfdriver_detach(&nvmm_cd);
+#endif
                        aprint_error("%s: unable to register cfdata\n",
                            nvmm_cd.cd_name);
                        return error;
@@ -1274,7 +1278,9 @@
                        aprint_error("%s: config_attach_pseudo failed\n",
                            nvmm_cd.cd_name);
                        config_cfattach_detach(nvmm_cd.cd_name, &nvmm_ca);
+#if defined(_MODULE)
                        config_cfdriver_detach(&nvmm_cd);
+#endif
                        return ENXIO;
                }
 
@@ -1283,8 +1289,8 @@
                error = devsw_attach(nvmm_cd.cd_name, NULL, &bmajor,
                        &nvmm_cdevsw, &cmajor);
                if (error) {
-                       aprint_error("%s: unable to register devsw\n",
-                           nvmm_cd.cd_name);
+                       aprint_error("%s: unable to register devsw, err %d\n",
+                           nvmm_cd.cd_name, error);
                        config_cfattach_detach(nvmm_cd.cd_name, &nvmm_ca);
                        config_cfdriver_detach(&nvmm_cd);
                        return error;



Home | Main Index | Thread Index | Old Index