[U-Boot] [RFC PATCH 2/2] tegra: Use fdtdec_find_aliases() to find USB ports
Simon Glass
sjg at chromium.org
Mon Dec 26 23:31:50 CET 2011
Use the new fdtdec_find_aliases() function instead of
fdtdec_next_alias() to locate our USB nodes.
As this example shows, the impact on drivers should be minimal.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
arch/arm/cpu/armv7/tegra2/usb.c | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/arch/arm/cpu/armv7/tegra2/usb.c b/arch/arm/cpu/armv7/tegra2/usb.c
index 215d0d3..5b2bd7e 100644
--- a/arch/arm/cpu/armv7/tegra2/usb.c
+++ b/arch/arm/cpu/armv7/tegra2/usb.c
@@ -395,21 +395,20 @@ int fdt_decode_usb(const void *blob, int node, unsigned osc_frequency_mhz,
int board_usb_init(const void *blob)
{
struct fdt_usb config;
- int node, upto = 0;
unsigned osc_freq = clock_get_rate(CLOCK_ID_OSC);
enum clock_osc_freq freq;
+ int node_list[USB_PORTS_MAX];
+ int node, count, i;
/* Set up the USB clocks correctly based on our oscillator frequency */
freq = clock_get_osc_freq();
config_clock(usb_pll[freq]);
- do {
- node = fdtdec_next_alias(blob, "usb",
- COMPAT_NVIDIA_TEGRA20_USB, &upto);
- if (node < 0) {
- debug("Cannot find usb%d alias in fdt\n", upto);
- break;
- }
+ /* count may return <0 on error */
+ count = fdtdec_find_aliases(blob, "usb", COMPAT_NVIDIA_TEGRA20_USB,
+ node_list, USB_PORTS_MAX);
+ for (i = 0; i < count; i++) {
+ node = node_list[i];
if (fdt_decode_usb(blob, node, osc_freq, &config)) {
debug("Cannot decode USB node %s\n",
fdt_get_name(blob, node, NULL));
@@ -423,7 +422,7 @@ int board_usb_init(const void *blob)
if (add_port(&config, usb_pll[freq]))
return -1;
- } while (node);
+ }
usb_set_host_mode();
port_current = -1;
return 0;
--
1.7.3.1
More information about the U-Boot
mailing list