Source-Changes-HG archive

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

src: PR/53177: David Binderman: Better error handling



details:   https://anonhg.NetBSD.org/src/rev/bf89c811ee15
branches:  trunk
changeset: 318118:bf89c811ee15
user:      christos <christos%NetBSD.org@localhost>
date:      Thu Apr 12 21:14:53 2018 +0000
description:
PR/53177: David Binderman: Better error handling

diffstat:

 sys/dev/i2c/xc5k.c |  33 ++++++++++++++++++++-------------
 1 files changed, 20 insertions(+), 13 deletions(-)

diffs (57 lines):

diff -r 57d2208c6cbb -r bf89c811ee15 sys/dev/i2c/xc5k.c
--- a/sys/dev/i2c/xc5k.c        Thu Apr 12 20:49:08 2018 +0000
+++ b/sys/dev/i2c/xc5k.c        Thu Apr 12 21:14:53 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xc5k.c,v 1.7 2017/06/01 02:45:10 chs Exp $ */
+/* $NetBSD: xc5k.c,v 1.8 2018/04/12 21:14:53 christos Exp $ */
 
 /*-
  * Copyright (c) 2010 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xc5k.c,v 1.7 2017/06/01 02:45:10 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xc5k.c,v 1.8 2018/04/12 21:14:53 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -158,20 +158,27 @@
 
        aprint_normal_dev(xc->parent, "xc5k: loading firmware '%s/%s'\n",
            XC5K_FIRMWARE_DRVNAME, XC5K_FIRMWARE_IMGNAME);
+
        error = xc5k_firmware_upload(xc, fw, fwlen);
-       if (!error) {
-               xc5k_read_2(xc, XC5K_REG_VERSION, &xcversion);
-               xc5k_read_2(xc, XC5K_REG_BUILD, &xcbuild);
-               if (!error)
-                       aprint_normal_dev(xc->parent,
-                           "xc5k: hw %d.%d, fw %d.%d.%d\n",
-                           (xcversion >> 12) & 0xf,
-                           (xcversion >> 8) & 0xf,
-                           (xcversion >> 4) & 0xf,
-                           xcversion & 0xf,
-                           xcbuild);
+       if (error)
+               goto done;
+
+       error = xc5k_read_2(xc, XC5K_REG_VERSION, &xcversion);
+       if (error) {
+               error = 0;
+               goto done;
        }
 
+       error = xc5k_read_2(xc, XC5K_REG_BUILD, &xcbuild);
+       if (error) {
+               error = 0;
+               xcbuild = 0;
+       }
+
+       aprint_normal_dev(xc->parent, "xc5k: hw %d.%d, fw %d.%d.%d\n",
+           (xcversion >> 12) & 0xf, (xcversion >> 8) & 0xf,
+           (xcversion >> 4) & 0xf, xcversion & 0xf, xcbuild);
+
 done:
        if (fw)
                firmware_free(fw, fwlen);



Home | Main Index | Thread Index | Old Index