summaryrefslogtreecommitdiffhomepage
path: root/device.c
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@openwrt.org>2012-07-12 23:17:38 +0200
committerFelix Fietkau <nbd@openwrt.org>2012-07-12 23:22:24 +0200
commit70dd0c05d1f06f6d9cec558227224e96224583eb (patch)
tree72fa8cbea64de82be405f8b9a01d3810dacb0528 /device.c
parentd7ce353d5656690b993acbfe73001b96fa788c97 (diff)
add some debug messages for device user count
Diffstat (limited to 'device.c')
-rw-r--r--device.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/device.c b/device.c
index f0361d9..bc5bc46 100644
--- a/device.c
+++ b/device.c
@@ -389,6 +389,17 @@ void device_set_present(struct device *dev, bool state)
device_refresh_present(dev);
}
+static int device_refcount(struct device *dev)
+{
+ struct list_head *list;
+ int count = 0;
+
+ list_for_each(list, &dev->users)
+ count++;
+
+ return count;
+}
+
void device_add_user(struct device_user *dep, struct device *dev)
{
struct list_head *head;
@@ -406,6 +417,7 @@ void device_add_user(struct device_user *dep, struct device *dev)
else
head = &dev->users;
list_add_tail(&dep->list, head);
+ D(DEVICE, "Add user for device '%s', refcount=%d\n", dev->ifname, device_refcount(dev));
if (dep->cb && dev->present) {
dep->cb(dep, DEV_EVENT_ADD);
@@ -446,6 +458,7 @@ void device_remove_user(struct device_user *dep)
list_del(&dep->list);
dep->dev = NULL;
+ D(DEVICE, "Remove user for device '%s', refcount=%d\n", dev->ifname, device_refcount(dev));
__device_free_unused(dev);
}