[U-Boot] [PATCH] [v2] tsec: fix the return value for tsec_eth_init() and tsec_standard_init()
Timur Tabi
timur at freescale.com
Mon Jun 7 20:31:27 CEST 2010
The Ethernet initialization functions are supposed to return the number of
devices initialized, so fix tsec_eth_init() and tsec_standard_init() so that
they 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.
In general, if an function initializes only one device, then it should return
a negative number if there's an error. If it initializes more than one device,
then it should never return a negative number. This is why these functions
now return an unsigned integer.
Signed-off-by: Timur Tabi <timur at freescale.com>
---
drivers/net/tsec.c | 22 ++++++++++++++++------
include/tsec.h | 4 ++--
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c
index 3e4c3bd..6ca9735 100644
--- a/drivers/net/tsec.c
+++ b/drivers/net/tsec.c
@@ -95,17 +95,27 @@ static struct tsec_info_struct tsec_info[] = {
#endif
};
-int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsecs, int num)
+/*
+ * Initialize all the TSEC devices
+ *
+ * Returns the number of TSEC devices that were initialized
+ */
+unsigned 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)
+ count += ret;
+ }
- return 0;
+ return count;
}
-int tsec_standard_init(bd_t *bis)
+unsigned int tsec_standard_init(bd_t *bis)
{
return tsec_eth_init(bis, tsec_info, ARRAY_SIZE(tsec_info));
}
diff --git a/include/tsec.h b/include/tsec.h
index 1e90365..9da2740 100644
--- a/include/tsec.h
+++ b/include/tsec.h
@@ -657,7 +657,7 @@ struct tsec_info_struct {
u32 flags;
};
-int tsec_standard_init(bd_t *bis);
-int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsec_info, int num);
+unsigned int tsec_standard_init(bd_t *bis);
+unsigned int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsecs, int num);
#endif /* __TSEC_H */
--
1.7.0.1
More information about the U-Boot
mailing list