Module Name:    src
Committed By:   jmcneill
Date:           Thu Aug 23 13:24:44 UTC 2018

Modified Files:
        src/sys/dev/ofw: ofw_subr.c openfirm.h

Log Message:
Add of_getprop_uint64


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/ofw/ofw_subr.c
cvs rdiff -u -r1.36 -r1.37 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.31 src/sys/dev/ofw/ofw_subr.c:1.32
--- src/sys/dev/ofw/ofw_subr.c:1.31	Tue Jun 26 06:24:52 2018
+++ src/sys/dev/ofw/ofw_subr.c	Thu Aug 23 13:24:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: ofw_subr.c,v 1.31 2018/06/26 06:24:52 thorpej Exp $	*/
+/*	$NetBSD: ofw_subr.c,v 1.32 2018/08/23 13:24:44 jmcneill Exp $	*/
 
 /*
  * Copyright 1998
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.31 2018/06/26 06:24:52 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ofw_subr.c,v 1.32 2018/08/23 13:24:44 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -531,3 +531,21 @@ of_getprop_uint32(int node, const char *
 	*val = be32toh(v);
 	return 0;
 }
+
+/*
+ * Get the value of a uint64 property, compensating for host byte order.
+ * Returns 0 on success, non-zero on failure.
+ */
+int
+of_getprop_uint64(int node, const char *prop, uint64_t *val)
+{
+	uint64_t v;
+	int len;
+
+	len = OF_getprop(node, prop, &v, sizeof(v));
+	if (len != sizeof(v))
+		return -1;
+
+	*val = be64toh(v);
+	return 0;
+}

Index: src/sys/dev/ofw/openfirm.h
diff -u src/sys/dev/ofw/openfirm.h:1.36 src/sys/dev/ofw/openfirm.h:1.37
--- src/sys/dev/ofw/openfirm.h:1.36	Mon Jul  3 00:47:34 2017
+++ src/sys/dev/ofw/openfirm.h	Thu Aug 23 13:24:44 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: openfirm.h,v 1.36 2017/07/03 00:47:34 jmcneill Exp $	*/
+/*	$NetBSD: openfirm.h,v 1.37 2018/08/23 13:24:44 jmcneill Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
@@ -130,5 +130,6 @@ void	of_enter_i2c_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_uint64(int, const char *, uint64_t *);
 
 #endif /*_OPENFIRM_H_*/

Reply via email to