diff options
author | Allan Stephens <allan.stephens@windriver.com> | 2010-05-11 10:30:15 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-05-13 02:02:27 -0400 |
commit | 43608edc2dbe83057544cf76b765ecdf63d59e8c (patch) | |
tree | 42d6e8c1f2d075c2523ff4f9e6ac07ffce758d5e /net/tipc | |
parent | 3e22e62b6204414cf31c414d5a91897e2b718135 (diff) |
tipc: Reduce footprint by un-inlining port list routines
Converts port list inline routines that are more than one line into
standard functions, thereby eliminating a significant amount of
repeated code.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r-- | net/tipc/bcast.c | 50 | ||||
-rw-r--r-- | net/tipc/bcast.h | 52 |
2 files changed, 52 insertions, 50 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 1ee6424ef3e0..a008c6689305 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
@@ -882,3 +882,53 @@ void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b, | |||
882 | } | 882 | } |
883 | } | 883 | } |
884 | } | 884 | } |
885 | |||
886 | /** | ||
887 | * tipc_port_list_add - add a port to a port list, ensuring no duplicates | ||
888 | */ | ||
889 | |||
890 | void tipc_port_list_add(struct port_list *pl_ptr, u32 port) | ||
891 | { | ||
892 | struct port_list *item = pl_ptr; | ||
893 | int i; | ||
894 | int item_sz = PLSIZE; | ||
895 | int cnt = pl_ptr->count; | ||
896 | |||
897 | for (; ; cnt -= item_sz, item = item->next) { | ||
898 | if (cnt < PLSIZE) | ||
899 | item_sz = cnt; | ||
900 | for (i = 0; i < item_sz; i++) | ||
901 | if (item->ports[i] == port) | ||
902 | return; | ||
903 | if (i < PLSIZE) { | ||
904 | item->ports[i] = port; | ||
905 | pl_ptr->count++; | ||
906 | return; | ||
907 | } | ||
908 | if (!item->next) { | ||
909 | item->next = kmalloc(sizeof(*item), GFP_ATOMIC); | ||
910 | if (!item->next) { | ||
911 | warn("Incomplete multicast delivery, no memory\n"); | ||
912 | return; | ||
913 | } | ||
914 | item->next->next = NULL; | ||
915 | } | ||
916 | } | ||
917 | } | ||
918 | |||
919 | /** | ||
920 | * tipc_port_list_free - free dynamically created entries in port_list chain | ||
921 | * | ||
922 | */ | ||
923 | |||
924 | void tipc_port_list_free(struct port_list *pl_ptr) | ||
925 | { | ||
926 | struct port_list *item; | ||
927 | struct port_list *next; | ||
928 | |||
929 | for (item = pl_ptr->next; item; item = next) { | ||
930 | next = item->next; | ||
931 | kfree(item); | ||
932 | } | ||
933 | } | ||
934 | |||
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h index cd779816383f..e8c2b81658c7 100644 --- a/net/tipc/bcast.h +++ b/net/tipc/bcast.h | |||
@@ -87,56 +87,8 @@ static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_m | |||
87 | void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b, | 87 | void tipc_nmap_diff(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b, |
88 | struct tipc_node_map *nm_diff); | 88 | struct tipc_node_map *nm_diff); |
89 | 89 | ||
90 | /** | 90 | void tipc_port_list_add(struct port_list *pl_ptr, u32 port); |
91 | * tipc_port_list_add - add a port to a port list, ensuring no duplicates | 91 | void tipc_port_list_free(struct port_list *pl_ptr); |
92 | */ | ||
93 | |||
94 | static inline void tipc_port_list_add(struct port_list *pl_ptr, u32 port) | ||
95 | { | ||
96 | struct port_list *item = pl_ptr; | ||
97 | int i; | ||
98 | int item_sz = PLSIZE; | ||
99 | int cnt = pl_ptr->count; | ||
100 | |||
101 | for (; ; cnt -= item_sz, item = item->next) { | ||
102 | if (cnt < PLSIZE) | ||
103 | item_sz = cnt; | ||
104 | for (i = 0; i < item_sz; i++) | ||
105 | if (item->ports[i] == port) | ||
106 | return; | ||
107 | if (i < PLSIZE) { | ||
108 | item->ports[i] = port; | ||
109 | pl_ptr->count++; | ||
110 | return; | ||
111 | } | ||
112 | if (!item->next) { | ||
113 | item->next = kmalloc(sizeof(*item), GFP_ATOMIC); | ||
114 | if (!item->next) { | ||
115 | warn("Incomplete multicast delivery, no memory\n"); | ||
116 | return; | ||
117 | } | ||
118 | item->next->next = NULL; | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | |||
123 | /** | ||
124 | * tipc_port_list_free - free dynamically created entries in port_list chain | ||
125 | * | ||
126 | * Note: First item is on stack, so it doesn't need to be released | ||
127 | */ | ||
128 | |||
129 | static inline void tipc_port_list_free(struct port_list *pl_ptr) | ||
130 | { | ||
131 | struct port_list *item; | ||
132 | struct port_list *next; | ||
133 | |||
134 | for (item = pl_ptr->next; item; item = next) { | ||
135 | next = item->next; | ||
136 | kfree(item); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | 92 | ||
141 | int tipc_bclink_init(void); | 93 | int tipc_bclink_init(void); |
142 | void tipc_bclink_stop(void); | 94 | void tipc_bclink_stop(void); |