aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/sysfs.c
diff options
context:
space:
mode:
authorSimon Wunderlich <simon@open-mesh.com>2015-11-17 08:11:26 -0500
committerAntonio Quartulli <a@unstable.cc>2016-01-09 07:56:00 -0500
commit9e728e84389ba8317d1444bdf256e34ad467f3da (patch)
tree14e706b793e44254299e60df3c69390edf8fd301 /net/batman-adv/sysfs.c
parente1544f3c87778ab4af9689d571570d6abfd2f6c2 (diff)
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/batman-adv/sysfs.c')
-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 48e2aaddda49..fe87777fda8a 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, \
242 242
243static int batadv_store_bool_attr(char *buff, size_t count, 243static int batadv_store_bool_attr(char *buff, size_t count,
244 struct net_device *net_dev, 244 struct net_device *net_dev,
245 const char *attr_name, atomic_t *attr) 245 const char *attr_name, atomic_t *attr,
246 bool *changed)
246{ 247{
247 int enabled = -1; 248 int enabled = -1;
248 249
250 *changed = false;
251
249 if (buff[count - 1] == '\n') 252 if (buff[count - 1] == '\n')
250 buff[count - 1] = '\0'; 253 buff[count - 1] = '\0';
251 254
@@ -272,6 +275,8 @@ static int batadv_store_bool_attr(char *buff, size_t count,
272 atomic_read(attr) == 1 ? "enabled" : "disabled", 275 atomic_read(attr) == 1 ? "enabled" : "disabled",
273 enabled == 1 ? "enabled" : "disabled"); 276 enabled == 1 ? "enabled" : "disabled");
274 277
278 *changed = true;
279
275 atomic_set(attr, (unsigned int)enabled); 280 atomic_set(attr, (unsigned int)enabled);
276 return count; 281 return count;
277} 282}
@@ -282,11 +287,12 @@ __batadv_store_bool_attr(char *buff, size_t count,
282 struct attribute *attr, 287 struct attribute *attr,
283 atomic_t *attr_store, struct net_device *net_dev) 288 atomic_t *attr_store, struct net_device *net_dev)
284{ 289{
290 bool changed;
285 int ret; 291 int ret;
286 292
287 ret = batadv_store_bool_attr(buff, count, net_dev, attr->name, 293 ret = batadv_store_bool_attr(buff, count, net_dev, attr->name,
288 attr_store); 294 attr_store, &changed);
289 if (post_func && ret) 295 if (post_func && changed)
290 post_func(net_dev); 296 post_func(net_dev);
291 297
292 return ret; 298 return ret;