]> git.baikalelectronics.ru Git - kernel.git/commitdiff
batman-adv: a delayed_work has to be initialised once
authorAntonio Quartulli <ordex@autistici.org>
Tue, 25 Dec 2012 12:14:37 +0000 (13:14 +0100)
committerAntonio Quartulli <ordex@autistici.org>
Sat, 19 Jan 2013 13:18:09 +0000 (21:18 +0800)
A delayed_work struct does not need to be initialized each
every time before being enqueued. Therefore the
INIT_DELAYED_WORK() macro should be used during the
initialization process only.

Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
net/batman-adv/bridge_loop_avoidance.c
net/batman-adv/main.h
net/batman-adv/originator.c
net/batman-adv/send.c
net/batman-adv/translation-table.c
net/batman-adv/vis.c

index 5e834c1df46913610c3f52015eb527910137a71c..bb5fbd64dc28438ea7d1a17504aa5b9ca018dd56 100644 (file)
@@ -1100,16 +1100,6 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
        }
 }
 
-
-
-/* (re)start the timer */
-static void batadv_bla_start_timer(struct batadv_priv *bat_priv)
-{
-       INIT_DELAYED_WORK(&bat_priv->bla.work, batadv_bla_periodic_work);
-       queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
-                          msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
-}
-
 /* periodic work to do:
  *  * purge structures when they are too old
  *  * send announcements
@@ -1180,7 +1170,8 @@ out:
        if (primary_if)
                batadv_hardif_free_ref(primary_if);
 
-       batadv_bla_start_timer(bat_priv);
+       queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
+                          msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
 }
 
 /* The hash for claim and backbone hash receive the same key because they
@@ -1238,7 +1229,10 @@ int batadv_bla_init(struct batadv_priv *bat_priv)
 
        batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n");
 
-       batadv_bla_start_timer(bat_priv);
+       INIT_DELAYED_WORK(&bat_priv->bla.work, batadv_bla_periodic_work);
+
+       queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
+                          msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH));
        return 0;
 }
 
index d04b209a8295984e54a8f3e6df6ba14c1d080b51..af73d603455d0c5030690bd014b1e0568e824c56 100644 (file)
@@ -44,6 +44,8 @@
 #define BATADV_TT_LOCAL_TIMEOUT 600000 /* in milliseconds */
 #define BATADV_TT_CLIENT_ROAM_TIMEOUT 600000 /* in milliseconds */
 #define BATADV_TT_CLIENT_TEMP_TIMEOUT 600000 /* in milliseconds */
+#define BATADV_TT_WORK_PERIOD 5000 /* 5 seconds */
+#define BATADV_ORIG_WORK_PERIOD 1000 /* 1 second */
 #define BATADV_DAT_ENTRY_TIMEOUT (5*60000) /* 5 mins in milliseconds */
 /* sliding packet range of received originator messages in sequence numbers
  * (should be a multiple of our word size)
index fa88b2bec9862f5256675a504d2771d3fc0b329a..92a55fddf44b7c821938f504eb65b69dd07f9109 100644 (file)
@@ -34,13 +34,6 @@ static struct lock_class_key batadv_orig_hash_lock_class_key;
 
 static void batadv_purge_orig(struct work_struct *work);
 
-static void batadv_start_purge_timer(struct batadv_priv *bat_priv)
-{
-       INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig);
-       queue_delayed_work(batadv_event_workqueue,
-                          &bat_priv->orig_work, msecs_to_jiffies(1000));
-}
-
 /* returns 1 if they are the same originator */
 static int batadv_compare_orig(const struct hlist_node *node, const void *data2)
 {
@@ -63,7 +56,11 @@ int batadv_originator_init(struct batadv_priv *bat_priv)
        batadv_hash_set_lock_class(bat_priv->orig_hash,
                                   &batadv_orig_hash_lock_class_key);
 
-       batadv_start_purge_timer(bat_priv);
+       INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig);
+       queue_delayed_work(batadv_event_workqueue,
+                          &bat_priv->orig_work,
+                          msecs_to_jiffies(BATADV_ORIG_WORK_PERIOD));
+
        return 0;
 
 err:
@@ -396,7 +393,9 @@ static void batadv_purge_orig(struct work_struct *work)
        delayed_work = container_of(work, struct delayed_work, work);
        bat_priv = container_of(delayed_work, struct batadv_priv, orig_work);
        _batadv_purge_orig(bat_priv);
-       batadv_start_purge_timer(bat_priv);
+       queue_delayed_work(batadv_event_workqueue,
+                          &bat_priv->orig_work,
+                          msecs_to_jiffies(BATADV_ORIG_WORK_PERIOD));
 }
 
 void batadv_purge_orig_ref(struct batadv_priv *bat_priv)
