aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2012-11-03 15:16:12 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-11-08 12:10:05 -0500
commit2be975c6d920de989ff5e4bc09ffe87e59d94662 (patch)
tree34b24d6559118a4aedc60bdef265834530cacde9 /include
parentfa8e2458ecfc959cd627e25ba86d8eddcb63c887 (diff)
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>
Diffstat (limited to 'include')
-rw-r--r--include/linux/input.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/include/linux/input.h b/include/linux/input.h
index cab994ba6d91..5538cc09a4f5 100644
--- a/include/linux/input.h
+++ b/include/linux/input.h
@@ -112,6 +112,8 @@ struct input_value {
112 * @h_list: list of input handles associated with the device. When 112 * @h_list: list of input handles associated with the device. When
113 * accessing the list dev->mutex must be held 113 * accessing the list dev->mutex must be held
114 * @node: used to place the device onto input_dev_list 114 * @node: used to place the device onto input_dev_list
115 * @devres_managed: indicates that devices is managed with devres framework
116 * and needs not be explicitly unregistered or freed.
115 */ 117 */
116struct input_dev { 118struct input_dev {
117 const char *name; 119 const char *name;
@@ -180,6 +182,8 @@ struct input_dev {
180 unsigned int num_vals; 182 unsigned int num_vals;
181 unsigned int max_vals; 183 unsigned int max_vals;
182 struct input_value *vals; 184 struct input_value *vals;
185
186 bool devres_managed;
183}; 187};
184#define to_input_dev(d) container_of(d, struct input_dev, dev) 188#define to_input_dev(d) container_of(d, struct input_dev, dev)
185 189
@@ -323,7 +327,8 @@ struct input_handle {
323 struct list_head h_node; 327 struct list_head h_node;
324}; 328};
325 329
326struct input_dev *input_allocate_device(void); 330struct input_dev __must_check *input_allocate_device(void);
331struct input_dev __must_check *devm_input_allocate_device(struct device *);
327void input_free_device(struct input_dev *dev); 332void input_free_device(struct input_dev *dev);
328 333
329static inline struct input_dev *input_get_device(struct input_dev *dev) 334static inline struct input_dev *input_get_device(struct input_dev *dev)