Skip to contentSkip to conversation

tsec: fix the return value for tsec_eth_init()

PATCH New Timur Tabi 2 participants 2 messages Jun 8, 2010 – Jun 21, 2010 Network drivers

lore
Share & tools
lore

Timur Tabi

author
#0 lore raw

PATCH v3 1/1 tsec: fix the return value for tsec_eth_init()

The Ethernet initialization functions are supposed to return the number of devices initialized, so fix tsec_eth_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.

---
 drivers/net/tsec.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)
drivers/net/tsec.c +12 -3
index 3e4c3bd..c62ff82 100644
@@ -95,14 +95,23 @@ static struct tsec_info_struct tsec_info[] = {
 #endif
 };
 
+/*
+ * Initialize all the TSEC devices
+ *
+ * Returns the number of TSEC devices that were initialized
+ */
 int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsecs, int num)
 {
 	int i;
+	int ret, count = 0;
 
-	for (i = 0; i < num; i++)
-		tsec_initialize(bis, &tsecs[i]);
+	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)
Signature · 1 line
1.7.0.1
Applied
#1 lore raw

PATCH v3 1/1 tsec: fix the return value for tsec_eth_init()

Timur,

Quoted 36 lines · Timur Tabi

The Ethernet initialization functions are supposed to return the number of devices initialized, so fix tsec_eth_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.

---
  drivers/net/tsec.c |   15 ++++++++++++---
  1 files changed, 12 insertions(+), 3 deletions(-)
drivers/net/tsec.c +7 -2
index 3e4c3bd..c62ff82 100644
@@ -95,14 +95,23 @@ static struct tsec_info_struct tsec_info[] = {
  #endif
  };
 
+/*
+ * Initialize all the TSEC devices
+ *
+ * Returns the number of TSEC devices that were initialized
+ */
  int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsecs, int num)
  {
  	int i;
+	int ret, count = 0;
 
-	for (i = 0; i<  num; i++)
-		tsec_initialize(bis,&tsecs[i]);
+	for (i = 0; i<  num; i++) {

drivers/net/tsec.c static struct tsec_info_struct tsec_info[] = { · line 117

Quoted 10 lines
drivers/net/tsec.c +5 -1
+		ret = tsec_initialize(bis,&tsecs[i]);
+		if (ret>  0)
+			count += ret;
+	}
 
-	return 0;
+	return count;
  }
 
  int tsec_standard_init(bd_t *bis)

Applied to net/next.

regards,
Ben