]> rtime.felk.cvut.cz Git - lisovros/linux_canprio.git/blobdiff - net/ax25/sysctl_net_ax25.c
AX.25: Fix sysctl registration if !CONFIG_AX25_DAMA_SLAVE
[lisovros/linux_canprio.git] / net / ax25 / sysctl_net_ax25.c
index 369a75b160f2d688a898fe43a1b2f7203658bbd1..f288fc4aef9bcd64a16add98a0b7ed86acb232da 100644 (file)
@@ -31,23 +31,10 @@ 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 ctl_table ax25_root_table[] = {
-       {
-               .ctl_name       = CTL_NET,
-               .procname       = "net",
-               .mode           = 0555,
-               .child          = ax25_dir_table
-       },
-       { .ctl_name = 0 }
+static struct ctl_path ax25_path[] = {
+       { .procname = "net", .ctl_name = CTL_NET, },
+       { .procname = "ax25", .ctl_name = NET_AX25, },
+       { }
 };
 
 static const ctl_table ax25_param_table[] = {
@@ -181,6 +168,7 @@ static const ctl_table ax25_param_table[] = {
                .extra1         = &min_proto,
                .extra2         = &max_proto
        },
+#ifdef CONFIG_AX25_DAMA_SLAVE
        {
                .ctl_name       = NET_AX25_DAMA_SLAVE_TIMEOUT,
                .procname       = "dama_slave_timeout",
@@ -191,6 +179,8 @@ static const ctl_table ax25_param_table[] = {
                .extra1         = &min_ds_timeout,
                .extra2         = &max_ds_timeout
        },
+#endif
+
        { .ctl_name = 0 }       /* that's all, folks! */
 };
 
@@ -203,15 +193,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,22 +209,11 @@ 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;
                ax25_table[n].mode         = 0555;
 
-#ifndef CONFIG_AX25_DAMA_SLAVE
-               /*
-                * We do not wish to have a representation of this parameter
-                * in /proc/sys/ when configured *not* to include the
-                * AX.25 DAMA slave code, do we?
-                */
-
-               child[AX25_VALUES_DS_TIMEOUT].procname = NULL;
-#endif
-
                child[AX25_MAX_VALUES].ctl_name = 0;    /* just in case... */
 
                for (k = 0; k < AX25_MAX_VALUES; k++)
@@ -244,9 +223,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 +231,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);