aboutsummaryrefslogtreecommitdiff
path: root/sys/sparc64/fhc/fhc.c
diff options
context:
space:
mode:
authorOleksandr Tymoshenko <gonzo@FreeBSD.org>2018-04-08 22:59:34 +0000
committerOleksandr Tymoshenko <gonzo@FreeBSD.org>2018-04-08 22:59:34 +0000
commit217d17bcd3f525fbdf124cfbc926f8033da69805 (patch)
tree146d3c2e0fb57898ccf50e647f680a89962f5c1b /sys/sparc64/fhc/fhc.c
parent9d9889b5eb221519c15655e86892440972fc2886 (diff)
downloadsrc-217d17bcd3f525fbdf124cfbc926f8033da69805.tar.gz
src-217d17bcd3f525fbdf124cfbc926f8033da69805.zip
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
Notes
Notes: svn path=/head/; revision=332310
Diffstat (limited to 'sys/sparc64/fhc/fhc.c')
-rw-r--r--sys/sparc64/fhc/fhc.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/sparc64/fhc/fhc.c b/sys/sparc64/fhc/fhc.c
index d55e2ddef698..cc858cfc9544 100644
--- a/sys/sparc64/fhc/fhc.c
+++ b/sys/sparc64/fhc/fhc.c
@@ -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++) {