diff options
author | Himangi Saraogi <himangi774@gmail.com> | 2014-05-29 03:17:59 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2014-05-29 03:26:34 -0400 |
commit | cde51e73cbfa00a85b17bb5dfc0a465d9233660e (patch) | |
tree | ca84b4e77608ea4563fe16e1cda757babb1a142f /drivers | |
parent | 157d45fbdde4919c2b0421bb41d52fc8da155e28 (diff) |
Input: 88pm860x_onkey - switch to 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>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/misc/88pm860x_onkey.c | 40 |
1 files changed, 10 insertions, 30 deletions
diff --git a/drivers/input/misc/88pm860x_onkey.c b/drivers/input/misc/88pm860x_onkey.c index abd8453e5212..220ce0fa15d9 100644 --- a/drivers/input/misc/88pm860x_onkey.c +++ b/drivers/input/misc/88pm860x_onkey.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include <linux/interrupt.h> | 26 | #include <linux/interrupt.h> |
27 | #include <linux/mfd/88pm860x.h> | 27 | #include <linux/mfd/88pm860x.h> |
28 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
29 | #include <linux/device.h> | ||
29 | 30 | ||
30 | #define PM8607_WAKEUP 0x0b | 31 | #define PM8607_WAKEUP 0x0b |
31 | 32 | ||
@@ -68,7 +69,8 @@ static int pm860x_onkey_probe(struct platform_device *pdev) | |||
68 | return -EINVAL; | 69 | return -EINVAL; |
69 | } | 70 | } |
70 | 71 | ||
71 | info = kzalloc(sizeof(struct pm860x_onkey_info), GFP_KERNEL); | 72 | info = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_onkey_info), |
73 | GFP_KERNEL); | ||
72 | if (!info) | 74 | if (!info) |
73 | return -ENOMEM; | 75 | return -ENOMEM; |
74 | info->chip = chip; | 76 | info->chip = chip; |
@@ -76,11 +78,10 @@ static int pm860x_onkey_probe(struct platform_device *pdev) | |||
76 | info->dev = &pdev->dev; | 78 | info->dev = &pdev->dev; |
77 | info->irq = irq; | 79 | info->irq = irq; |
78 | 80 | ||
79 | info->idev = input_allocate_device(); | 81 | info->idev = devm_input_allocate_device(&pdev->dev); |
80 | if (!info->idev) { | 82 | if (!info->idev) { |
81 | dev_err(chip->dev, "Failed to allocate input dev\n"); | 83 | dev_err(chip->dev, "Failed to allocate input dev\n"); |
82 | ret = -ENOMEM; | 84 | return -ENOMEM; |
83 | goto out; | ||
84 | } | 85 | } |
85 | 86 | ||
86 | info->idev->name = "88pm860x_on"; | 87 | info->idev->name = "88pm860x_on"; |
@@ -93,42 +94,22 @@ static int pm860x_onkey_probe(struct platform_device *pdev) | |||
93 | ret = input_register_device(info->idev); | 94 | ret = input_register_device(info->idev); |
94 | if (ret) { | 95 | if (ret) { |
95 | dev_err(chip->dev, "Can't register input device: %d\n", ret); | 96 | dev_err(chip->dev, "Can't register input device: %d\n", ret); |
96 | goto out_reg; | 97 | return ret; |
97 | } | 98 | } |
98 | 99 | ||
99 | ret = request_threaded_irq(info->irq, NULL, pm860x_onkey_handler, | 100 | ret = devm_request_threaded_irq(&pdev->dev, info->irq, NULL, |
100 | IRQF_ONESHOT, "onkey", info); | 101 | pm860x_onkey_handler, IRQF_ONESHOT, |
102 | "onkey", info); | ||
101 | if (ret < 0) { | 103 | if (ret < 0) { |
102 | dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", | 104 | dev_err(chip->dev, "Failed to request IRQ: #%d: %d\n", |
103 | info->irq, ret); | 105 | info->irq, ret); |
104 | goto out_irq; | 106 | return ret; |
105 | } | 107 | } |
106 | 108 | ||
107 | platform_set_drvdata(pdev, info); | 109 | platform_set_drvdata(pdev, info); |
108 | device_init_wakeup(&pdev->dev, 1); | 110 | device_init_wakeup(&pdev->dev, 1); |
109 | 111 | ||
110 | return 0; | 112 | return 0; |
111 | |||
112 | out_irq: | ||
113 | input_unregister_device(info->idev); | ||
114 | kfree(info); | ||
115 | return ret; | ||
116 | |||
117 | out_reg: | ||
118 | input_free_device(info->idev); | ||
119 | out: | ||
120 | kfree(info); | ||
121 | return ret; | ||
122 | } | ||
123 | |||
124 | static int pm860x_onkey_remove(struct platform_device *pdev) | ||
125 | { | ||
126 | struct pm860x_onkey_info *info = platform_get_drvdata(pdev); | ||
127 | |||
128 | free_irq(info->irq, info); | ||
129 | input_unregister_device(info->idev); | ||
130 | kfree(info); | ||
131 | return 0; | ||
132 | } | 113 | } |
133 | 114 | ||
134 | #ifdef CONFIG_PM_SLEEP | 115 | #ifdef CONFIG_PM_SLEEP |
@@ -161,7 +142,6 @@ static struct platform_driver pm860x_onkey_driver = { | |||
161 | .pm = &pm860x_onkey_pm_ops, | 142 | .pm = &pm860x_onkey_pm_ops, |
162 | }, | 143 | }, |
163 | .probe = pm860x_onkey_probe, | 144 | .probe = pm860x_onkey_probe, |
164 | .remove = pm860x_onkey_remove, | ||
165 | }; | 145 | }; |
166 | module_platform_driver(pm860x_onkey_driver); | 146 | module_platform_driver(pm860x_onkey_driver); |
167 | 147 | ||