Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/fdt Use of_getprop_bool/of_getprop_uint32
details: https://anonhg.NetBSD.org/src/rev/794a4b6007f6
branches: trunk
changeset: 342328:794a4b6007f6
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Wed Dec 16 19:33:55 2015 +0000
description:
Use of_getprop_bool/of_getprop_uint32
diffstat:
sys/dev/fdt/fdt_intr.c | 12 ++++--------
sys/dev/fdt/fdt_subr.c | 20 ++++++--------------
sys/dev/fdt/fixedregulator.c | 16 ++++++----------
sys/dev/fdt/gpiokeys.c | 18 ++++++------------
4 files changed, 22 insertions(+), 44 deletions(-)
diffs (190 lines):
diff -r c5f84c746fb8 -r 794a4b6007f6 sys/dev/fdt/fdt_intr.c
--- a/sys/dev/fdt/fdt_intr.c Wed Dec 16 19:33:39 2015 +0000
+++ b/sys/dev/fdt/fdt_intr.c Wed Dec 16 19:33:55 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_intr.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $ */
+/* $NetBSD: fdt_intr.c,v 1.3 2015/12/16 19:33:55 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.2 2015/12/16 12:17:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_intr.c,v 1.3 2015/12/16 19:33:55 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -50,12 +50,10 @@
fdtbus_get_interrupt_parent(int phandle)
{
u_int interrupt_parent;
- int len;
while (phandle >= 0) {
- len = OF_getprop(phandle, "interrupt-parent",
- &interrupt_parent, sizeof(interrupt_parent));
- if (len == sizeof(interrupt_parent)) {
+ if (of_getprop_uint32(phandle, "interrupt-parent",
+ &interrupt_parent) == 0) {
break;
}
if (phandle == 0) {
@@ -67,8 +65,6 @@
return -1;
}
- interrupt_parent = fdt32_to_cpu(interrupt_parent);
-
const void *data = fdtbus_get_data();
const int off = fdt_node_offset_by_phandle(data, interrupt_parent);
if (off < 0) {
diff -r c5f84c746fb8 -r 794a4b6007f6 sys/dev/fdt/fdt_subr.c
--- a/sys/dev/fdt/fdt_subr.c Wed Dec 16 19:33:39 2015 +0000
+++ b/sys/dev/fdt/fdt_subr.c Wed Dec 16 19:33:55 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fdt_subr.c,v 1.3 2015/12/16 12:17:45 jmcneill Exp $ */
+/* $NetBSD: fdt_subr.c,v 1.4 2015/12/16 19:33:55 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.3 2015/12/16 12:17:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fdt_subr.c,v 1.4 2015/12/16 19:33:55 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -82,18 +82,14 @@
static int
fdtbus_get_addr_cells(int phandle)
{
- int val, addr_cells, error;
+ uint32_t addr_cells;
const int parent = OF_parent(phandle);
if (parent == -1)
return -1;
- error = OF_getprop(parent, "#address-cells", &val, sizeof(val));
- if (error <= 0) {
+ if (of_getprop_uint32(parent, "#address-cells", &addr_cells))
addr_cells = 2;
- } else {
- addr_cells = fdt32_to_cpu(val);
- }
return addr_cells;
}
@@ -101,18 +97,14 @@
static int
fdtbus_get_size_cells(int phandle)
{
- int val, size_cells, error;
+ uint32_t size_cells;
const int parent = OF_parent(phandle);
if (parent == -1)
return -1;
- error = OF_getprop(parent, "#size-cells", &val, sizeof(val));
- if (error <= 0) {
+ if (of_getprop_uint32(parent, "#size-cells", &size_cells))
size_cells = 0;
- } else {
- size_cells = fdt32_to_cpu(val);
- }
return size_cells;
}
diff -r c5f84c746fb8 -r 794a4b6007f6 sys/dev/fdt/fixedregulator.c
--- a/sys/dev/fdt/fixedregulator.c Wed Dec 16 19:33:39 2015 +0000
+++ b/sys/dev/fdt/fixedregulator.c Wed Dec 16 19:33:55 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fixedregulator.c,v 1.1 2015/12/13 17:30:40 jmcneill Exp $ */
+/* $NetBSD: fixedregulator.c,v 1.2 2015/12/16 19:33:55 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: fixedregulator.c,v 1.1 2015/12/13 17:30:40 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fixedregulator.c,v 1.2 2015/12/16 19:33:55 jmcneill Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -100,18 +100,14 @@
}
gpioflags = GPIO_PIN_OUTPUT;
- if (OF_getproplen(phandle, "gpio-open-drain") >= 0) {
+ if (of_getprop_bool(phandle, "gpio-open-drain"))
gpioflags |= GPIO_PIN_OPENDRAIN;
- }
+ sc->sc_always_on = of_getprop_bool(phandle, "regulator-always-on");
sc->sc_pin = fdtbus_gpio_acquire(phandle, "gpio", gpioflags);
- if (sc->sc_pin == NULL ||
- OF_getproplen(phandle, "regulator-always-on") >= 0) {
+ if (sc->sc_pin == NULL)
sc->sc_always_on = true;
- }
- if (OF_getproplen(phandle, "enable-active-high") >= 0) {
- sc->sc_enable_val = 1;
- }
+ sc->sc_enable_val = of_getprop_bool(phandle, "enable-active-high");
fdtbus_register_regulator_controller(self, phandle,
&fixedregulator_funcs);
diff -r c5f84c746fb8 -r 794a4b6007f6 sys/dev/fdt/gpiokeys.c
--- a/sys/dev/fdt/gpiokeys.c Wed Dec 16 19:33:39 2015 +0000
+++ b/sys/dev/fdt/gpiokeys.c Wed Dec 16 19:33:55 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: gpiokeys.c,v 1.1 2015/12/14 20:58:45 jmcneill Exp $ */
+/* $NetBSD: gpiokeys.c,v 1.2 2015/12/16 19:33:55 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: gpiokeys.c,v 1.1 2015/12/14 20:58:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpiokeys.c,v 1.2 2015/12/16 19:33:55 jmcneill Exp $");
#include <sys/param.h>
#include <sys/kernel.h>
@@ -108,11 +108,10 @@
aprint_normal(":");
for (child = OF_child(phandle); child; child = OF_peer(child)) {
- len = OF_getprop(child, "linux,code", &code, sizeof(code));
- if (len != sizeof(code)) {
+ if (of_getprop_uint32(child, "linux,code", &code))
continue;
- }
- code = be32toh(code);
+ if (of_getprop_uint32(child, "debounce-interval", &debounce))
+ debounce = 5; /* default */
len = OF_getproplen(child, "label");
if (len <= 0) {
continue;
@@ -126,12 +125,7 @@
kmem_free(key, sizeof(*key));
continue;
}
- if (OF_getprop(child, "debounce-interval", &debounce,
- sizeof(debounce)) == sizeof(debounce)) {
- key->key_debounce = be32toh(debounce);
- } else {
- key->key_debounce = 5; /* default */
- }
+ key->key_debounce = debounce;
key->key_pin = fdtbus_gpio_acquire(child, "gpios",
GPIO_PIN_INPUT);
Home |
Main Index |
Thread Index |
Old Index