diff options
Diffstat (limited to 'drivers/staging/batman-adv/main.c')
-rw-r--r-- | drivers/staging/batman-adv/main.c | 60 |
1 files changed, 33 insertions, 27 deletions
diff --git a/drivers/staging/batman-adv/main.c b/drivers/staging/batman-adv/main.c index 2e0b482e710..9d13979c2d8 100644 --- a/drivers/staging/batman-adv/main.c +++ b/drivers/staging/batman-adv/main.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2009 B.A.T.M.A.N. contributors: + * Copyright (C) 2007-2010 B.A.T.M.A.N. contributors: * * Marek Lindner, Simon Wunderlich * @@ -20,7 +20,7 @@ */ #include "main.h" -#include "proc.h" +#include "bat_sysfs.h" #include "routing.h" #include "send.h" #include "originator.h" @@ -41,12 +41,11 @@ DEFINE_SPINLOCK(orig_hash_lock); DEFINE_SPINLOCK(forw_bat_list_lock); DEFINE_SPINLOCK(forw_bcast_list_lock); -atomic_t originator_interval; atomic_t vis_interval; -atomic_t vis_mode; -atomic_t aggregation_enabled; +atomic_t bcast_queue_left; +atomic_t batman_queue_left; + int16_t num_hna; -int16_t num_ifs; struct net_device *soft_device; @@ -81,11 +80,10 @@ int init_module(void) atomic_set(&module_state, MODULE_INACTIVE); - atomic_set(&originator_interval, 1000); atomic_set(&vis_interval, 1000);/* TODO: raise this later, this is only * for debugging now. */ - atomic_set(&vis_mode, VIS_TYPE_CLIENT_UPDATE); - atomic_set(&aggregation_enabled, 1); + 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/ */ @@ -94,10 +92,6 @@ int init_module(void) if (!bat_event_workqueue) return -ENOMEM; - retval = setup_procfs(); - if (retval < 0) - return retval; - bat_device_init(); /* initialize layer 2 interface */ @@ -105,25 +99,35 @@ int init_module(void) interface_setup); if (!soft_device) { - printk(KERN_ERR "batman-adv:Unable to allocate the batman interface\n"); + printk(KERN_ERR "batman-adv:" + "Unable to allocate the batman interface\n"); goto end; } retval = register_netdev(soft_device); if (retval < 0) { - printk(KERN_ERR "batman-adv:Unable to register the batman interface: %i\n", retval); + printk(KERN_ERR "batman-adv:" + "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; + register_netdevice_notifier(&hard_if_notifier); dev_add_pack(&batman_adv_packet_type); - printk(KERN_INFO "batman-adv:B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded \n", - SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION); + printk(KERN_INFO "batman-adv:" + "B.A.T.M.A.N. advanced %s%s (compatibility version %i) loaded\n", + SOURCE_VERSION, REVISION_VERSION_STR, COMPAT_VERSION); return 0; +unreg_soft_device: + unregister_netdevice(soft_device); free_soft_device: free_netdev(soft_device); soft_device = NULL; @@ -133,18 +137,19 @@ end: void cleanup_module(void) { - shutdown_module(); + deactivate_module(); + + unregister_netdevice_notifier(&hard_if_notifier); + hardif_remove_interfaces(); if (soft_device) { + sysfs_del_meshif(soft_device); unregister_netdev(soft_device); soft_device = NULL; } dev_remove_pack(&batman_adv_packet_type); - unregister_netdevice_notifier(&hard_if_notifier); - cleanup_procfs(); - destroy_workqueue(bat_event_workqueue); bat_event_workqueue = NULL; } @@ -174,18 +179,20 @@ void activate_module(void) goto end; err: - printk(KERN_ERR "batman-adv:Unable to allocate memory for mesh information structures: out of mem ?\n"); - shutdown_module(); + printk(KERN_ERR "batman-adv:" + "Unable to allocate memory for mesh information structures: " + "out of mem ?\n"); + deactivate_module(); end: return; } /* shuts down the whole module.*/ -void shutdown_module(void) +void deactivate_module(void) { atomic_set(&module_state, MODULE_DEACTIVATING); - purge_outstanding_packets(); + purge_outstanding_packets(NULL); flush_workqueue(bat_event_workqueue); vis_quit(); @@ -200,7 +207,6 @@ void shutdown_module(void) synchronize_net(); bat_device_destroy(); - hardif_remove_interfaces(); synchronize_rcu(); atomic_set(&module_state, MODULE_INACTIVE); } @@ -217,7 +223,7 @@ void dec_module_count(void) int addr_to_string(char *buff, uint8_t *addr) { - return sprintf(buff, "%02x:%02x:%02x:%02x:%02x:%02x", + return sprintf(buff, MAC_FMT, addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]); } |