projects
/
project
/
netifd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
add a helper function for freeing a device
[project/netifd.git]
/
device.c
diff --git
a/device.c
b/device.c
index
0efdba5
..
57b0ac9
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);
}
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);
{
cleanup_device(dev);
free(dev);
@@
-96,7
+96,7
@@
void init_virtual_device(struct device *dev, const struct device_type *type, con
if (name)
strncpy(dev->ifname, name, IFNAMSIZ);
if (name)
strncpy(dev->ifname, name, IFNAMSIZ);
- fprintf(stderr, "Initialize
interfa
ce '%s'\n", dev->ifname);
+ fprintf(stderr, "Initialize
devi
ce '%s'\n", dev->ifname);
INIT_LIST_HEAD(&dev->users);
dev->type = type;
}
INIT_LIST_HEAD(&dev->users);
dev->type = type;
}
@@
-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,
static const struct device_type simple_type = {
.name = "Device",
.check_state = system_if_check,
- .free = free_device,
+ .free = free_
simple_
device,
};
struct device *dev;
};
struct device *dev;
@@
-151,7
+151,7
@@
void cleanup_device(struct device *dev)
{
struct device_user *dep, *tmp;
{
struct device_user *dep, *tmp;
- fprintf(stderr, "Clean up
interfa
ce '%s'\n", dev->ifname);
+ fprintf(stderr, "Clean up
devi
ce '%s'\n", dev->ifname);
list_for_each_entry_safe(dep, tmp, &dev->users, list) {
if (!dep->cb)
continue;
list_for_each_entry_safe(dep, tmp, &dev->users, list) {
if (!dep->cb)
continue;
@@
-191,8
+191,8
@@
void remove_device_user(struct device_user *dep)
list_del(&dep->list);
if (list_empty(&dev->users)) {
list_del(&dep->list);
if (list_empty(&dev->users)) {
- /* all references have gone away, remove this
interfa
ce */
-
dev->type->fre
e(dev);
+ /* all references have gone away, remove this
devi
ce */
+
free_devic
e(dev);
}
dep->dev = NULL;
}
dep->dev = NULL;