add a helper function for freeing a device
authorFelix Fietkau <nbd@openwrt.org>
Tue, 5 Apr 2011 01:48:59 +0000 (03:48 +0200)
committerFelix Fietkau <nbd@openwrt.org>
Tue, 5 Apr 2011 01:48:59 +0000 (03:48 +0200)
device.c
device.h

index 6b409a02fa167f69a2947a1e60c6bc5784500158..57b0ac96ac2dade9eb7a83f828faadfa9741987b 100644 (file)
--- a/device.c
+++ b/device.c
@@ -20,7 +20,7 @@ static void API_CTOR dev_init(void)
        avl_init(&devices, avl_strcmp, false, NULL);
 }
 
-static void free_device(struct device *dev)
+static void free_simple_device(struct device *dev)
 {
        cleanup_device(dev);
        free(dev);
@@ -126,7 +126,7 @@ struct device *get_device(const char *name, bool create)
        static const struct device_type simple_type = {
                .name = "Device",
                .check_state = system_if_check,
-               .free = free_device,
+               .free = free_simple_device,
        };
        struct device *dev;
 
@@ -192,7 +192,7 @@ void remove_device_user(struct device_user *dep)
 
        if (list_empty(&dev->users)) {
                /* all references have gone away, remove this device */
-               dev->type->free(dev);
+               free_device(dev);
        }
 
        dep->dev = NULL;
index bfd044ae6eab1231d18d340bb4a50be1c6f8cdc2..79aec322c07bc5349efd9edd46a08c33005b007e 100644 (file)
--- a/device.h
+++ b/device.h
@@ -82,6 +82,12 @@ struct device_hotplug_ops {
        int (*del)(struct device *main, struct device *member);
 };
 
+static inline void
+free_device(struct device *dev)
+{
+       dev->type->free(dev);
+}
+
 void init_virtual_device(struct device *dev, const struct device_type *type, const char *name);
 int init_device(struct device *iface, const struct device_type *type, const char *ifname);
 void cleanup_device(struct device *iface);