]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
tipc: simplify include dependencies
authorJon Paul Maloy <jon.maloy@ericsson.com>
Thu, 14 May 2015 14:46:13 +0000 (10:46 -0400)
committerDavid S. Miller <davem@davemloft.net>
Thu, 14 May 2015 16:24:45 +0000 (12:24 -0400)
When we try to add new inline functions in the code, we sometimes
run into circular include dependencies.

The main problem is that the file core.h, which really should be at
the root of the dependency chain, instead is a leaf. I.e., core.h
includes a number of header files that themselves should be allowed
to include core.h. In reality this is unnecessary, because core.h does
not need to know the full signature of any of the structs it refers to,
only their type declaration.

In this commit, we remove all dependencies from core.h towards any
other tipc header file.

As a consequence of this change, we can now move the function
tipc_own_addr(net) from addr.c to addr.h, and make it inline.

There are no functional changes in this commit.

Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/addr.c
net/tipc/addr.h
net/tipc/bearer.h
net/tipc/core.h
net/tipc/net.c
net/tipc/node.c
net/tipc/node.h
net/tipc/socket.c

index ba7daa864d44471ad6c57d630bcaa4379aabea0c..48fd3b5a73fbaf934178c444cbba07aa1a0f5b8c 100644 (file)
 #include "addr.h"
 #include "core.h"
 
-u32 tipc_own_addr(struct net *net)
-{
-       struct tipc_net *tn = net_generic(net, tipc_net_id);
-
-       return tn->own_addr;
-}
-
 /**
  * in_own_cluster - test for cluster inclusion; <0.0.0> always matches
  */
index 7ba6d5c8ae405727721ba8ace46c7051938163ef..93f7c983be3322237a8cf20985de1131a21f417f 100644 (file)
 #include <linux/tipc.h>
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
+#include "core.h"
 
 #define TIPC_ZONE_MASK         0xff000000u
 #define TIPC_CLUSTER_MASK      0xfffff000u
 
+static inline u32 tipc_own_addr(struct net *net)
+{
+       struct tipc_net *tn = net_generic(net, tipc_net_id);
+
+       return tn->own_addr;
+}
+
 static inline u32 tipc_zone_mask(u32 addr)
 {
        return addr & TIPC_ZONE_MASK;
index 5cad243ee8fc646efccfe72f26ad49ebdfe42f4f..dc714d977768c105cff0b774b49be1e5ec1c59fd 100644 (file)
@@ -38,9 +38,9 @@
 #define _TIPC_BEARER_H
 
 #include "netlink.h"
+#include "core.h"
 #include <net/genetlink.h>
 
-#define MAX_BEARERS    2
 #define MAX_MEDIA      3
 #define MAX_NODES      4096
 #define WSIZE          32
index 3dc68c7a966d4d8e2d8fe6a979a33100866c520c..53e8146b14e00c8be34fa31f5acf71e803e56827 100644 (file)
 #include <net/netns/generic.h>
 #include <linux/rhashtable.h>
 
-#include "node.h"
-#include "bearer.h"
-#include "bcast.h"
-#include "netlink.h"
-#include "link.h"
-#include "node.h"
-#include "msg.h"
+struct tipc_node;
+struct tipc_bearer;
+struct tipc_bcbearer;
+struct tipc_bclink;
+struct tipc_link;
+struct tipc_name_table;
+struct tipc_server;
 
 #define TIPC_MOD_VER "2.0.0"
 
+#define NODE_HTABLE_SIZE   512
+#define MAX_BEARERS       3
+
 extern int tipc_net_id __read_mostly;
 extern int sysctl_tipc_rmem[3] __read_mostly;
 extern int sysctl_tipc_named_timeout __read_mostly;
index a54f3cbe2246c8daff5d89923f31e09c2e082098..d6d1399ae22922754ba24364e21e89a6a3497d22 100644 (file)
@@ -40,6 +40,7 @@
 #include "subscr.h"
 #include "socket.h"
 #include "node.h"
+#include "bcast.h"
 
 static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = {
        [TIPC_NLA_NET_UNSPEC]   = { .type = NLA_UNSPEC },
index 22c059ad29991abbdc40e3eca4a09de78df2c1d0..eb3856bb8c5a3d81bb37b217a0c52b40baeaf3e3 100644 (file)
@@ -39,6 +39,7 @@
 #include "node.h"
 #include "name_distr.h"
 #include "socket.h"
+#include "bcast.h"
 
 static void node_lost_contact(struct tipc_node *n_ptr);
 static void node_established_contact(struct tipc_node *n_ptr);
index 02d5c20dc5511a1669c0262e17d1127a5b2b6a1e..5a834cf142c8432fc4b5d65ab9ada044b342f438 100644 (file)
@@ -45,8 +45,6 @@
 /* Out-of-range value for node signature */
 #define INVALID_NODE_SIG       0x10000
 
-#define NODE_HTABLE_SIZE       512
-
 /* Flags used to take different actions according to flag type
  * TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down
  * TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down
index 8f3c8e2cef8e15d359a43445ae265741068b0f5c..9370f953e16fc2a05941375439c0e031f6af2cbf 100644 (file)
@@ -41,6 +41,7 @@
 #include "link.h"
 #include "name_distr.h"
 #include "socket.h"
+#include "bcast.h"
 
 #define SS_LISTENING           -1      /* socket is listening */
 #define SS_READY               -2      /* socket is connectionless */