aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lepore <ian@FreeBSD.org>2014-12-24 01:19:11 +0000
committerIan Lepore <ian@FreeBSD.org>2014-12-24 01:19:11 +0000
commitcbe686f7093b29ad1060178f78626e6ec5166af7 (patch)
treef7c0e9f81cfcae6e9e39494e5d49399f6dc0c821
parent1dda8e90c989ad97a8dd3e8c9914c8100da1f3a5 (diff)
downloadsrc-cbe686f7093b29ad1060178f78626e6ec5166af7.tar.gz
src-cbe686f7093b29ad1060178f78626e6ec5166af7.zip
Don't assume required FDT properties are present.
Notes
Notes: svn path=/head/; revision=276162
-rw-r--r--sys/dev/ofw/ofw_cpu.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/dev/ofw/ofw_cpu.c b/sys/dev/ofw/ofw_cpu.c
index 226514059d56..1d01b63993e9 100644
--- a/sys/dev/ofw/ofw_cpu.c
+++ b/sys/dev/ofw/ofw_cpu.c
@@ -171,7 +171,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");
@@ -182,12 +182,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);