Author: gonzo
Date: Sun Apr  8 22:59:34 2018
New Revision: 332310
URL: https://svnweb.freebsd.org/changeset/base/332310

Log:
  Clean up OF_getprop_alloc API
  
  OF_getprop_alloc takes element size argument and returns number of
  elements in the property. There are valid use cases for such behavior
  but mostly API consumers pass 1 as element size to get string
  properties. What API users would expect from OF_getprop_alloc is to be
  a combination of malloc + OF_getprop with the same semantic of return
  value. This patch modifies API signature to match these expectations.
  
  For the valid use cases with element size != 1 and to reduce
  modification scope new OF_getprop_alloc_multi function has been
  introduced that behaves the same way OF_getprop_alloc behaved prior to
  this patch.
  
  Reviewed by:  ian, manu
  Differential Revision:        https://reviews.freebsd.org/D14850

Modified:
  head/sys/arm/allwinner/aw_gpio.c
  head/sys/arm/allwinner/aw_if_dwc.c
  head/sys/arm/allwinner/if_awg.c
  head/sys/arm/amlogic/aml8726/aml8726_ccm.c
  head/sys/arm/amlogic/aml8726/aml8726_mmc.c
  head/sys/arm/amlogic/aml8726/aml8726_pinctrl.c
  head/sys/arm/amlogic/aml8726/aml8726_sdxc-m8.c
  head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c
  head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c
  head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
  head/sys/arm/freescale/vybrid/vf_ccm.c
  head/sys/arm/mv/mv_localbus.c
  head/sys/arm/nvidia/as3722_gpio.c
  head/sys/arm/nvidia/as3722_regulators.c
  head/sys/arm/nvidia/tegra124/tegra124_xusbpadctl.c
  head/sys/arm/nvidia/tegra_pinmux.c
  head/sys/arm/nvidia/tegra_usbphy.c
  head/sys/arm/ti/cpsw/if_cpsw.c
  head/sys/arm/ti/ti_hwmods.c
  head/sys/arm/ti/usb/omap_host.c
  head/sys/dev/altera/avgen/altera_avgen_fdt.c
  head/sys/dev/atkbdc/atkbdc_ebus.c
  head/sys/dev/etherswitch/e6000sw/e6000sw.c
  head/sys/dev/extres/regulator/regulator.c
  head/sys/dev/fdt/fdt_pinctrl.c
  head/sys/dev/fdt/fdt_slicer.c
  head/sys/dev/gpio/gpiokeys.c
  head/sys/dev/gpio/gpioled_fdt.c
  head/sys/dev/iicbus/adt746x.c
  head/sys/dev/le/lebuffer_sbus.c
  head/sys/dev/neta/if_mvneta_fdt.c
  head/sys/dev/ofw/ofw_bus_subr.c
  head/sys/dev/ofw/openfirm.c
  head/sys/dev/ofw/openfirm.h
  head/sys/dev/usb/controller/ehci_fsl.c
  head/sys/dev/vnic/thunder_bgx_fdt.c
  head/sys/mips/mediatek/mtk_pinctrl.c
  head/sys/powerpc/mpc85xx/fsl_diu.c
  head/sys/powerpc/powermac/macio.c
  head/sys/powerpc/powermac/uninorth.c
  head/sys/powerpc/psim/iobus.c
  head/sys/sparc64/central/central.c
  head/sys/sparc64/ebus/ebus.c
  head/sys/sparc64/fhc/fhc.c
  head/sys/sparc64/isa/isa.c
  head/sys/sparc64/pci/ofw_pci.c
  head/sys/sparc64/sbus/dma_sbus.c
  head/sys/sparc64/sbus/sbus.c
  head/sys/sparc64/sparc64/nexus.c
  head/sys/sparc64/sparc64/upa.c

