Author: marek Date: 2010-05-21 19:05:04 +0200 (Fri, 21 May 2010) New Revision: 1674
Modified: trunk/batman-adv-kernelland/bat_sysfs.c Log: batman-adv: convert all sysfs files to single value files
This patch removes the extra usage output which came when the sysfs files were read.
Signed-off-by: Marek Lindner lindner_marek@yahoo.de
Modified: trunk/batman-adv-kernelland/bat_sysfs.c =================================================================== --- trunk/batman-adv-kernelland/bat_sysfs.c 2010-05-21 11:33:40 UTC (rev 1673) +++ trunk/batman-adv-kernelland/bat_sysfs.c 2010-05-21 17:05:04 UTC (rev 1674) @@ -39,18 +39,18 @@ .store = _store, \ };
-static ssize_t show_aggr_ogm(struct kobject *kobj, struct attribute *attr, +static ssize_t show_aggr_ogms(struct kobject *kobj, struct attribute *attr, char *buff) { struct device *dev = to_dev(kobj->parent); struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev)); int aggr_status = atomic_read(&bat_priv->aggregation_enabled);
- return sprintf(buff, "status: %s\ncommands: enable, disable, 0, 1\n", + return sprintf(buff, "%s\n", aggr_status == 0 ? "disabled" : "enabled"); }
-static ssize_t store_aggr_ogm(struct kobject *kobj, struct attribute *attr, +static ssize_t store_aggr_ogms(struct kobject *kobj, struct attribute *attr, char *buff, size_t count) { struct device *dev = to_dev(kobj->parent); @@ -94,7 +94,7 @@ struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev)); int bond_status = atomic_read(&bat_priv->bonding_enabled);
- return sprintf(buff, "status: %s\ncommands: enable, disable, 0, 1\n", + return sprintf(buff, "%s\n", bond_status == 0 ? "disabled" : "enabled"); }
@@ -143,10 +143,9 @@ struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev)); int vis_mode = atomic_read(&bat_priv->vis_mode);
- return sprintf(buff, "status: %s\ncommands: client, server, %d, %d\n", + return sprintf(buff, "%s\n", vis_mode == VIS_TYPE_CLIENT_UPDATE ? - "client" : "server", - VIS_TYPE_SERVER_SYNC, VIS_TYPE_CLIENT_UPDATE); + "client" : "server"); }
static ssize_t store_vis_mode(struct kobject *kobj, struct attribute *attr, @@ -161,7 +160,8 @@ ret = strict_strtoul(buff, 10, &val);
if (((count == 2) && (!ret) && (val == VIS_TYPE_CLIENT_UPDATE)) || - (strncmp(buff, "client", 6) == 0)) + (strncmp(buff, "client", 6) == 0) || + (strncmp(buff, "off", 3) == 0)) vis_mode_tmp = VIS_TYPE_CLIENT_UPDATE;
if (((count == 2) && (!ret) && (val == VIS_TYPE_SERVER_SYNC)) || @@ -200,13 +200,13 @@
switch (gw_mode) { case GW_MODE_CLIENT: - bytes_written = sprintf(buff, "status: %s (gw_class: %i)\n", + bytes_written = sprintf(buff, "%s (gw_class: %i)\n", GW_MODE_CLIENT_NAME, gw_class); break; case GW_MODE_SERVER: gw_srv_class_to_kbit(gw_class, &down, &up); bytes_written = sprintf(buff, - "status: %s (gw_class: %i " + "%s (gw_class: %i " "-> propagating: %i%s/%i%s)\n", GW_MODE_SERVER_NAME, gw_class, (down > 2048 ? down / 1024 : down), @@ -215,15 +215,11 @@ (up > 2048 ? "MBit" : "KBit")); break; default: - bytes_written = sprintf(buff, "status: %s\n", + bytes_written = sprintf(buff, "%s\n", GW_MODE_OFF_NAME); break; }
- bytes_written += sprintf(buff + bytes_written, - "commands: %s, %s <opt arg>, %s <opt arg>\n", - GW_MODE_OFF_NAME, GW_MODE_CLIENT_NAME, - GW_MODE_SERVER_NAME); return bytes_written; }
@@ -243,7 +239,7 @@ struct device *dev = to_dev(kobj->parent); struct bat_priv *bat_priv = netdev_priv(to_net_dev(dev));
- return sprintf(buff, "status: %i\n", + return sprintf(buff, "%i\n", atomic_read(&bat_priv->orig_interval)); }
@@ -280,8 +276,8 @@ return count; }
-static BAT_ATTR(aggregate_ogm, S_IRUGO | S_IWUSR, - show_aggr_ogm, store_aggr_ogm); +static BAT_ATTR(aggregated_ogms, S_IRUGO | S_IWUSR, + show_aggr_ogms, store_aggr_ogms); static BAT_ATTR(bonding, S_IRUGO | S_IWUSR, show_bond, store_bond); static BAT_ATTR(vis_mode, S_IRUGO | S_IWUSR, show_vis_mode, store_vis_mode); static BAT_ATTR(gw_mode, S_IRUGO | S_IWUSR, show_gw_mode, store_gw_mode); @@ -289,7 +285,7 @@ show_orig_interval, store_orig_interval);
static struct bat_attribute *mesh_attrs[] = { - &bat_attr_aggregate_ogm, + &bat_attr_aggregated_ogms, &bat_attr_bonding, &bat_attr_vis_mode, &bat_attr_gw_mode, @@ -371,7 +367,7 @@ if (!batman_if) return 0;
- return sprintf(buff, "status: %s\ncommands: none, bat0\n", + return sprintf(buff, "%s\n", batman_if->if_status == IF_NOT_IN_USE ? "none" : "bat0"); }