mirror of
https://github.com/Stichting-MINIX-Research-Foundation/u-boot.git
synced 2025-09-10 12:39:22 -04:00
powerpc/8xxx: Cleanup USB device-tree fixup
Some code cleanup done for USB device-tree fixup: - handling error value returned from fdt_fixup_usb_mode_phy_type() - using ARRAY_SIZE macro - using snprintf instead of sprintf Signed-off-by: Ramneek Mehresh <ramneek.mehresh@freescale.com>
This commit is contained in:
parent
9a3aae22ed
commit
5a52977f28
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2009-2011 Freescale Semiconductor, Inc.
|
* Copyright 2009-2012 Freescale Semiconductor, Inc.
|
||||||
*
|
*
|
||||||
* This file is derived from arch/powerpc/cpu/mpc85xx/cpu.c and
|
* This file is derived from arch/powerpc/cpu/mpc85xx/cpu.c and
|
||||||
* arch/powerpc/cpu/mpc86xx/cpu.c. Basically this file contains
|
* arch/powerpc/cpu/mpc86xx/cpu.c. Basically this file contains
|
||||||
@ -137,28 +137,34 @@ void fdt_fixup_dr_usb(void *blob, bd_t *bd)
|
|||||||
|
|
||||||
for (i = 1; i <= FSL_MAX_NUM_USB_CTRLS; i++) {
|
for (i = 1; i <= FSL_MAX_NUM_USB_CTRLS; i++) {
|
||||||
int mode_idx = -1, phy_idx = -1;
|
int mode_idx = -1, phy_idx = -1;
|
||||||
sprintf(str, "%s%d", "usb", i);
|
snprintf(str, 5, "%s%d", "usb", i);
|
||||||
if (hwconfig(str)) {
|
if (hwconfig(str)) {
|
||||||
for (j = 0; j < sizeof(modes); j++) {
|
for (j = 0; j < ARRAY_SIZE(modes); j++) {
|
||||||
if (hwconfig_subarg_cmp(str, "dr_mode",
|
if (hwconfig_subarg_cmp(str, "dr_mode",
|
||||||
modes[j])) {
|
modes[j])) {
|
||||||
mode_idx = j;
|
mode_idx = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (j = 0; j < sizeof(phys); j++) {
|
for (j = 0; j < ARRAY_SIZE(phys); j++) {
|
||||||
if (hwconfig_subarg_cmp(str, "phy_type",
|
if (hwconfig_subarg_cmp(str, "phy_type",
|
||||||
phys[j])) {
|
phys[j])) {
|
||||||
phy_idx = j;
|
phy_idx = j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mode_idx >= 0)
|
if (mode_idx >= 0) {
|
||||||
usb_mode_off = fdt_fixup_usb_mode_phy_type(blob,
|
usb_mode_off = fdt_fixup_usb_mode_phy_type(blob,
|
||||||
modes[mode_idx], NULL, usb_mode_off);
|
modes[mode_idx], NULL, usb_mode_off);
|
||||||
if (phy_idx >= 0)
|
if (usb_mode_off < 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (phy_idx >= 0) {
|
||||||
usb_phy_off = fdt_fixup_usb_mode_phy_type(blob,
|
usb_phy_off = fdt_fixup_usb_mode_phy_type(blob,
|
||||||
NULL, phys[phy_idx], usb_phy_off);
|
NULL, phys[phy_idx], usb_phy_off);
|
||||||
|
if (usb_phy_off < 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!strcmp(str, "usb1"))
|
if (!strcmp(str, "usb1"))
|
||||||
usb1_defined = 1;
|
usb1_defined = 1;
|
||||||
if (mode_idx < 0 && phy_idx < 0)
|
if (mode_idx < 0 && phy_idx < 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user