From owner-svn-src-head@FreeBSD.ORG Wed Dec 24 01:19:12 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id B262C271; Wed, 24 Dec 2014 01:19:12 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9EFCF16DF; Wed, 24 Dec 2014 01:19:12 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sBO1JCVs076916; Wed, 24 Dec 2014 01:19:12 GMT (envelope-from ian@FreeBSD.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sBO1JCJB076915; Wed, 24 Dec 2014 01:19:12 GMT (envelope-from ian@FreeBSD.org) Message-Id: <201412240119.sBO1JCJB076915@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: ian set sender to ian@FreeBSD.org using -f From: Ian Lepore Date: Wed, 24 Dec 2014 01:19:12 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r276162 - head/sys/dev/ofw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Dec 2014 01:19:12 -0000 Author: ian Date: Wed Dec 24 01:19:11 2014 New Revision: 276162 URL: https://svnweb.freebsd.org/changeset/base/276162 Log: Don't assume required FDT properties are present. Modified: head/sys/dev/ofw/ofw_cpu.c Modified: head/sys/dev/ofw/ofw_cpu.c ============================================================================== --- head/sys/dev/ofw/ofw_cpu.c Wed Dec 24 01:10:53 2014 (r276161) +++ head/sys/dev/ofw/ofw_cpu.c Wed Dec 24 01:19:11 2014 (r276162) @@ -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);