Index: sys/dev/ofw/ofw_bus_subr.c =================================================================== --- sys/dev/ofw/ofw_bus_subr.c +++ sys/dev/ofw/ofw_bus_subr.c @@ -629,6 +629,8 @@ * node - consumers device node * list_name - name of parsed list - "clocks" * cells_name - name of size property - "#clock-cells" + * idx - the index of the requested list entry, or, if -1, an indication + * to return the number of entries in the parsed list. * Output arguments: * producer - handle of producer * ncells - number of cells in result @@ -649,7 +651,7 @@ (void **)&elems); if (nelems <= 0) return (ENOENT); - rv = ENOENT; + rv = (idx == -1) ? 0 : ENOENT; for (i = 0, cnt = 0; i < nelems; i += pcells, cnt++) { pnode = elems[i++]; if (OF_getencprop(OF_node_from_xref(pnode), @@ -678,6 +680,8 @@ } if (elems != NULL) free(elems, M_OFWPROP); + if (idx == -1 && rv == 0) + return (cnt); return (rv); }