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
This commit is contained in:
Oleksandr Tymoshenko 2018-04-08 22:59:34 +00:00
parent 9d9889b5eb
commit 217d17bcd3
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=332310
50 changed files with 139 additions and 110 deletions

View File

@ -559,10 +559,10 @@ aw_gpio_parse_function(phandle_t node)
{ {
char *function; char *function;
if (OF_getprop_alloc(node, "function", sizeof(*function), if (OF_getprop_alloc(node, "function",
(void **)&function) != -1) (void **)&function) != -1)
return (function); return (function);
if (OF_getprop_alloc(node, "allwinner,function", sizeof(*function), if (OF_getprop_alloc(node, "allwinner,function",
(void **)&function) != -1) (void **)&function) != -1)
return (function); return (function);

View File

@ -72,7 +72,7 @@ a20_if_dwc_init(device_t dev)
node = ofw_bus_get_node(dev); node = ofw_bus_get_node(dev);
/* Configure PHY for MII or RGMII mode */ /* 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); error = clk_get_by_ofw_name(dev, 0, "allwinner_gmac_tx", &clk_tx);
if (error != 0) { if (error != 0) {
device_printf(dev, "could not get tx clk\n"); device_printf(dev, "could not get tx clk\n");

View File

@ -1233,7 +1233,7 @@ awg_setup_phy(device_t dev)
node = ofw_bus_get_node(dev); node = ofw_bus_get_node(dev);
use_syscon = false; 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); return (0);
if (sc->syscon != NULL || sc->res[_RES_SYSCON] != NULL) if (sc->syscon != NULL || sc->res[_RES_SYSCON] != NULL)

View File

@ -87,7 +87,7 @@ aml8726_ccm_configure_gates(struct aml8726_ccm_softc *sc)
node = ofw_bus_get_node(sc->dev); node = ofw_bus_get_node(sc->dev);
len = OF_getprop_alloc(node, "functions", sizeof(char), len = OF_getprop_alloc(node, "functions",
(void **)&functions); (void **)&functions);
if (len < 0) { if (len < 0) {

View File

@ -585,7 +585,7 @@ aml8726_mmc_attach(device_t dev)
} }
len = OF_getprop_alloc(OF_node_from_xref(prop[0]), "amlogic,function", len = OF_getprop_alloc(OF_node_from_xref(prop[0]), "amlogic,function",
sizeof(char), (void **)&function_name); (void **)&function_name);
if (len < 0) { if (len < 0) {
device_printf(dev, device_printf(dev,
@ -635,7 +635,7 @@ aml8726_mmc_attach(device_t dev)
} }
len = OF_getprop_alloc(node, "mmc-voltages", len = OF_getprop_alloc(node, "mmc-voltages",
sizeof(char), (void **)&voltages); (void **)&voltages);
if (len < 0) { if (len < 0) {
device_printf(dev, "missing mmc-voltages attribute in FDT\n"); device_printf(dev, "missing mmc-voltages attribute in FDT\n");

View File

@ -194,7 +194,7 @@ aml8726_pinctrl_configure_pins(device_t dev, phandle_t cfgxref)
node = OF_node_from_xref(cfgxref); node = OF_node_from_xref(cfgxref);
len = OF_getprop_alloc(node, "amlogic,function", len = OF_getprop_alloc(node, "amlogic,function",
sizeof(char), (void **)&function_name); (void **)&function_name);
if (len < 0) { if (len < 0) {
device_printf(dev, device_printf(dev,
@ -216,7 +216,7 @@ aml8726_pinctrl_configure_pins(device_t dev, phandle_t cfgxref)
OF_prop_free(function_name); OF_prop_free(function_name);
len = OF_getprop_alloc(node, "amlogic,pull", len = OF_getprop_alloc(node, "amlogic,pull",
sizeof(char), (void **)&pull); (void **)&pull);
pm = aml8726_unknown_pm; pm = aml8726_unknown_pm;
@ -257,7 +257,7 @@ aml8726_pinctrl_configure_pins(device_t dev, phandle_t cfgxref)
} }
len = OF_getprop_alloc(node, "amlogic,pins", len = OF_getprop_alloc(node, "amlogic,pins",
sizeof(char), (void **)&pins); (void **)&pins);
if (len < 0) { if (len < 0) {
device_printf(dev, "missing amlogic,pins attribute in FDT\n"); device_printf(dev, "missing amlogic,pins attribute in FDT\n");

View File

@ -796,7 +796,7 @@ aml8726_sdxc_attach(device_t dev)
} }
len = OF_getprop_alloc(node, "mmc-voltages", len = OF_getprop_alloc(node, "mmc-voltages",
sizeof(char), (void **)&voltages); (void **)&voltages);
if (len < 0) { if (len < 0) {
device_printf(dev, "missing mmc-voltages attribute in FDT\n"); device_printf(dev, "missing mmc-voltages attribute in FDT\n");

View File

@ -126,7 +126,7 @@ aml8726_usb_phy_mode(const char *dwcotg_path, uint32_t *mode)
*mode = 0; *mode = 0;
len = OF_getprop_alloc(node, "dr_mode", len = OF_getprop_alloc(node, "dr_mode",
sizeof(char), (void **)&usb_mode); (void **)&usb_mode);
if (len <= 0) if (len <= 0)
return (0); return (0);

View File

@ -154,7 +154,7 @@ aml8726_usb_phy_attach(device_t dev)
node = ofw_bus_get_node(dev); node = ofw_bus_get_node(dev);
len = OF_getprop_alloc(node, "force-aca", len = OF_getprop_alloc(node, "force-aca",
sizeof(char), (void **)&force_aca); (void **)&force_aca);
sc->force_aca = FALSE; sc->force_aca = FALSE;

View File

@ -677,7 +677,7 @@ bcm_gpio_get_reserved_pins(struct bcm_gpio_softc *sc)
reserved = 0; reserved = 0;
node = OF_child(gpio); node = OF_child(gpio);
while ((node != 0) && (reserved == 0)) { 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) if (len == -1)
return (-1); return (-1);
if (strcmp(name, "reserved") == 0) if (strcmp(name, "reserved") == 0)

View File

@ -419,7 +419,7 @@ ccm_fdt_set(struct ccm_softc *sc)
if ((len = OF_getproplen(child, "clock_names")) > 0) { if ((len = OF_getproplen(child, "clock_names")) > 0) {
len = OF_getproplen(child, "clock_names"); len = OF_getproplen(child, "clock_names");
OF_getprop_alloc(child, "clock_names", 1, OF_getprop_alloc(child, "clock_names",
(void **)&fdt_config); (void **)&fdt_config);
while (len > 0) { while (len > 0) {

View File

@ -175,7 +175,7 @@ fdt_localbus_reg_decode(phandle_t node, struct localbus_softc *sc,
return (ENXIO); return (ENXIO);
tuple_size = sizeof(pcell_t) * (addr_cells + size_cells); 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("addr_cells = %d, size_cells = %d\n", addr_cells, size_cells);
debugf("tuples = %d, tuple size = %d\n", tuples, tuple_size); debugf("tuples = %d, tuple size = %d\n", tuples, tuple_size);
if (tuples <= 0) if (tuples <= 0)

View File

@ -212,12 +212,12 @@ as3722_pinmux_read_node(struct as3722_softc *sc, phandle_t node,
{ {
int rv, i; int rv, i;
*lpins = OF_getprop_alloc(node, "pins", 1, (void **)pins); *lpins = OF_getprop_alloc(node, "pins", (void **)pins);
if (*lpins <= 0) if (*lpins <= 0)
return (ENOENT); return (ENOENT);
/* Read function (mux) settings. */ /* 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) if (rv <= 0)
cfg->function = NULL; cfg->function = NULL;

View File

@ -542,7 +542,7 @@ struct as3722_regnode_init_def *init_def)
if (rv <= 0) if (rv <= 0)
return; return;
supply_node = OF_node_from_xref(supply_node); 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); (void **)&init_def->reg_init_def.parent_name);
if (rv <= 0) if (rv <= 0)
init_def->reg_init_def.parent_name = NULL; init_def->reg_init_def.parent_name = NULL;

View File

@ -874,7 +874,7 @@ process_lane(struct padctl_softc *sc, phandle_t node, struct padctl_pad *pad)
name = NULL; name = NULL;
function = NULL; function = NULL;
rv = OF_getprop_alloc(node, "name", 1, (void **)&name); rv = OF_getprop_alloc(node, "name", (void **)&name);
if (rv <= 0) { if (rv <= 0) {
device_printf(sc->dev, "Cannot read lane name.\n"); device_printf(sc->dev, "Cannot read lane name.\n");
return (ENXIO); return (ENXIO);
@ -888,7 +888,7 @@ process_lane(struct padctl_softc *sc, phandle_t node, struct padctl_pad *pad)
} }
/* Read function (mux) settings. */ /* 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) { if (rv <= 0) {
device_printf(sc->dev, "Cannot read lane function.\n"); device_printf(sc->dev, "Cannot read lane function.\n");
rv = ENXIO; rv = ENXIO;
@ -947,7 +947,7 @@ process_pad(struct padctl_softc *sc, phandle_t node)
int rv; int rv;
name = NULL; name = NULL;
rv = OF_getprop_alloc(node, "name", 1, (void **)&name); rv = OF_getprop_alloc(node, "name", (void **)&name);
if (rv <= 0) { if (rv <= 0) {
device_printf(sc->dev, "Cannot read pad name.\n"); device_printf(sc->dev, "Cannot read pad name.\n");
return (ENXIO); return (ENXIO);
@ -992,7 +992,7 @@ process_port(struct padctl_softc *sc, phandle_t node)
int rv; int rv;
name = NULL; name = NULL;
rv = OF_getprop_alloc(node, "name", 1, (void **)&name); rv = OF_getprop_alloc(node, "name", (void **)&name);
if (rv <= 0) { if (rv <= 0) {
device_printf(sc->dev, "Cannot read port name.\n"); device_printf(sc->dev, "Cannot read port name.\n");
return (ENXIO); return (ENXIO);

View File

@ -648,12 +648,12 @@ pinmux_read_node(struct pinmux_softc *sc, phandle_t node, struct pincfg *cfg,
{ {
int rv, i; 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) if (*lpins <= 0)
return (ENOENT); return (ENOENT);
/* Read function (mux) settings. */ /* Read function (mux) settings. */
rv = OF_getprop_alloc(node, "nvidia,function", 1, rv = OF_getprop_alloc(node, "nvidia,function",
(void **)&cfg->function); (void **)&cfg->function);
if (rv <= 0) if (rv <= 0)
cfg->function = NULL; cfg->function = NULL;

View File

@ -593,7 +593,7 @@ usb_get_ifc_mode(device_t dev, phandle_t node, char *name)
int rv; int rv;
enum usb_ifc_type ret; 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) if (rv <= 0)
return (USB_IFC_TYPE_UNKNOWN); return (USB_IFC_TYPE_UNKNOWN);
@ -615,7 +615,7 @@ usb_get_dr_mode(device_t dev, phandle_t node, char *name)
int rv; int rv;
enum usb_dr_mode ret; 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) if (rv <= 0)
return (USB_DR_MODE_UNKNOWN); return (USB_DR_MODE_UNKNOWN);

