Module Name:    src
Committed By:   thorpej
Date:           Sat Jul 13 21:56:23 UTC 2019

Modified Files:
        src/sys/arch/arm/sunxi: sunxi_emac.c

Log Message:
Make failure-to-attach errors a little more informative.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/sunxi/sunxi_emac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/sunxi/sunxi_emac.c
diff -u src/sys/arch/arm/sunxi/sunxi_emac.c:1.27 src/sys/arch/arm/sunxi/sunxi_emac.c:1.28
--- src/sys/arch/arm/sunxi/sunxi_emac.c:1.27	Thu May 23 10:40:39 2019
+++ src/sys/arch/arm/sunxi/sunxi_emac.c	Sat Jul 13 21:56:23 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_emac.c,v 1.27 2019/05/23 10:40:39 msaitoh Exp $ */
+/* $NetBSD: sunxi_emac.c,v 1.28 2019/07/13 21:56:23 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2016-2017 Jared McNeill <jmcne...@invisible.ca>
@@ -33,7 +33,7 @@
 #include "opt_net_mpsafe.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sunxi_emac.c,v 1.27 2019/05/23 10:40:39 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_emac.c,v 1.28 2019/07/13 21:56:23 thorpej Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -1280,23 +1280,33 @@ sunxi_emac_get_resources(struct sunxi_em
 	bus_addr_t addr, size;
 
 	/* Map EMAC registers */
-	if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0)
+	if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
+		aprint_error_dev(sc->dev, "unable to get registers\n");
 		return ENXIO;
-	if (bus_space_map(sc->bst, addr, size, 0, &sc->bsh) != 0)
+	}
+	if (bus_space_map(sc->bst, addr, size, 0, &sc->bsh) != 0) {
+		aprint_error_dev(sc->dev, "unable to map registers\n");
 		return ENXIO;
+	}
 
 	/* Get SYSCON registers */
 	sc->syscon = fdtbus_syscon_acquire(phandle, "syscon");
-	if (sc->syscon == NULL)
+	if (sc->syscon == NULL) {
+		aprint_error_dev(sc->dev, "unable to acquire syscon\n");
 		return ENXIO;
+	}
 
 	/* The "ahb"/"stmmaceth" clock and reset is required */
 	if ((sc->clk_ahb = fdtbus_clock_get(phandle, "ahb")) == NULL &&
-	    (sc->clk_ahb = fdtbus_clock_get(phandle, "stmmaceth")) == NULL)
+	    (sc->clk_ahb = fdtbus_clock_get(phandle, "stmmaceth")) == NULL) {
+		aprint_error_dev(sc->dev, "unable to get clock\n");
 		return ENXIO;
+	}
 	if ((sc->rst_ahb = fdtbus_reset_get(phandle, "ahb")) == NULL &&
-	    (sc->rst_ahb = fdtbus_reset_get(phandle, "stmmaceth")) == NULL)
+	    (sc->rst_ahb = fdtbus_reset_get(phandle, "stmmaceth")) == NULL) {
+		aprint_error_dev(sc->dev, "unable to get reset\n");
 		return ENXIO;
+	}
 
 	/* Internal PHY clock and reset are optional properties. */
 	sc->clk_ephy = fdtbus_clock_get(phandle, "ephy");
@@ -1366,12 +1376,16 @@ sunxi_emac_attach(device_t parent, devic
 	sc->type = of_search_compatible(phandle, compat_data)->data;
 	sc->phy_id = sunxi_emac_get_phyid(sc);
 
+	aprint_naive("\n");
+	aprint_normal(": EMAC\n");
+
 	if (sunxi_emac_get_resources(sc) != 0) {
-		aprint_error(": cannot allocate resources for device\n");
+		aprint_error_dev(self,
+		    "cannot allocate resources for device\n");
 		return;
 	}
 	if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
-		aprint_error(": cannot decode interrupt\n");
+		aprint_error_dev(self, "cannot decode interrupt\n");
 		return;
 	}
 
@@ -1379,9 +1393,6 @@ sunxi_emac_attach(device_t parent, devic
 	callout_init(&sc->stat_ch, CALLOUT_FLAGS);
 	callout_setfunc(&sc->stat_ch, sunxi_emac_tick, sc);
 
-	aprint_naive("\n");
-	aprint_normal(": EMAC\n");
-
 	/* Setup clocks and regulators */
 	if (sunxi_emac_setup_resources(sc) != 0)
 		return;

Reply via email to