From 3ff546249d2d99ff62ce20ae12017881d04c49e5 Mon Sep 17 00:00:00 2001 From: kettenis Date: Thu, 6 May 2021 19:45:16 +0000 Subject: [PATCH] Add OF_getpropbool(9). ok visa@ --- sys/dev/ofw/fdt.c | 11 ++++++++++- sys/dev/ofw/openfirm.h | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/dev/ofw/fdt.c b/sys/dev/ofw/fdt.c index 62ca7392c45..b7d1d739bb2 100644 --- a/sys/dev/ofw/fdt.c +++ b/sys/dev/ofw/fdt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: fdt.c,v 1.26 2020/12/30 06:06:31 gkoehler Exp $ */ +/* $OpenBSD: fdt.c,v 1.27 2021/05/06 19:45:16 kettenis Exp $ */ /* * Copyright (c) 2009 Dariusz Swiderski @@ -962,6 +962,15 @@ OF_getprop(int handle, char *prop, void *buf, int buflen) return len; } +int +OF_getpropbool(int handle, char *prop) +{ + void *node = (char *)tree.header + handle; + char *data; + + return (fdt_node_property(node, prop, &data) >= 0); +} + uint32_t OF_getpropint(int handle, char *prop, uint32_t defval) { diff --git a/sys/dev/ofw/openfirm.h b/sys/dev/ofw/openfirm.h index ea631c2f0e4..54ccdf3d37e 100644 --- a/sys/dev/ofw/openfirm.h +++ b/sys/dev/ofw/openfirm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: openfirm.h,v 1.17 2020/12/30 06:06:31 gkoehler Exp $ */ +/* $OpenBSD: openfirm.h,v 1.18 2021/05/06 19:45:16 kettenis Exp $ */ /* $NetBSD: openfirm.h,v 1.1 1996/09/30 16:35:10 ws Exp $ */ /* @@ -50,6 +50,7 @@ int OF_parent(int phandle); int OF_instance_to_package(int ihandle); int OF_getproplen(int handle, char *prop); int OF_getprop(int handle, char *prop, void *buf, int buflen); +int OF_getpropbool(int handle, char *); uint32_t OF_getpropint(int handle, char *, uint32_t); int OF_getpropintarray(int, char *, uint32_t *, int); uint64_t OF_getpropint64(int handle, char *, uint64_t); -- 2.20.1