From owner-svn-src-all@FreeBSD.ORG Wed Oct 23 13:55:43 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 1CE59E39; Wed, 23 Oct 2013 13:55:43 +0000 (UTC) (envelope-from nwhitehorn@FreeBSD.org) 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)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id F08D3211A; Wed, 23 Oct 2013 13:55:42 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9NDtgeL095836; Wed, 23 Oct 2013 13:55:42 GMT (envelope-from nwhitehorn@svn.freebsd.org) Received: (from nwhitehorn@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9NDtgvN095831; Wed, 23 Oct 2013 13:55:42 GMT (envelope-from nwhitehorn@svn.freebsd.org) Message-Id: <201310231355.r9NDtgvN095831@svn.freebsd.org> From: Nathan Whitehorn Date: Wed, 23 Oct 2013 13:55:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r256966 - 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-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Oct 2013 13:55:43 -0000 Author: nwhitehorn Date: Wed Oct 23 13:55:41 2013 New Revision: 256966 URL: http://svnweb.freebsd.org/changeset/base/256966 Log: Make all Open Firmware internal interfaces endian-safe by using the new OF_getencprop() API. This removes one explicit endianness conversion in ofw_iicbus.c. Modified: head/sys/dev/ofw/ofw_bus_subr.c head/sys/dev/ofw/ofw_console.c head/sys/dev/ofw/ofw_iicbus.c head/sys/dev/ofw/openfirm.c Modified: head/sys/dev/ofw/ofw_bus_subr.c ============================================================================== --- head/sys/dev/ofw/ofw_bus_subr.c Wed Oct 23 13:40:52 2013 (r256965) +++ head/sys/dev/ofw/ofw_bus_subr.c Wed Oct 23 13:55:41 2013 (r256966) @@ -214,14 +214,14 @@ ofw_bus_setup_iinfo(phandle_t node, stru pcell_t addrc; int msksz; - if (OF_getprop(node, "#address-cells", &addrc, sizeof(addrc)) == -1) + if (OF_getencprop(node, "#address-cells", &addrc, sizeof(addrc)) == -1) addrc = 2; ii->opi_addrc = addrc * sizeof(pcell_t); - ii->opi_imapsz = OF_getprop_alloc(node, "interrupt-map", 1, + ii->opi_imapsz = OF_getencprop_alloc(node, "interrupt-map", 1, (void **)&ii->opi_imap); if (ii->opi_imapsz > 0) { - msksz = OF_getprop_alloc(node, "interrupt-map-mask", 1, + msksz = OF_getencprop_alloc(node, "interrupt-map-mask", 1, (void **)&ii->opi_imapmsk); /* * Failure to get the mask is ignored; a full mask is used @@ -246,7 +246,7 @@ ofw_bus_lookup_imap(phandle_t node, stru ("ofw_bus_lookup_imap: register size too small: %d < %d", regsz, ii->opi_addrc)); if (node != -1) { - rv = OF_getprop(node, "reg", reg, regsz); + rv = OF_getencprop(node, "reg", reg, regsz); if (rv < regsz) panic("ofw_bus_lookup_imap: cannot get reg property"); } @@ -301,8 +301,8 @@ ofw_bus_search_intrmap(void *intr, int i i = imapsz; while (i > 0) { bcopy(mptr + physsz + intrsz, &parent, sizeof(parent)); - if (OF_searchprop(OF_xref_phandle(parent), "#interrupt-cells", - &pintrsz, sizeof(pintrsz)) == -1) + if (OF_searchencprop(OF_xref_phandle(parent), + "#interrupt-cells", &pintrsz, sizeof(pintrsz)) == -1) pintrsz = 1; /* default */ pintrsz *= sizeof(pcell_t); Modified: head/sys/dev/ofw/ofw_console.c ============================================================================== --- head/sys/dev/ofw/ofw_console.c Wed Oct 23 13:40:52 2013 (r256965) +++ head/sys/dev/ofw/ofw_console.c Wed Oct 23 13:55:41 2013 (r256966) @@ -106,8 +106,8 @@ cn_drvinit(void *unused) SYSINIT(cndev, SI_SUB_CONFIGURE, SI_ORDER_MIDDLE, cn_drvinit, NULL); -static int stdin; -static int stdout; +static pcell_t stdin; +static pcell_t stdout; static int ofwtty_open(struct tty *tp) @@ -170,12 +170,12 @@ ofw_cnprobe(struct consdev *cp) return; } - if (OF_getprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1) { + if (OF_getencprop(chosen, "stdin", &stdin, sizeof(stdin)) == -1) { cp->cn_pri = CN_DEAD; return; } - if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) { + if (OF_getencprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) { cp->cn_pri = CN_DEAD; return; } Modified: head/sys/dev/ofw/ofw_iicbus.c ============================================================================== --- head/sys/dev/ofw/ofw_iicbus.c Wed Oct 23 13:40:52 2013 (r256965) +++ head/sys/dev/ofw/ofw_iicbus.c Wed Oct 23 13:55:41 2013 (r256966) @@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$"); #include #include -#include #include #include #include @@ -104,7 +103,6 @@ ofw_iicbus_attach(device_t dev) phandle_t child; pcell_t paddr; device_t childdev; - uint32_t addr; sc->dev = dev; mtx_init(&sc->lock, "iicbus", NULL, MTX_DEF); @@ -123,11 +121,12 @@ ofw_iicbus_attach(device_t dev) * property, then try the reg property. It moves around * on different systems. */ - if (OF_getprop(child, "i2c-address", &paddr, sizeof(paddr)) == -1) - if (OF_getprop(child, "reg", &paddr, sizeof(paddr)) == -1) + if (OF_getencprop(child, "i2c-address", &paddr, + sizeof(paddr)) == -1) + if (OF_getencprop(child, "reg", &paddr, + sizeof(paddr)) == -1) continue; - addr = fdt32_to_cpu(paddr); /* * Now set up the I2C and OFW bus layer devinfo and add it * to the bus. @@ -136,7 +135,7 @@ ofw_iicbus_attach(device_t dev) M_NOWAIT | M_ZERO); if (dinfo == NULL) continue; - dinfo->opd_dinfo.addr = addr; + dinfo->opd_dinfo.addr = paddr; if (ofw_bus_gen_setup_devinfo(&dinfo->opd_obdinfo, child) != 0) { free(dinfo, M_DEVBUF); Modified: head/sys/dev/ofw/openfirm.c ============================================================================== --- head/sys/dev/ofw/openfirm.c Wed Oct 23 13:40:52 2013 (r256965) +++ head/sys/dev/ofw/openfirm.c Wed Oct 23 13:55:41 2013 (r256966) @@ -135,7 +135,8 @@ OF_init(void *cookie) rv = OFW_INIT(ofw_obj, cookie); if ((chosen = OF_finddevice("/chosen")) != -1) - if (OF_getprop(chosen, "stdout", &stdout, sizeof(stdout)) == -1) + if (OF_getencprop(chosen, "stdout", &stdout, + sizeof(stdout)) == -1) stdout = -1; return (rv); @@ -354,11 +355,9 @@ OF_getencprop_alloc(phandle_t package, c pcell_t *cell; int i; - KASSERT(elsz % 4 == 0, ("Need a multiple of 4 bytes")); - retval = OF_getprop_alloc(package, name, elsz, buf); - if (retval == -1) - return (retval); + if (retval == -1 || retval*elsz % 4 != 0) + return (-1); cell = *buf; for (i = 0; i < retval*elsz/4; i++) @@ -450,9 +449,9 @@ OF_child_xref_phandle(phandle_t parent, if (rxref != -1) return (rxref); - if (OF_getprop(child, "phandle", &rxref, sizeof(rxref)) == -1 && - OF_getprop(child, "ibm,phandle", &rxref, - sizeof(rxref)) == -1 && OF_getprop(child, + if (OF_getencprop(child, "phandle", &rxref, sizeof(rxref)) == + -1 && OF_getencprop(child, "ibm,phandle", &rxref, + sizeof(rxref)) == -1 && OF_getencprop(child, "linux,phandle", &rxref, sizeof(rxref)) == -1) continue;