Author: gonzo
Date: Mon Apr  9 22:06:16 2018
New Revision: 332341
URL: https://svnweb.freebsd.org/changeset/base/332341

Log:
  Align OF_getencprop_alloc API with OF_getencprop and OF_getprop_alloc
  
  Change OF_getencprop_alloc semantics to be combination of malloc and
  OF_getencprop and return size of the property, not number of elements
  allocated.
  
  For the use cases where number of elements is preferred introduce
  OF_getencprop_alloc_multi helper function that copies semantics
  of OF_getencprop_alloc prior to this change.
  
  This is to make OF_getencprop_alloc and OF_getencprop_alloc_multi
  function signatures consistent with OF_getencprop_alloc and
  OF_getencprop_alloc_multi.
  
  Functionality-wise this patch is mostly rename of OF_getencprop_alloc
  to OF_getencprop_alloc_multi except two calls in ofw_bus_setup_iinfo
  where 1 was used as a block size.

Modified:
  head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c
  head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c
  head/sys/arm/annapurna/alpine/alpine_pci_msix.c
  head/sys/arm/at91/at91_pinctrl.c
  head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
  head/sys/arm/freescale/imx/imx_iomux.c
  head/sys/arm/nvidia/drm2/tegra_drm_subr.c
  head/sys/arm/ti/ti_adc.c
  head/sys/arm/ti/ti_pinmux.c
  head/sys/dev/cpufreq/cpufreq_dt.c
  head/sys/dev/dpaa/qman_fdt.c
  head/sys/dev/extres/clk/clk.c
  head/sys/dev/extres/phy/phy.c
  head/sys/dev/extres/regulator/regulator.c
  head/sys/dev/extres/syscon/syscon.c
  head/sys/dev/fdt/fdt_clock.c
  head/sys/dev/fdt/fdt_pinctrl.c
  head/sys/dev/gpio/gpioregulator.c
  head/sys/dev/gpio/ofw_gpiobus.c
  head/sys/dev/ofw/ofw_bus_subr.c
  head/sys/dev/ofw/openfirm.c
  head/sys/dev/ofw/openfirm.h
  head/sys/dev/vnic/thunder_bgx_fdt.c
  head/sys/mips/ingenic/jz4780_pinctrl.c
  head/sys/mips/mediatek/fdt_reset.c
  head/sys/powerpc/mpc85xx/lbc.c

Modified: head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c
==============================================================================
--- head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c   Mon Apr  9 21:46:58 
2018        (r332340)
+++ head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m3.c   Mon Apr  9 22:06:16 
2018        (r332341)
@@ -195,7 +195,7 @@ aml8726_usb_phy_attach(device_t dev)
 
        err = 0;
 
