Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4da361b6 authored by Bruno Prémont's avatar Bruno Prémont Committed by Jiri Kosina
Browse files

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: default avatarBruno Prémont <bonbons@linux-vserver.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent a85821fc
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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;
}