]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
batman-adv: use atomic_xchg() for gw.reselect check
authorSven Eckelmann <sven@narfation.org>
Tue, 12 May 2026 20:03:53 +0000 (22:03 +0200)
committerSven Eckelmann <sven@narfation.org>
Fri, 29 May 2026 19:19:21 +0000 (21:19 +0200)
batadv_gw_election() only needs to test whether gw.reselect was set and
clear it afterwards. Replace the batadv_atomic_dec_not_zero()
[atomic_add_unless(..., -1, 0)] call with atomic_xchg(..., 0) to simplify
the logic and make the intent more explicit.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
net/batman-adv/gateway_client.c

index ec743ce39be470c53e64a96fc9d78586d57fe90b..026627c8ba45b83525a0157db8352f41a2b9e2c4 100644 (file)
@@ -211,7 +211,7 @@ void batadv_gw_election(struct batadv_priv *bat_priv)
 
        curr_gw = batadv_gw_get_selected_gw_node(bat_priv);
 
-       if (!batadv_atomic_dec_not_zero(&bat_priv->gw.reselect) && curr_gw)
+       if (atomic_xchg(&bat_priv->gw.reselect, 0) == 0 && curr_gw)
                goto out;
 
        /* if gw.reselect is set to 1 it means that a previous call to