Commit 9e728e84389ba8317d1444bdf256e34ad467f3da

Authored by Simon Wunderlich
Committed by Antonio Quartulli
1 parent e1544f3c87

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>

Showing 1 changed file with 9 additions and 3 deletions Side-by-side Diff

net/batman-adv/sysfs.c
... ... @@ -242,10 +242,13 @@
242 242  
243 243 static int batadv_store_bool_attr(char *buff, size_t count,
244 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 248 int enabled = -1;
248 249  
  250 + *changed = false;
  251 +
249 252 if (buff[count - 1] == '\n')
250 253 buff[count - 1] = '\0';
251 254  
... ... @@ -272,6 +275,8 @@
272 275 atomic_read(attr) == 1 ? "enabled" : "disabled",
273 276 enabled == 1 ? "enabled" : "disabled");
274 277  
  278 + *changed = true;
  279 +
275 280 atomic_set(attr, (unsigned int)enabled);
276 281 return count;
277 282 }
278 283  
... ... @@ -282,11 +287,12 @@
282 287 struct attribute *attr,
283 288 atomic_t *attr_store, struct net_device *net_dev)
284 289 {
  290 + bool changed;
285 291 int ret;
286 292  
287 293 ret = batadv_store_bool_attr(buff, count, net_dev, attr->name,
288   - attr_store);
289   - if (post_func && ret)
  294 + attr_store, &changed);
  295 + if (post_func && changed)
290 296 post_func(net_dev);
291 297  
292 298 return ret;