* [B.A.T.M.A.N.] [PATCH] batman-adv: only call post function if something changed
@ 2015-11-17 13:11 Simon Wunderlich
2015-11-21 21:41 ` Marek Lindner
0 siblings, 1 reply; 2+ messages in thread
From: Simon Wunderlich @ 2015-11-17 13:11 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Simon Wunderlich
From: Simon Wunderlich <simon@open-mesh.com>
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>
---
net/batman-adv/sysfs.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c
index 6d6df12..f38d7b7 100644
--- a/net/batman-adv/sysfs.c
+++ b/net/batman-adv/sysfs.c
@@ -243,10 +243,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';
@@ -273,6 +276,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;
}
@@ -283,11 +288,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;
--
2.6.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCH] batman-adv: only call post function if something changed
2015-11-17 13:11 [B.A.T.M.A.N.] [PATCH] batman-adv: only call post function if something changed Simon Wunderlich
@ 2015-11-21 21:41 ` Marek Lindner
0 siblings, 0 replies; 2+ messages in thread
From: Marek Lindner @ 2015-11-21 21:41 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Simon Wunderlich
[-- Attachment #1: Type: text/plain, Size: 478 bytes --]
On Tuesday, November 17, 2015 14:11:26 Simon Wunderlich wrote:
> From: Simon Wunderlich <simon@open-mesh.com>
>
> 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>
> ---
> net/batman-adv/sysfs.c | 12 +++++++++---
> 1 file changed, 9 insertions(+), 3 deletions(-)
Applied in revision 743df46.
Thanks,
Marek
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 473 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-21 21:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-17 13:11 [B.A.T.M.A.N.] [PATCH] batman-adv: only call post function if something changed Simon Wunderlich
2015-11-21 21:41 ` Marek Lindner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox