Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/isa unregister sensors only when registered.



details:   https://anonhg.NetBSD.org/src/rev/c06d17745fb9
branches:  trunk
changeset: 368218:c06d17745fb9
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Wed Jun 29 15:56:58 2022 +0000

description:
unregister sensors only when registered.

diffstat:

 sys/dev/isa/aps.c        |  6 ++++--
 sys/dev/isa/finsio_isa.c |  8 +++++---
 sys/dev/isa/itesio_isa.c |  6 ++++--
 sys/dev/isa/smsc.c       |  9 ++++++---
 sys/dev/isa/ug_isa.c     |  9 ++++++---
 5 files changed, 25 insertions(+), 13 deletions(-)

diffs (193 lines):

diff -r a6d6835f5f7c -r c06d17745fb9 sys/dev/isa/aps.c
--- a/sys/dev/isa/aps.c Wed Jun 29 15:37:25 2022 +0000
+++ b/sys/dev/isa/aps.c Wed Jun 29 15:56:58 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aps.c,v 1.17 2015/04/23 23:23:00 pgoyette Exp $        */
+/*     $NetBSD: aps.c,v 1.18 2022/06/29 15:56:58 mlelstv Exp $ */
 /*     $OpenBSD: aps.c,v 1.15 2007/05/19 19:14:11 tedu Exp $   */
 /*     $OpenBSD: aps.c,v 1.17 2008/06/27 06:08:43 canacar Exp $        */
 /*
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: aps.c,v 1.17 2015/04/23 23:23:00 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: aps.c,v 1.18 2022/06/29 15:56:58 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -348,6 +348,7 @@
                if (sysmon_envsys_sensor_attach(sc->sc_sme,
                        &sc->sc_sensor[i])) {
                        sysmon_envsys_destroy(sc->sc_sme);
+                       sc->sc_sme = NULL;
                        goto out;
                }
        }
@@ -361,6 +362,7 @@
                aprint_error_dev(self,
                    "unable to register with sysmon (%d)\n", i);
                sysmon_envsys_destroy(sc->sc_sme);
+               sc->sc_sme = NULL;
                goto out;
        }
 
diff -r a6d6835f5f7c -r c06d17745fb9 sys/dev/isa/finsio_isa.c
--- a/sys/dev/isa/finsio_isa.c  Wed Jun 29 15:37:25 2022 +0000
+++ b/sys/dev/isa/finsio_isa.c  Wed Jun 29 15:56:58 2022 +0000
@@ -1,5 +1,5 @@
 /*     $OpenBSD: fins.c,v 1.1 2008/03/19 19:33:09 deraadt Exp $        */
