Source-Changes-HG archive

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

[src/bouyer-socketcan]: src/sys/arch/arm/allwinner Fix the reset code



details:   https://anonhg.NetBSD.org/src/rev/e062b8b080e3
branches:  bouyer-socketcan
changeset: 820890:e062b8b080e3
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Wed Apr 19 17:54:18 2017 +0000

description:
Fix the reset code
clear the IFF_UP flag if we can't get the interface running.

diffstat:

 sys/arch/arm/allwinner/awin_can.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (57 lines):

diff -r 9cb5ed4f244a -r e062b8b080e3 sys/arch/arm/allwinner/awin_can.c
--- a/sys/arch/arm/allwinner/awin_can.c Wed Apr 19 17:53:32 2017 +0000
+++ b/sys/arch/arm/allwinner/awin_can.c Wed Apr 19 17:54:18 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: awin_can.c,v 1.1.2.1 2017/04/18 21:30:38 bouyer Exp $  */
+/*     $NetBSD: awin_can.c,v 1.1.2.2 2017/04/19 17:54:18 bouyer Exp $  */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -36,7 +36,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: awin_can.c,v 1.1.2.1 2017/04/18 21:30:38 bouyer Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_can.c,v 1.1.2.2 2017/04/19 17:54:18 bouyer Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -119,8 +119,9 @@
        KASSERT(cf->cf_loc[AWINIOCF_PORT] == AWINIOCF_PORT_DEFAULT
            || cf->cf_loc[AWINIOCF_PORT] == loc->loc_port);
 
-       if (!awin_gpio_pinset_available(pinset))
+       if (!awin_gpio_pinset_available(pinset)) {
                return 0;
+       }
 
        return 1;
 }
@@ -465,6 +466,9 @@
                        if ((ifp->if_flags & IFF_UP) != 0 &&
                            (ifp->if_flags & IFF_RUNNING) == 0) {
                                error = awin_can_ifup(sc);
+                               if (error) {
+                                       ifp->if_flags &= ~IFF_UP;
+                               }
                        } else if ((ifp->if_flags & IFF_UP) == 0 &&
                            (ifp->if_flags & IFF_RUNNING) != 0) {
                                awin_can_ifdown(sc);
@@ -493,7 +497,7 @@
                val |= AWIN_CAN_MODSEL_RST;
                awin_can_write(sc, AWIN_CAN_MODSEL_REG, val);
                val = awin_can_read(sc, AWIN_CAN_MODSEL_REG);
-               if (val & AWIN_CAN_MODSEL_REG)
+               if (val & AWIN_CAN_MODSEL_RST)
                        return;
        }
        printf("%s: couldn't enter reset mode\n", device_xname(sc->sc_dev));
@@ -510,7 +514,7 @@
                val &= ~AWIN_CAN_MODSEL_RST;
                awin_can_write(sc, AWIN_CAN_MODSEL_REG, val);
                val = awin_can_read(sc, AWIN_CAN_MODSEL_REG);
-               if ((val & AWIN_CAN_MODSEL_REG) == 0)
+               if ((val & AWIN_CAN_MODSEL_RST) == 0)
                        return;
        }
        printf("%s: couldn't leave reset mode\n", device_xname(sc->sc_dev));



Home | Main Index | Thread Index | Old Index