-       len = OF_getencprop_alloc(node, "usb-pwr-en",
+       len = OF_getencprop_alloc_multi(node, "usb-pwr-en",
            3 * sizeof(pcell_t), (void **)&prop);
        npwr_en = (len > 0) ? len : 0;
 

Modified: head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c
==============================================================================
--- head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c   Mon Apr  9 21:46:58 
2018        (r332340)
+++ head/sys/arm/amlogic/aml8726/aml8726_usb_phy-m6.c   Mon Apr  9 22:06:16 
2018        (r332341)
@@ -167,7 +167,7 @@ aml8726_usb_phy_attach(device_t dev)
 
        err = 0;
 
-       len = OF_getencprop_alloc(node, "usb-pwr-en",
+       len = OF_getencprop_alloc_multi(node, "usb-pwr-en",
            3 * sizeof(pcell_t), (void **)&prop);
        npwr_en = (len > 0) ? len : 0;
 
@@ -188,7 +188,7 @@ aml8726_usb_phy_attach(device_t dev)
 
        OF_prop_free(prop);
 
-       len = OF_getencprop_alloc(node, "usb-hub-rst",
+       len = OF_getencprop_alloc_multi(node, "usb-hub-rst",
            3 * sizeof(pcell_t), (void **)&prop);
        if (len > 0) {
                sc->hub_rst.dev = OF_device_from_xref(prop[0]);

Modified: head/sys/arm/annapurna/alpine/alpine_pci_msix.c
==============================================================================
--- head/sys/arm/annapurna/alpine/alpine_pci_msix.c     Mon Apr  9 21:46:58 
2018        (r332340)
+++ head/sys/arm/annapurna/alpine/alpine_pci_msix.c     Mon Apr  9 22:06:16 
2018        (r332341)
@@ -188,7 +188,7 @@ al_msix_attach(device_t dev)
        sc->gic_dev = gic_dev;
 
        /* Manually read range of interrupts from DTB */
-       nintr = OF_getencprop_alloc(node, "interrupts",  sizeof(*intr),
+       nintr = OF_getencprop_alloc_multi(node, "interrupts", sizeof(*intr),
            (void **)&intr);
        if (nintr == 0) {
                device_printf(dev, "Cannot read interrupts prop from DTB\n");

Modified: head/sys/arm/at91/at91_pinctrl.c
==============================================================================
--- head/sys/arm/at91/at91_pinctrl.c    Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/arm/at91/at91_pinctrl.c    Mon Apr  9 22:06:16 2018        
(r332341)
@@ -101,7 +101,8 @@ at91_pinctrl_setup_dinfo(device_t dev, phandle_t node)
        }
 
        resource_list_init(&ndi->rl);
-       nreg = OF_getencprop_alloc(node, "reg", sizeof(*reg), (void **)&reg);
+       nreg = OF_getencprop_alloc_multi(node, "reg", sizeof(*reg),
+           (void **)&reg);
        if (nreg == -1)
                nreg = 0;
        if (nreg % (sc->acells + sc->scells) != 0) {
@@ -127,7 +128,7 @@ at91_pinctrl_setup_dinfo(device_t dev, phandle_t node)
        }
        OF_prop_free(reg);
 
-       nintr = OF_getencprop_alloc(node, "interrupts",  sizeof(*intr),
+       nintr = OF_getencprop_alloc_multi(node, "interrupts",  sizeof(*intr),
            (void **)&intr);
        if (nintr > 0) {
                if (OF_searchencprop(node, "interrupt-parent", &iparent,
@@ -393,7 +394,7 @@ pinctrl_configure_pins(device_t bus, phandle_t cfgxref
        node = OF_node_from_xref(cfgxref);
        memset(name, 0, sizeof(name));
        OF_getprop(node, "name", name, sizeof(name));
-       npins = OF_getencprop_alloc(node, "atmel,pins", sizeof(*cfgdata),
+       npins = OF_getencprop_alloc_multi(node, "atmel,pins", sizeof(*cfgdata),
            (void **)&cfgdata);
        if (npins < 0) {
                printf("We're doing it wrong %s\n", name);

Modified: head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c
==============================================================================
--- head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c        Mon Apr  9 21:46:58 
2018        (r332340)
+++ head/sys/arm/broadcom/bcm2835/bcm2835_gpio.c        Mon Apr  9 22:06:16 
2018        (r332341)
@@ -623,7 +623,7 @@ bcm_gpio_get_ro_pins(struct bcm_gpio_softc *sc, phandl
        pcell_t *pins;
 
        /* Get the property data. */
-       npins = OF_getencprop_alloc(node, propname, sizeof(*pins),
+       npins = OF_getencprop_alloc_multi(node, propname, sizeof(*pins),
            (void **)&pins);
        if (npins < 0)
                return (-1);
@@ -1214,8 +1214,8 @@ bcm_gpio_configure_pins(device_t dev, phandle_t cfgxre
        cfgnode = OF_node_from_xref(cfgxref);
 
        pins = NULL;
-       pintuples = OF_getencprop_alloc(cfgnode, "brcm,pins", sizeof(*pins),
-           (void **)&pins);
+       pintuples = OF_getencprop_alloc_multi(cfgnode, "brcm,pins",
+           sizeof(*pins), (void **)&pins);
 
        char name[32];
        OF_getprop(cfgnode, "name", &name, sizeof(name));
@@ -1233,8 +1233,8 @@ bcm_gpio_configure_pins(device_t dev, phandle_t cfgxre
        }
 
        pulls = NULL;
-       pulltuples = OF_getencprop_alloc(cfgnode, "brcm,pull", sizeof(*pulls),
-           (void **)&pulls);
+       pulltuples = OF_getencprop_alloc_multi(cfgnode, "brcm,pull",
+           sizeof(*pulls), (void **)&pulls);
 
        if ((pulls != NULL) && (pulltuples != pintuples)) {
                OF_prop_free(pins);

Modified: head/sys/arm/freescale/imx/imx_iomux.c
==============================================================================
--- head/sys/arm/freescale/imx/imx_iomux.c      Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/arm/freescale/imx/imx_iomux.c      Mon Apr  9 22:06:16 2018        
(r332341)
@@ -153,8 +153,8 @@ iomux_configure_pins(device_t dev, phandle_t cfgxref)
 
        sc = device_get_softc(dev);
        cfgnode = OF_node_from_xref(cfgxref);
-       ntuples = OF_getencprop_alloc(cfgnode, "fsl,pins", sizeof(*cfgtuples),
-           (void **)&cfgtuples);
+       ntuples = OF_getencprop_alloc_multi(cfgnode, "fsl,pins",
+           sizeof(*cfgtuples), (void **)&cfgtuples);
        if (ntuples < 0)
                return (ENOENT);
        if (ntuples == 0)

Modified: head/sys/arm/nvidia/drm2/tegra_drm_subr.c
==============================================================================
--- head/sys/arm/nvidia/drm2/tegra_drm_subr.c   Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/arm/nvidia/drm2/tegra_drm_subr.c   Mon Apr  9 22:06:16 2018        
(r332341)
@@ -125,7 +125,7 @@ tegra_drm_encoder_attach(struct tegra_drm_encoder *out
 
        /* XXX parse output panel here */
 
-       rv = OF_getencprop_alloc(node, "nvidia,edid", 1,
+       rv = OF_getencprop_alloc(node, "nvidia,edid",
            (void **)&output->edid);
 
        /* EDID exist but have invalid size */
@@ -174,4 +174,4 @@ int tegra_drm_encoder_exit(struct tegra_drm_encoder *o
                /* detach panel */
        }
        return (0);
-}
\ No newline at end of file
+}

Modified: head/sys/arm/ti/ti_adc.c
==============================================================================
--- head/sys/arm/ti/ti_adc.c    Mon Apr  9 21:46:58 2018        (r332340)
+++ head/sys/arm/ti/ti_adc.c    Mon Apr  9 22:06:16 2018        (r332341)
@@ -777,8 +777,9 @@ ti_adc_attach(device_t dev)
                if ((OF_getencprop(child, "ti,charge-delay", &cell,
                    sizeof(cell))) > 0)
                        sc->sc_charge_delay = cell;
-               nwire_configs = OF_getencprop_alloc(child, "ti,wire-config",
-                   sizeof(*wire_configs), (void **)&wire_configs);
+               nwire_configs = OF_getencprop_alloc_multi(child,
+                   "ti,wire-config", sizeof(*wire_configs),
+                   (void **)&wire_configs);
                if (nwire_configs != sc->sc_tsc_wires) {
                        device_printf(sc->sc_dev,
                            "invalid number of ti,wire-config: %d (should be 
%d)\n",
@@ -795,8 +796,8 @@ ti_adc_attach(device_t dev)
        /* Read "adc" node properties */
        child = ofw_bus_find_child(node, "adc");
        if (child != 0) {
-               sc->sc_adc_nchannels = OF_getencprop_alloc(child, 
"ti,adc-channels",
-                   sizeof(*channels), (void **)&channels);
+               sc->sc_adc_nchannels = OF_getencprop_alloc_multi(child,
+                   "ti,adc-channels", sizeof(*channels), (void **)&channels);
                if (sc->sc_adc_nchannels > 0) {
                        for (i = 0; i < sc->sc_adc_nchannels; i++)
                                sc->sc_adc_channels[i] = channels[i];

Modified: head/sys/arm/ti/ti_pinmux.c
==============================================================================
--- head/sys/arm/ti/ti_pinmux.c Mon Apr  9 21:46:58 2018        (r332340)
+++ head/sys/arm/ti/ti_pinmux.c Mon Apr  9 22:06:16 2018        (r332341)
@@ -340,8 +340,8 @@ ti_pinmux_configure_pins(device_t dev, phandle_t cfgxr
 
        sc = device_get_softc(dev);
        cfgnode = OF_node_from_xref(cfgxref);
-       ntuples = OF_getencprop_alloc(cfgnode, "pinctrl-single,pins", 
sizeof(*cfgtuples),
-           (void **)&cfgtuples);
+       ntuples = OF_getencprop_alloc_multi(cfgnode, "pinctrl-single,pins",
+           sizeof(*cfgtuples), (void **)&cfgtuples);
 
        if (ntuples < 0)
                return (ENOENT);

Modified: head/sys/dev/cpufreq/cpufreq_dt.c
==============================================================================
--- head/sys/dev/cpufreq/cpufreq_dt.c   Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/dev/cpufreq/cpufreq_dt.c   Mon Apr  9 22:06:16 2018        
(r332341)
@@ -289,7 +289,7 @@ cpufreq_dt_attach(device_t dev)
                return (ENXIO);
        }
 
-       sc->nopp = OF_getencprop_alloc(node, "operating-points",
+       sc->nopp = OF_getencprop_alloc_multi(node, "operating-points",
            sizeof(*sc->opp), (void **)&opp);
        if (sc->nopp == -1)
                return (ENXIO);

Modified: head/sys/dev/dpaa/qman_fdt.c
==============================================================================
--- head/sys/dev/dpaa/qman_fdt.c        Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/dev/dpaa/qman_fdt.c        Mon Apr  9 22:06:16 2018        
(r332341)
@@ -185,7 +185,7 @@ qman_portals_fdt_attach(device_t dev)
        get_addr_props(ofw_bus_get_node(device_get_parent(dev)), &paddr, &size);
        get_addr_props(node, &addr, &size);
 
-       nrange = OF_getencprop_alloc(node, "ranges",
+       nrange = OF_getencprop_alloc_multi(node, "ranges",
            sizeof(*range), (void **)&range);
        if (nrange < addr + paddr + size)
                return (ENXIO);

Modified: head/sys/dev/extres/clk/clk.c
==============================================================================
--- head/sys/dev/extres/clk/clk.c       Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/dev/extres/clk/clk.c       Mon Apr  9 22:06:16 2018        
(r332341)
@@ -1409,7 +1409,7 @@ clk_parse_ofw_out_names(device_t dev, phandle_t node, 
 
        if (!OF_hasprop(node, "clock-indices"))
                return (name_items);
-       rv = OF_getencprop_alloc(node, "clock-indices", sizeof (uint32_t),
+       rv = OF_getencprop_alloc_multi(node, "clock-indices", sizeof (uint32_t),
            (void **)indices);
        if (rv != name_items) {
                device_printf(dev, " Size of 'clock-output-names' and "

Modified: head/sys/dev/extres/phy/phy.c
==============================================================================
--- head/sys/dev/extres/phy/phy.c       Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/dev/extres/phy/phy.c       Mon Apr  9 22:06:16 2018        
(r332341)
@@ -563,7 +563,7 @@ phy_get_by_ofw_property(device_t consumer_dev, phandle
                    "%s called on not ofw based device\n", __func__);
                return (ENXIO);
        }
-       ncells = OF_getencprop_alloc(cnode, name, sizeof(pcell_t),
+       ncells = OF_getencprop_alloc_multi(cnode, name, sizeof(pcell_t),
            (void **)&cells);
        if (ncells < 1)
                return (ENXIO);

Modified: head/sys/dev/extres/regulator/regulator.c
==============================================================================
--- head/sys/dev/extres/regulator/regulator.c   Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/dev/extres/regulator/regulator.c   Mon Apr  9 22:06:16 2018        
(r332341)
@@ -1085,7 +1085,7 @@ regulator_get_by_ofw_property(device_t cdev, phandle_t
        }
 
        cells = NULL;
-       ncells = OF_getencprop_alloc(cnode, name,  sizeof(*cells),
+       ncells = OF_getencprop_alloc_multi(cnode, name, sizeof(*cells),
            (void **)&cells);
        if (ncells <= 0)
                return (ENXIO);

Modified: head/sys/dev/extres/syscon/syscon.c
==============================================================================
--- head/sys/dev/extres/syscon/syscon.c Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/dev/extres/syscon/syscon.c Mon Apr  9 22:06:16 2018        
(r332341)
@@ -236,7 +236,7 @@ syscon_get_by_ofw_property(device_t cdev, phandle_t cn
                    "%s called on not ofw based device\n", __func__);
                return (ENXIO);
        }
-       ncells = OF_getencprop_alloc(cnode, name, sizeof(pcell_t),
+       ncells = OF_getencprop_alloc_multi(cnode, name, sizeof(pcell_t),
            (void **)&cells);
        if (ncells < 1)
                return (ENXIO);

Modified: head/sys/dev/fdt/fdt_clock.c
==============================================================================
--- head/sys/dev/fdt/fdt_clock.c        Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/dev/fdt/fdt_clock.c        Mon Apr  9 22:06:16 2018        
(r332341)
@@ -58,7 +58,7 @@ enable_disable_all(device_t consumer, boolean_t enable
        boolean_t anyerrors;
 
        cnode = ofw_bus_get_node(consumer);
-       ncells = OF_getencprop_alloc(cnode, "clocks", sizeof(*clks),
+       ncells = OF_getencprop_alloc_multi(cnode, "clocks", sizeof(*clks),
            (void **)&clks);
        if (enable && ncells < 2) {
                device_printf(consumer, "Warning: No clocks specified in fdt "
@@ -102,7 +102,7 @@ fdt_clock_get_info(device_t consumer, int n, struct fd
        uint32_t *clks;
 
        cnode = ofw_bus_get_node(consumer);
-       ncells = OF_getencprop_alloc(cnode, "clocks", sizeof(*clks),
+       ncells = OF_getencprop_alloc_multi(cnode, "clocks", sizeof(*clks),
            (void **)&clks);
        if (ncells <= 0)
                return (ENXIO);

Modified: head/sys/dev/fdt/fdt_pinctrl.c
==============================================================================
--- head/sys/dev/fdt/fdt_pinctrl.c      Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/dev/fdt/fdt_pinctrl.c      Mon Apr  9 22:06:16 2018        
(r332341)
@@ -46,7 +46,7 @@ fdt_pinctrl_configure(device_t client, u_int index)
        char name[16];
 
        snprintf(name, sizeof(name), "pinctrl-%u", index);
-       nconfigs = OF_getencprop_alloc(ofw_bus_get_node(client), name,
+       nconfigs = OF_getencprop_alloc_multi(ofw_bus_get_node(client), name,
            sizeof(*configs), (void **)&configs);
        if (nconfigs < 0)
                return (ENOENT);
@@ -122,7 +122,7 @@ pinctrl_configure_children(device_t pinctrl, phandle_t
                if (!ofw_bus_node_status_okay(node))
                        continue;
                pinctrl_configure_children(pinctrl, node);
-               nconfigs = OF_getencprop_alloc(node, "pinctrl-0",
+               nconfigs = OF_getencprop_alloc_multi(node, "pinctrl-0",
                    sizeof(*configs), (void **)&configs);
                if (nconfigs <= 0)
                        continue;

Modified: head/sys/dev/gpio/gpioregulator.c
==============================================================================
--- head/sys/dev/gpio/gpioregulator.c   Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/dev/gpio/gpioregulator.c   Mon Apr  9 22:06:16 2018        
(r332341)
@@ -216,7 +216,7 @@ gpioregulator_parse_fdt(struct gpioregulator_softc *sc
                return (error);
 
        /* "states" property (required) */
-       len = OF_getencprop_alloc(node, "states", sizeof(*pstates),
+       len = OF_getencprop_alloc_multi(node, "states", sizeof(*pstates),
            (void **)&pstates);
        if (len < 2) {
                device_printf(sc->dev, "invalid 'states' property\n");

Modified: head/sys/dev/gpio/ofw_gpiobus.c
==============================================================================
--- head/sys/dev/gpio/ofw_gpiobus.c     Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/dev/gpio/ofw_gpiobus.c     Mon Apr  9 22:06:16 2018        
(r332341)
@@ -364,7 +364,7 @@ ofw_gpiobus_parse_gpios_impl(device_t consumer, phandl
        pcell_t *gpios;
        phandle_t gpio;
 
-       ncells = OF_getencprop_alloc(cnode, pname, sizeof(*gpios),
+       ncells = OF_getencprop_alloc_multi(cnode, pname, sizeof(*gpios),
             (void **)&gpios);
        if (ncells == -1) {
                device_printf(consumer,

Modified: head/sys/dev/ofw/ofw_bus_subr.c
==============================================================================
--- head/sys/dev/ofw/ofw_bus_subr.c     Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/dev/ofw/ofw_bus_subr.c     Mon Apr  9 22:06:16 2018        
(r332341)
@@ -319,10 +319,10 @@ ofw_bus_setup_iinfo(phandle_t node, struct ofw_bus_iin
                addrc = 2;
        ii->opi_addrc = addrc * sizeof(pcell_t);
 
-       ii->opi_imapsz = OF_getencprop_alloc(node, "interrupt-map", 1,
+       ii->opi_imapsz = OF_getencprop_alloc(node, "interrupt-map",
            (void **)&ii->opi_imap);
        if (ii->opi_imapsz > 0) {
-               msksz = OF_getencprop_alloc(node, "interrupt-map-mask", 1,
+               msksz = OF_getencprop_alloc(node, "interrupt-map-mask",
                    (void **)&ii->opi_imapmsk);
                /*
                 * Failure to get the mask is ignored; a full mask is used
@@ -449,7 +449,8 @@ ofw_bus_msimap(phandle_t node, uint16_t pci_rid, phand
        int err, i;
 
        /* TODO: This should be OF_searchprop_alloc if we had it */
-       len = OF_getencprop_alloc(node, "msi-map", sizeof(*map), (void **)&map);
+       len = OF_getencprop_alloc_multi(node, "msi-map", sizeof(*map),
+           (void **)&map);
        if (len < 0) {
                if (msi_parent != NULL) {
                        *msi_parent = 0;
@@ -506,7 +507,8 @@ ofw_bus_reg_to_rl_helper(device_t dev, phandle_t node,
        if (ret == -1)
                name = NULL;
 
-       ret = OF_getencprop_alloc(node, reg_source, sizeof(*reg), (void 
**)&reg);
+       ret = OF_getencprop_alloc_multi(node, reg_source, sizeof(*reg),
+           (void **)&reg);
        nreg = (ret == -1) ? 0 : ret;
 
        if (nreg % (acells + scells) != 0) {
@@ -584,7 +586,7 @@ ofw_bus_intr_to_rl(device_t dev, phandle_t node,
        int err, i, irqnum, nintr, rid;
        boolean_t extended;
 
-       nintr = OF_getencprop_alloc(node, "interrupts",  sizeof(*intr),
+       nintr = OF_getencprop_alloc_multi(node, "interrupts",  sizeof(*intr),
            (void **)&intr);
        if (nintr > 0) {
                iparent = ofw_bus_find_iparent(node);
@@ -607,7 +609,7 @@ ofw_bus_intr_to_rl(device_t dev, phandle_t node,
                }
                extended = false;
        } else {
-               nintr = OF_getencprop_alloc(node, "interrupts-extended",
+               nintr = OF_getencprop_alloc_multi(node, "interrupts-extended",
                    sizeof(*intr), (void **)&intr);
                if (nintr <= 0)
                        return (0);
@@ -650,7 +652,7 @@ ofw_bus_intr_by_rid(device_t dev, phandle_t node, int 
        int err, i, nintr, rid;
        boolean_t extended;
 
-       nintr = OF_getencprop_alloc(node, "interrupts",  sizeof(*intr),
+       nintr = OF_getencprop_alloc_multi(node, "interrupts",  sizeof(*intr),
            (void **)&intr);
        if (nintr > 0) {
                iparent = ofw_bus_find_iparent(node);
@@ -673,7 +675,7 @@ ofw_bus_intr_by_rid(device_t dev, phandle_t node, int 
                }
                extended = false;
        } else {
-               nintr = OF_getencprop_alloc(node, "interrupts-extended",
+               nintr = OF_getencprop_alloc_multi(node, "interrupts-extended",
                    sizeof(*intr), (void **)&intr);
                if (nintr <= 0)
                        return (ESRCH);
@@ -821,7 +823,7 @@ ofw_bus_parse_xref_list_internal(phandle_t node, const
        int rv, i, j, nelems, cnt;
 
        elems = NULL;
-       nelems = OF_getencprop_alloc(node, list_name,  sizeof(*elems),
+       nelems = OF_getencprop_alloc_multi(node, list_name,  sizeof(*elems),
            (void **)&elems);
        if (nelems <= 0)
                return (ENOENT);

Modified: head/sys/dev/ofw/openfirm.c
==============================================================================
--- head/sys/dev/ofw/openfirm.c Mon Apr  9 21:46:58 2018        (r332340)
+++ head/sys/dev/ofw/openfirm.c Mon Apr  9 22:06:16 2018        (r332341)
@@ -488,9 +488,22 @@ OF_getprop_alloc_multi(phandle_t package, const char *
        return (len / elsz);
 }
 
+ssize_t
+OF_getencprop_alloc(phandle_t package, const char *name, void **buf)
+{
+       ssize_t ret;
 
+       ret = OF_getencprop_alloc_multi(package, name, sizeof(pcell_t),
+           buf);
+       if (ret < 0)
+               return (ret);
+       else
+               return (ret * sizeof(pcell_t));
+}
+
 ssize_t
-OF_getencprop_alloc(phandle_t package, const char *name, int elsz, void **buf)
+OF_getencprop_alloc_multi(phandle_t package, const char *name, int elsz,
+    void **buf)
 {
        ssize_t retval;
        pcell_t *cell;
@@ -499,11 +512,6 @@ OF_getencprop_alloc(phandle_t package, const char *nam
        retval = OF_getprop_alloc_multi(package, name, elsz, buf);
        if (retval == -1)
                return (-1);
-       if (retval * elsz % 4 != 0) {
-               free(*buf, M_OFWPROP);
-               *buf = NULL;
-               return (-1);
-       }
 
        cell = *buf;
        for (i = 0; i < retval * elsz / 4; i++)

Modified: head/sys/dev/ofw/openfirm.h
==============================================================================
--- head/sys/dev/ofw/openfirm.h Mon Apr  9 21:46:58 2018        (r332340)
+++ head/sys/dev/ofw/openfirm.h Mon Apr  9 22:06:16 2018        (r332341)
@@ -120,6 +120,8 @@ ssize_t             OF_getprop_alloc(phandle_t node, const 
char *
 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,
+                   void **buf);
+ssize_t                OF_getencprop_alloc_multi(phandle_t node, const char 
*propname,
                    int elsz, void **buf);
 void           OF_prop_free(void *buf);
 int            OF_nextprop(phandle_t node, const char *propname, char *buf,

Modified: head/sys/dev/vnic/thunder_bgx_fdt.c
==============================================================================
--- head/sys/dev/vnic/thunder_bgx_fdt.c Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/dev/vnic/thunder_bgx_fdt.c Mon Apr  9 22:06:16 2018        
(r332341)
@@ -258,7 +258,7 @@ bgx_fdt_traverse_nodes(uint8_t unit, phandle_t start, 
                    BGX_NODE_NAME, sizeof(BGX_NODE_NAME) - 1) != 0)
                        continue;
                /* Get reg */
-               err = OF_getencprop_alloc(node, "reg", sizeof(*reg),
+               err = OF_getencprop_alloc_multi(node, "reg", sizeof(*reg),
                    (void **)&reg);
                if (err == -1) {
                        free(reg, M_OFWPROP);

Modified: head/sys/mips/ingenic/jz4780_pinctrl.c
==============================================================================
--- head/sys/mips/ingenic/jz4780_pinctrl.c      Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/mips/ingenic/jz4780_pinctrl.c      Mon Apr  9 22:06:16 2018        
(r332341)
@@ -196,8 +196,8 @@ jz4780_pinctrl_configure_pins(device_t dev, phandle_t 
 
        node = OF_node_from_xref(cfgxref);
 
-       len = OF_getencprop_alloc(node, "ingenic,pins", sizeof(uint32_t) * 4,
-           (void **)&value);
+       len = OF_getencprop_alloc_multi(node, "ingenic,pins",
+           sizeof(uint32_t) * 4, (void **)&value);
        if (len < 0) {
                device_printf(dev,
                    "missing ingenic,pins attribute in FDT\n");

Modified: head/sys/mips/mediatek/fdt_reset.c
==============================================================================
--- head/sys/mips/mediatek/fdt_reset.c  Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/mips/mediatek/fdt_reset.c  Mon Apr  9 22:06:16 2018        
(r332341)
@@ -59,7 +59,7 @@ assert_deassert_all(device_t consumer, boolean_t asser
        boolean_t anyerrors;
 
        rnode = ofw_bus_get_node(consumer);
-       ncells = OF_getencprop_alloc(rnode, "resets", sizeof(*resets),
+       ncells = OF_getencprop_alloc_multi(rnode, "resets", sizeof(*resets),
            (void **)&resets);
        if (!assert && ncells < 2) {
                device_printf(consumer, "Warning: No resets specified in fdt "

Modified: head/sys/powerpc/mpc85xx/lbc.c
==============================================================================
--- head/sys/powerpc/mpc85xx/lbc.c      Mon Apr  9 21:46:58 2018        
(r332340)
+++ head/sys/powerpc/mpc85xx/lbc.c      Mon Apr  9 22:06:16 2018        
(r332341)
@@ -374,7 +374,8 @@ fdt_lbc_reg_decode(phandle_t node, struct lbc_softc *s
                return (ENXIO);
 
        tuple_size = sizeof(pcell_t) * (addr_cells + size_cells);
-       tuples = OF_getencprop_alloc(node, "reg", tuple_size, (void **)&reg);
+       tuples = OF_getencprop_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)
@@ -545,7 +546,7 @@ lbc_attach(device_t dev)
        tuple_size = sizeof(pcell_t) * (sc->sc_addr_cells + par_addr_cells +
            sc->sc_size_cells);
 
-       tuples = OF_getencprop_alloc(node, "ranges", tuple_size,
+       tuples = OF_getencprop_alloc_multi(node, "ranges", tuple_size,
            (void **)&ranges);
        if (tuples < 0) {
                device_printf(dev, "could not retrieve 'ranges' property\n");
_______________________________________________
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