diff options
author | Himangi Saraogi <himangi774@gmail.com> | 2014-05-26 01:30:19 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-05-29 02:49:11 -0400 |
commit | 50525cb3bf9dc7fe4cb8d4cd9b9e389257eaa8ee (patch) | |
tree | ca561560cb9a6a43887f98750700b1b87fd38d75 /drivers/input | |
parent | ec62c7a8f8ebb81a07ac68a5126ad74dca113b09 (diff) |
Input: jornada680_kbd - switch top using managed resources
Let's switch the driver to use managed resources, this will simplify
error handling and driver unbinding logic.
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/keyboard/jornada680_kbd.c | 36 |
1 files changed, 10 insertions, 26 deletions
diff --git a/drivers/input/keyboard/jornada680_kbd.c b/drivers/input/keyboard/jornada680_kbd.c index 69b1f002ff52..0ba4428da24a 100644 --- a/drivers/input/keyboard/jornada680_kbd.c +++ b/drivers/input/keyboard/jornada680_kbd.c | |||
@@ -16,6 +16,7 @@ | |||
16 | * published by the Free Software Foundation. | 16 | * published by the Free Software Foundation. |
17 | */ | 17 | */ |
18 | 18 | ||
19 | #include <linux/device.h> | ||
19 | #include <linux/input.h> | 20 | #include <linux/input.h> |
20 | #include <linux/input-polldev.h> | 21 | #include <linux/input-polldev.h> |
21 | #include <linux/interrupt.h> | 22 | #include <linux/interrupt.h> |
@@ -185,14 +186,15 @@ static int jornada680kbd_probe(struct platform_device *pdev) | |||
185 | struct input_dev *input_dev; | 186 | struct input_dev *input_dev; |
186 | int i, error; | 187 | int i, error; |
187 | 188 | ||
188 | jornadakbd = kzalloc(sizeof(struct jornadakbd), GFP_KERNEL); | 189 | jornadakbd = devm_kzalloc(&pdev->dev, sizeof(struct jornadakbd), |
190 | GFP_KERNEL); | ||
189 | if (!jornadakbd) | 191 | if (!jornadakbd) |
190 | return -ENOMEM; | 192 | return -ENOMEM; |
191 | 193 | ||
192 | poll_dev = input_allocate_polled_device(); | 194 | poll_dev = devm_input_allocate_polled_device(&pdev->dev); |
193 | if (!poll_dev) { | 195 | if (!poll_dev) { |
194 | error = -ENOMEM; | 196 | dev_err(&pdev->dev, "failed to allocate polled input device\n"); |
195 | goto failed; | 197 | return -ENOMEM; |
196 | } | 198 | } |
197 | 199 | ||
198 | platform_set_drvdata(pdev, jornadakbd); | 200 | platform_set_drvdata(pdev, jornadakbd); |
@@ -224,27 +226,10 @@ static int jornada680kbd_probe(struct platform_device *pdev) | |||
224 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); | 226 | input_set_capability(input_dev, EV_MSC, MSC_SCAN); |
225 | 227 | ||
226 | error = input_register_polled_device(jornadakbd->poll_dev); | 228 | error = input_register_polled_device(jornadakbd->poll_dev); |
227 | if (error) | 229 | if (error) { |
228 | goto failed; | 230 | dev_err(&pdev->dev, "failed to register polled input device\n"); |
229 | 231 | return error; | |
230 | return 0; | 232 | } |
231 | |||
232 | failed: | ||
233 | printk(KERN_ERR "Jornadakbd: failed to register driver, error: %d\n", | ||
234 | error); | ||
235 | input_free_polled_device(poll_dev); | ||
236 | kfree(jornadakbd); | ||
237 | return error; | ||
238 | |||
239 | } | ||
240 | |||
241 | static int jornada680kbd_remove(struct platform_device *pdev) | ||
242 | { | ||
243 | struct jornadakbd *jornadakbd = platform_get_drvdata(pdev); | ||
244 | |||
245 | input_unregister_polled_device(jornadakbd->poll_dev); | ||
246 | input_free_polled_device(jornadakbd->poll_dev); | ||
247 | kfree(jornadakbd); | ||
248 | 233 | ||
249 | return 0; | 234 | return 0; |
250 | } | 235 | } |
@@ -255,7 +240,6 @@ static struct platform_driver jornada680kbd_driver = { | |||
255 | .owner = THIS_MODULE, | 240 | .owner = THIS_MODULE, |
256 | }, | 241 | }, |
257 | .probe = jornada680kbd_probe, | 242 | .probe = jornada680kbd_probe, |
258 | .remove = jornada680kbd_remove, | ||
259 | }; | 243 | }; |
260 | module_platform_driver(jornada680kbd_driver); | 244 | module_platform_driver(jornada680kbd_driver); |
261 | 245 | ||