All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] [v2] tsec: fix the return value for tsec_eth_init() and tsec_standard_init()
@ 2010-06-07 18:31 Timur Tabi
  2010-06-07 22:49 ` Mike Frysinger
  0 siblings, 1 reply; 10+ messages in thread
From: Timur Tabi @ 2010-06-07 18:31 UTC (permalink / raw)
  To: u-boot

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@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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-06-08 19:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-07 18:31 [U-Boot] [PATCH] [v2] tsec: fix the return value for tsec_eth_init() and tsec_standard_init() Timur Tabi
2010-06-07 22:49 ` Mike Frysinger
2010-06-07 22:55   ` Timur Tabi
2010-06-08  4:04     ` Mike Frysinger
2010-06-08 14:34       ` Timur Tabi
2010-06-08 14:42         ` Reinhard Meyer
2010-06-08 14:55           ` Timur Tabi
2010-06-08 19:25         ` Mike Frysinger
2010-06-08  7:14     ` Wolfgang Denk
2010-06-08 13:01       ` Timur Tabi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.