diff options
author | Antonio Quartulli <ordex@autistici.org> | 2012-12-25 07:14:37 -0500 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2013-01-19 08:18:09 -0500 |
commit | 7241444209f88f804ea33483394a601c1afb1d64 (patch) | |
tree | 28f2b2dae11c5367182eec51d9ad2ff422217406 /net/batman-adv | |
parent | 1ad759d8479b4b28f2a6c874d380066cf987b341 (diff) |
batman-adv: a delayed_work has to be initialised once
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>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/bridge_loop_avoidance.c | 18 | ||||
-rw-r--r-- | net/batman-adv/main.h | 2 | ||||
-rw-r--r-- | net/batman-adv/originator.c | 17 | ||||
-rw-r--r-- | net/batman-adv/send.c | 5 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 14 | ||||
-rw-r--r-- | net/batman-adv/vis.c | 20 |
6 files changed, 32 insertions, 44 deletions
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 5e834c1df469..bb5fbd64dc28 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c | |||
@@ -1100,16 +1100,6 @@ void batadv_bla_update_orig_address(struct batadv_priv *bat_priv, | |||
1100 | } | 1100 | } |
1101 | } | 1101 | } |
1102 | 1102 | ||
1103 | |||
1104 | |||
1105 | /* (re)start the timer */ | ||
1106 | static void batadv_bla_start_timer(struct batadv_priv *bat_priv) | ||
1107 | { | ||
1108 | INIT_DELAYED_WORK(&bat_priv->bla.work, batadv_bla_periodic_work); | ||
1109 | queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work, | ||
1110 | msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH)); | ||
1111 | } | ||
1112 | |||
1113 | /* periodic work to do: | 1103 | /* periodic work to do: |
1114 | * * purge structures when they are too old | 1104 | * * purge structures when they are too old |
1115 | * * send announcements | 1105 | * * send announcements |
@@ -1180,7 +1170,8 @@ out: | |||
1180 | if (primary_if) | 1170 | if (primary_if) |
1181 | batadv_hardif_free_ref(primary_if); | 1171 | batadv_hardif_free_ref(primary_if); |
1182 | 1172 | ||
1183 | batadv_bla_start_timer(bat_priv); | 1173 | queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work, |
1174 | msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH)); | ||
1184 | } | 1175 | } |
1185 | 1176 | ||
1186 | /* The hash for claim and backbone hash receive the same key because they | 1177 | /* 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) | |||
1238 | 1229 | ||
1239 | batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n"); | 1230 | batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n"); |
1240 | 1231 | ||
1241 | batadv_bla_start_timer(bat_priv); | 1232 | INIT_DELAYED_WORK(&bat_priv->bla.work, batadv_bla_periodic_work); |
1233 | |||
1234 | queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work, | ||
1235 | msecs_to_jiffies(BATADV_BLA_PERIOD_LENGTH)); | ||
1242 | return 0; | 1236 | return 0; |
1243 | } | 1237 | } |
1244 | 1238 | ||
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index d04b209a8295..af73d603455d 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h | |||
@@ -44,6 +44,8 @@ | |||
44 | #define BATADV_TT_LOCAL_TIMEOUT 600000 /* in milliseconds */ | 44 | #define BATADV_TT_LOCAL_TIMEOUT 600000 /* in milliseconds */ |
45 | #define BATADV_TT_CLIENT_ROAM_TIMEOUT 600000 /* in milliseconds */ | 45 | #define BATADV_TT_CLIENT_ROAM_TIMEOUT 600000 /* in milliseconds */ |
46 | #define BATADV_TT_CLIENT_TEMP_TIMEOUT 600000 /* in milliseconds */ | 46 | #define BATADV_TT_CLIENT_TEMP_TIMEOUT 600000 /* in milliseconds */ |
47 | #define BATADV_TT_WORK_PERIOD 5000 /* 5 seconds */ | ||
48 | #define BATADV_ORIG_WORK_PERIOD 1000 /* 1 second */ | ||
47 | #define BATADV_DAT_ENTRY_TIMEOUT (5*60000) /* 5 mins in milliseconds */ | 49 | #define BATADV_DAT_ENTRY_TIMEOUT (5*60000) /* 5 mins in milliseconds */ |
48 | /* sliding packet range of received originator messages in sequence numbers | 50 | /* sliding packet range of received originator messages in sequence numbers |
49 | * (should be a multiple of our word size) | 51 | * (should be a multiple of our word size) |
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index fa88b2bec986..92a55fddf44b 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c | |||
@@ -34,13 +34,6 @@ static struct lock_class_key batadv_orig_hash_lock_class_key; | |||
34 | 34 | ||
35 | static void batadv_purge_orig(struct work_struct *work); | 35 | static void batadv_purge_orig(struct work_struct *work); |
36 | 36 | ||
37 | static void batadv_start_purge_timer(struct batadv_priv *bat_priv) | ||
38 | { | ||
39 | INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig); | ||
40 | queue_delayed_work(batadv_event_workqueue, | ||
41 | &bat_priv->orig_work, msecs_to_jiffies(1000)); | ||
42 | } | ||
43 | |||
44 | /* returns 1 if they are the same originator */ | 37 | /* returns 1 if they are the same originator */ |
45 | static int batadv_compare_orig(const struct hlist_node *node, const void *data2) | 38 | static int batadv_compare_orig(const struct hlist_node *node, const void *data2) |
46 | { | 39 | { |
@@ -63,7 +56,11 @@ int batadv_originator_init(struct batadv_priv *bat_priv) | |||
63 | batadv_hash_set_lock_class(bat_priv->orig_hash, | 56 | batadv_hash_set_lock_class(bat_priv->orig_hash, |
64 | &batadv_orig_hash_lock_class_key); | 57 | &batadv_orig_hash_lock_class_key); |
65 | 58 | ||
66 | batadv_start_purge_timer(bat_priv); | 59 | INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig); |
60 | queue_delayed_work(batadv_event_workqueue, | ||
61 | &bat_priv->orig_work, | ||
62 | msecs_to_jiffies(BATADV_ORIG_WORK_PERIOD)); | ||
63 | |||
67 | return 0; | 64 | return 0; |
68 | 65 | ||
69 | err: | 66 | err: |
@@ -396,7 +393,9 @@ static void batadv_purge_orig(struct work_struct *work) | |||
396 | delayed_work = container_of(work, struct delayed_work, work); | 393 | delayed_work = container_of(work, struct delayed_work, work); |
397 | bat_priv = container_of(delayed_work, struct batadv_priv, orig_work); | 394 | bat_priv = container_of(delayed_work, struct batadv_priv, orig_work); |
398 | _batadv_purge_orig(bat_priv); | 395 | _batadv_purge_orig(bat_priv); |
399 | batadv_start_purge_timer(bat_priv); | 396 | queue_delayed_work(batadv_event_workqueue, |
397 | &bat_priv->orig_work, | ||
398 | msecs_to_jiffies(BATADV_ORIG_WORK_PERIOD)); | ||
400 | } | 399 | } |
401 | 400 | ||
402 | void batadv_purge_orig_ref(struct batadv_priv *bat_priv) | 401 | void batadv_purge_orig_ref(struct batadv_priv *bat_priv) |
diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index 89810cea0530..0b6f65bc4611 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c | |||
@@ -155,8 +155,6 @@ _batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, | |||
155 | spin_unlock_bh(&bat_priv->forw_bcast_list_lock); | 155 | spin_unlock_bh(&bat_priv->forw_bcast_list_lock); |
156 | 156 | ||
157 | /* start timer for this packet */ | 157 | /* start timer for this packet */ |
158 | INIT_DELAYED_WORK(&forw_packet->delayed_work, | ||
159 | batadv_send_outstanding_bcast_packet); | ||
160 | queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work, | 158 | queue_delayed_work(batadv_event_workqueue, &forw_packet->delayed_work, |
161 | send_time); | 159 | send_time); |
162 | } | 160 | } |
@@ -210,6 +208,9 @@ int batadv_add_bcast_packet_to_list(struct batadv_priv *bat_priv, | |||
210 | /* how often did we send the bcast packet ? */ | 208 | /* how often did we send the bcast packet ? */ |
211 | forw_packet->num_packets = 0; | 209 | forw_packet->num_packets = 0; |
212 | 210 | ||
211 | INIT_DELAYED_WORK(&forw_packet->delayed_work, | ||
212 | batadv_send_outstanding_bcast_packet); | ||
213 | |||
213 | _batadv_add_bcast_packet_to_list(bat_priv, forw_packet, delay); | 214 | _batadv_add_bcast_packet_to_list(bat_priv, forw_packet, delay); |
214 | return NETDEV_TX_OK; | 215 | return NETDEV_TX_OK; |
215 | 216 | ||
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index d4b27b65d6e9..877acd149178 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -52,13 +52,6 @@ static int batadv_compare_tt(const struct hlist_node *node, const void *data2) | |||
52 | return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); | 52 | return (memcmp(data1, data2, ETH_ALEN) == 0 ? 1 : 0); |
53 | } | 53 | } |
54 | 54 | ||
55 | static void batadv_tt_start_timer(struct batadv_priv *bat_priv) | ||
56 | { | ||
57 | INIT_DELAYED_WORK(&bat_priv->tt.work, batadv_tt_purge); | ||
58 | queue_delayed_work(batadv_event_workqueue, &bat_priv->tt.work, | ||
59 | msecs_to_jiffies(5000)); | ||
60 | } | ||
61 | |||
62 | static struct batadv_tt_common_entry * | 55 | static struct batadv_tt_common_entry * |
63 | batadv_tt_hash_find(struct batadv_hashtable *hash, const void *data) | 56 | batadv_tt_hash_find(struct batadv_hashtable *hash, const void *data) |
64 | { | 57 | { |
@@ -2136,7 +2129,9 @@ int batadv_tt_init(struct batadv_priv *bat_priv) | |||
2136 | if (ret < 0) | 2129 | if (ret < 0) |
2137 | return ret; | 2130 | return ret; |
2138 | 2131 | ||
2139 | batadv_tt_start_timer(bat_priv); | 2132 | INIT_DELAYED_WORK(&bat_priv->tt.work, batadv_tt_purge); |
2133 | queue_delayed_work(batadv_event_workqueue, &bat_priv->tt.work, | ||
2134 | msecs_to_jiffies(BATADV_TT_WORK_PERIOD)); | ||
2140 | 2135 | ||
2141 | return 1; | 2136 | return 1; |
2142 | } | 2137 | } |
@@ -2286,7 +2281,8 @@ static void batadv_tt_purge(struct work_struct *work) | |||
2286 | batadv_tt_req_purge(bat_priv); | 2281 | batadv_tt_req_purge(bat_priv); |
2287 | batadv_tt_roam_purge(bat_priv); | 2282 | batadv_tt_roam_purge(bat_priv); |
2288 | 2283 | ||
2289 | batadv_tt_start_timer(bat_priv); | 2284 | queue_delayed_work(batadv_event_workqueue, &bat_priv->tt.work, |
2285 | msecs_to_jiffies(BATADV_TT_WORK_PERIOD)); | ||
2290 | } | 2286 | } |
2291 | 2287 | ||
2292 | void batadv_tt_free(struct batadv_priv *bat_priv) | 2288 | void batadv_tt_free(struct batadv_priv *bat_priv) |
diff --git a/net/batman-adv/vis.c b/net/batman-adv/vis.c index 60eb9b7ca8d1..51e2bf01c919 100644 --- a/net/batman-adv/vis.c +++ b/net/batman-adv/vis.c | |||
@@ -31,8 +31,6 @@ | |||
31 | /* hash class keys */ | 31 | /* hash class keys */ |
32 | static struct lock_class_key batadv_vis_hash_lock_class_key; | 32 | static struct lock_class_key batadv_vis_hash_lock_class_key; |
33 | 33 | ||
34 | static void batadv_start_vis_timer(struct batadv_priv *bat_priv); | ||
35 | |||
36 | /* free the info */ | 34 | /* free the info */ |
37 | static void batadv_free_info(struct kref *ref) | 35 | static void batadv_free_info(struct kref *ref) |
38 | { | 36 | { |
@@ -830,7 +828,9 @@ static void batadv_send_vis_packets(struct work_struct *work) | |||
830 | kref_put(&info->refcount, batadv_free_info); | 828 | kref_put(&info->refcount, batadv_free_info); |
831 | } | 829 | } |
832 | spin_unlock_bh(&bat_priv->vis.hash_lock); | 830 | spin_unlock_bh(&bat_priv->vis.hash_lock); |
833 | batadv_start_vis_timer(bat_priv); | 831 | |
832 | queue_delayed_work(batadv_event_workqueue, &bat_priv->vis.work, | ||
833 | msecs_to_jiffies(BATADV_VIS_INTERVAL)); | ||
834 | } | 834 | } |
835 | 835 | ||
836 | /* init the vis server. this may only be called when if_list is already | 836 | /* 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) | |||
900 | } | 900 | } |
901 | 901 | ||
902 | spin_unlock_bh(&bat_priv->vis.hash_lock); | 902 | spin_unlock_bh(&bat_priv->vis.hash_lock); |
903 | batadv_start_vis_timer(bat_priv); | 903 | |
904 | INIT_DELAYED_WORK(&bat_priv->vis.work, batadv_send_vis_packets); | ||
905 | queue_delayed_work(batadv_event_workqueue, &bat_priv->vis.work, | ||
906 | msecs_to_jiffies(BATADV_VIS_INTERVAL)); | ||
907 | |||
904 | return 0; | 908 | return 0; |
905 | 909 | ||
906 | free_info: | 910 | free_info: |
@@ -937,11 +941,3 @@ void batadv_vis_quit(struct batadv_priv *bat_priv) | |||
937 | bat_priv->vis.my_info = NULL; | 941 | bat_priv->vis.my_info = NULL; |
938 | spin_unlock_bh(&bat_priv->vis.hash_lock); | 942 | spin_unlock_bh(&bat_priv->vis.hash_lock); |
939 | } | 943 | } |
940 | |||
941 | /* schedule packets for (re)transmission */ | ||
942 | static void batadv_start_vis_timer(struct batadv_priv *bat_priv) | ||
943 | { | ||
944 | INIT_DELAYED_WORK(&bat_priv->vis.work, batadv_send_vis_packets); | ||
945 | queue_delayed_work(batadv_event_workqueue, &bat_priv->vis.work, | ||
946 | msecs_to_jiffies(BATADV_VIS_INTERVAL)); | ||
947 | } | ||