Module Name: src Committed By: ryo Date: Thu Dec 31 15:10:46 UTC 2020
Modified Files: src/sys/dev/ofw: ofw_subr.c openfirm.h Log Message: add of_getprop_uint32_array() To generate a diff of this commit: cvs rdiff -u -r1.40 -r1.41 src/sys/dev/ofw/ofw_subr.c cvs rdiff -u -r1.39 -r1.40 src/sys/dev/ofw/openfirm.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/ofw/ofw_subr.c diff -u src/sys/dev/ofw/ofw_subr.c:1.40 src/sys/dev/ofw/ofw_subr.c:1.41 --- src/sys/dev/ofw/ofw_subr.c:1.40 Thu Jul 16 21:32:44 2020 +++ src/sys/dev/ofw/ofw_subr.c Thu Dec 31 15:10:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ofw_subr.c,v 1.40 2020/07/16 21:32:44 jmcneill Exp $ */ +/* $NetBSD: ofw_subr.c,v 1.41 2020/12/31 15:10:46 ryo Exp $ */ /* * Copyright 1998 @@ -34,7 +34,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.40 2020/07/16 21:32:44 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.41 2020/12/31 15:10:46 ryo Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -603,6 +603,23 @@ of_getprop_uint32(int node, const char * return 0; } +int +of_getprop_uint32_array(int node, const char *prop, uint32_t *array, int n) +{ + uint32_t *v = array; + int len; + + len = OF_getprop(node, prop, array, n * sizeof(*v)); + if (len < (int)(n * sizeof(*v))) + return -1; + + for (; n > 0; n--) { + BE32TOH(*v); + v++; + } + + return 0; +} /* * Get the value of a uint64 property, compensating for host byte order. * Returns 0 on success, non-zero on failure. Index: src/sys/dev/ofw/openfirm.h diff -u src/sys/dev/ofw/openfirm.h:1.39 src/sys/dev/ofw/openfirm.h:1.40 --- src/sys/dev/ofw/openfirm.h:1.39 Thu Jul 16 21:32:44 2020 +++ src/sys/dev/ofw/openfirm.h Thu Dec 31 15:10:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: openfirm.h,v 1.39 2020/07/16 21:32:44 jmcneill Exp $ */ +/* $NetBSD: openfirm.h,v 1.40 2020/12/31 15:10:46 ryo Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -132,6 +132,7 @@ void of_enter_spi_devs(prop_dictionary_t bool of_hasprop(int, const char *); #define of_getprop_bool of_hasprop int of_getprop_uint32(int, const char *, uint32_t *); +int of_getprop_uint32_array(int, const char *, uint32_t *, int); int of_getprop_uint64(int, const char *, uint64_t *); #endif /*_OPENFIRM_H_*/