]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - net/ax25/sysctl_net_ax25.c
Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzi...
[linux-2.6-omap-h63xx.git] / net / ax25 / sysctl_net_ax25.c
index 369a75b160f2d688a898fe43a1b2f7203658bbd1..f597987b242439556c66cc83cc93cb8373ab7a30 100644 (file)
@@ -31,25 +31,11 @@ static struct ctl_table_header *ax25_table_header;
 static ctl_table *ax25_table;
 static int ax25_table_size;
 
-static ctl_table ax25_dir_table[] = {
-       {
-               .ctl_name       = NET_AX25,
-               .procname       = "ax25",
-               .mode           = 0555,
-       },
-       { .ctl_name = 0 }
+static struct ctl_path ax25_path[] = {
+       { .procname = "net", .ctl_name = CTL_NET, },
+       { .procname = "ax25", .ctl_name = NET_AX25, },
+       { }
 };
-
-static ctl_table ax25_root_table[] = {
-       {
-               .ctl_name       = CTL_NET,
-               .procname       = "net",
-               .mode           = 0555,
-               .child          = ax25_dir_table
-       },
-       { .ctl_name = 0 }
-};
-
 static const ctl_table ax25_param_table[] = {
        {
                .ctl_name       = NET_AX25_IP_DEFAULT_MODE,
@@ -203,15 +189,15 @@ void ax25_register_sysctl(void)
        for (ax25_table_size = sizeof(ctl_table), ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next)
                ax25_table_size += sizeof(ctl_table);
 
-       if ((ax25_table = kmalloc(ax25_table_size, GFP_ATOMIC)) == NULL) {
+       if ((ax25_table = kzalloc(ax25_table_size, GFP_ATOMIC)) == NULL) {
                spin_unlock_bh(&ax25_dev_lock);
                return;
        }
 
-       memset(ax25_table, 0x00, ax25_table_size);
-
        for (n = 0, ax25_dev = ax25_dev_list; ax25_dev != NULL; ax25_dev = ax25_dev->next) {
-               ctl_table *child = kmalloc(sizeof(ax25_param_table), GFP_ATOMIC);
+               struct ctl_table *child = kmemdup(ax25_param_table,
+                                                 sizeof(ax25_param_table),
+                                                 GFP_ATOMIC);
                if (!child) {
                        while (n--)
                                kfree(ax25_table[n].child);
@@ -219,7 +205,6 @@ void ax25_register_sysctl(void)
                        spin_unlock_bh(&ax25_dev_lock);
                        return;
                }
-               memcpy(child, ax25_param_table, sizeof(ax25_param_table));
                ax25_table[n].child = ax25_dev->systable = child;
                ax25_table[n].ctl_name     = n + 1;
                ax25_table[n].procname     = ax25_dev->dev->name;
@@ -244,9 +229,7 @@ void ax25_register_sysctl(void)
        }
        spin_unlock_bh(&ax25_dev_lock);
 
-       ax25_dir_table[0].child = ax25_table;
-
-       ax25_table_header = register_sysctl_table(ax25_root_table, 1);
+       ax25_table_header = register_sysctl_paths(ax25_path, ax25_table);
 }
 
 void ax25_unregister_sysctl(void)
@@ -254,7 +237,6 @@ void ax25_unregister_sysctl(void)
        ctl_table *p;
        unregister_sysctl_table(ax25_table_header);
 
-       ax25_dir_table[0].child = NULL;
        for (p = ax25_table; p->ctl_name; p++)
                kfree(p->child);
        kfree(ax25_table);