]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/staging/batman-adv/main.c
Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jlbec/ocfs2
[mv-sheeva.git] / drivers / staging / batman-adv / main.c
index 74c70d589a932d1d42ed249d3b9b04c0558d276b..2686019fe4e133f60e445cf2f2b5eddcf211cd73 100644 (file)
 
 #include "main.h"
 #include "bat_sysfs.h"
+#include "bat_debugfs.h"
 #include "routing.h"
 #include "send.h"
 #include "originator.h"
 #include "soft-interface.h"
-#include "device.h"
+#include "icmp_socket.h"
 #include "translation-table.h"
 #include "hard-interface.h"
 #include "types.h"
@@ -41,7 +42,6 @@ DEFINE_SPINLOCK(orig_hash_lock);
 DEFINE_SPINLOCK(forw_bat_list_lock);
 DEFINE_SPINLOCK(forw_bcast_list_lock);
 
-atomic_t vis_interval;
 atomic_t bcast_queue_left;
 atomic_t batman_queue_left;
 
@@ -49,7 +49,7 @@ int16_t num_hna;
 
 struct net_device *soft_device;
 
-unsigned char broadcastAddr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+unsigned char broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
 atomic_t module_state;
 
 static struct packet_type batman_adv_packet_type __read_mostly = {
@@ -59,18 +59,7 @@ static struct packet_type batman_adv_packet_type __read_mostly = {
 
 struct workqueue_struct *bat_event_workqueue;
 
-#ifdef CONFIG_BATMAN_ADV_DEBUG
-int debug;
-
-module_param(debug, int, 0644);
-
-int bat_debug_type(int type)
-{
-       return debug & type;
-}
-#endif
-
-int init_module(void)
+static int __init batman_init(void)
 {
        int retval;
 
@@ -80,8 +69,6 @@ int init_module(void)
 
        atomic_set(&module_state, MODULE_INACTIVE);
 
-       atomic_set(&vis_interval, 1000);/* TODO: raise this later, this is only
-                                        * for debugging now. */
        atomic_set(&bcast_queue_left, BCAST_QUEUE_LEN);
        atomic_set(&batman_queue_left, BATMAN_QUEUE_LEN);
 
@@ -92,23 +79,22 @@ int init_module(void)
        if (!bat_event_workqueue)
                return -ENOMEM;
 
-       bat_device_init();
+       bat_socket_init();
+       debugfs_init();
 
        /* initialize layer 2 interface */
        soft_device = alloc_netdev(sizeof(struct bat_priv) , "bat%d",
                                   interface_setup);
 
        if (!soft_device) {
-               printk(KERN_ERR "batman-adv:"
-                      "Unable to allocate the batman interface\n");
+               pr_err("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);
+               pr_err("Unable to register the batman interface: %i\n", retval);
                goto free_soft_device;
        }
 
@@ -117,15 +103,22 @@ int init_module(void)
        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);
 
-       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);
+       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;
@@ -138,14 +131,16 @@ end:
        return -ENOMEM;
 }
 
-void cleanup_module(void)
+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;
@@ -157,7 +152,7 @@ void cleanup_module(void)
        bat_event_workqueue = NULL;
 }
 
-/* activates the module, creates bat device, starts timer ... */
+/* activates the module, starts timer ... */
 void activate_module(void)
 {
        if (originator_init() < 1)
@@ -171,9 +166,6 @@ void activate_module(void)
 
        hna_local_add(soft_device->dev_addr);
 
-       if (bat_device_setup() < 1)
-               goto end;
-
        if (vis_init() < 1)
                goto err;
 
@@ -182,8 +174,7 @@ void activate_module(void)
        goto end;
 
 err:
-       printk(KERN_ERR "batman-adv:"
-              "Unable to allocate memory for mesh information structures: "
+       pr_err("Unable to allocate memory for mesh information structures: "
               "out of mem ?\n");
        deactivate_module();
 end:
@@ -208,7 +199,6 @@ void deactivate_module(void)
        hna_global_free();
 
        synchronize_net();
-       bat_device_destroy();
 
        synchronize_rcu();
        atomic_set(&module_state, MODULE_INACTIVE);
@@ -226,8 +216,7 @@ void dec_module_count(void)
 
 int addr_to_string(char *buff, uint8_t *addr)
 {
-       return sprintf(buff, MAC_FMT,
-                      addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
+       return sprintf(buff, "%pM", addr);
 }
 
 /* returns 1 if they are the same originator */
@@ -284,6 +273,9 @@ int is_mcast(uint8_t *addr)
        return *addr & 0x01;
 }
 
+module_init(batman_init);
+module_exit(batman_exit);
+
 MODULE_LICENSE("GPL");
 
 MODULE_AUTHOR(DRIVER_AUTHOR);