-/*     $NetBSD: finsio_isa.c,v 1.8 2015/04/23 23:23:00 pgoyette Exp $  */
+/*     $NetBSD: finsio_isa.c,v 1.9 2022/06/29 15:56:58 mlelstv Exp $   */
 
 /*
  * Copyright (c) 2008 Juan Romero Pardines
@@ -19,7 +19,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: finsio_isa.c,v 1.8 2015/04/23 23:23:00 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: finsio_isa.c,v 1.9 2022/06/29 15:56:58 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -573,6 +573,7 @@
 
 fail:
        sysmon_envsys_destroy(sc->sc_sme);
+       sc->sc_sme = NULL;
        bus_space_unmap(sc->sc_iot, sc->sc_ioh, FINSIO_DECODE_SIZE);
 }
 
@@ -581,7 +582,8 @@
 {
        struct finsio_softc *sc = device_private(self);
 
-       sysmon_envsys_unregister(sc->sc_sme);
+       if (sc->sc_sme != NULL)
+               sysmon_envsys_unregister(sc->sc_sme);
        bus_space_unmap(sc->sc_iot, sc->sc_ioh, FINSIO_DECODE_SIZE);
        return 0;
 }
diff -r a6d6835f5f7c -r c06d17745fb9 sys/dev/isa/itesio_isa.c
--- a/sys/dev/isa/itesio_isa.c  Wed Jun 29 15:37:25 2022 +0000
+++ b/sys/dev/isa/itesio_isa.c  Wed Jun 29 15:56:58 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: itesio_isa.c,v 1.29 2021/07/03 04:44:16 nonaka Exp $ */
+/*     $NetBSD: itesio_isa.c,v 1.30 2022/06/29 15:56:58 mlelstv Exp $ */
 /*     Derived from $OpenBSD: it.c,v 1.19 2006/04/10 00:57:54 deraadt Exp $    */
 
 /*
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: itesio_isa.c,v 1.29 2021/07/03 04:44:16 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: itesio_isa.c,v 1.30 2022/06/29 15:56:58 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -311,6 +311,7 @@
                if (sysmon_envsys_sensor_attach(sc->sc_sme,
                                                &sc->sc_sensor[i])) {
                        sysmon_envsys_destroy(sc->sc_sme);
+                       sc->sc_sme = NULL;
                        goto out;
                }
        }
@@ -325,6 +326,7 @@
                aprint_error_dev(self,
                    "unable to register with sysmon (%d)\n", error);
                sysmon_envsys_destroy(sc->sc_sme);
+               sc->sc_sme = NULL;
                goto out;
        }
        sc->sc_hwmon_enabled = true;
diff -r a6d6835f5f7c -r c06d17745fb9 sys/dev/isa/smsc.c
--- a/sys/dev/isa/smsc.c        Wed Jun 29 15:37:25 2022 +0000
+++ b/sys/dev/isa/smsc.c        Wed Jun 29 15:56:58 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: smsc.c,v 1.12 2015/04/23 23:23:00 pgoyette Exp $ */
+/*     $NetBSD: smsc.c,v 1.13 2022/06/29 15:56:58 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: smsc.c,v 1.12 2015/04/23 23:23:00 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smsc.c,v 1.13 2022/06/29 15:56:58 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -217,6 +217,7 @@
                if (sysmon_envsys_sensor_attach(sc->sc_sme,
                                                &sc->sc_sensor[i])) {
                        sysmon_envsys_destroy(sc->sc_sme);
+                       sc->sc_sme = NULL;
                        bus_space_unmap(sc->sc_iot, sc->sc_ioh, 2);
                        return;
                }
@@ -229,6 +230,7 @@
        if ((i = sysmon_envsys_register(sc->sc_sme)) != 0) {
                aprint_error(": unable to register with sysmon (%d)\n", i);
                sysmon_envsys_destroy(sc->sc_sme);
+               sc->sc_sme = NULL;
                bus_space_unmap(sc->sc_iot, sc->sc_ioh, 2);
                return;
        }
@@ -255,7 +257,8 @@
 {
        struct smsc_softc *sc = device_private(self);
 
-       sysmon_envsys_unregister(sc->sc_sme);
+       if (sc->sc_sme != NULL)
+               sysmon_envsys_unregister(sc->sc_sme);
        bus_space_unmap(sc->sc_iot, sc->sc_ioh, 2);
        return 0;
 }
diff -r a6d6835f5f7c -r c06d17745fb9 sys/dev/isa/ug_isa.c
--- a/sys/dev/isa/ug_isa.c      Wed Jun 29 15:37:25 2022 +0000
+++ b/sys/dev/isa/ug_isa.c      Wed Jun 29 15:56:58 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ug_isa.c,v 1.8 2020/06/24 19:24:44 jdolecek Exp $ */
+/* $NetBSD: ug_isa.c,v 1.9 2022/06/29 15:56:58 mlelstv Exp $ */
 
 /*
  * Copyright (c) 2007 Mihai Chelaru <kefren%netbsd.ro@localhost>
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ug_isa.c,v 1.8 2020/06/24 19:24:44 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ug_isa.c,v 1.9 2022/06/29 15:56:58 mlelstv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -148,6 +148,7 @@
                if (sysmon_envsys_sensor_attach(sc->sc_sme,
                                                &sc->sc_sensor[i])) {
                        sysmon_envsys_destroy(sc->sc_sme);
+                       sc->sc_sme = NULL;
                        goto out;
                }
        }
@@ -158,6 +159,7 @@
        if (sysmon_envsys_register(sc->sc_sme)) {
                aprint_error_dev(self, "unable to register with sysmon\n");
                sysmon_envsys_destroy(sc->sc_sme);
+               sc->sc_sme = NULL;
                goto out;
        }
 
@@ -173,7 +175,8 @@
 {
        struct ug_softc *sc = device_private(self);
 
-       sysmon_envsys_unregister(sc->sc_sme);
+       if (sc->sc_sme != NULL)
+               sysmon_envsys_unregister(sc->sc_sme);
        bus_space_unmap(sc->sc_iot, sc->sc_ioh, 8);
        return 0;
 }



Home | Main Index | Thread Index | Old Index