public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [RFC 1/2] batman-adv: invoke post_func only if the attribute has been changed
@ 2013-03-06 10:33 Antonio Quartulli
  2013-03-06 10:33 ` [B.A.T.M.A.N.] [RFC 2/2] batman-adv: enable/disable promiscuous mode on interface when needed Antonio Quartulli
  2013-03-06 10:53 ` [B.A.T.M.A.N.] [RFC 1/2] batman-adv: invoke post_func only if the attribute has been changed Marek Lindner
  0 siblings, 2 replies; 4+ messages in thread
From: Antonio Quartulli @ 2013-03-06 10:33 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Marek Lindner

In the sysfs boolean attribute handling mechanism, the
post_func passed as argument to the store procedure had to
be invoked if and only if the value of the attribute has
been switched. This avoids to invoke the post_func many
times while it does not expect so.

Cc: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---

* compiled test only *
will do more tests later, hoping that the concept is not entirely wrong :)

 sysfs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sysfs.c b/sysfs.c
index 15a22ef..c9b5257 100644
--- a/sysfs.c
+++ b/sysfs.c
@@ -149,7 +149,7 @@ static int batadv_store_bool_attr(char *buff, size_t count,
 	}
 
 	if (atomic_read(attr) == enabled)
-		return count;
+		return 0;
 
 	batadv_info(net_dev, "%s: Changing from: %s to: %s\n", attr_name,
 		    atomic_read(attr) == 1 ? "enabled" : "disabled",
@@ -169,7 +169,7 @@ __batadv_store_bool_attr(char *buff, size_t count,
 
 	ret = batadv_store_bool_attr(buff, count, net_dev, attr->name,
 				     attr_store);
-	if (post_func && ret)
+	if (post_func && ret > 0)
 		post_func(net_dev);
 
 	return ret;
-- 
1.8.1.5


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-03-06 10:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-06 10:33 [B.A.T.M.A.N.] [RFC 1/2] batman-adv: invoke post_func only if the attribute has been changed Antonio Quartulli
2013-03-06 10:33 ` [B.A.T.M.A.N.] [RFC 2/2] batman-adv: enable/disable promiscuous mode on interface when needed Antonio Quartulli
2013-03-06 10:53 ` [B.A.T.M.A.N.] [RFC 1/2] batman-adv: invoke post_func only if the attribute has been changed Marek Lindner
2013-03-06 10:54   ` Antonio Quartulli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox