aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorWagner Ferenc <wferi@niif.hu>2007-12-07 02:40:29 -0500
committerJeff Garzik <jeff@garzik.org>2007-12-07 15:00:25 -0500
commit16cd0160d5e7e22c2818b30bf1a1d4c262a8df8a (patch)
tree9b308a86ac51c52edcdaa3967a3a89d28d048b07 /drivers
parent7bd4650895137760f6c686d06ca2bc174e3c861c (diff)
bonding: Return nothing for not applicable values
From: Wagner Ferenc <wferi@niif.hu> The previous code returned '\n' (that is, a single empty line) from most files, with one exception (xmit_hash_policy), where it returned 'NA\n'. This patch consolidates each file to return nothing at all if not applicable, not even a '\n'. I find this behaviour more usual, more useful, more efficient and shorter to code from both sides. Signed-off-by: Ferenc Wagner <wferi@niif.hu> Acked-by: Jay Vosburgh <fubar@us.ibm.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/bonding/bond_sysfs.c25
1 files changed, 4 insertions, 21 deletions
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index a3f1b4afb40a..6bb91e296415 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -455,14 +455,11 @@ static ssize_t bonding_show_xmit_hash(struct device *d,
455 struct device_attribute *attr, 455 struct device_attribute *attr,
456 char *buf) 456 char *buf)
457{ 457{
458 int count; 458 int count = 0;
459 struct bonding *bond = to_bond(d); 459 struct bonding *bond = to_bond(d);
460 460
461 if ((bond->params.mode != BOND_MODE_XOR) && 461 if ((bond->params.mode == BOND_MODE_XOR) ||
462 (bond->params.mode != BOND_MODE_8023AD)) { 462 (bond->params.mode == BOND_MODE_8023AD)) {
463 // Not Applicable
464 count = sprintf(buf, "NA\n");
465 } else {
466 count = sprintf(buf, "%s %d\n", 463 count = sprintf(buf, "%s %d\n",
467 xmit_hashtype_tbl[bond->params.xmit_policy].modename, 464 xmit_hashtype_tbl[bond->params.xmit_policy].modename,
468 bond->params.xmit_policy); 465 bond->params.xmit_policy);
@@ -1079,8 +1076,6 @@ static ssize_t bonding_show_primary(struct device *d,
1079 1076
1080 if (bond->primary_slave) 1077 if (bond->primary_slave)
1081 count = sprintf(buf, "%s\n", bond->primary_slave->dev->name); 1078 count = sprintf(buf, "%s\n", bond->primary_slave->dev->name);
1082 else
1083 count = sprintf(buf, "\n");
1084 1079
1085 return count; 1080 return count;
1086} 1081}
@@ -1186,7 +1181,7 @@ static ssize_t bonding_show_active_slave(struct device *d,
1186{ 1181{
1187 struct slave *curr; 1182 struct slave *curr;
1188 struct bonding *bond = to_bond(d); 1183 struct bonding *bond = to_bond(d);
1189 int count; 1184 int count = 0;
1190 1185
1191 read_lock(&bond->curr_slave_lock); 1186 read_lock(&bond->curr_slave_lock);
1192 curr = bond->curr_active_slave; 1187 curr = bond->curr_active_slave;
@@ -1194,8 +1189,6 @@ static ssize_t bonding_show_active_slave(struct device *d,
1194 1189
1195 if (USES_PRIMARY(bond->params.mode) && curr) 1190 if (USES_PRIMARY(bond->params.mode) && curr)
1196 count = sprintf(buf, "%s\n", curr->dev->name); 1191 count = sprintf(buf, "%s\n", curr->dev->name);
1197 else
1198 count = sprintf(buf, "\n");
1199 return count; 1192 return count;
1200} 1193}
1201 1194
@@ -1309,8 +1302,6 @@ static ssize_t bonding_show_ad_aggregator(struct device *d,
1309 struct ad_info ad_info; 1302 struct ad_info ad_info;
1310 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.aggregator_id); 1303 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.aggregator_id);
1311 } 1304 }
1312 else
1313 count = sprintf(buf, "\n");
1314 1305
1315 return count; 1306 return count;
1316} 1307}
@@ -1331,8 +1322,6 @@ static ssize_t bonding_show_ad_num_ports(struct device *d,
1331 struct ad_info ad_info; 1322 struct ad_info ad_info;
1332 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0: ad_info.ports); 1323 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0: ad_info.ports);
1333 } 1324 }
1334 else
1335 count = sprintf(buf, "\n");
1336 1325
1337 return count; 1326 return count;
1338} 1327}
@@ -1353,8 +1342,6 @@ static ssize_t bonding_show_ad_actor_key(struct device *d,
1353 struct ad_info ad_info; 1342 struct ad_info ad_info;
1354 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.actor_key); 1343 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.actor_key);
1355 } 1344 }
1356 else
1357 count = sprintf(buf, "\n");
1358 1345
1359 return count; 1346 return count;
1360} 1347}
@@ -1375,8 +1362,6 @@ static ssize_t bonding_show_ad_partner_key(struct device *d,
1375 struct ad_info ad_info; 1362 struct ad_info ad_info;
1376 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.partner_key); 1363 count = sprintf(buf, "%d\n", (bond_3ad_get_active_agg_info(bond, &ad_info)) ? 0 : ad_info.partner_key);
1377 } 1364 }
1378 else
1379 count = sprintf(buf, "\n");
1380 1365
1381 return count; 1366 return count;
1382} 1367}
@@ -1401,8 +1386,6 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,
1401 print_mac(mac, ad_info.partner_system)); 1386 print_mac(mac, ad_info.partner_system));
1402 } 1387 }
1403 } 1388 }
1404 else
1405 count = sprintf(buf, "\n");
1406 1389
1407 return count; 1390 return count;
1408} 1391}