summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorSimon Wunderlich <simon@open-mesh.com>2015-11-17 14:11:26 +0100
committerAntonio Quartulli <a@unstable.cc>2016-01-09 20:56:00 +0800
commit9e728e84389ba8317d1444bdf256e34ad467f3da (patch)
tree14e706b793e44254299e60df3c69390edf8fd301 /net
parente1544f3c87778ab4af9689d571570d6abfd2f6c2 (diff)
downloadop-kernel-dev-9e728e84389ba8317d1444bdf256e34ad467f3da.zip
op-kernel-dev-9e728e84389ba8317d1444bdf256e34ad467f3da.tar.gz
batman-adv: only call post function if something changed
Currently, the post function is also called on errors or if there were no changes, which is redundant for the functions currently using these facilities. Signed-off-by: Simon Wunderlich <simon@open-mesh.com> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch> Signed-off-by: Antonio Quartulli <a@unstable.cc>
Diffstat (limited to 'net')
-rw-r--r--net/batman-adv/sysfs.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 48e2aad..fe87777 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -242,10 +242,13 @@ ssize_t batadv_show_vlan_##_name(struct kobject *kobj, \
static int batadv_store_bool_attr(char *buff, size_t count,
struct net_device *net_dev,
- const char *attr_name, atomic_t *attr)
+ const char *attr_name, atomic_t *attr,
+ bool *changed)
{
int enabled = -1;
+ *changed = false;
+
if (buff[count - 1] == '\n')
buff[count - 1] = '\0';
@@ -272,6 +275,8 @@ static int batadv_store_bool_attr(char *buff, size_t count,
atomic_read(attr) == 1 ? "enabled" : "disabled",
enabled == 1 ? "enabled" : "disabled");
+ *changed = true;
+
atomic_set(attr, (unsigned int)enabled);
return count;
}
@@ -282,11 +287,12 @@ __batadv_store_bool_attr(char *buff, size_t count,
struct attribute *attr,
atomic_t *attr_store, struct net_device *net_dev)
{
+ bool changed;
int ret;
ret = batadv_store_bool_attr(buff, count, net_dev, attr->name,
- attr_store);
- if (post_func && ret)
+ attr_store, &changed);
+ if (post_func && changed)
post_func(net_dev);
return ret;
OpenPOWER on IntegriCloud