Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/arm/nvidia use of_getprop_uint32
details: https://anonhg.NetBSD.org/src/rev/8c643c0b681b
branches: trunk
changeset: 342329:8c643c0b681b
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Wed Dec 16 19:46:55 2015 +0000
description:
use of_getprop_uint32
diffstat:
sys/arch/arm/nvidia/tegra_com.c | 17 +++++++----------
sys/arch/arm/nvidia/tegra_i2c.c | 25 +++++++++++--------------
sys/arch/arm/nvidia/tegra_lic.c | 17 +++++++----------
sys/arch/arm/nvidia/tegra_sdhc.c | 10 +++-------
sys/arch/arm/nvidia/tegra_usbphy.c | 35 ++++++++++++++---------------------
5 files changed, 42 insertions(+), 62 deletions(-)
diffs (272 lines):
diff -r 794a4b6007f6 -r 8c643c0b681b sys/arch/arm/nvidia/tegra_com.c
--- a/sys/arch/arm/nvidia/tegra_com.c Wed Dec 16 19:33:55 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_com.c Wed Dec 16 19:46:55 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_com.c,v 1.3 2015/12/13 17:39:19 jmcneill Exp $ */
+/* $NetBSD: tegra_com.c,v 1.4 2015/12/16 19:46:55 jmcneill Exp $ */
/*-
* Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
#include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: tegra_com.c,v 1.3 2015/12/13 17:39:19 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: tegra_com.c,v 1.4 2015/12/16 19:46:55 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -98,17 +98,17 @@
bus_addr_t addr;
bus_size_t size;
u_int reg_shift;
- int error, len;
+ int error;
if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) {
aprint_error(": couldn't get registers\n");
return;
}
- len = OF_getprop(faa->faa_phandle, "reg-shift", ®_shift,
- sizeof(reg_shift));
- if (len == sizeof(reg_shift)) {
- reg_shift = be32toh(reg_shift);
+ if (of_getprop_uint32(faa->faa_phandle, "reg-shift", ®_shift)) {
+ /* missing or bad reg-shift property, assume 2 */
+ bst = faa->faa_a4x_bst;
+ } else {
if (reg_shift == 2) {
bst = faa->faa_a4x_bst;
} else if (reg_shift == 0) {
@@ -118,9 +118,6 @@
reg_shift);
return;
}
- } else {
- /* missing or bad reg-shift property, assume 2 */
- bst = faa->faa_a4x_bst;
}
sc->sc_dev = self;
diff -r 794a4b6007f6 -r 8c643c0b681b sys/arch/arm/nvidia/tegra_i2c.c
--- a/sys/arch/arm/nvidia/tegra_i2c.c Wed Dec 16 19:33:55 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_i2c.c Wed Dec 16 19:46:55 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_i2c.c,v 1.9 2015/12/13 17:39:19 jmcneill Exp $ */
+/* $NetBSD: tegra_i2c.c,v 1.10 2015/12/16 19:46: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: tegra_i2c.c,v 1.9 2015/12/13 17:39:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_i2c.c,v 1.10 2015/12/16 19:46:55 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -126,15 +126,16 @@
{
struct tegra_i2c_softc * const sc = device_private(self);
struct fdt_attach_args * const faa = aux;
+ const int phandle = faa->faa_phandle;
struct i2cbus_attach_args iba;
prop_dictionary_t devs;
char intrstr[128];
bus_addr_t addr;
bus_size_t size;
u_int address_cells;
- int len, error;
+ int error;
- if (fdtbus_get_reg(faa->faa_phandle, 0, &addr, &size) != 0) {
+ if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
aprint_error(": couldn't get registers\n");
return;
}
@@ -153,12 +154,12 @@
aprint_naive("\n");
aprint_normal(": I2C%d\n", sc->sc_port + 1);
- if (!fdtbus_intr_str(faa->faa_phandle, 0, intrstr, sizeof(intrstr))) {
+ if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
aprint_error_dev(self, "failed to decode interrupt\n");
return;
}
- sc->sc_ih = fdtbus_intr_establish(faa->faa_phandle, 0, IPL_VM,
+ sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_VM,
FDT_INTR_MPSAFE, tegra_i2c_intr, sc);
if (sc->sc_ih == NULL) {
aprint_error_dev(self, "couldn't establish interrupt on %s\n",
@@ -180,17 +181,13 @@
sc->sc_ic.ic_release_bus = tegra_i2c_release_bus;
sc->sc_ic.ic_exec = tegra_i2c_exec;
- fdtbus_register_i2c_controller(self, faa->faa_phandle,
- &tegra_i2c_funcs);
+ fdtbus_register_i2c_controller(self, phandle, &tegra_i2c_funcs);
devs = prop_dictionary_create();
- len = OF_getprop(faa->faa_phandle, "#address-cells",
- &address_cells, sizeof(address_cells));
- if (len == sizeof(address_cells)) {
- address_cells = be32toh(address_cells);
- } else {
+
+ if (of_getprop_uint32(phandle, "#address-cells", &address_cells))
address_cells = 1;
- }
+
of_enter_i2c_devs(devs, faa->faa_phandle, address_cells * 4, 0);
iba.iba_tag = &sc->sc_ic;
diff -r 794a4b6007f6 -r 8c643c0b681b sys/arch/arm/nvidia/tegra_lic.c
--- a/sys/arch/arm/nvidia/tegra_lic.c Wed Dec 16 19:33:55 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_lic.c Wed Dec 16 19:46:55 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_lic.c,v 1.1 2015/12/13 17:39:19 jmcneill Exp $ */
+/* $NetBSD: tegra_lic.c,v 1.2 2015/12/16 19:46: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: tegra_lic.c,v 1.1 2015/12/13 17:39:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_lic.c,v 1.2 2015/12/16 19:46:55 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -105,11 +105,10 @@
u_int *interrupts;
int interrupt_cells, len;
- len = OF_getprop(sc->sc_phandle, "#interrupt-cells", &interrupt_cells,
- sizeof(interrupt_cells));
- if (len != sizeof(interrupt_cells) || interrupt_cells <= 0)
+ if (of_getprop_uint32(sc->sc_phandle, "#interrupt-cells",
+ &interrupt_cells)) {
return NULL;
- interrupt_cells = be32toh(interrupt_cells);
+ }
len = OF_getproplen(phandle, "interrupts");
if (len <= 0)
@@ -157,12 +156,10 @@
u_int *interrupts;
int interrupt_cells, len;
- len = OF_getprop(sc->sc_phandle, "#interrupt-cells", &interrupt_cells,
- sizeof(interrupt_cells));
- if (len != sizeof(interrupt_cells) || interrupt_cells <= 0) {
+ if (of_getprop_uint32(sc->sc_phandle, "#interrupt-cells",
+ &interrupt_cells)) {
return false;
}
- interrupt_cells = be32toh(interrupt_cells);
len = OF_getproplen(phandle, "interrupts");
if (len <= 0) {
diff -r 794a4b6007f6 -r 8c643c0b681b sys/arch/arm/nvidia/tegra_sdhc.c
--- a/sys/arch/arm/nvidia/tegra_sdhc.c Wed Dec 16 19:33:55 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_sdhc.c Wed Dec 16 19:46:55 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_sdhc.c,v 1.13 2015/12/15 15:33:19 jmcneill Exp $ */
+/* $NetBSD: tegra_sdhc.c,v 1.14 2015/12/16 19:46:55 jmcneill Exp $ */
/*-
* Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
#include "locators.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tegra_sdhc.c,v 1.13 2015/12/15 15:33:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_sdhc.c,v 1.14 2015/12/16 19:46:55 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -115,12 +115,8 @@
return;
}
- if (OF_getprop(faa->faa_phandle, "bus-width", &bus_width,
- sizeof(bus_width)) == sizeof(bus_width)) {
- bus_width = be32toh(bus_width);
- } else {
+ if (of_getprop_uint32(faa->faa_phandle, "bus-width", &bus_width))
bus_width = 4;
- }
sc->sc.sc_dev = self;
sc->sc.sc_dmat = faa->faa_dmat;
diff -r 794a4b6007f6 -r 8c643c0b681b sys/arch/arm/nvidia/tegra_usbphy.c
--- a/sys/arch/arm/nvidia/tegra_usbphy.c Wed Dec 16 19:33:55 2015 +0000
+++ b/sys/arch/arm/nvidia/tegra_usbphy.c Wed Dec 16 19:46:55 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tegra_usbphy.c,v 1.3 2015/12/13 17:39:19 jmcneill Exp $ */
+/* $NetBSD: tegra_usbphy.c,v 1.4 2015/12/16 19:46: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: tegra_usbphy.c,v 1.3 2015/12/13 17:39:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tegra_usbphy.c,v 1.4 2015/12/16 19:46:55 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -69,16 +69,16 @@
u_int sc_port;
struct tegra_gpio_pin *sc_pin_vbus;
- uint8_t sc_hssync_start_delay;
- uint8_t sc_idle_wait_delay;
- uint8_t sc_elastic_limit;
- uint8_t sc_term_range_adj;
- uint8_t sc_xcvr_setup;
- uint8_t sc_xcvr_lsfslew;
- uint8_t sc_xcvr_lsrslew;
- uint8_t sc_hssquelch_level;
- uint8_t sc_hsdiscon_level;
- uint8_t sc_xcvr_hsslew;
+ uint32_t sc_hssync_start_delay;
+ uint32_t sc_idle_wait_delay;
+ uint32_t sc_elastic_limit;
+ uint32_t sc_term_range_adj;
+ uint32_t sc_xcvr_setup;
+ uint32_t sc_xcvr_lsfslew;
+ uint32_t sc_xcvr_lsrslew;
+ uint32_t sc_hssquelch_level;
+ uint32_t sc_hsdiscon_level;
+ uint32_t sc_xcvr_hsslew;
};
static int tegra_usbphy_parse_properties(struct tegra_usbphy_softc *);
@@ -147,19 +147,12 @@
static int
tegra_usbphy_parse_properties(struct tegra_usbphy_softc *sc)
{
- const int phandle = sc->sc_phandle;
- const int plen = sizeof(u_int);
- u_int val;
-
#define PROPGET(k, v) \
-do { \
- if (OF_getprop(phandle, (k), &val, plen) != plen) { \
+ if (of_getprop_uint32(sc->sc_phandle, (k), (v))) { \
aprint_error_dev(sc->sc_dev, \
"missing property '%s'\n", (k)); \
return EIO; \
- } \
- *(v) = be32toh(val); \
-} while (0)
+ }
PROPGET("nvidia,hssync-start-delay", &sc->sc_hssync_start_delay);
PROPGET("nvidia,idle-wait-delay", &sc->sc_idle_wait_delay);
Home |
Main Index |
Thread Index |
Old Index