Modified: head/sys/arm/allwinner/aw_gpio.c
==============================================================================
--- head/sys/arm/allwinner/aw_gpio.c    Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/arm/allwinner/aw_gpio.c    Sun Apr  8 22:59:34 2018        
(r332310)
@@ -559,10 +559,10 @@ aw_gpio_parse_function(phandle_t node)
 {
        char *function;
 
-       if (OF_getprop_alloc(node, "function", sizeof(*function),
+       if (OF_getprop_alloc(node, "function",
            (void **)&function) != -1)
                return (function);
-       if (OF_getprop_alloc(node, "allwinner,function", sizeof(*function),
+       if (OF_getprop_alloc(node, "allwinner,function",
            (void **)&function) != -1)
                return (function);
 

Modified: head/sys/arm/allwinner/aw_if_dwc.c
==============================================================================
--- head/sys/arm/allwinner/aw_if_dwc.c  Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/arm/allwinner/aw_if_dwc.c  Sun Apr  8 22:59:34 2018        
(r332310)
@@ -72,7 +72,7 @@ a20_if_dwc_init(device_t dev)
        node = ofw_bus_get_node(dev);
 
        /* Configure PHY for MII or RGMII mode */
-       if (OF_getprop_alloc(node, "phy-mode", 1, (void **)&phy_type)) {
+       if (OF_getprop_alloc(node, "phy-mode", (void **)&phy_type)) {
                error = clk_get_by_ofw_name(dev, 0, "allwinner_gmac_tx", 
&clk_tx);
                if (error != 0) {
                        device_printf(dev, "could not get tx clk\n");

Modified: head/sys/arm/allwinner/if_awg.c
==============================================================================
--- head/sys/arm/allwinner/if_awg.c     Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/arm/allwinner/if_awg.c     Sun Apr  8 22:59:34 2018        
(r332310)
@@ -1233,7 +1233,7 @@ awg_setup_phy(device_t dev)
        node = ofw_bus_get_node(dev);
        use_syscon = false;
 
-       if (OF_getprop_alloc(node, "phy-mode", 1, (void **)&phy_type) == 0)
+       if (OF_getprop_alloc(node, "phy-mode", (void **)&phy_type) == 0)
                return (0);
 
        if (sc->syscon != NULL || sc->res[_RES_SYSCON] != NULL)

Modified: head/sys/arm/amlogic/aml8726/aml8726_ccm.c
==============================================================================
--- head/sys/arm/amlogic/aml8726/aml8726_ccm.c  Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/arm/amlogic/aml8726/aml8726_ccm.c  Sun Apr  8 22:59:34 2018        
(r332310)
@@ -87,7 +87,7 @@ aml8726_ccm_configure_gates(struct aml8726_ccm_softc *
 
        node = ofw_bus_get_node(sc->dev);
 
-       len = OF_getprop_alloc(node, "functions", sizeof(char),
+       len = OF_getprop_alloc(node, "functions",
            (void **)&functions);
 
        if (len < 0) {

Modified: head/sys/arm/amlogic/aml8726/aml8726_mmc.c
==============================================================================
--- head/sys/arm/amlogic/aml8726/aml8726_mmc.c  Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/arm/amlogic/aml8726/aml8726_mmc.c  Sun Apr  8 22:59:34 2018        
(r332310)
@@ -585,7 +585,7 @@ aml8726_mmc_attach(device_t dev)
        }
 
        len = OF_getprop_alloc(OF_node_from_xref(prop[0]), "amlogic,function",
-           sizeof(char), (void **)&function_name);
+           (void **)&function_name);
 
        if (len < 0) {
                device_printf(dev,
@@ -635,7 +635,7 @@ aml8726_mmc_attach(device_t dev)
        }
 
        len = OF_getprop_alloc(node, "mmc-voltages",
-           sizeof(char), (void **)&voltages);
+           (void **)&voltages);
 
        if (len < 0) {
                device_printf(dev, "missing mmc-voltages attribute in FDT\n");

Modified: head/sys/arm/amlogic/aml8726/aml8726_pinctrl.c
==============================================================================
--- head/sys/arm/amlogic/aml8726/aml8726_pinctrl.c      Sun Apr  8 22:07:06 
2018        (r332309)
+++ head/sys/arm/amlogic/aml8726/aml8726_pinctrl.c      Sun Apr  8 22:59:34 
2018        (r332310)
@@ -194,7 +194,7 @@ aml8726_pinctrl_configure_pins(device_t dev, phandle_t
        node = OF_node_from_xref(cfgxref);
 
        len = OF_getprop_alloc(node, "amlogic,function",
-           sizeof(char), (void **)&function_name);
+           (void **)&function_name);
 
        if (len < 0) {
                device_printf(dev,
@@ -216,7 +216,7 @@ aml8726_pinctrl_configure_pins(device_t dev, phandle_t
        OF_prop_free(function_name);
 
        len = OF_getprop_alloc(node, "amlogic,pull",
-           sizeof(char), (void **)&pull);
+           (void **)&pull);
 
        pm = aml8726_unknown_pm;
 
@@ -257,7 +257,7 @@ aml8726_pinctrl_configure_pins(device_t dev, phandle_t
        }
 
        len = OF_getprop_alloc(node, "amlogic,pins",
-           sizeof(char), (void **)&pins);
+           (void **)&pins);
 
        if (len < 0) {
                device_printf(dev, "missing amlogic,pins attribute in FDT\n");

Modified: head/sys/arm/amlogic/aml8726/aml8726_sdxc-m8.c
==============================================================================
--- head/sys/arm/amlogic/aml8726/aml8726_sdxc-m8.c      Sun Apr  8 22:07:06 
2018        (r332309)
+++ head/sys/arm/amlogic/aml8726/aml8726_sdxc-m8.c      Sun Apr  8 22:59:34 
2018        (r332310)
@@ -796,7 +796,7 @@ aml8726_sdxc_attach(device_t dev)
        }
 
        len = OF_getprop_alloc(node, "mmc-voltages",
-           sizeof(char), (void **)&voltages);
+           (void **)&voltages);
 
        if (len < 0) {
                device_printf(dev, "missing mmc-voltages attribute in FDT\n");

Modified: head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c
==============================================================================
--- head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c   Sun Apr  8 22:07:06 
2018        (r332309)
+++ head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c   Sun Apr  8 22:59:34 
2018        (r332310)
@@ -126,7 +126,7 @@ aml8726_usb_phy_mode(const char *dwcotg_path, uint32_t
        *mode = 0;
 
        len = OF_getprop_alloc(node, "dr_mode",
-           sizeof(char), (void **)&usb_mode);
+           (void **)&usb_mode);
 
        if (len <= 0)
                return (0);

Modified: head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c
==============================================================================
--- head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c   Sun Apr  8 22:07:06 
2018        (r332309)
+++ head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c   Sun Apr  8 22:59:34 
2018        (r332310)
@@ -154,7 +154,7 @@ aml8726_usb_phy_attach(device_t dev)
        node = ofw_bus_get_node(dev);
 
        len = OF_getprop_alloc(node, "force-aca",
-           sizeof(char), (void **)&force_aca);
+           (void **)&force_aca);
 
        sc->force_aca = FALSE;
 

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
==============================================================================
--- head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c        Sun Apr  8 22:07:06 
2018        (r332309)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c        Sun Apr  8 22:59:34 
2018        (r332310)
@@ -677,7 +677,7 @@ bcm_gpio_get_reserved_pins(struct bcm_gpio_softc *sc)
        reserved = 0;
        node = OF_child(gpio);
        while ((node != 0) && (reserved == 0)) {
-               len = OF_getprop_alloc(node, "name", 1, (void **)&name);
+               len = OF_getprop_alloc(node, "name", (void **)&name);
                if (len == -1)
                        return (-1);
                if (strcmp(name, "reserved") == 0)

Modified: head/sys/arm/freescale/vybrid/vf_ccm.c
==============================================================================
--- head/sys/arm/freescale/vybrid/vf_ccm.c      Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/arm/freescale/vybrid/vf_ccm.c      Sun Apr  8 22:59:34 2018        
(r332310)
@@ -419,7 +419,7 @@ ccm_fdt_set(struct ccm_softc *sc)
 
                if ((len = OF_getproplen(child, "clock_names")) > 0) {
                        len = OF_getproplen(child, "clock_names");
-                       OF_getprop_alloc(child, "clock_names", 1,
+                       OF_getprop_alloc(child, "clock_names",
                            (void **)&fdt_config);
 
                        while (len > 0) {

Modified: head/sys/arm/mv/mv_localbus.c
==============================================================================
--- head/sys/arm/mv/mv_localbus.c       Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/arm/mv/mv_localbus.c       Sun Apr  8 22:59:34 2018        
(r332310)
@@ -175,7 +175,7 @@ fdt_localbus_reg_decode(phandle_t node, struct localbu
                return (ENXIO);
 
        tuple_size = sizeof(pcell_t) * (addr_cells + size_cells);
-       tuples = OF_getprop_alloc(node, "reg", tuple_size, (void **)&reg);
+       tuples = OF_getprop_alloc_multi(node, "reg", tuple_size, (void **)&reg);
        debugf("addr_cells = %d, size_cells = %d\n", addr_cells, size_cells);
        debugf("tuples = %d, tuple size = %d\n", tuples, tuple_size);
        if (tuples <= 0)

Modified: head/sys/arm/nvidia/as3722_gpio.c
==============================================================================
--- head/sys/arm/nvidia/as3722_gpio.c   Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/arm/nvidia/as3722_gpio.c   Sun Apr  8 22:59:34 2018        
(r332310)
@@ -212,12 +212,12 @@ as3722_pinmux_read_node(struct as3722_softc *sc, phand
 {
        int rv, i;
 
-       *lpins = OF_getprop_alloc(node, "pins", 1, (void **)pins);
+       *lpins = OF_getprop_alloc(node, "pins", (void **)pins);
        if (*lpins <= 0)
                return (ENOENT);
 
        /* Read function (mux) settings. */
-       rv = OF_getprop_alloc(node, "function", 1, (void **)&cfg->function);
+       rv = OF_getprop_alloc(node, "function", (void **)&cfg->function);
        if (rv <= 0)
                cfg->function = NULL;
 

Modified: head/sys/arm/nvidia/as3722_regulators.c
==============================================================================
--- head/sys/arm/nvidia/as3722_regulators.c     Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/arm/nvidia/as3722_regulators.c     Sun Apr  8 22:59:34 2018        
(r332310)
@@ -542,7 +542,7 @@ struct as3722_regnode_init_def *init_def)
        if (rv <= 0)
                return;
        supply_node = OF_node_from_xref(supply_node);
-       rv = OF_getprop_alloc(supply_node, "regulator-name", 1,
+       rv = OF_getprop_alloc(supply_node, "regulator-name",
            (void **)&init_def->reg_init_def.parent_name);
        if (rv <= 0)
                init_def->reg_init_def.parent_name = NULL;

Modified: head/sys/arm/nvidia/tegra124/tegra124_xusbpadctl.c
==============================================================================
--- head/sys/arm/nvidia/tegra124/tegra124_xusbpadctl.c  Sun Apr  8 22:07:06 
2018        (r332309)
+++ head/sys/arm/nvidia/tegra124/tegra124_xusbpadctl.c  Sun Apr  8 22:59:34 
2018        (r332310)
@@ -874,7 +874,7 @@ process_lane(struct padctl_softc *sc, phandle_t node, 
 
        name = NULL;
        function = NULL;
-       rv = OF_getprop_alloc(node, "name", 1, (void **)&name);
+       rv = OF_getprop_alloc(node, "name", (void **)&name);
        if (rv <= 0) {
                device_printf(sc->dev, "Cannot read lane name.\n");
                return (ENXIO);
@@ -888,7 +888,7 @@ process_lane(struct padctl_softc *sc, phandle_t node, 
        }
 
        /* Read function (mux) settings. */
-       rv = OF_getprop_alloc(node, "nvidia,function", 1, (void **)&function);
+       rv = OF_getprop_alloc(node, "nvidia,function", (void **)&function);
        if (rv <= 0) {
                device_printf(sc->dev, "Cannot read lane function.\n");
                rv = ENXIO;
@@ -947,7 +947,7 @@ process_pad(struct padctl_softc *sc, phandle_t node)
        int rv;
 
        name = NULL;
-       rv = OF_getprop_alloc(node, "name", 1, (void **)&name);
+       rv = OF_getprop_alloc(node, "name", (void **)&name);
        if (rv <= 0) {
                device_printf(sc->dev, "Cannot read pad name.\n");
                return (ENXIO);
@@ -992,7 +992,7 @@ process_port(struct padctl_softc *sc, phandle_t node)
        int rv;
 
        name = NULL;
-       rv = OF_getprop_alloc(node, "name", 1, (void **)&name);
+       rv = OF_getprop_alloc(node, "name", (void **)&name);
        if (rv <= 0) {
                device_printf(sc->dev, "Cannot read port name.\n");
                return (ENXIO);

Modified: head/sys/arm/nvidia/tegra_pinmux.c
==============================================================================
--- head/sys/arm/nvidia/tegra_pinmux.c  Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/arm/nvidia/tegra_pinmux.c  Sun Apr  8 22:59:34 2018        
(r332310)
@@ -648,12 +648,12 @@ pinmux_read_node(struct pinmux_softc *sc, phandle_t no
 {
        int rv, i;
 
-       *lpins = OF_getprop_alloc(node, "nvidia,pins", 1, (void **)pins);
+       *lpins = OF_getprop_alloc(node, "nvidia,pins", (void **)pins);
        if (*lpins <= 0)
                return (ENOENT);
 
        /* Read function (mux) settings. */
-       rv = OF_getprop_alloc(node, "nvidia,function", 1,
+       rv = OF_getprop_alloc(node, "nvidia,function",
            (void **)&cfg->function);
        if (rv <= 0)
                cfg->function = NULL;

Modified: head/sys/arm/nvidia/tegra_usbphy.c
==============================================================================
--- head/sys/arm/nvidia/tegra_usbphy.c  Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/arm/nvidia/tegra_usbphy.c  Sun Apr  8 22:59:34 2018        
(r332310)
@@ -593,7 +593,7 @@ usb_get_ifc_mode(device_t dev, phandle_t node, char *n
        int rv;
        enum usb_ifc_type ret;
 
-       rv = OF_getprop_alloc(node, name, 1, (void **)&tmpstr);
+       rv = OF_getprop_alloc(node, name, (void **)&tmpstr);
        if (rv <= 0)
                return (USB_IFC_TYPE_UNKNOWN);
 
@@ -615,7 +615,7 @@ usb_get_dr_mode(device_t dev, phandle_t node, char *na
        int rv;
        enum usb_dr_mode ret;
 
-       rv = OF_getprop_alloc(node, name, 1, (void **)&tmpstr);
+       rv = OF_getprop_alloc(node, name, (void **)&tmpstr);
        if (rv <= 0)
                return (USB_DR_MODE_UNKNOWN);
 

Modified: head/sys/arm/ti/cpsw/if_cpsw.c
==============================================================================
--- head/sys/arm/ti/cpsw/if_cpsw.c      Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/arm/ti/cpsw/if_cpsw.c      Sun Apr  8 22:59:34 2018        
(r332310)
@@ -746,7 +746,7 @@ cpsw_get_fdt_data(struct cpsw_softc *sc, int port)
        phy = -1;
        vlan = -1;
        for (child = OF_child(sc->node); child != 0; child = OF_peer(child)) {
-               if (OF_getprop_alloc(child, "name", 1, (void **)&name) < 0)
+               if (OF_getprop_alloc(child, "name", (void **)&name) < 0)
                        continue;
                if (sscanf(name, "slave@%lx", &mdio_child_addr) != 1) {
                        OF_prop_free(name);

Modified: head/sys/arm/ti/ti_hwmods.c
==============================================================================
--- head/sys/arm/ti/ti_hwmods.c Sun Apr  8 22:07:06 2018        (r332309)
+++ head/sys/arm/ti/ti_hwmods.c Sun Apr  8 22:59:34 2018        (r332310)
@@ -110,7 +110,7 @@ ti_hwmods_get_clock(device_t dev)
        if ((node = ofw_bus_get_node(dev)) == 0)
                return (INVALID_CLK_IDENT);
 
-       if ((len = OF_getprop_alloc(node, "ti,hwmods", 1, (void**)&name)) <= 0)
+       if ((len = OF_getprop_alloc(node, "ti,hwmods", (void**)&name)) <= 0)
                return (INVALID_CLK_IDENT);
 
        buf = name;
@@ -148,7 +148,7 @@ int ti_hwmods_contains(device_t dev, const char *hwmod
        if ((node = ofw_bus_get_node(dev)) == 0)
                return (0);
 
-       if ((len = OF_getprop_alloc(node, "ti,hwmods", 1, (void**)&name)) <= 0)
+       if ((len = OF_getprop_alloc(node, "ti,hwmods", (void**)&name)) <= 0)
                return (0);
 
        buf = name;
@@ -182,7 +182,7 @@ ti_hwmods_get_unit(device_t dev, const char *hwmod)
        if ((node = ofw_bus_get_node(dev)) == 0)
                return (0);
 
-       if ((len = OF_getprop_alloc(node, "ti,hwmods", 1, (void**)&name)) <= 0)
+       if ((len = OF_getprop_alloc(node, "ti,hwmods", (void**)&name)) <= 0)
                return (0);
 
        buf = name;

Modified: head/sys/arm/ti/usb/omap_host.c
==============================================================================
--- head/sys/arm/ti/usb/omap_host.c     Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/arm/ti/usb/omap_host.c     Sun Apr  8 22:59:34 2018        
(r332310)
@@ -392,7 +392,7 @@ omap_uhh_attach(device_t dev)
                snprintf(propname, sizeof(propname),
                    "port%d-mode", i+1);
 
-               if (OF_getprop_alloc(node, propname, 1, (void**)&mode) <= 0)
+               if (OF_getprop_alloc(node, propname, (void**)&mode) <= 0)
                        continue;
                if (strcmp(mode, "ehci-phy") == 0)
                        isc->port_mode[i] = EHCI_HCD_OMAP_MODE_PHY;

Modified: head/sys/dev/altera/avgen/altera_avgen_fdt.c
==============================================================================
--- head/sys/dev/altera/avgen/altera_avgen_fdt.c        Sun Apr  8 22:07:06 
2018        (r332309)
+++ head/sys/dev/altera/avgen/altera_avgen_fdt.c        Sun Apr  8 22:59:34 
2018        (r332310)
@@ -100,13 +100,13 @@ altera_avgen_fdt_attach(device_t dev)
        node = ofw_bus_get_node(dev);
        if (OF_getprop(node, "sri-cambridge,width", &cell, sizeof(cell)) > 0)
                sc->avg_width = cell;
-       (void)OF_getprop_alloc(node, "sri-cambridge,fileio", sizeof(char),
+       (void)OF_getprop_alloc(node, "sri-cambridge,fileio",
            (void **)&str_fileio);
-       (void)OF_getprop_alloc(node, "sri-cambridge,geomio", sizeof(char),
+       (void)OF_getprop_alloc(node, "sri-cambridge,geomio",
            (void **)&str_geomio);
-       (void)OF_getprop_alloc(node, "sri-cambridge,mmapio", sizeof(char),
+       (void)OF_getprop_alloc(node, "sri-cambridge,mmapio",
            (void **)&str_mmapio);
-       (void)OF_getprop_alloc(node,  "sri-cambridge,devname", sizeof(char),
+       (void)OF_getprop_alloc(node,  "sri-cambridge,devname",
            (void **)&str_devname);
        if (OF_getprop(node, "sri-cambridge,devunit", &cell, sizeof(cell)) > 0)
                devunit = cell;

Modified: head/sys/dev/atkbdc/atkbdc_ebus.c
==============================================================================
--- head/sys/dev/atkbdc/atkbdc_ebus.c   Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/dev/atkbdc/atkbdc_ebus.c   Sun Apr  8 22:59:34 2018        
(r332310)
@@ -238,7 +238,7 @@ atkbdc_ebus_attach(device_t dev)
        children = 0;
        for (child = OF_child(ofw_bus_get_node(dev)); child != 0;
            child = OF_peer(child)) {
-               if ((OF_getprop_alloc(child, "name", 1, (void **)&cname)) == -1)
+               if ((OF_getprop_alloc(child, "name", (void **)&cname)) == -1)
                        continue;
                if (children >= 2) {
                        device_printf(dev,

Modified: head/sys/dev/etherswitch/e6000sw/e6000sw.c
==============================================================================
--- head/sys/dev/etherswitch/e6000sw/e6000sw.c  Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/dev/etherswitch/e6000sw/e6000sw.c  Sun Apr  8 22:59:34 2018        
(r332310)
@@ -276,7 +276,7 @@ e6000sw_parse_child_fdt(e6000sw_softc_t *sc, phandle_t
                return (ENXIO);
        *pport = port;
 
-       if (OF_getprop_alloc(child, "label", 1, (void **)&portlabel) > 0) {
+       if (OF_getprop_alloc(child, "label", (void **)&portlabel) > 0) {
                if (strncmp(portlabel, "cpu", 3) == 0) {
                        device_printf(sc->dev, "CPU port at %d\n", port);
                        sc->cpuports_mask |= (1 << port);
@@ -287,7 +287,7 @@ e6000sw_parse_child_fdt(e6000sw_softc_t *sc, phandle_t
 
        fixed_link = OF_child(child);
        if (fixed_link != 0 &&
-           OF_getprop_alloc(fixed_link, "name", 1, (void **)&name) > 0) {
+           OF_getprop_alloc(fixed_link, "name", (void **)&name) > 0) {
                if (strncmp(name, "fixed-link", 10) == 0) {
                        /* Assume defaults: 1g - full-duplex. */
                        sc->fixed_mask |= (1 << port);

Modified: head/sys/dev/extres/regulator/regulator.c
==============================================================================
--- head/sys/dev/extres/regulator/regulator.c   Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/dev/extres/regulator/regulator.c   Sun Apr  8 22:59:34 2018        
(r332310)
@@ -1007,7 +1007,7 @@ regulator_parse_ofw_stdparam(device_t pdev, phandle_t 
        int rv;
 
        par = &def->std_param;
-       rv = OF_getprop_alloc(node, "regulator-name", 1,
+       rv = OF_getprop_alloc(node, "regulator-name",
            (void **)&def->name);
        if (rv <= 0) {
                device_printf(pdev, "%s: Missing regulator name\n",
@@ -1057,7 +1057,7 @@ regulator_parse_ofw_stdparam(device_t pdev, phandle_t 
        rv = OF_getencprop(node, "vin-supply", &supply_xref,
            sizeof(supply_xref));
        if (rv >=  0) {
-               rv = OF_getprop_alloc(supply_xref, "regulator-name", 1,
+               rv = OF_getprop_alloc(supply_xref, "regulator-name",
                    (void **)&def->parent_name);
                if (rv <= 0)
                        def->parent_name = NULL;

Modified: head/sys/dev/fdt/fdt_pinctrl.c
==============================================================================
--- head/sys/dev/fdt/fdt_pinctrl.c      Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/dev/fdt/fdt_pinctrl.c      Sun Apr  8 22:59:34 2018        
(r332310)
@@ -67,7 +67,7 @@ fdt_pinctrl_configure_by_name(device_t client, const c
        int i, offset, nameslen;
 
        nameslen = OF_getprop_alloc(ofw_bus_get_node(client), "pinctrl-names",
-           sizeof(*names), (void **)&names);
+           (void **)&names);
        if (nameslen <= 0)
                return (ENOENT);
        for (i = 0, offset = 0; offset < nameslen; i++) {

Modified: head/sys/dev/fdt/fdt_slicer.c
==============================================================================
--- head/sys/dev/fdt/fdt_slicer.c       Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/dev/fdt/fdt_slicer.c       Sun Apr  8 22:59:34 2018        
(r332310)
@@ -94,12 +94,12 @@ fdt_flash_fill_slices(device_t dev, const char *provid
                /*
                 * Retrieve label.
                 */
-               name_len = OF_getprop_alloc(dt_child, "label", sizeof(char),
+               name_len = OF_getprop_alloc(dt_child, "label",
                    (void **)&slice_name);
                if (name_len <= 0) {
                        /* Use node name if no label defined */
                        name_len = OF_getprop_alloc(dt_child, "name",
-                           sizeof(char), (void **)&slice_name);
+                           (void **)&slice_name);
                        if (name_len <= 0) {
                                debugf("slice i=%d with no name\n", i);
                                slice_name = NULL;

Modified: head/sys/dev/gpio/gpiokeys.c
==============================================================================
--- head/sys/dev/gpio/gpiokeys.c        Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/dev/gpio/gpiokeys.c        Sun Apr  8 22:59:34 2018        
(r332310)
@@ -271,8 +271,8 @@ gpiokeys_attach_key(struct gpiokeys_softc *sc, phandle
        callout_init_mtx(&key->repeat_callout, &key->mtx, 0);
 
        name = NULL;
-       if (OF_getprop_alloc(node, "label", 1, (void **)&name) == -1)
-               OF_getprop_alloc(node, "name", 1, (void **)&name);
+       if (OF_getprop_alloc(node, "label", (void **)&name) == -1)
+               OF_getprop_alloc(node, "name", (void **)&name);
 
        if (name != NULL)
                key_name = name;

Modified: head/sys/dev/gpio/gpioled_fdt.c
==============================================================================
--- head/sys/dev/gpio/gpioled_fdt.c     Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/dev/gpio/gpioled_fdt.c     Sun Apr  8 22:59:34 2018        
(r332310)
@@ -89,7 +89,7 @@ gpioleds_attach_led(struct gpioleds_softc *sc, phandle
 
        state = 0;
        if (OF_getprop_alloc(node, "default-state",
-           sizeof(char), (void **)&default_state) != -1) {
+           (void **)&default_state) != -1) {
                if (strcasecmp(default_state, "on") == 0)
                        state = 1;
                else if (strcasecmp(default_state, "off") == 0)
@@ -105,8 +105,8 @@ gpioleds_attach_led(struct gpioleds_softc *sc, phandle
        }
 
        name = NULL;
-       if (OF_getprop_alloc(node, "label", 1, (void **)&name) == -1)
-               OF_getprop_alloc(node, "name", 1, (void **)&name);
+       if (OF_getprop_alloc(node, "label", (void **)&name) == -1)
+               OF_getprop_alloc(node, "name", (void **)&name);
 
        if (name == NULL) {
                device_printf(sc->sc_dev,

Modified: head/sys/dev/iicbus/adt746x.c
==============================================================================
--- head/sys/dev/iicbus/adt746x.c       Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/dev/iicbus/adt746x.c       Sun Apr  8 22:59:34 2018        
(r332310)
@@ -360,8 +360,8 @@ adt746x_fill_fan_prop(device_t dev)
        child = ofw_bus_get_node(dev);
 
        /* Fill the fan location property. */
-       location_len = OF_getprop_alloc(child, "hwctrl-location", 1, (void 
**)&location);
-       id_len = OF_getprop_alloc(child, "hwctrl-id", sizeof(cell_t), (void 
**)&id);
+       location_len = OF_getprop_alloc(child, "hwctrl-location", (void 
**)&location);
+       id_len = OF_getprop_alloc_multi(child, "hwctrl-id", sizeof(cell_t), 
(void **)&id);
        if (location_len == -1 || id_len == -1) {
                OF_prop_free(location);
                OF_prop_free(id);

Modified: head/sys/dev/le/lebuffer_sbus.c
==============================================================================
--- head/sys/dev/le/lebuffer_sbus.c     Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/dev/le/lebuffer_sbus.c     Sun Apr  8 22:59:34 2018        
(r332310)
@@ -183,7 +183,7 @@ lebuffer_setup_dinfo(device_t dev, phandle_t node)
        }
        resource_list_init(&ldi->ldi_rl);
        slot = -1;
-       nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)&reg);
+       nreg = OF_getprop_alloc_multi(node, "reg", sizeof(*reg), (void **)&reg);
        if (nreg == -1) {
                device_printf(dev, "<%s>: incomplete\n",
                    ldi->ldi_obdinfo.obd_name);
@@ -217,7 +217,7 @@ lebuffer_setup_dinfo(device_t dev, phandle_t node)
        /*
         * The `interrupts' property contains the SBus interrupt level.
         */
-       nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intr),
+       nintr = OF_getprop_alloc_multi(node, "interrupts", sizeof(*intr),
            (void **)&intr);
        if (nintr != -1) {
                for (i = 0; i < nintr; i++) {

Modified: head/sys/dev/neta/if_mvneta_fdt.c
==============================================================================
--- head/sys/dev/neta/if_mvneta_fdt.c   Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/dev/neta/if_mvneta_fdt.c   Sun Apr  8 22:59:34 2018        
(r332310)
@@ -159,7 +159,7 @@ mvneta_fdt_phy_acquire(device_t dev)
                /* Test for fixed-link (present i.e. in 388-gp) */
                for (child = OF_child(node); child != 0; child = 
OF_peer(child)) {
                        if (OF_getprop_alloc(child,
-                           "name", 1, (void **)&name) <= 0) {
+                           "name", (void **)&name) <= 0) {
                                continue;
                        }
                        if (strncmp(name, "fixed-link", 10) == 0) {

Modified: head/sys/dev/ofw/ofw_bus_subr.c
==============================================================================
--- head/sys/dev/ofw/ofw_bus_subr.c     Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/dev/ofw/ofw_bus_subr.c     Sun Apr  8 22:59:34 2018        
(r332310)
@@ -57,12 +57,12 @@ ofw_bus_gen_setup_devinfo(struct ofw_bus_devinfo *obd,
        if (obd == NULL)
                return (ENOMEM);
        /* The 'name' property is considered mandatory. */
-       if ((OF_getprop_alloc(node, "name", 1, (void **)&obd->obd_name)) == -1)
+       if ((OF_getprop_alloc(node, "name", (void **)&obd->obd_name)) == -1)
                return (EINVAL);
-       OF_getprop_alloc(node, "compatible", 1, (void **)&obd->obd_compat);
-       OF_getprop_alloc(node, "device_type", 1, (void **)&obd->obd_type);
-       OF_getprop_alloc(node, "model", 1, (void **)&obd->obd_model);
-       OF_getprop_alloc(node, "status", 1, (void **)&obd->obd_status);
+       OF_getprop_alloc(node, "compatible", (void **)&obd->obd_compat);
+       OF_getprop_alloc(node, "device_type", (void **)&obd->obd_type);
+       OF_getprop_alloc(node, "model", (void **)&obd->obd_model);
+       OF_getprop_alloc(node, "status", (void **)&obd->obd_status);
        obd->obd_node = node;
        return (0);
 }
@@ -502,7 +502,7 @@ ofw_bus_reg_to_rl_helper(device_t dev, phandle_t node,
         * This may be just redundant when having ofw_bus_devinfo
         * but makes this routine independent of it.
         */
-       ret = OF_getprop_alloc(node, "name", sizeof(*name), (void **)&name);
+       ret = OF_getprop_alloc(node, "name", (void **)&name);
        if (ret == -1)
                name = NULL;
 
@@ -720,7 +720,7 @@ ofw_bus_find_child(phandle_t start, const char *child_
        phandle_t child;
 
        for (child = OF_child(start); child != 0; child = OF_peer(child)) {
-               ret = OF_getprop_alloc(child, "name", sizeof(*name), (void 
**)&name);
+               ret = OF_getprop_alloc(child, "name", (void **)&name);
                if (ret == -1)
                        continue;
                if (strcmp(name, child_name) == 0) {
@@ -916,7 +916,7 @@ ofw_bus_find_string_index(phandle_t node, const char *
        int rv, i, cnt, nelems;
 
        elems = NULL;
-       nelems = OF_getprop_alloc(node, list_name, 1, (void **)&elems);
+       nelems = OF_getprop_alloc(node, list_name, (void **)&elems);
        if (nelems <= 0)
                return (ENOENT);
 
@@ -947,7 +947,7 @@ ofw_bus_string_list_to_array(phandle_t node, const cha
        int i, cnt, nelems, len;
 
        elems = NULL;
-       nelems = OF_getprop_alloc(node, list_name, 1, (void **)&elems);
+       nelems = OF_getprop_alloc(node, list_name, (void **)&elems);
        if (nelems <= 0)
                return (nelems);
 

Modified: head/sys/dev/ofw/openfirm.c
==============================================================================
--- head/sys/dev/ofw/openfirm.c Sun Apr  8 22:07:06 2018        (r332309)
+++ head/sys/dev/ofw/openfirm.c Sun Apr  8 22:59:34 2018        (r332310)
@@ -440,11 +440,35 @@ OF_searchencprop(phandle_t node, const char *propname,
 
 /*
  * Store the value of a property of a package into newly allocated memory
+ * (using the M_OFWPROP malloc pool and M_WAITOK).
+ */
+ssize_t
+OF_getprop_alloc(phandle_t package, const char *propname, void **buf)
+{
+       int len;
+
+       *buf = NULL;
+       if ((len = OF_getproplen(package, propname)) == -1)
+               return (-1);
+
+       if (len > 0) {
+               *buf = malloc(len, M_OFWPROP, M_WAITOK);
+               if (OF_getprop(package, propname, *buf, len) == -1) {
+                       free(*buf, M_OFWPROP);
+                       *buf = NULL;
+                       return (-1);
+               }
+       }
+       return (len);
+}
+
+/*
+ * Store the value of a property of a package into newly allocated memory
  * (using the M_OFWPROP malloc pool and M_WAITOK).  elsz is the size of a
  * single element, the number of elements is return in number.
  */
 ssize_t
-OF_getprop_alloc(phandle_t package, const char *propname, int elsz, void **buf)
+OF_getprop_alloc_multi(phandle_t package, const char *propname, int elsz, void 
**buf)
 {
        int len;
 
@@ -453,15 +477,18 @@ OF_getprop_alloc(phandle_t package, const char *propna
            len % elsz != 0)
                return (-1);
 
-       *buf = malloc(len, M_OFWPROP, M_WAITOK);
-       if (OF_getprop(package, propname, *buf, len) == -1) {
-               free(*buf, M_OFWPROP);
-               *buf = NULL;
-               return (-1);
+       if (len > 0) {
+               *buf = malloc(len, M_OFWPROP, M_WAITOK);
+               if (OF_getprop(package, propname, *buf, len) == -1) {
+                       free(*buf, M_OFWPROP);
+                       *buf = NULL;
+                       return (-1);
+               }
        }
        return (len / elsz);
 }
 
+
 ssize_t
 OF_getencprop_alloc(phandle_t package, const char *name, int elsz, void **buf)
 {
@@ -469,7 +496,7 @@ OF_getencprop_alloc(phandle_t package, const char *nam
        pcell_t *cell;
        int i;
 
-       retval = OF_getprop_alloc(package, name, elsz, buf);
+       retval = OF_getprop_alloc_multi(package, name, elsz, buf);
        if (retval == -1)
                return (-1);
        if (retval * elsz % 4 != 0) {

Modified: head/sys/dev/ofw/openfirm.h
==============================================================================
--- head/sys/dev/ofw/openfirm.h Sun Apr  8 22:07:06 2018        (r332309)
+++ head/sys/dev/ofw/openfirm.h Sun Apr  8 22:59:34 2018        (r332310)
@@ -116,6 +116,8 @@ ssize_t             OF_searchprop(phandle_t node, const 
char *pro
 ssize_t                OF_searchencprop(phandle_t node, const char *propname,
                    void *buf, size_t len);
 ssize_t                OF_getprop_alloc(phandle_t node, const char *propname,
+                   void **buf);
+ssize_t                OF_getprop_alloc_multi(phandle_t node, const char 
*propname,
                    int elsz, void **buf);
 ssize_t                OF_getencprop_alloc(phandle_t node, const char 
*propname,
                    int elsz, void **buf);

Modified: head/sys/dev/usb/controller/ehci_fsl.c
==============================================================================
--- head/sys/dev/usb/controller/ehci_fsl.c      Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/dev/usb/controller/ehci_fsl.c      Sun Apr  8 22:59:34 2018        
(r332310)
@@ -175,7 +175,7 @@ enable_usb(device_t dev, bus_space_tag_t iot, bus_spac
 
        node = ofw_bus_get_node(dev);
        if ((node != 0) &&
-           (OF_getprop_alloc(node, "phy_type", 1, (void **)&phy_type) > 0)) {
+           (OF_getprop_alloc(node, "phy_type", (void **)&phy_type) > 0)) {
                if (strncasecmp(phy_type, "utmi", strlen("utmi")) == 0)
                        tmp |= UTMI_PHY_EN;
                OF_prop_free(phy_type);

Modified: head/sys/dev/vnic/thunder_bgx_fdt.c
==============================================================================
--- head/sys/dev/vnic/thunder_bgx_fdt.c Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/dev/vnic/thunder_bgx_fdt.c Sun Apr  8 22:59:34 2018        
(r332310)
@@ -396,7 +396,7 @@ bgx_fdt_init_phy(struct bgx *bgx)
                                continue;
                        }
                } else {
-                       len = OF_getprop_alloc(child, "name", 1,
+                       len = OF_getprop_alloc(child, "name",
                            (void **)&node_name);
                        if (len <= 0) {
                                continue;

Modified: head/sys/mips/mediatek/mtk_pinctrl.c
==============================================================================
--- head/sys/mips/mediatek/mtk_pinctrl.c        Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/mips/mediatek/mtk_pinctrl.c        Sun Apr  8 22:59:34 2018        
(r332310)
@@ -136,7 +136,7 @@ mtk_pinctrl_process_node(device_t dev, struct mtk_pin_
        if (num_groups <= 0)
                return (ENOENT);
 
-       if (OF_getprop_alloc(node, "ralink,function", sizeof(*pin_function),
+       if (OF_getprop_alloc_multi(node, "ralink,function", 
sizeof(*pin_function),
                             (void **)&pin_function) == -1) {
                ret = ENOENT;
                goto out;

Modified: head/sys/powerpc/mpc85xx/fsl_diu.c
==============================================================================
--- head/sys/powerpc/mpc85xx/fsl_diu.c  Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/powerpc/mpc85xx/fsl_diu.c  Sun Apr  8 22:59:34 2018        
(r332310)
@@ -362,7 +362,7 @@ diu_attach(device_t dev)
        }
 
        /* TODO: Eventually, allow EDID to be dynamically provided. */
-       if (OF_getprop_alloc(node, "edid", 1, &edid_cells) <= 0) {
+       if (OF_getprop_alloc(node, "edid", &edid_cells) <= 0) {
                /*
                 * u-boot uses the environment variable name 'video-mode', so
                 * just use the same name here.  Should allow another variable

Modified: head/sys/powerpc/powermac/macio.c
==============================================================================
--- head/sys/powerpc/powermac/macio.c   Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/powerpc/powermac/macio.c   Sun Apr  8 22:59:34 2018        
(r332310)
@@ -203,10 +203,10 @@ macio_add_intr(phandle_t devnode, struct macio_devinfo
                return;
        }
 
-       nintr = OF_getprop_alloc(devnode, "interrupts", sizeof(*intr), 
+       nintr = OF_getprop_alloc_multi(devnode, "interrupts", sizeof(*intr), 
                (void **)&intr);
        if (nintr == -1) {
-               nintr = OF_getprop_alloc(devnode, "AAPL,interrupts", 
+               nintr = OF_getprop_alloc_multi(devnode, "AAPL,interrupts", 
                        sizeof(*intr), (void **)&intr);
                if (nintr == -1)
                        return;
@@ -243,7 +243,7 @@ macio_add_reg(phandle_t devnode, struct macio_devinfo 
        char            buf[8];
        int             i, layout_id = 0, nreg, res;
 
-       nreg = OF_getprop_alloc(devnode, "reg", sizeof(*reg), (void **)&reg);
+       nreg = OF_getprop_alloc_multi(devnode, "reg", sizeof(*reg), (void 
**)&reg);
        if (nreg == -1)
                return;
 
@@ -269,7 +269,7 @@ macio_add_reg(phandle_t devnode, struct macio_devinfo 
                                sizeof(layout_id));
 
                 if (res > 0 && (layout_id == 36 || layout_id == 76)) {
-                        res = OF_getprop_alloc(OF_parent(devnode), "reg",
+                        res = OF_getprop_alloc_multi(OF_parent(devnode), "reg",
                                                sizeof(*regp), (void **)&regp);
                         reg[0] = regp[0];
                         reg[1].mr_base = regp[1].mr_base;

Modified: head/sys/powerpc/powermac/uninorth.c
==============================================================================
--- head/sys/powerpc/powermac/uninorth.c        Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/powerpc/powermac/uninorth.c        Sun Apr  8 22:59:34 2018        
(r332310)
@@ -164,10 +164,10 @@ unin_chip_add_intr(phandle_t devnode, struct unin_chip
                return;
        }
 
-       nintr = OF_getprop_alloc(devnode, "interrupts", sizeof(*intr), 
+       nintr = OF_getprop_alloc_multi(devnode, "interrupts", sizeof(*intr), 
                (void **)&intr);
        if (nintr == -1) {
-               nintr = OF_getprop_alloc(devnode, "AAPL,interrupts", 
+               nintr = OF_getprop_alloc_multi(devnode, "AAPL,interrupts", 
                        sizeof(*intr), (void **)&intr);
                if (nintr == -1)
                        return;
@@ -207,7 +207,7 @@ unin_chip_add_reg(phandle_t devnode, struct unin_chip_
        struct  unin_chip_reg *reg;
        int     i, nreg;
 
-       nreg = OF_getprop_alloc(devnode, "reg", sizeof(*reg), (void **)&reg);
+       nreg = OF_getprop_alloc_multi(devnode, "reg", sizeof(*reg), (void 
**)&reg);
        if (nreg == -1)
                return;
 

Modified: head/sys/powerpc/psim/iobus.c
==============================================================================
--- head/sys/powerpc/psim/iobus.c       Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/powerpc/psim/iobus.c       Sun Apr  8 22:59:34 2018        
(r332310)
@@ -221,7 +221,7 @@ iobus_attach(device_t dev)
         root = sc->sc_node;
 
         for (child = OF_child(root); child != 0; child = OF_peer(child)) {
-                OF_getprop_alloc(child, "name", 1, (void **)&name);
+                OF_getprop_alloc(child, "name", (void **)&name);
 
                 cdev = device_add_child(dev, NULL, -1);
                 if (cdev != NULL) {

Modified: head/sys/sparc64/central/central.c
==============================================================================
--- head/sys/sparc64/central/central.c  Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/sparc64/central/central.c  Sun Apr  8 22:59:34 2018        
(r332310)
@@ -140,7 +140,7 @@ central_attach(device_t dev)
        sc = device_get_softc(dev);
        node = ofw_bus_get_node(dev);
 
-       sc->sc_nrange = OF_getprop_alloc(node, "ranges",
+       sc->sc_nrange = OF_getprop_alloc_multi(node, "ranges",
            sizeof(*sc->sc_ranges), (void **)&sc->sc_ranges);
        if (sc->sc_nrange == -1) {
                device_printf(dev, "can't get ranges\n");
@@ -153,7 +153,7 @@ central_attach(device_t dev)
                        free(cdi, M_DEVBUF);
                        continue;
                }
-               nreg = OF_getprop_alloc(child, "reg", sizeof(*reg),
+               nreg = OF_getprop_alloc_multi(child, "reg", sizeof(*reg),
                    (void **)&reg);
                if (nreg == -1) {
                        device_printf(dev, "<%s>: incomplete\n",

Modified: head/sys/sparc64/ebus/ebus.c
==============================================================================
--- head/sys/sparc64/ebus/ebus.c        Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/sparc64/ebus/ebus.c        Sun Apr  8 22:59:34 2018        
(r332310)
@@ -292,7 +292,7 @@ ebus_nexus_attach(device_t dev)
        }
 #endif
 
-       sc->sc_nrange = OF_getprop_alloc(node, "ranges",
+       sc->sc_nrange = OF_getprop_alloc_multi(node, "ranges",
            sizeof(struct ebus_nexus_ranges), &sc->sc_range);
        if (sc->sc_nrange == -1) {
                device_printf(dev, "could not get ranges property\n");
@@ -321,7 +321,7 @@ ebus_pci_attach(device_t dev)
        pci_write_config(dev, PCIR_LATTIMER, 64 /* 64 PCI cycles */, 1);
 
        node = ofw_bus_get_node(dev);
-       sc->sc_nrange = OF_getprop_alloc(node, "ranges",
+       sc->sc_nrange = OF_getprop_alloc_multi(node, "ranges",
            sizeof(struct isa_ranges), &sc->sc_range);
        if (sc->sc_nrange == -1) {
                device_printf(dev, "could not get ranges property\n");
@@ -660,7 +660,7 @@ ebus_setup_dinfo(device_t dev, struct ebus_softc *sc, 
                return (NULL);
        }
        resource_list_init(&edi->edi_rl);
-       nreg = OF_getprop_alloc(node, "reg", sizeof(*regs), (void **)&regs);
+       nreg = OF_getprop_alloc_multi(node, "reg", sizeof(*regs), (void 
**)&regs);
        if (nreg == -1) {
                device_printf(dev, "<%s>: incomplete\n",
                    edi->edi_obdinfo.obd_name);
@@ -674,7 +674,7 @@ ebus_setup_dinfo(device_t dev, struct ebus_softc *sc, 
        }
        OF_prop_free(regs);
 
-       nintr = OF_getprop_alloc(node, "interrupts",  sizeof(*intrs),
+       nintr = OF_getprop_alloc_multi(node, "interrupts",  sizeof(*intrs),
            (void **)&intrs);
        if (nintr == -1)
                return (edi);

Modified: head/sys/sparc64/fhc/fhc.c
==============================================================================
--- head/sys/sparc64/fhc/fhc.c  Sun Apr  8 22:07:06 2018        (r332309)
+++ head/sys/sparc64/fhc/fhc.c  Sun Apr  8 22:59:34 2018        (r332310)
@@ -205,7 +205,7 @@ fhc_attach(device_t dev)
        }
 
        device_printf(dev, "board %d, ", board);
-       if (OF_getprop_alloc(node, "board-model", 1, (void **)&name) != -1) {
+       if (OF_getprop_alloc(node, "board-model", (void **)&name) != -1) {
                printf("model %s\n", name);
                OF_prop_free(name);
        } else
@@ -227,7 +227,7 @@ fhc_attach(device_t dev)
        bus_write_4(sc->sc_memres[FHC_INTERNAL], FHC_CTRL, ctrl);
        (void)bus_read_4(sc->sc_memres[FHC_INTERNAL], FHC_CTRL);
 
-       sc->sc_nrange = OF_getprop_alloc(node, "ranges",
+       sc->sc_nrange = OF_getprop_alloc_multi(node, "ranges",
            sizeof(*sc->sc_ranges), (void **)&sc->sc_ranges);
        if (sc->sc_nrange == -1) {
                device_printf(dev, "cannot get ranges\n");
@@ -285,7 +285,7 @@ fhc_attach(device_t dev)
                        free(fdi, M_DEVBUF);
                        continue;
                }
-               i = OF_getprop_alloc(child, "reg", sizeof(*reg),
+               i = OF_getprop_alloc_multi(child, "reg", sizeof(*reg),
                    (void **)&reg);
                if (i == -1) {
                        device_printf(dev, "<%s>: incomplete\n",
@@ -301,7 +301,7 @@ fhc_attach(device_t dev)
                            reg[j].sbr_size, reg[j].sbr_size);
                OF_prop_free(reg);
                if (central == 1) {
-                       i = OF_getprop_alloc(child, "interrupts",
+                       i = OF_getprop_alloc_multi(child, "interrupts",
                            sizeof(*intr), (void **)&intr);
                        if (i != -1) {
                                for (j = 0; j < i; j++) {

Modified: head/sys/sparc64/isa/isa.c
==============================================================================
--- head/sys/sparc64/isa/isa.c  Sun Apr  8 22:07:06 2018        (r332309)
+++ head/sys/sparc64/isa/isa.c  Sun Apr  8 22:59:34 2018        (r332310)
@@ -92,7 +92,7 @@ isa_init(device_t dev)
        /* The parent of the bus must be a PCI-ISA bridge. */
        bridge = device_get_parent(dev);
        isab_node = ofw_bus_get_node(bridge);
-       isab_nrange = OF_getprop_alloc(isab_node, "ranges",
+       isab_nrange = OF_getprop_alloc_multi(isab_node, "ranges",
            sizeof(*isab_ranges), (void **)&isab_ranges);
        if (isab_nrange <= 0)
                panic("isa_init: cannot get bridge range property");
@@ -162,7 +162,7 @@ isa_setup_children(device_t dev, phandle_t parent)
         * allow for an isa_activate_resource().
         */
        for (node = OF_child(parent); node != 0; node = OF_peer(node)) {
-               if ((OF_getprop_alloc(node, "name", 1, (void **)&name)) == -1)
+               if ((OF_getprop_alloc(node, "name", (void **)&name)) == -1)
                        continue;
 
                /*
@@ -192,7 +192,7 @@ isa_setup_children(device_t dev, phandle_t parent)
                isa_set_vendorid(cdev, ofw_isa_pnp_map[i].id);
 
                rl = BUS_GET_RESOURCE_LIST(dev, cdev);
-               nreg = OF_getprop_alloc(node, "reg", sizeof(*regs),
+               nreg = OF_getprop_alloc_multi(node, "reg", sizeof(*regs),
                    (void **)&regs);
                for (i = 0; i < nreg; i++) {
                        start = ISA_REG_PHYS(&regs[i]);
@@ -211,12 +211,12 @@ isa_setup_children(device_t dev, phandle_t parent)
                         * the set of registers of the parent device like
                         * with the nodes hanging off of the `8042' node.
                         */
-                       nregidx = OF_getprop_alloc(node, "reg", sizeof(*regidx),
+                       nregidx = OF_getprop_alloc_multi(node, "reg", 
sizeof(*regidx),
                            (void **)&regidx);
                        if (nregidx > 2)
                                panic("isa_setup_children: impossible number "
                                    "of register indices");
-                       if (nregidx != -1 && (nreg = OF_getprop_alloc(parent,
+                       if (nregidx != -1 && (nreg = 
OF_getprop_alloc_multi(parent,
                            "reg", sizeof(*regs), (void **)&regs)) >= nregidx) {
                                for (i = 0; i < nregidx; i++) {
                                        start = ISA_REG_PHYS(&regs[regidx[i]]);
@@ -237,7 +237,7 @@ isa_setup_children(device_t dev, phandle_t parent)
                if (regs != NULL)
                        OF_prop_free(regs);
 
-               nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intrs),
+               nintr = OF_getprop_alloc_multi(node, "interrupts", 
sizeof(*intrs),
                    (void **)&intrs);
                for (i = 0; i < nintr; i++) {
                        if (intrs[i] > 7)
@@ -255,7 +255,7 @@ isa_setup_children(device_t dev, phandle_t parent)
                if (intrs != NULL)
                        OF_prop_free(intrs);
 
-               ndrq = OF_getprop_alloc(node, "dma-channel", sizeof(*drqs),
+               ndrq = OF_getprop_alloc_multi(node, "dma-channel", 
sizeof(*drqs),
                    (void **)&drqs);
                for (i = 0; i < ndrq; i++)
                        bus_set_resource(cdev, SYS_RES_DRQ, i, drqs[i], 1);

Modified: head/sys/sparc64/pci/ofw_pci.c
==============================================================================
--- head/sys/sparc64/pci/ofw_pci.c      Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/sparc64/pci/ofw_pci.c      Sun Apr  8 22:59:34 2018        
(r332310)
@@ -93,7 +93,7 @@ ofw_pci_attach_common(device_t dev, bus_dma_tag_t dmat
         * start addresses of the ranges are the configuration, I/O and
         * memory handles.  There should not be multiple ones of one kind.
         */
-       nrange = OF_getprop_alloc(node, "ranges", sizeof(*range),
+       nrange = OF_getprop_alloc_multi(node, "ranges", sizeof(*range),
            (void **)&range);
        for (i = 0; i < nrange; i++) {
                j = OFW_PCI_RANGE_CS(&range[i]);

Modified: head/sys/sparc64/sbus/dma_sbus.c
==============================================================================
--- head/sys/sparc64/sbus/dma_sbus.c    Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/sparc64/sbus/dma_sbus.c    Sun Apr  8 22:59:34 2018        
(r332310)
@@ -209,7 +209,7 @@ dma_attach(device_t dev)
                 * the user can change it via a "media" option to ifconfig.
                 */
                csr = L64854_GCSR(lsc);
-               if ((OF_getprop_alloc(node, "cable-selection", 1,
+               if ((OF_getprop_alloc(node, "cable-selection",
                    (void **)&cabletype)) == -1) {
                        /* assume TP if nothing there */
                        csr |= E_TP_AUI;
@@ -295,7 +295,7 @@ dma_setup_dinfo(device_t dev, struct dma_softc *dsc, p
        }
        resource_list_init(&ddi->ddi_rl);
        slot = -1;
-       nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)&reg);
+       nreg = OF_getprop_alloc_multi(node, "reg", sizeof(*reg), (void **)&reg);
        if (nreg == -1) {
                device_printf(dev, "<%s>: incomplete\n",
                    ddi->ddi_obdinfo.obd_name);
@@ -329,7 +329,7 @@ dma_setup_dinfo(device_t dev, struct dma_softc *dsc, p
        /*
         * The `interrupts' property contains the SBus interrupt level.
         */
-       nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intr),
+       nintr = OF_getprop_alloc_multi(node, "interrupts", sizeof(*intr),
            (void **)&intr);
        if (nintr != -1) {
                for (i = 0; i < nintr; i++) {

Modified: head/sys/sparc64/sbus/sbus.c
==============================================================================
--- head/sys/sparc64/sbus/sbus.c        Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/sparc64/sbus/sbus.c        Sun Apr  8 22:59:34 2018        
(r332310)
@@ -299,7 +299,7 @@ sbus_attach(device_t dev)
        /*
         * Collect address translations from the OBP.
         */
-       if ((sc->sc_nrange = OF_getprop_alloc(node, "ranges",
+       if ((sc->sc_nrange = OF_getprop_alloc_multi(node, "ranges",
            sizeof(*range), (void **)&range)) == -1) {
                panic("%s: error getting ranges property", __func__);
        }
@@ -478,7 +478,7 @@ sbus_setup_dinfo(device_t dev, struct sbus_softc *sc, 
        }
        resource_list_init(&sdi->sdi_rl);
        slot = -1;
-       nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)&reg);
+       nreg = OF_getprop_alloc_multi(node, "reg", sizeof(*reg), (void **)&reg);
        if (nreg == -1) {
                if (sdi->sdi_obdinfo.obd_type == NULL ||
                    strcmp(sdi->sdi_obdinfo.obd_type, "hierarchical") != 0) {
@@ -512,7 +512,7 @@ sbus_setup_dinfo(device_t dev, struct sbus_softc *sc, 
        /*
         * The `interrupts' property contains the SBus interrupt level.
         */
-       nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intr),
+       nintr = OF_getprop_alloc_multi(node, "interrupts", sizeof(*intr),
            (void **)&intr);
        if (nintr != -1) {
                for (i = 0; i < nintr; i++) {

Modified: head/sys/sparc64/sparc64/nexus.c
==============================================================================
--- head/sys/sparc64/sparc64/nexus.c    Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/sparc64/sparc64/nexus.c    Sun Apr  8 22:59:34 2018        
(r332310)
@@ -545,7 +545,7 @@ nexus_setup_dinfo(device_t dev, phandle_t node)
                return (NULL);
        }
        resource_list_init(&ndi->ndi_rl);
-       nreg = OF_getprop_alloc(node, "reg", sizeof(*reg), (void **)&reg);
+       nreg = OF_getprop_alloc_multi(node, "reg", sizeof(*reg), (void **)&reg);
        if (nreg == -1) {
                device_printf(dev, "<%s>: incomplete\n",
                    ndi->ndi_obdinfo.obd_name);
@@ -561,7 +561,7 @@ nexus_setup_dinfo(device_t dev, phandle_t node)
        }
        OF_prop_free(reg);
 
-       nintr = OF_getprop_alloc(node, "interrupts",  sizeof(*intr),
+       nintr = OF_getprop_alloc_multi(node, "interrupts",  sizeof(*intr),
            (void **)&intr);
        if (nintr > 0) {
                if (OF_getprop(node, PCPU_GET(impl) < CPU_IMPL_ULTRASPARCIII ?

Modified: head/sys/sparc64/sparc64/upa.c
==============================================================================
--- head/sys/sparc64/sparc64/upa.c      Sun Apr  8 22:07:06 2018        
(r332309)
+++ head/sys/sparc64/sparc64/upa.c      Sun Apr  8 22:59:34 2018        
(r332310)
@@ -285,7 +285,7 @@ upa_attach(device_t dev)
                goto fail;
        }
 
-       sc->sc_nrange = OF_getprop_alloc(node, "ranges", sizeof(*sc->sc_ranges),

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to