diff options
Diffstat (limited to 'net/netrom/nr_route.c')
| -rw-r--r-- | net/netrom/nr_route.c | 54 |
1 files changed, 10 insertions, 44 deletions
diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index e2e2d33cafdf..44059d0c8dd1 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <linux/string.h> | 17 | #include <linux/string.h> |
| 18 | #include <linux/sockios.h> | 18 | #include <linux/sockios.h> |
| 19 | #include <linux/net.h> | 19 | #include <linux/net.h> |
| 20 | #include <linux/slab.h> | ||
| 20 | #include <net/ax25.h> | 21 | #include <net/ax25.h> |
| 21 | #include <linux/inet.h> | 22 | #include <linux/inet.h> |
| 22 | #include <linux/netdevice.h> | 23 | #include <linux/netdevice.h> |
| @@ -863,33 +864,13 @@ int nr_route_frame(struct sk_buff *skb, ax25_cb *ax25) | |||
| 863 | 864 | ||
| 864 | static void *nr_node_start(struct seq_file *seq, loff_t *pos) | 865 | static void *nr_node_start(struct seq_file *seq, loff_t *pos) |
| 865 | { | 866 | { |
| 866 | struct nr_node *nr_node; | ||
| 867 | struct hlist_node *node; | ||
| 868 | int i = 1; | ||
| 869 | |||
| 870 | spin_lock_bh(&nr_node_list_lock); | 867 | spin_lock_bh(&nr_node_list_lock); |
| 871 | if (*pos == 0) | 868 | return seq_hlist_start_head(&nr_node_list, *pos); |
| 872 | return SEQ_START_TOKEN; | ||
| 873 | |||
| 874 | nr_node_for_each(nr_node, node, &nr_node_list) { | ||
| 875 | if (i == *pos) | ||
| 876 | return nr_node; | ||
| 877 | ++i; | ||
| 878 | } | ||
| 879 | |||
| 880 | return NULL; | ||
| 881 | } | 869 | } |
| 882 | 870 | ||
| 883 | static void *nr_node_next(struct seq_file *seq, void *v, loff_t *pos) | 871 | static void *nr_node_next(struct seq_file *seq, void *v, loff_t *pos) |
| 884 | { | 872 | { |
| 885 | struct hlist_node *node; | 873 | return seq_hlist_next(v, &nr_node_list, pos); |
| 886 | ++*pos; | ||
| 887 | |||
| 888 | node = (v == SEQ_START_TOKEN) | ||
| 889 | ? nr_node_list.first | ||
| 890 | : ((struct nr_node *)v)->node_node.next; | ||
| 891 | |||
| 892 | return hlist_entry(node, struct nr_node, node_node); | ||
| 893 | } | 874 | } |
| 894 | 875 | ||
| 895 | static void nr_node_stop(struct seq_file *seq, void *v) | 876 | static void nr_node_stop(struct seq_file *seq, void *v) |
| @@ -906,7 +887,9 @@ static int nr_node_show(struct seq_file *seq, void *v) | |||
| 906 | seq_puts(seq, | 887 | seq_puts(seq, |
| 907 | "callsign mnemonic w n qual obs neigh qual obs neigh qual obs neigh\n"); | 888 | "callsign mnemonic w n qual obs neigh qual obs neigh qual obs neigh\n"); |
| 908 | else { | 889 | else { |
| 909 | struct nr_node *nr_node = v; | 890 | struct nr_node *nr_node = hlist_entry(v, struct nr_node, |
| 891 | node_node); | ||
| 892 | |||
| 910 | nr_node_lock(nr_node); | 893 | nr_node_lock(nr_node); |
| 911 | seq_printf(seq, "%-9s %-7s %d %d", | 894 | seq_printf(seq, "%-9s %-7s %d %d", |
| 912 | ax2asc(buf, &nr_node->callsign), | 895 | ax2asc(buf, &nr_node->callsign), |
| @@ -949,31 +932,13 @@ const struct file_operations nr_nodes_fops = { | |||
| 949 | 932 | ||
| 950 | static void *nr_neigh_start(struct seq_file *seq, loff_t *pos) | 933 | static void *nr_neigh_start(struct seq_file *seq, loff_t *pos) |
| 951 | { | 934 | { |
| 952 | struct nr_neigh *nr_neigh; | ||
| 953 | struct hlist_node *node; | ||
| 954 | int i = 1; | ||
| 955 | |||
| 956 | spin_lock_bh(&nr_neigh_list_lock); | 935 | spin_lock_bh(&nr_neigh_list_lock); |
| 957 | if (*pos == 0) | 936 | return seq_hlist_start_head(&nr_neigh_list, *pos); |
| 958 | return SEQ_START_TOKEN; | ||
| 959 | |||
| 960 | nr_neigh_for_each(nr_neigh, node, &nr_neigh_list) { | ||
| 961 | if (i == *pos) | ||
| 962 | return nr_neigh; | ||
| 963 | } | ||
| 964 | return NULL; | ||
| 965 | } | 937 | } |
| 966 | 938 | ||
| 967 | static void *nr_neigh_next(struct seq_file *seq, void *v, loff_t *pos) | 939 | static void *nr_neigh_next(struct seq_file *seq, void *v, loff_t *pos) |
| 968 | { | 940 | { |
| 969 | struct hlist_node *node; | 941 | return seq_hlist_next(v, &nr_neigh_list, pos); |
| 970 | ++*pos; | ||
| 971 | |||
| 972 | node = (v == SEQ_START_TOKEN) | ||
| 973 | ? nr_neigh_list.first | ||
| 974 | : ((struct nr_neigh *)v)->neigh_node.next; | ||
| 975 | |||
| 976 | return hlist_entry(node, struct nr_neigh, neigh_node); | ||
| 977 | } | 942 | } |
| 978 | 943 | ||
| 979 | static void nr_neigh_stop(struct seq_file *seq, void *v) | 944 | static void nr_neigh_stop(struct seq_file *seq, void *v) |
| @@ -989,8 +954,9 @@ static int nr_neigh_show(struct seq_file *seq, void *v) | |||
| 989 | if (v == SEQ_START_TOKEN) | 954 | if (v == SEQ_START_TOKEN) |
| 990 | seq_puts(seq, "addr callsign dev qual lock count failed digipeaters\n"); | 955 | seq_puts(seq, "addr callsign dev qual lock count failed digipeaters\n"); |
| 991 | else { | 956 | else { |
| 992 | struct nr_neigh *nr_neigh = v; | 957 | struct nr_neigh *nr_neigh; |
| 993 | 958 | ||
| 959 | nr_neigh = hlist_entry(v, struct nr_neigh, neigh_node); | ||
| 994 | seq_printf(seq, "%05d %-9s %-4s %3d %d %3d %3d", | 960 | seq_printf(seq, "%05d %-9s %-4s %3d %d %3d %3d", |
| 995 | nr_neigh->number, | 961 | nr_neigh->number, |
| 996 | ax2asc(buf, &nr_neigh->callsign), | 962 | ax2asc(buf, &nr_neigh->callsign), |
