[U-Boot] [PATCH] tsec: fix the return value for tsec_eth_init()
Andy Fleming
afleming at freescale.com
Fri Jun 4 22:57:00 CEST 2010
On Jun 4, 2010, at 3:50 PM, Timur Tabi wrote:
> The Ethernet initialization functions are supposed to return the number of
> devices initialized, so fix tsec_eth_init() so that it returns the number of
> TSECs initialized instead of just zero. This is safe because the return value
> is currently ignored by all callers, but now they don't have to ignore it.
>
> Signed-off-by: Timur Tabi <timur at freescale.com>
> ---
> drivers/net/tsec.c | 18 ++++++++++++------
> 1 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
> index 3e4c3bd..abfc80a 100644
> --- a/drivers/net/tsec.c
> +++ b/drivers/net/tsec.c
> @@ -97,12 +97,18 @@ static struct tsec_info_struct tsec_info[] = {
>
> int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsecs, int num)
> {
> - int i;
> -
> - for (i = 0; i < num; i++)
> - tsec_initialize(bis, &tsecs[i]);
> + unsigned int i;
> + unsigned int count = 0;
> + int ret;
> +
> + for (i = 0; i < num; i++) {
> + ret = tsec_initialize(bis, &tsecs[i]);
> + if (ret < 0)
> + return ret;
> + count += ret;
The old way continued even if one of the tsecs failed to initialize. Let's preserve the original behavior in that sense:
for (i = 0; i < num; i++) {
ret = tsec_initialize(bis, &tsecs[i]);
if (ret >= 0)
count++;
}
Andy
More information about the U-Boot
mailing list