Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Feb 2015 00:35:59 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r278609 - stable/10/sys/dev/ofw
Message-ID:  <201502120035.t1C0ZxKn021260@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Thu Feb 12 00:35:58 2015
New Revision: 278609
URL: https://svnweb.freebsd.org/changeset/base/278609

Log:
  MFC r276162:  Don't assume required FDT properties are present.

Modified:
  stable/10/sys/dev/ofw/ofw_cpu.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/dev/ofw/ofw_cpu.c
==============================================================================
--- stable/10/sys/dev/ofw/ofw_cpu.c	Thu Feb 12 00:25:33 2015	(r278608)
+++ stable/10/sys/dev/ofw/ofw_cpu.c	Thu Feb 12 00:35:58 2015	(r278609)
@@ -170,7 +170,7 @@ ofw_cpu_probe(device_t dev)
 {
 	const char *type = ofw_bus_get_type(dev);
 
-	if (strcmp(type, "cpu") != 0)
+	if (type == NULL || strcmp(type, "cpu") != 0)
 		return (ENXIO);
 
 	device_set_desc(dev, "Open Firmware CPU");
@@ -181,12 +181,20 @@ static int
 ofw_cpu_attach(device_t dev)
 {
 	struct ofw_cpu_softc *sc;
+	phandle_t node;
 	uint32_t cell;
 
 	sc = device_get_softc(dev);
-	OF_getprop(ofw_bus_get_node(dev), "reg", &cell, sizeof(cell));
+	node = ofw_bus_get_node(dev);
+	if (OF_getencprop(node, "reg", &cell, sizeof(cell)) < 0) {
+		cell = device_get_unit(dev);
+		device_printf(dev, "missing 'reg' property, using %u\n", cell);
+	}
 	sc->sc_cpu_pcpu = pcpu_find(cell);
-	OF_getprop(ofw_bus_get_node(dev), "clock-frequency", &cell, sizeof(cell));
+	if (OF_getencprop(node, "clock-frequency", &cell, sizeof(cell)) < 0) {
+		device_printf(dev, "missing 'clock-frequency' property\n");
+		return (ENXIO);
+	}
 	sc->sc_nominal_mhz = cell / 1000000; /* convert to MHz */
 
 	bus_generic_probe(dev);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201502120035.t1C0ZxKn021260>