diff options
author | Felix Fietkau <nbd@openwrt.org> | 2011-09-05 04:12:10 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2011-09-05 04:12:10 +0200 |
commit | f026eb8247d74f88a6b704af866879867574f9f0 (patch) | |
tree | 8aca119f60f36e69910e31b89100e54a2b54c73f /device.c | |
parent | f5bb1c61228b7900e69eaea0788ee9d5fb304691 (diff) |
remove code duplication
Diffstat (limited to 'device.c')
-rw-r--r-- | device.c | 25 |
1 files changed, 10 insertions, 15 deletions
@@ -261,6 +261,15 @@ void device_add_user(struct device_user *dep, struct device *dev) } } +static void +__device_free_unused(struct device *dev) +{ + if (!list_empty(&dev->users)) + return; + + device_free(dev); +} + void device_remove_user(struct device_user *dep) { struct device *dev = dep->dev; @@ -269,22 +278,8 @@ void device_remove_user(struct device_user *dep) device_release(dep); list_del(&dep->list); - - if (list_empty(&dev->users)) { - /* all references have gone away, remove this device */ - device_free(dev); - } - dep->dev = NULL; -} - -static void -__device_free_unused(struct device *dev) -{ - if (!list_empty(&dev->users)) - return; - - device_free(dev); + __device_free_unused(dev); } void |