index 89810cea053077f8fa4126cf14b748767a87f73a..0b6f65bc461190cb8c64703f69f3a31854dab5e9 100644 (file)
@@ -155,8 +155,6 @@ _batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
        spin_unlock_bh(&bat_priv->forw_bcast_list_lock);
 
        /* start timer for this packet */
-       INIT_DELAYED_WORK(&forw_packet->delayed_work,
-                         batadv_send_outstanding_bcast_packet);
        queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work,
                           send_time);
 }
@@ -210,6 +208,9 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv,
        /* how often did we send the bcast packet ? */
        forw_packet->num_packets = 0;
 
+       INIT_DELAYED_WORK(&forw_packet->delayed_work,
+                         batadv_send_outstanding_bcast_packet);
+
        _batadv_add_bcast_packet_to_list(bat_priv, forw_packet, delay);
        return NETDEV_TX_OK;
 
index d4b27b65d6e93634f12033e9d9c1edf559b15f32..877acd149178688a2fc1b928835acf8d7e5f583c 100644 (file)
@@ -52,13 +52,6 @@ static int batadv_compare_tt(const struct hlist_node *node, const void *data2)
        return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0);
 }
 
-static void batadv_tt_start_timer(struct batadv_priv *bat_priv)
-{
-       INIT_DELAYED_WORK(&bat_priv->tt.work, batadv_tt_purge);
-       queue_delayed_work(batadv_event_workqueue, &bat_priv->tt.work,
-                          msecs_to_jiffies(5000));
-}
-
 static struct batadv_tt_common_entry *
 batadv_tt_hash_find(struct batadv_hashtable *hash, const void *data)
 {
@@ -2136,7 +2129,9 @@ int batadv_tt_init(struct batadv_priv *bat_priv)
        if (ret < 0)
                return ret;
 
-       batadv_tt_start_timer(bat_priv);
+       INIT_DELAYED_WORK(&bat_priv->tt.work, batadv_tt_purge);
+       queue_delayed_work(batadv_event_workqueue, &bat_priv->tt.work,
+                          msecs_to_jiffies(BATADV_TT_WORK_PERIOD));
 
        return 1;
 }
@@ -2286,7 +2281,8 @@ static void batadv_tt_purge(struct work_struct *work)
        batadv_tt_req_purge(bat_priv);
        batadv_tt_roam_purge(bat_priv);
 
-       batadv_tt_start_timer(bat_priv);
+       queue_delayed_work(batadv_event_workqueue, &bat_priv->tt.work,
+                          msecs_to_jiffies(BATADV_TT_WORK_PERIOD));
 }
 
 void batadv_tt_free(struct batadv_priv *bat_priv)
index 60eb9b7ca8d10643fc7c807fc36d8b8632312c2d..51e2bf01c919540ae566242e54c70fa17148ea0d 100644 (file)
@@ -31,8 +31,6 @@
 /* hash class keys */
 static struct lock_class_key batadv_vis_hash_lock_class_key;
 
-static void batadv_start_vis_timer(struct batadv_priv *bat_priv);
-
 /* free the info */
 static void batadv_free_info(struct kref *ref)
 {
@@ -830,7 +828,9 @@ static void batadv_send_vis_packets(struct work_struct *work)
                kref_put(&info->refcount, batadv_free_info);
        }
        spin_unlock_bh(&bat_priv->vis.hash_lock);
-       batadv_start_vis_timer(bat_priv);
+
+       queue_delayed_work(batadv_event_workqueue, &bat_priv->vis.work,
+                          msecs_to_jiffies(BATADV_VIS_INTERVAL));
 }
 
 /* init the vis server. this may only be called when if_list is already
@@ -900,7 +900,11 @@ int batadv_vis_init(struct batadv_priv *bat_priv)
        }
 
        spin_unlock_bh(&bat_priv->vis.hash_lock);
-       batadv_start_vis_timer(bat_priv);
+
+       INIT_DELAYED_WORK(&bat_priv->vis.work, batadv_send_vis_packets);
+       queue_delayed_work(batadv_event_workqueue, &bat_priv->vis.work,
+                          msecs_to_jiffies(BATADV_VIS_INTERVAL));
+
        return 0;
 
 free_info:
@@ -937,11 +941,3 @@ void batadv_vis_quit(struct batadv_priv *bat_priv)
        bat_priv->vis.my_info = NULL;
        spin_unlock_bh(&bat_priv->vis.hash_lock);
 }
-
-/* schedule packets for (re)transmission */
-static void batadv_start_vis_timer(struct batadv_priv *bat_priv)
-{
-       INIT_DELAYED_WORK(&bat_priv->vis.work, batadv_send_vis_packets);
-       queue_delayed_work(batadv_event_workqueue, &bat_priv->vis.work,
-                          msecs_to_jiffies(BATADV_VIS_INTERVAL));
-}