Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ofw add of_getprop_uint32_array()



details:   https://anonhg.NetBSD.org/src/rev/1bb4d8c56365
branches:  trunk
changeset: 1017566:1bb4d8c56365
user:      ryo <ryo%NetBSD.org@localhost>
date:      Thu Dec 31 15:10:46 2020 +0000

description:
add of_getprop_uint32_array()

diffstat:

 sys/dev/ofw/ofw_subr.c |  21 +++++++++++++++++++--
 sys/dev/ofw/openfirm.h |   3 ++-
 2 files changed, 21 insertions(+), 3 deletions(-)

diffs (59 lines):

diff -r 7c68f6a5dfe3 -r 1bb4d8c56365 sys/dev/ofw/ofw_subr.c
--- a/sys/dev/ofw/ofw_subr.c    Thu Dec 31 15:09:12 2020 +0000
+++ b/sys/dev/ofw/ofw_subr.c    Thu Dec 31 15:10:46 2020 +0000
@@ -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 @@
        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.
diff -r 7c68f6a5dfe3 -r 1bb4d8c56365 sys/dev/ofw/openfirm.h
--- a/sys/dev/ofw/openfirm.h    Thu Dec 31 15:09:12 2020 +0000
+++ b/sys/dev/ofw/openfirm.h    Thu Dec 31 15:10:46 2020 +0000
@@ -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 @@
 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_*/



Home | Main Index | Thread Index | Old Index