mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
Input: introduce managed input devices (add devres support)
There is a demand from driver's writers to use managed devices framework for their drivers. Unfortunately up to this moment input devices did not provide support for managed devices and that lead to mixing two styles of resource management which usually introduced more bugs, such as manually unregistering input device but relying in devres to free interrupt handler which (unless device is properly shut off) can cause ISR to reference already freed memory. This change introduces devm_input_allocate_device() that will allocate managed instance of input device so that driver writers who prefer using devm_* framework do not have to mix 2 styles. Reviewed-by: Henrik Rydberg <rydberg@euromail.se> Reviewed-by: Tejun Heo <tj@kernel.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
fa8e2458ec
commit
2be975c6d9
2 changed files with 155 additions and 28 deletions
|
@ -112,6 +112,8 @@ struct input_value {
|
|||
* @h_list: list of input handles associated with the device. When
|
||||
* accessing the list dev->mutex must be held
|
||||
* @node: used to place the device onto input_dev_list
|
||||
* @devres_managed: indicates that devices is managed with devres framework
|
||||
* and needs not be explicitly unregistered or freed.
|
||||
*/
|
||||
struct input_dev {
|
||||
const char *name;
|
||||
|
@ -180,6 +182,8 @@ struct input_dev {
|
|||
unsigned int num_vals;
|
||||
unsigned int max_vals;
|
||||
struct input_value *vals;
|
||||
|
||||
bool devres_managed;
|
||||
};
|
||||
#define to_input_dev(d) container_of(d, struct input_dev, dev)
|
||||
|
||||
|
@ -323,7 +327,8 @@ struct input_handle {
|
|||
struct list_head h_node;
|
||||
};
|
||||
|
||||
struct input_dev *input_allocate_device(void);
|
||||
struct input_dev __must_check *input_allocate_device(void);
|
||||
struct input_dev __must_check *devm_input_allocate_device(struct device *);
|
||||
void input_free_device(struct input_dev *dev);
|
||||
|
||||
static inline struct input_dev *input_get_device(struct input_dev *dev)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue