diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-28 12:13:00 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-28 12:13:00 -0700 |
commit | f063a0c0c995d010960efcc1b2ed14b99674f25c (patch) | |
tree | 106e30acd1a58b3cf9f3c15abe1de83f1919e03b /drivers/staging/batman-adv/main.c | |
parent | 3c3762957818dc902222733a8184f23102e24472 (diff) | |
parent | 5af634789c93b97cfb314a102436716be8fbc577 (diff) | |
download | op-kernel-dev-f063a0c0c995d010960efcc1b2ed14b99674f25c.zip op-kernel-dev-f063a0c0c995d010960efcc1b2ed14b99674f25c.tar.gz |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6: (841 commits)
Staging: brcm80211: fix usage of roundup in structures
Staging: bcm: fix up network device reference counting
Staging: keucr: fix up US_ macro change
staging: brcm80211: brcmfmac: Removed codeversion from firmware filenames.
staging: brcm80211: Remove unnecessary header files.
staging: brcm80211: Remove unnecessary includes from bcmutils.c
staging: brcm80211: Removed unnecessary pktsetprio() function.
Staging: brcm80211: remove typedefs.h
Staging: brcm80211: remove uintptr typedef usage
Staging: hv: remove struct vmbus_channel_interface
Staging: hv: remove Open from struct vmbus_channel_interface
Staging: hv: storvsc: call vmbus_open directly
Staging: hv: netvsc: call vmbus_open directly
Staging: hv: channel: export vmbus_open to modules
Staging: hv: remove Close from struct vmbus_channel_interface
Staging: hv: netvsc: call vmbus_close directly
Staging: hv: storvsc: call vmbus_close directly
Staging: hv: channel: export vmbus_close to modules
Staging: hv: remove SendPacket from struct vmbus_channel_interface
Staging: hv: storvsc: call vmbus_sendpacket directly
...
Fix up conflicts in
drivers/staging/cx25821/cx25821-audio-upstream.c
drivers/staging/cx25821/cx25821-audio.h
due to warring whitespace cleanups (neither of which were all that great)
Diffstat (limited to 'drivers/staging/batman-adv/main.c')
-rw-r--r-- | drivers/staging/batman-adv/main.c | 146 |
1 files changed, 36 insertions, 110 deletions
diff --git a/drivers/staging/batman-adv/main.c b/drivers/staging/batman-adv/main.c index ef7c20a..0587940 100644 --- a/drivers/staging/batman-adv/main.c +++ b/drivers/staging/batman-adv/main.c @@ -34,43 +34,14 @@ #include "hash.h" struct list_head if_list; -struct hlist_head forw_bat_list; -struct hlist_head forw_bcast_list; -struct hashtable_t *orig_hash; - -DEFINE_SPINLOCK(orig_hash_lock); -DEFINE_SPINLOCK(forw_bat_list_lock); -DEFINE_SPINLOCK(forw_bcast_list_lock); - -atomic_t bcast_queue_left; -atomic_t batman_queue_left; - -int16_t num_hna; - -struct net_device *soft_device; unsigned char broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; -atomic_t module_state; - -static struct packet_type batman_adv_packet_type __read_mostly = { - .type = __constant_htons(ETH_P_BATMAN), - .func = batman_skb_recv, -}; struct workqueue_struct *bat_event_workqueue; static int __init batman_init(void) { - int retval; - INIT_LIST_HEAD(&if_list); - INIT_HLIST_HEAD(&forw_bat_list); - INIT_HLIST_HEAD(&forw_bcast_list); - - atomic_set(&module_state, MODULE_INACTIVE); - - atomic_set(&bcast_queue_left, BCAST_QUEUE_LEN); - atomic_set(&batman_queue_left, BATMAN_QUEUE_LEN); /* the name should not be longer than 10 chars - see * http://lwn.net/Articles/23634/ */ @@ -82,126 +53,86 @@ static int __init batman_init(void) bat_socket_init(); debugfs_init(); - /* initialize layer 2 interface */ - soft_device = alloc_netdev(sizeof(struct bat_priv) , "bat%d", - interface_setup); - - if (!soft_device) { - pr_err("Unable to allocate the batman interface\n"); - goto end; - } - - retval = register_netdev(soft_device); - - if (retval < 0) { - pr_err("Unable to register the batman interface: %i\n", retval); - goto free_soft_device; - } - - retval = sysfs_add_meshif(soft_device); - - if (retval < 0) - goto unreg_soft_device; - - retval = debugfs_add_meshif(soft_device); - - if (retval < 0) - goto unreg_sysfs; - register_netdevice_notifier(&hard_if_notifier); - dev_add_pack(&batman_adv_packet_type); pr_info("B.A.T.M.A.N. advanced %s%s (compatibility version %i) " "loaded\n", SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION); return 0; - -unreg_sysfs: - sysfs_del_meshif(soft_device); -unreg_soft_device: - unregister_netdev(soft_device); - soft_device = NULL; - return -ENOMEM; - -free_soft_device: - free_netdev(soft_device); - soft_device = NULL; -end: - return -ENOMEM; } static void __exit batman_exit(void) { - deactivate_module(); - debugfs_destroy(); unregister_netdevice_notifier(&hard_if_notifier); hardif_remove_interfaces(); - if (soft_device) { - debugfs_del_meshif(soft_device); - sysfs_del_meshif(soft_device); - unregister_netdev(soft_device); - soft_device = NULL; - } - - dev_remove_pack(&batman_adv_packet_type); - + flush_workqueue(bat_event_workqueue); destroy_workqueue(bat_event_workqueue); bat_event_workqueue = NULL; + + rcu_barrier(); } -/* activates the module, starts timer ... */ -void activate_module(void) +int mesh_init(struct net_device *soft_iface) { - if (originator_init() < 1) + struct bat_priv *bat_priv = netdev_priv(soft_iface); + + spin_lock_init(&bat_priv->orig_hash_lock); + spin_lock_init(&bat_priv->forw_bat_list_lock); + spin_lock_init(&bat_priv->forw_bcast_list_lock); + spin_lock_init(&bat_priv->hna_lhash_lock); + spin_lock_init(&bat_priv->hna_ghash_lock); + spin_lock_init(&bat_priv->vis_hash_lock); + spin_lock_init(&bat_priv->vis_list_lock); + + INIT_HLIST_HEAD(&bat_priv->forw_bat_list); + INIT_HLIST_HEAD(&bat_priv->forw_bcast_list); + + if (originator_init(bat_priv) < 1) goto err; - if (hna_local_init() < 1) + if (hna_local_init(bat_priv) < 1) goto err; - if (hna_global_init() < 1) + if (hna_global_init(bat_priv) < 1) goto err; - hna_local_add(soft_device->dev_addr); + hna_local_add(soft_iface, soft_iface->dev_addr); - if (vis_init() < 1) + if (vis_init(bat_priv) < 1) goto err; - update_min_mtu(); - atomic_set(&module_state, MODULE_ACTIVE); + atomic_set(&bat_priv->mesh_state, MESH_ACTIVE); goto end; err: pr_err("Unable to allocate memory for mesh information structures: " "out of mem ?\n"); - deactivate_module(); + mesh_free(soft_iface); + return -1; + end: - return; + return 0; } -/* shuts down the whole module.*/ -void deactivate_module(void) +void mesh_free(struct net_device *soft_iface) { - atomic_set(&module_state, MODULE_DEACTIVATING); + struct bat_priv *bat_priv = netdev_priv(soft_iface); - purge_outstanding_packets(NULL); - flush_workqueue(bat_event_workqueue); + atomic_set(&bat_priv->mesh_state, MESH_DEACTIVATING); - vis_quit(); + purge_outstanding_packets(bat_priv, NULL); - /* TODO: unregister BATMAN pack */ + vis_quit(bat_priv); - originator_free(); + originator_free(bat_priv); - hna_local_free(); - hna_global_free(); + hna_local_free(bat_priv); + hna_global_free(bat_priv); - synchronize_net(); - - synchronize_rcu(); - atomic_set(&module_state, MODULE_INACTIVE); + atomic_set(&bat_priv->mesh_state, MESH_INACTIVE); } void inc_module_count(void) @@ -214,11 +145,6 @@ void dec_module_count(void) module_put(THIS_MODULE); } -int addr_to_string(char *buff, uint8_t *addr) -{ - return sprintf(buff, "%pM", addr); -} - /* returns 1 if they are the same originator */ int compare_orig(void *data1, void *data2) |