summaryrefslogtreecommitdiff
path: root/drivers/hid/hid-core.c
diff options
context:
space:
mode:
authorBruno Prémont <bonbons@linux-vserver.org>2010-03-15 14:55:40 +0100
committerJiri Kosina <jkosina@suse.cz>2010-03-15 14:55:40 +0100
commit4da361b69102cdffe73006771eae7504d2cb8736 (patch)
treec6603f821d4eb3711571e1346185d1d2bd795b03 /drivers/hid/hid-core.c
parenta85821fce2c100a6680511f9693b76f9717fbdee (diff)
downloadlwn-4da361b69102cdffe73006771eae7504d2cb8736.tar.gz
lwn-4da361b69102cdffe73006771eae7504d2cb8736.zip
HID: register debugfs entries before adding device
Register debugfs entries before calling device_add() so debugfs entries are already present when HID driver's probe function gets called on device hotplug. Also undo debugfs entry registration if device_add() fails so status HID_STAT_ADDED and debugfs registration status remain consistent and we don't leak the debugfs entries. Signed-off-by: Bruno Prémont <bonbons@linux-vserver.org> Cc: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid/hid-core.c')
-rw-r--r--drivers/hid/hid-core.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 368fbb0c4ca6..7396f47c79db 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1768,11 +1768,12 @@ int hid_add_device(struct hid_device *hdev)
dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
hdev->vendor, hdev->product, atomic_inc_return(&id));
+ hid_debug_register(hdev, dev_name(&hdev->dev));
ret = device_add(&hdev->dev);
if (!ret)
hdev->status |= HID_STAT_ADDED;
-
- hid_debug_register(hdev, dev_name(&hdev->dev));
+ else
+ hid_debug_unregister(hdev);
return ret;
}