View File

@ -746,7 +746,7 @@ cpsw_get_fdt_data(struct cpsw_softc *sc, int port)
phy = -1; phy = -1;
vlan = -1; vlan = -1;
for (child = OF_child(sc->node); child != 0; child = OF_peer(child)) { 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; continue;
if (sscanf(name, "slave@%lx", &mdio_child_addr) != 1) { if (sscanf(name, "slave@%lx", &mdio_child_addr) != 1) {
OF_prop_free(name); OF_prop_free(name);

View File

@ -110,7 +110,7 @@ ti_hwmods_get_clock(device_t dev)
if ((node = ofw_bus_get_node(dev)) == 0) if ((node = ofw_bus_get_node(dev)) == 0)
return (INVALID_CLK_IDENT); 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); return (INVALID_CLK_IDENT);
buf = name; buf = name;
@ -148,7 +148,7 @@ int ti_hwmods_contains(device_t dev, const char *hwmod)
if ((node = ofw_bus_get_node(dev)) == 0) if ((node = ofw_bus_get_node(dev)) == 0)
return (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); return (0);
buf = name; buf = name;
@ -182,7 +182,7 @@ ti_hwmods_get_unit(device_t dev, const char *hwmod)
if ((node = ofw_bus_get_node(dev)) == 0) if ((node = ofw_bus_get_node(dev)) == 0)
return (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); return (0);
buf = name; buf = name;

View File

@ -392,7 +392,7 @@ omap_uhh_attach(device_t dev)
snprintf(propname, sizeof(propname), snprintf(propname, sizeof(propname),
"port%d-mode", i+1); "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; continue;
if (strcmp(mode, "ehci-phy") == 0) if (strcmp(mode, "ehci-phy") == 0)
isc->port_mode[i] = EHCI_HCD_OMAP_MODE_PHY; isc->port_mode[i] = EHCI_HCD_OMAP_MODE_PHY;

View File

@ -100,13 +100,13 @@ altera_avgen_fdt_attach(device_t dev)
node = ofw_bus_get_node(dev); node = ofw_bus_get_node(dev);
if (OF_getprop(node, "sri-cambridge,width", &cell, sizeof(cell)) > 0) if (OF_getprop(node, "sri-cambridge,width", &cell, sizeof(cell)) > 0)
sc->avg_width = cell; 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 **)&str_fileio);
(void)OF_getprop_alloc(node, "sri-cambridge,geomio", sizeof(char), (void)OF_getprop_alloc(node, "sri-cambridge,geomio",
(void **)&str_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 **)&str_mmapio);
(void)OF_getprop_alloc(node, "sri-cambridge,devname", sizeof(char), (void)OF_getprop_alloc(node, "sri-cambridge,devname",
(void **)&str_devname); (void **)&str_devname);
if (OF_getprop(node, "sri-cambridge,devunit", &cell, sizeof(cell)) > 0) if (OF_getprop(node, "sri-cambridge,devunit", &cell, sizeof(cell)) > 0)
devunit = cell; devunit = cell;

View File

@ -238,7 +238,7 @@ atkbdc_ebus_attach(device_t dev)
children = 0; children = 0;
for (child = OF_child(ofw_bus_get_node(dev)); child != 0; for (child = OF_child(ofw_bus_get_node(dev)); child != 0;
child = OF_peer(child)) { child = OF_peer(child)) {
if ((OF_getprop_alloc(child, "name", 1, (void **)&cname)) == -1) if ((OF_getprop_alloc(child, "name", (void **)&cname)) == -1)
continue; continue;
if (children >= 2) { if (children >= 2) {
device_printf(dev, device_printf(dev,

View File

@ -276,7 +276,7 @@ e6000sw_parse_child_fdt(e6000sw_softc_t *sc, phandle_t child, int *pport)
return (ENXIO); return (ENXIO);
*pport = port; *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) { if (strncmp(portlabel, "cpu", 3) == 0) {
device_printf(sc->dev, "CPU port at %d\n", port); device_printf(sc->dev, "CPU port at %d\n", port);
sc->cpuports_mask |= (1 << port); sc->cpuports_mask |= (1 << port);
@ -287,7 +287,7 @@ e6000sw_parse_child_fdt(e6000sw_softc_t *sc, phandle_t child, int *pport)
fixed_link = OF_child(child); fixed_link = OF_child(child);
if (fixed_link != 0 && 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) { if (strncmp(name, "fixed-link", 10) == 0) {
/* Assume defaults: 1g - full-duplex. */ /* Assume defaults: 1g - full-duplex. */
sc->fixed_mask |= (1 << port); sc->fixed_mask |= (1 << port);

View File

@ -1007,7 +1007,7 @@ regulator_parse_ofw_stdparam(device_t pdev, phandle_t node,
int rv; int rv;
par = &def->std_param; par = &def->std_param;
rv = OF_getprop_alloc(node, "regulator-name", 1, rv = OF_getprop_alloc(node, "regulator-name",
(void **)&def->name); (void **)&def->name);
if (rv <= 0) { if (rv <= 0) {
device_printf(pdev, "%s: Missing regulator name\n", device_printf(pdev, "%s: Missing regulator name\n",
@ -1057,7 +1057,7 @@ regulator_parse_ofw_stdparam(device_t pdev, phandle_t node,
rv = OF_getencprop(node, "vin-supply", &supply_xref, rv = OF_getencprop(node, "vin-supply", &supply_xref,
sizeof(supply_xref)); sizeof(supply_xref));
if (rv >= 0) { if (rv >= 0) {
rv = OF_getprop_alloc(supply_xref, "regulator-name", 1, rv = OF_getprop_alloc(supply_xref, "regulator-name",
(void **)&def->parent_name); (void **)&def->parent_name);
if (rv <= 0) if (rv <= 0)
def->parent_name = NULL; def->parent_name = NULL;

View File

@ -67,7 +67,7 @@ fdt_pinctrl_configure_by_name(device_t client, const char * name)
int i, offset, nameslen; int i, offset, nameslen;
nameslen = OF_getprop_alloc(ofw_bus_get_node(client), "pinctrl-names", nameslen = OF_getprop_alloc(ofw_bus_get_node(client), "pinctrl-names",
sizeof(*names), (void **)&names); (void **)&names);
if (nameslen <= 0) if (nameslen <= 0)
return (ENOENT); return (ENOENT);
for (i = 0, offset = 0; offset < nameslen; i++) { for (i = 0, offset = 0; offset < nameslen; i++) {

View File

@ -94,12 +94,12 @@ fdt_flash_fill_slices(device_t dev, const char *provider __unused,
/* /*
* Retrieve label. * Retrieve label.
*/ */
name_len = OF_getprop_alloc(dt_child, "label", sizeof(char), name_len = OF_getprop_alloc(dt_child, "label",
(void **)&slice_name); (void **)&slice_name);
if (name_len <= 0) { if (name_len <= 0) {
/* Use node name if no label defined */ /* Use node name if no label defined */
name_len = OF_getprop_alloc(dt_child, "name", name_len = OF_getprop_alloc(dt_child, "name",
sizeof(char), (void **)&slice_name); (void **)&slice_name);
if (name_len <= 0) { if (name_len <= 0) {
debugf("slice i=%d with no name\n", i); debugf("slice i=%d with no name\n", i);
slice_name = NULL; slice_name = NULL;

View File

@ -271,8 +271,8 @@ gpiokeys_attach_key(struct gpiokeys_softc *sc, phandle_t node,
callout_init_mtx(&key->repeat_callout, &key->mtx, 0); callout_init_mtx(&key->repeat_callout, &key->mtx, 0);
name = NULL; name = NULL;
if (OF_getprop_alloc(node, "label", 1, (void **)&name) == -1) if (OF_getprop_alloc(node, "label", (void **)&name) == -1)
OF_getprop_alloc(node, "name", 1, (void **)&name); OF_getprop_alloc(node, "name", (void **)&name);
if (name != NULL) if (name != NULL)
key_name = name; key_name = name;

View File

@ -89,7 +89,7 @@ gpioleds_attach_led(struct gpioleds_softc *sc, phandle_t node,
state = 0; state = 0;
if (OF_getprop_alloc(node, "default-state", if (OF_getprop_alloc(node, "default-state",
sizeof(char), (void **)&default_state) != -1) { (void **)&default_state) != -1) {
if (strcasecmp(default_state, "on") == 0) if (strcasecmp(default_state, "on") == 0)
state = 1; state = 1;
else if (strcasecmp(default_state, "off") == 0) else if (strcasecmp(default_state, "off") == 0)
@ -105,8 +105,8 @@ gpioleds_attach_led(struct gpioleds_softc *sc, phandle_t node,
} }
name = NULL; name = NULL;
if (OF_getprop_alloc(node, "label", 1, (void **)&name) == -1) if (OF_getprop_alloc(node, "label", (void **)&name) == -1)
OF_getprop_alloc(node, "name", 1, (void **)&name); OF_getprop_alloc(node, "name", (void **)&name);
if (name == NULL) { if (name == NULL) {
device_printf(sc->sc_dev, device_printf(sc->sc_dev,

View File

@ -360,8 +360,8 @@ adt746x_fill_fan_prop(device_t dev)
child = ofw_bus_get_node(dev); child = ofw_bus_get_node(dev);
/* Fill the fan location property. */ /* Fill the fan location property. */
location_len = OF_getprop_alloc(child, "hwctrl-location", 1, (void **)&location); location_len = OF_getprop_alloc(child, "hwctrl-location", (void **)&location);
id_len = OF_getprop_alloc(child, "hwctrl-id", sizeof(cell_t), (void **)&id); id_len = OF_getprop_alloc_multi(child, "hwctrl-id", sizeof(cell_t), (void **)&id);
if (location_len == -1 || id_len == -1) { if (location_len == -1 || id_len == -1) {
OF_prop_free(location); OF_prop_free(location);
OF_prop_free(id); OF_prop_free(id);

View File

@ -183,7 +183,7 @@ lebuffer_setup_dinfo(device_t dev, phandle_t node)
} }
resource_list_init(&ldi->ldi_rl); resource_list_init(&ldi->ldi_rl);
slot = -1; 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 (nreg == -1) {
device_printf(dev, "<%s>: incomplete\n", device_printf(dev, "<%s>: incomplete\n",
ldi->ldi_obdinfo.obd_name); 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. * 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); (void **)&intr);
if (nintr != -1) { if (nintr != -1) {
for (i = 0; i < nintr; i++) { for (i = 0; i < nintr; i++) {

View File

@ -159,7 +159,7 @@ mvneta_fdt_phy_acquire(device_t dev)
/* Test for fixed-link (present i.e. in 388-gp) */ /* Test for fixed-link (present i.e. in 388-gp) */
for (child = OF_child(node); child != 0; child = OF_peer(child)) { for (child = OF_child(node); child != 0; child = OF_peer(child)) {
if (OF_getprop_alloc(child, if (OF_getprop_alloc(child,
"name", 1, (void **)&name) <= 0) { "name", (void **)&name) <= 0) {
continue; continue;
} }
if (strncmp(name, "fixed-link", 10) == 0) { if (strncmp(name, "fixed-link", 10) == 0) {

View File

@ -57,12 +57,12 @@ ofw_bus_gen_setup_devinfo(struct ofw_bus_devinfo *obd, phandle_t node)
if (obd == NULL) if (obd == NULL)
return (ENOMEM); return (ENOMEM);
/* The 'name' property is considered mandatory. */ /* 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); return (EINVAL);
OF_getprop_alloc(node, "compatible", 1, (void **)&obd->obd_compat); OF_getprop_alloc(node, "compatible", (void **)&obd->obd_compat);
OF_getprop_alloc(node, "device_type", 1, (void **)&obd->obd_type); OF_getprop_alloc(node, "device_type", (void **)&obd->obd_type);
OF_getprop_alloc(node, "model", 1, (void **)&obd->obd_model); OF_getprop_alloc(node, "model", (void **)&obd->obd_model);
OF_getprop_alloc(node, "status", 1, (void **)&obd->obd_status); OF_getprop_alloc(node, "status", (void **)&obd->obd_status);
obd->obd_node = node; obd->obd_node = node;
return (0); return (0);
} }
@ -502,7 +502,7 @@ ofw_bus_reg_to_rl_helper(device_t dev, phandle_t node, pcell_t acells, pcell_t s
* This may be just redundant when having ofw_bus_devinfo * This may be just redundant when having ofw_bus_devinfo
* but makes this routine independent of it. * 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) if (ret == -1)
name = NULL; name = NULL;
@ -720,7 +720,7 @@ ofw_bus_find_child(phandle_t start, const char *child_name)
phandle_t child; phandle_t child;
for (child = OF_child(start); child != 0; child = OF_peer(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) if (ret == -1)
continue; continue;
if (strcmp(name, child_name) == 0) { if (strcmp(name, child_name) == 0) {
@ -916,7 +916,7 @@ ofw_bus_find_string_index(phandle_t node, const char *list_name,
int rv, i, cnt, nelems; int rv, i, cnt, nelems;
elems = NULL; elems = NULL;
nelems = OF_getprop_alloc(node, list_name, 1, (void **)&elems); nelems = OF_getprop_alloc(node, list_name, (void **)&elems);
if (nelems <= 0) if (nelems <= 0)
return (ENOENT); return (ENOENT);
@ -947,7 +947,7 @@ ofw_bus_string_list_to_array(phandle_t node, const char *list_name,
int i, cnt, nelems, len; int i, cnt, nelems, len;
elems = NULL; elems = NULL;
nelems = OF_getprop_alloc(node, list_name, 1, (void **)&elems); nelems = OF_getprop_alloc(node, list_name, (void **)&elems);
if (nelems <= 0) if (nelems <= 0)
return (nelems); return (nelems);

View File

@ -438,13 +438,37 @@ OF_searchencprop(phandle_t node, const char *propname, void *buf, size_t len)
return (-1); return (-1);
} }
/*
* 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 * 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 * (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. * single element, the number of elements is return in number.
*/ */
ssize_t 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; int len;
@ -453,15 +477,18 @@ OF_getprop_alloc(phandle_t package, const char *propname, int elsz, void **buf)
len % elsz != 0) len % elsz != 0)
return (-1); return (-1);
*buf = malloc(len, M_OFWPROP, M_WAITOK); if (len > 0) {
if (OF_getprop(package, propname, *buf, len) == -1) { *buf = malloc(len, M_OFWPROP, M_WAITOK);
free(*buf, M_OFWPROP); if (OF_getprop(package, propname, *buf, len) == -1) {
*buf = NULL; free(*buf, M_OFWPROP);
return (-1); *buf = NULL;
return (-1);
}
} }
return (len / elsz); return (len / elsz);
} }
ssize_t ssize_t
OF_getencprop_alloc(phandle_t package, const char *name, int elsz, void **buf) 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 *name, int elsz, void **buf)
pcell_t *cell; pcell_t *cell;
int i; int i;
retval = OF_getprop_alloc(package, name, elsz, buf); retval = OF_getprop_alloc_multi(package, name, elsz, buf);
if (retval == -1) if (retval == -1)
return (-1); return (-1);
if (retval * elsz % 4 != 0) { if (retval * elsz % 4 != 0) {

View File

@ -116,6 +116,8 @@ ssize_t OF_searchprop(phandle_t node, const char *propname, void *buf,
ssize_t OF_searchencprop(phandle_t node, const char *propname, ssize_t OF_searchencprop(phandle_t node, const char *propname,
void *buf, size_t len); void *buf, size_t len);
ssize_t OF_getprop_alloc(phandle_t node, const char *propname, 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); int elsz, void **buf);
ssize_t OF_getencprop_alloc(phandle_t node, const char *propname, ssize_t OF_getencprop_alloc(phandle_t node, const char *propname,
int elsz, void **buf); int elsz, void **buf);

View File

@ -175,7 +175,7 @@ enable_usb(device_t dev, bus_space_tag_t iot, bus_space_handle_t ioh)
node = ofw_bus_get_node(dev); node = ofw_bus_get_node(dev);
if ((node != 0) && 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) if (strncasecmp(phy_type, "utmi", strlen("utmi")) == 0)
tmp |= UTMI_PHY_EN; tmp |= UTMI_PHY_EN;
OF_prop_free(phy_type); OF_prop_free(phy_type);

View File

@ -396,7 +396,7 @@ bgx_fdt_init_phy(struct bgx *bgx)
continue; continue;
} }
} else { } else {
len = OF_getprop_alloc(child, "name", 1, len = OF_getprop_alloc(child, "name",
(void **)&node_name); (void **)&node_name);
if (len <= 0) { if (len <= 0) {
continue; continue;

View File

@ -136,7 +136,7 @@ mtk_pinctrl_process_node(device_t dev, struct mtk_pin_group *table,
if (num_groups <= 0) if (num_groups <= 0)
return (ENOENT); 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) { (void **)&pin_function) == -1) {
ret = ENOENT; ret = ENOENT;
goto out; goto out;

View File

@ -362,7 +362,7 @@ diu_attach(device_t dev)
} }
/* TODO: Eventually, allow EDID to be dynamically provided. */ /* 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 * u-boot uses the environment variable name 'video-mode', so
* just use the same name here. Should allow another variable * just use the same name here. Should allow another variable

View File

@ -203,10 +203,10 @@ macio_add_intr(phandle_t devnode, struct macio_devinfo *dinfo)
return; return;
} }
nintr = OF_getprop_alloc(devnode, "interrupts", sizeof(*intr), nintr = OF_getprop_alloc_multi(devnode, "interrupts", sizeof(*intr),
(void **)&intr); (void **)&intr);
if (nintr == -1) { if (nintr == -1) {
nintr = OF_getprop_alloc(devnode, "AAPL,interrupts", nintr = OF_getprop_alloc_multi(devnode, "AAPL,interrupts",
sizeof(*intr), (void **)&intr); sizeof(*intr), (void **)&intr);
if (nintr == -1) if (nintr == -1)
return; return;
@ -243,7 +243,7 @@ macio_add_reg(phandle_t devnode, struct macio_devinfo *dinfo)
char buf[8]; char buf[8];
int i, layout_id = 0, nreg, res; 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) if (nreg == -1)
return; return;
@ -269,7 +269,7 @@ macio_add_reg(phandle_t devnode, struct macio_devinfo *dinfo)
sizeof(layout_id)); sizeof(layout_id));
if (res > 0 && (layout_id == 36 || layout_id == 76)) { 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); sizeof(*regp), (void **)&regp);
reg[0] = regp[0]; reg[0] = regp[0];
reg[1].mr_base = regp[1].mr_base; reg[1].mr_base = regp[1].mr_base;

View File

@ -164,10 +164,10 @@ unin_chip_add_intr(phandle_t devnode, struct unin_chip_devinfo *dinfo)
return; return;
} }
nintr = OF_getprop_alloc(devnode, "interrupts", sizeof(*intr), nintr = OF_getprop_alloc_multi(devnode, "interrupts", sizeof(*intr),
(void **)&intr); (void **)&intr);
if (nintr == -1) { if (nintr == -1) {
nintr = OF_getprop_alloc(devnode, "AAPL,interrupts", nintr = OF_getprop_alloc_multi(devnode, "AAPL,interrupts",
sizeof(*intr), (void **)&intr); sizeof(*intr), (void **)&intr);
if (nintr == -1) if (nintr == -1)
return; return;
@ -207,7 +207,7 @@ unin_chip_add_reg(phandle_t devnode, struct unin_chip_devinfo *dinfo)
struct unin_chip_reg *reg; struct unin_chip_reg *reg;
int i, nreg; 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) if (nreg == -1)
return; return;

View File

@ -221,7 +221,7 @@ iobus_attach(device_t dev)
root = sc->sc_node; root = sc->sc_node;
for (child = OF_child(root); child != 0; child = OF_peer(child)) { 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); cdev = device_add_child(dev, NULL, -1);
if (cdev != NULL) { if (cdev != NULL) {

View File

@ -140,7 +140,7 @@ central_attach(device_t dev)
sc = device_get_softc(dev); sc = device_get_softc(dev);
node = ofw_bus_get_node(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); sizeof(*sc->sc_ranges), (void **)&sc->sc_ranges);
if (sc->sc_nrange == -1) { if (sc->sc_nrange == -1) {
device_printf(dev, "can't get ranges\n"); device_printf(dev, "can't get ranges\n");
@ -153,7 +153,7 @@ central_attach(device_t dev)
free(cdi, M_DEVBUF); free(cdi, M_DEVBUF);
continue; continue;
} }
nreg = OF_getprop_alloc(child, "reg", sizeof(*reg), nreg = OF_getprop_alloc_multi(child, "reg", sizeof(*reg),
(void **)&reg); (void **)&reg);
if (nreg == -1) { if (nreg == -1) {
device_printf(dev, "<%s>: incomplete\n", device_printf(dev, "<%s>: incomplete\n",

View File

@ -292,7 +292,7 @@ ebus_nexus_attach(device_t dev)
} }
#endif #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); sizeof(struct ebus_nexus_ranges), &sc->sc_range);
if (sc->sc_nrange == -1) { if (sc->sc_nrange == -1) {
device_printf(dev, "could not get ranges property\n"); 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); pci_write_config(dev, PCIR_LATTIMER, 64 /* 64 PCI cycles */, 1);
node = ofw_bus_get_node(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(struct isa_ranges), &sc->sc_range); sizeof(struct isa_ranges), &sc->sc_range);
if (sc->sc_nrange == -1) { if (sc->sc_nrange == -1) {
device_printf(dev, "could not get ranges property\n"); device_printf(dev, "could not get ranges property\n");
@ -660,7 +660,7 @@ ebus_setup_dinfo(device_t dev, struct ebus_softc *sc, phandle_t node)
return (NULL); return (NULL);
} }
resource_list_init(&edi->edi_rl); 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) { if (nreg == -1) {
device_printf(dev, "<%s>: incomplete\n", device_printf(dev, "<%s>: incomplete\n",
edi->edi_obdinfo.obd_name); edi->edi_obdinfo.obd_name);
@ -674,7 +674,7 @@ ebus_setup_dinfo(device_t dev, struct ebus_softc *sc, phandle_t node)
} }
OF_prop_free(regs); OF_prop_free(regs);
nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intrs), nintr = OF_getprop_alloc_multi(node, "interrupts", sizeof(*intrs),
(void **)&intrs); (void **)&intrs);
if (nintr == -1) if (nintr == -1)
return (edi); return (edi);

View File

@ -205,7 +205,7 @@ fhc_attach(device_t dev)
} }
device_printf(dev, "board %d, ", board); 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); printf("model %s\n", name);
OF_prop_free(name); OF_prop_free(name);
} else } else
@ -227,7 +227,7 @@ fhc_attach(device_t dev)
bus_write_4(sc->sc_memres[FHC_INTERNAL], FHC_CTRL, ctrl); bus_write_4(sc->sc_memres[FHC_INTERNAL], FHC_CTRL, ctrl);
(void)bus_read_4(sc->sc_memres[FHC_INTERNAL], FHC_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); sizeof(*sc->sc_ranges), (void **)&sc->sc_ranges);
if (sc->sc_nrange == -1) { if (sc->sc_nrange == -1) {
device_printf(dev, "cannot get ranges\n"); device_printf(dev, "cannot get ranges\n");
@ -285,7 +285,7 @@ fhc_attach(device_t dev)
free(fdi, M_DEVBUF); free(fdi, M_DEVBUF);
continue; continue;
} }
i = OF_getprop_alloc(child, "reg", sizeof(*reg), i = OF_getprop_alloc_multi(child, "reg", sizeof(*reg),
(void **)&reg); (void **)&reg);
if (i == -1) { if (i == -1) {
device_printf(dev, "<%s>: incomplete\n", device_printf(dev, "<%s>: incomplete\n",
@ -301,7 +301,7 @@ fhc_attach(device_t dev)
reg[j].sbr_size, reg[j].sbr_size); reg[j].sbr_size, reg[j].sbr_size);
OF_prop_free(reg); OF_prop_free(reg);
if (central == 1) { if (central == 1) {
i = OF_getprop_alloc(child, "interrupts", i = OF_getprop_alloc_multi(child, "interrupts",
sizeof(*intr), (void **)&intr); sizeof(*intr), (void **)&intr);
if (i != -1) { if (i != -1) {
for (j = 0; j < i; j++) { for (j = 0; j < i; j++) {

View File

@ -92,7 +92,7 @@ isa_init(device_t dev)
/* The parent of the bus must be a PCI-ISA bridge. */ /* The parent of the bus must be a PCI-ISA bridge. */
bridge = device_get_parent(dev); bridge = device_get_parent(dev);
isab_node = ofw_bus_get_node(bridge); 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); sizeof(*isab_ranges), (void **)&isab_ranges);
if (isab_nrange <= 0) if (isab_nrange <= 0)
panic("isa_init: cannot get bridge range property"); 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(). * allow for an isa_activate_resource().
*/ */
for (node = OF_child(parent); node != 0; node = OF_peer(node)) { 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; continue;
/* /*
@ -192,7 +192,7 @@ isa_setup_children(device_t dev, phandle_t parent)
isa_set_vendorid(cdev, ofw_isa_pnp_map[i].id); isa_set_vendorid(cdev, ofw_isa_pnp_map[i].id);
rl = BUS_GET_RESOURCE_LIST(dev, cdev); 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); (void **)&regs);
for (i = 0; i < nreg; i++) { for (i = 0; i < nreg; i++) {
start = ISA_REG_PHYS(&regs[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 * the set of registers of the parent device like
* with the nodes hanging off of the `8042' node. * 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); (void **)&regidx);
if (nregidx > 2) if (nregidx > 2)
panic("isa_setup_children: impossible number " panic("isa_setup_children: impossible number "
"of register indices"); "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) { "reg", sizeof(*regs), (void **)&regs)) >= nregidx) {
for (i = 0; i < nregidx; i++) { for (i = 0; i < nregidx; i++) {
start = ISA_REG_PHYS(&regs[regidx[i]]); start = ISA_REG_PHYS(&regs[regidx[i]]);
@ -237,7 +237,7 @@ isa_setup_children(device_t dev, phandle_t parent)
if (regs != NULL) if (regs != NULL)
OF_prop_free(regs); OF_prop_free(regs);
nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intrs), nintr = OF_getprop_alloc_multi(node, "interrupts", sizeof(*intrs),
(void **)&intrs); (void **)&intrs);
for (i = 0; i < nintr; i++) { for (i = 0; i < nintr; i++) {
if (intrs[i] > 7) if (intrs[i] > 7)
@ -255,7 +255,7 @@ isa_setup_children(device_t dev, phandle_t parent)
if (intrs != NULL) if (intrs != NULL)
OF_prop_free(intrs); 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); (void **)&drqs);
for (i = 0; i < ndrq; i++) for (i = 0; i < ndrq; i++)
bus_set_resource(cdev, SYS_RES_DRQ, i, drqs[i], 1); bus_set_resource(cdev, SYS_RES_DRQ, i, drqs[i], 1);

View File

@ -93,7 +93,7 @@ ofw_pci_attach_common(device_t dev, bus_dma_tag_t dmat, u_long iosize,
* start addresses of the ranges are the configuration, I/O and * start addresses of the ranges are the configuration, I/O and
* memory handles. There should not be multiple ones of one kind. * 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); (void **)&range);
for (i = 0; i < nrange; i++) { for (i = 0; i < nrange; i++) {
j = OFW_PCI_RANGE_CS(&range[i]); j = OFW_PCI_RANGE_CS(&range[i]);

View File

@ -209,7 +209,7 @@ dma_attach(device_t dev)
* the user can change it via a "media" option to ifconfig. * the user can change it via a "media" option to ifconfig.
*/ */
csr = L64854_GCSR(lsc); csr = L64854_GCSR(lsc);
if ((OF_getprop_alloc(node, "cable-selection", 1, if ((OF_getprop_alloc(node, "cable-selection",
(void **)&cabletype)) == -1) { (void **)&cabletype)) == -1) {
/* assume TP if nothing there */ /* assume TP if nothing there */
csr |= E_TP_AUI; csr |= E_TP_AUI;
@ -295,7 +295,7 @@ dma_setup_dinfo(device_t dev, struct dma_softc *dsc, phandle_t node)
} }
resource_list_init(&ddi->ddi_rl); resource_list_init(&ddi->ddi_rl);
slot = -1; 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 (nreg == -1) {
device_printf(dev, "<%s>: incomplete\n", device_printf(dev, "<%s>: incomplete\n",
ddi->ddi_obdinfo.obd_name); ddi->ddi_obdinfo.obd_name);
@ -329,7 +329,7 @@ dma_setup_dinfo(device_t dev, struct dma_softc *dsc, phandle_t node)
/* /*
* The `interrupts' property contains the SBus interrupt level. * 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); (void **)&intr);
if (nintr != -1) { if (nintr != -1) {
for (i = 0; i < nintr; i++) { for (i = 0; i < nintr; i++) {

View File

@ -299,7 +299,7 @@ sbus_attach(device_t dev)
/* /*
* Collect address translations from the OBP. * 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) { sizeof(*range), (void **)&range)) == -1) {
panic("%s: error getting ranges property", __func__); panic("%s: error getting ranges property", __func__);
} }
@ -478,7 +478,7 @@ sbus_setup_dinfo(device_t dev, struct sbus_softc *sc, phandle_t node)
} }
resource_list_init(&sdi->sdi_rl); resource_list_init(&sdi->sdi_rl);
slot = -1; 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 (nreg == -1) {
if (sdi->sdi_obdinfo.obd_type == NULL || if (sdi->sdi_obdinfo.obd_type == NULL ||
strcmp(sdi->sdi_obdinfo.obd_type, "hierarchical") != 0) { strcmp(sdi->sdi_obdinfo.obd_type, "hierarchical") != 0) {
@ -512,7 +512,7 @@ sbus_setup_dinfo(device_t dev, struct sbus_softc *sc, phandle_t node)
/* /*
* The `interrupts' property contains the SBus interrupt level. * 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); (void **)&intr);
if (nintr != -1) { if (nintr != -1) {
for (i = 0; i < nintr; i++) { for (i = 0; i < nintr; i++) {

View File

@ -545,7 +545,7 @@ nexus_setup_dinfo(device_t dev, phandle_t node)
return (NULL); return (NULL);
} }
resource_list_init(&ndi->ndi_rl); 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) { if (nreg == -1) {
device_printf(dev, "<%s>: incomplete\n", device_printf(dev, "<%s>: incomplete\n",
ndi->ndi_obdinfo.obd_name); ndi->ndi_obdinfo.obd_name);
@ -561,7 +561,7 @@ nexus_setup_dinfo(device_t dev, phandle_t node)
} }
OF_prop_free(reg); OF_prop_free(reg);
nintr = OF_getprop_alloc(node, "interrupts", sizeof(*intr), nintr = OF_getprop_alloc_multi(node, "interrupts", sizeof(*intr),
(void **)&intr); (void **)&intr);
if (nintr > 0) { if (nintr > 0) {
if (OF_getprop(node, PCPU_GET(impl) < CPU_IMPL_ULTRASPARCIII ? if (OF_getprop(node, PCPU_GET(impl) < CPU_IMPL_ULTRASPARCIII ?

View File

@ -285,7 +285,7 @@ upa_attach(device_t dev)
goto fail; goto fail;
} }
sc->sc_nrange = OF_getprop_alloc(node, "ranges", sizeof(*sc->sc_ranges), sc->sc_nrange = OF_getprop_alloc_multi(node, "ranges", sizeof(*sc->sc_ranges),
(void **)&sc->sc_ranges); (void **)&sc->sc_ranges);
if (sc->sc_nrange == -1) { if (sc->sc_nrange == -1) {
device_printf(dev, "could not determine ranges\n"); device_printf(dev, "could not determine ranges\n");
@ -553,7 +553,7 @@ upa_setup_dinfo(device_t dev, struct upa_softc *sc, phandle_t node,
} }
resource_list_init(&udi->udi_rl); resource_list_init(&udi->udi_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) { if (nreg == -1) {
device_printf(dev, "<%s>: incomplete\n", device_printf(dev, "<%s>: incomplete\n",
udi->udi_obdinfo.obd_name); udi->udi_obdinfo.obd_name);