Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/i2c Fix build and improve error handling



details:   https://anonhg.NetBSD.org/src/rev/2600d02ed528
branches:  trunk
changeset: 946414:2600d02ed528
user:      skrll <skrll%NetBSD.org@localhost>
date:      Thu Nov 26 12:53:03 2020 +0000

description:
Fix build and improve error handling

diffstat:

 sys/dev/i2c/g760a.c |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (49 lines):

diff -r 05f641c5ecd7 -r 2600d02ed528 sys/dev/i2c/g760a.c
--- a/sys/dev/i2c/g760a.c       Thu Nov 26 08:37:54 2020 +0000
+++ b/sys/dev/i2c/g760a.c       Thu Nov 26 12:53:03 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: g760a.c,v 1.5 2018/06/16 21:22:13 thorpej Exp $        */
+/*     $NetBSD: g760a.c,v 1.6 2020/11/26 12:53:03 skrll Exp $  */
 
 /*-
  * Copyright (C) 2008 A.Leo.
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(0, "$NetBSD: g760a.c,v 1.5 2018/06/16 21:22:13 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: g760a.c,v 1.6 2020/11/26 12:53:03 skrll Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -227,6 +227,8 @@
                        CTLTYPE_NODE, device_xname(sc->sc_dev), NULL,
                        NULL, 0, NULL, 0,
                        CTL_MACHDEP, CTL_CREATE, CTL_EOL);
+       if (ret)
+               goto sysctl_failed;
 
        (void)strlcpy(sc->sc_sensor.desc, "sysfan rpm",
                        sizeof(sc->sc_sensor.desc));
@@ -242,6 +244,9 @@
                        sysctl_g760a_rpm, 0x42, (void*)sc, 0,
                        CTL_MACHDEP, me->sysctl_num, CTL_CREATE, CTL_EOL);
 
+       if (ret)
+               goto sysctl_failed;
+
        sc->sc_sme->sme_name = device_xname(sc->sc_dev);
        sc->sc_sme->sme_cookie = sc;
        sc->sc_sme->sme_refresh = g760a_refresh;
@@ -255,6 +260,11 @@
        }
 
        return;
+
+sysctl_failed:
+       aprint_error_dev(sc->sc_dev,
+           "couldn't create sysctl nodes (%d)\n", ret);
+
 out:
        sysmon_envsys_destroy(sc->sc_sme);
 }



Home | Main Index | Thread Index | Old Index