Module Name: src Committed By: jmcneill Date: Wed Dec 16 19:33:55 UTC 2015
Modified Files: src/sys/dev/fdt: fdt_intr.c fdt_subr.c fixedregulator.c gpiokeys.c Log Message: Use of_getprop_bool/of_getprop_uint32 To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/dev/fdt/fdt_intr.c cvs rdiff -u -r1.3 -r1.4 src/sys/dev/fdt/fdt_subr.c cvs rdiff -u -r1.1 -r1.2 src/sys/dev/fdt/fixedregulator.c \ src/sys/dev/fdt/gpiokeys.c 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/fdt/fdt_intr.c diff -u src/sys/dev/fdt/fdt_intr.c:1.2 src/sys/dev/fdt/fdt_intr.c:1.3 --- src/sys/dev/fdt/fdt_intr.c:1.2 Wed Dec 16 12:17:45 2015 +++ src/sys/dev/fdt/fdt_intr.c Wed Dec 16 19:33:55 2015 @@ -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 <jmcne...@invisible.ca> @@ -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 @@ static int 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 @@ fdtbus_get_interrupt_parent(int phandle) 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) { Index: src/sys/dev/fdt/fdt_subr.c diff -u src/sys/dev/fdt/fdt_subr.c:1.3 src/sys/dev/fdt/fdt_subr.c:1.4 --- src/sys/dev/fdt/fdt_subr.c:1.3 Wed Dec 16 12:17:45 2015 +++ src/sys/dev/fdt/fdt_subr.c Wed Dec 16 19:33:55 2015 @@ -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 <jmcne...@invisible.ca> @@ -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 @@ fdtbus_phandle2offset(int phandle) 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 @@ fdtbus_get_addr_cells(int phandle) 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; } Index: src/sys/dev/fdt/fixedregulator.c diff -u src/sys/dev/fdt/fixedregulator.c:1.1 src/sys/dev/fdt/fixedregulator.c:1.2 --- src/sys/dev/fdt/fixedregulator.c:1.1 Sun Dec 13 17:30:40 2015 +++ src/sys/dev/fdt/fixedregulator.c Wed Dec 16 19:33:55 2015 @@ -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 <jmcne...@invisible.ca> @@ -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 @@ fixedregulator_attach(device_t parent, d } 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); Index: src/sys/dev/fdt/gpiokeys.c diff -u src/sys/dev/fdt/gpiokeys.c:1.1 src/sys/dev/fdt/gpiokeys.c:1.2 --- src/sys/dev/fdt/gpiokeys.c:1.1 Mon Dec 14 20:58:45 2015 +++ src/sys/dev/fdt/gpiokeys.c Wed Dec 16 19:33:55 2015 @@ -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 <jmcne...@invisible.ca> @@ -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 @@ gpiokeys_attach(device_t parent, device_ 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 @@ gpiokeys_attach(device_t parent, device_ 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);