Skip to content

Commit b666263

Browse files
committed
Input: document that unregistering managed devices is not necessary
Apparently some users of managed input devices are confused whether input_unregister_device() is needed when working with them. Clarify this in the kernel doc for devm_input_allocate_device(): in most cases there is no need to call neither input_unregister_device() nor input_free_device() when working with managed devices. Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent bec7a4b commit b666263

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

‎drivers/input/input.c‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,12 +1785,13 @@ static void devm_input_device_release(struct device *dev, void *res)
17851785
* its driver (or binding fails). Once managed input device is allocated,
17861786
* it is ready to be set up and registered in the same fashion as regular
17871787
* input device. There are no special devm_input_device_[un]register()
1788-
* variants, regular ones work with both managed and unmanaged devices.
1788+
* variants, regular ones work with both managed and unmanaged devices,
1789+
* should you need them. In most cases however, managed input device need
1790+
* not be explicitly unregistered or freed.
17891791
*
17901792
* NOTE: the owner device is set up as parent of input device and users
17911793
* should not override it.
17921794
*/
1793-
17941795
struct input_dev *devm_input_allocate_device(struct device *dev)
17951796
{
17961797
struct input_dev *input;
@@ -2004,6 +2005,17 @@ static void devm_input_device_unregister(struct device *dev, void *res)
20042005
* Once device has been successfully registered it can be unregistered
20052006
* with input_unregister_device(); input_free_device() should not be
20062007
* called in this case.
2008+
*
2009+
* Note that this function is also used to register managed input devices
2010+
* (ones allocated with devm_input_allocate_device()). Such managed input
2011+
* devices need not be explicitly unregistered or freed, their tear down
2012+
* is controlled by the devres infrastructure. It is also worth noting
2013+
* that tear down of managed input devices is internally a 2-step process:
2014+
* registered managed input device is first unregistered, but stays in
2015+
* memory and can still handle input_event() calls (although events will
2016+
* not be delivered anywhere). The freeing of managed input device will
2017+
* happen later, when devres stack is unwound to the point where device
2018+
* allocation was made.
20072019
*/
20082020
int input_register_device(struct input_dev *dev)
20092021
{

0 commit comments

Comments
 (0)