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;