Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/mii Check the return value of PHY_READ(). Because, i...



details:   https://anonhg.NetBSD.org/src/rev/457811a0296f
branches:  trunk
changeset: 457565:457811a0296f
user:      maxv <maxv%NetBSD.org@localhost>
date:      Wed Jul 03 17:40:29 2019 +0000

description:
Check the return value of PHY_READ(). Because, if it fails, 'reg' is not
initialized. On Qemu, this read systematically fails.

Print an error in this case, and act as if there was no fiber. Maybe there
is a smarter way to fix this kind of things.

diffstat:

 sys/dev/mii/makphy.c |  10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diffs (31 lines):

diff -r eb2b868217da -r 457811a0296f sys/dev/mii/makphy.c
--- a/sys/dev/mii/makphy.c      Wed Jul 03 17:31:32 2019 +0000
+++ b/sys/dev/mii/makphy.c      Wed Jul 03 17:40:29 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: makphy.c,v 1.59 2019/03/25 07:34:13 msaitoh Exp $      */
+/*     $NetBSD: makphy.c,v 1.60 2019/07/03 17:40:29 maxv Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.59 2019/03/25 07:34:13 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: makphy.c,v 1.60 2019/07/03 17:40:29 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -204,7 +204,11 @@
        switch (model) {
        case MII_MODEL_xxMARVELL_E1011:
        case MII_MODEL_xxMARVELL_E1112:
-               PHY_READ(sc, MAKPHY_ESSR, &reg);
+               if (PHY_READ(sc, MAKPHY_ESSR, &reg) != 0) {
+                       aprint_verbose_dev(self,
+                           "Failed to read MAKPHY_ESSR\n");
+                       break;
+               }
                if (reg & ESSR_FIBER_LINK)
                        sc->mii_flags |= MIIF_HAVEFIBER;
                break;



Home | Main Index | Thread Index | Old Index