device: Move the different device type registrations to the device type file
authorHans Dedecker <dedeckeh@gmail.com>
Fri, 23 Sep 2016 13:08:17 +0000 (15:08 +0200)
committerFelix Fietkau <nbd@nbd.name>
Mon, 26 Sep 2016 09:51:19 +0000 (11:51 +0200)
While at it; make device_types static if only used in the device type file

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
alias.c
bridge.c
device.c
device.h
macvlan.c
tunnel.c
vlandev.c

diff --git a/alias.c b/alias.c
index f95c9f5c09ebefabcc2ce6b9fdc4294f60282737..649f2d1317deee9e08d89a0810fc832b8cccdf23 100644 (file)
--- a/alias.c
+++ b/alias.c
@@ -30,8 +30,6 @@ struct alias_device {
        char name[];
 };
 
-static struct device_type alias_device_type;
-
 static void alias_set_device(struct alias_device *alias, struct device *dev)
 {
        if (dev == alias->dep.dev) {
index bcece52865684b5e5bbb8e4a20dc35d3be93bfc4..98e237b394d86c39f86aeeb0ff9d91374afdf46c 100644 (file)
--- a/bridge.c
+++ b/bridge.c
@@ -729,3 +729,8 @@ bridge_create(const char *name, struct device_type *devtype,
 
        return dev;
 }
+
+static void __init bridge_device_type_init(void)
+{
+       device_type_add(&bridge_device_type);
+}
index a7d18af7d1d489d61c88411ab503e6e0daf04352..e17df13dbaca202055edb37efb019227f0e0c773 100644 (file)
--- a/device.c
+++ b/device.c
@@ -82,16 +82,6 @@ int device_type_add(struct device_type *devtype)
        return 0;
 }
 
-/* initialize device type list and add known types */
-static void __init devtypes_init(void)
-{
-       device_type_add(&simple_device_type);
-       device_type_add(&bridge_device_type);
-       device_type_add(&tunnel_device_type);
-       device_type_add(&macvlan_device_type);
-       device_type_add(&vlandev_device_type);
-}
-
 /* Retrieve the device type for the given name. If 'bridge' is true, the type
  * must have bridge capabilities
  */
@@ -1065,3 +1055,8 @@ device_dump_status(struct blob_buf *b, struct device *dev)
                system_if_dump_stats(dev, b);
        blobmsg_close_table(b, s);
 }
+
+static void __init simple_device_type_init(void)
+{
+       device_type_add(&simple_device_type);
+}
index c669beb966f31f3d62864a4dc71f5784b00cdb90..f3ca95768edb0767d5972a6e303fb86eb7a0ff16 100644 (file)
--- a/device.h
+++ b/device.h
@@ -228,8 +228,6 @@ extern const struct uci_blob_param_list device_attr_list;
 extern struct device_type simple_device_type;
 extern struct device_type bridge_device_type;
 extern struct device_type tunnel_device_type;
-extern struct device_type macvlan_device_type;
-extern struct device_type vlandev_device_type;
 
 void device_lock(void);
 void device_unlock(void);
index ffadfd4d77b501295985c5881cb29ba17eb12635..01a48cd9e97488bfab176ee4777e690457a553a7 100644 (file)
--- a/macvlan.c
+++ b/macvlan.c
@@ -253,7 +253,7 @@ macvlan_create(const char *name, struct device_type *devtype,
        return dev;
 }
 
-struct device_type macvlan_device_type = {
+static struct device_type macvlan_device_type = {
        .name = "MAC VLAN",
        .config_params = &macvlan_attr_list,
        .create = macvlan_create,
@@ -262,3 +262,8 @@ struct device_type macvlan_device_type = {
        .free = macvlan_free,
        .dump_info = macvlan_dump_info,
 };
+
+static void __init macvlan_device_type_init(void)
+{
+       device_type_add(&macvlan_device_type);
+}
index ec622d8d47ac10aa04762f803f5a831fdd536cd7..32f361342fe605586fd22cf6c9590edd62480643 100644 (file)
--- a/tunnel.c
+++ b/tunnel.c
@@ -97,4 +97,7 @@ struct device_type tunnel_device_type = {
        .free = tunnel_free,
 };
 
-
+static void __init tunnel_device_type_init(void)
+{
+       device_type_add(&tunnel_device_type);
+}
index b8f7a259e23bd7208fd4572b8bb2924737e35407..becaed88fa785d93d1fd47e8e85ccd3b30fa3777 100644 (file)
--- a/vlandev.c
+++ b/vlandev.c
@@ -241,7 +241,7 @@ vlandev_create(const char *name, struct device_type *devtype,
        return dev;
 }
 
-struct device_type vlandev_device_type = {
+static struct device_type vlandev_device_type = {
        .name = "VLANDEV",
        .config_params = &vlandev_attr_list,
        .create = vlandev_create,
@@ -250,3 +250,8 @@ struct device_type vlandev_device_type = {
        .free = vlandev_free,
        .dump_info = vlandev_dump_info,
 };
+
+static void __init vlandev_device_type_init(void)
+{
+       device_type_add(&vlandev_device_type);
+}