aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard
diff options
context:
space:
mode:
authorHimangi Saraogi <himangi774@gmail.com>2014-05-22 13:40:42 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-05-29 02:49:10 -0400
commitec62c7a8f8ebb81a07ac68a5126ad74dca113b09 (patch)
treed785e7d4c6c44016462279ed26f77de4763cf369 /drivers/input/keyboard
parent4f8edc3c9c7e78f7c22338470d0f330f11b1ba9a (diff)
Input: adp5520-keys - 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> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r--drivers/input/keyboard/adp5520-keys.c32
1 files changed, 10 insertions, 22 deletions
diff --git a/drivers/input/keyboard/adp5520-keys.c b/drivers/input/keyboard/adp5520-keys.c
index 4cc14c2fa7d5..7f4a8b58efc1 100644
--- a/drivers/input/keyboard/adp5520-keys.c
+++ b/drivers/input/keyboard/adp5520-keys.c
@@ -12,6 +12,7 @@
12#include <linux/input.h> 12#include <linux/input.h>
13#include <linux/mfd/adp5520.h> 13#include <linux/mfd/adp5520.h>
14#include <linux/slab.h> 14#include <linux/slab.h>
15#include <linux/device.h>
15 16
16struct adp5520_keys { 17struct adp5520_keys {
17 struct input_dev *input; 18 struct input_dev *input;
@@ -81,7 +82,7 @@ static int adp5520_keys_probe(struct platform_device *pdev)
81 return -EINVAL; 82 return -EINVAL;
82 } 83 }
83 84
84 if (pdata == NULL) { 85 if (!pdata) {
85 dev_err(&pdev->dev, "missing platform data\n"); 86 dev_err(&pdev->dev, "missing platform data\n");
86 return -EINVAL; 87 return -EINVAL;
87 } 88 }
@@ -89,17 +90,15 @@ static int adp5520_keys_probe(struct platform_device *pdev)
89 if (!(pdata->rows_en_mask && pdata->cols_en_mask)) 90 if (!(pdata->rows_en_mask && pdata->cols_en_mask))
90 return -EINVAL; 91 return -EINVAL;
91 92
92 dev = kzalloc(sizeof(*dev), GFP_KERNEL); 93 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
93 if (dev == NULL) { 94 if (!dev) {
94 dev_err(&pdev->dev, "failed to alloc memory\n"); 95 dev_err(&pdev->dev, "failed to alloc memory\n");
95 return -ENOMEM; 96 return -ENOMEM;
96 } 97 }
97 98
98 input = input_allocate_device(); 99 input = devm_input_allocate_device(&pdev->dev);
99 if (!input) { 100 if (!input)
100 ret = -ENOMEM; 101 return -ENOMEM;
101 goto err;
102 }
103 102
104 dev->master = pdev->dev.parent; 103 dev->master = pdev->dev.parent;
105 dev->input = input; 104 dev->input = input;
@@ -135,7 +134,7 @@ static int adp5520_keys_probe(struct platform_device *pdev)
135 ret = input_register_device(input); 134 ret = input_register_device(input);
136 if (ret) { 135 if (ret) {
137 dev_err(&pdev->dev, "unable to register input device\n"); 136 dev_err(&pdev->dev, "unable to register input device\n");
138 goto err; 137 return ret;
139 } 138 }
140 139
141 en_mask = pdata->rows_en_mask | pdata->cols_en_mask; 140 en_mask = pdata->rows_en_mask | pdata->cols_en_mask;
@@ -157,8 +156,7 @@ static int adp5520_keys_probe(struct platform_device *pdev)
157 156
158 if (ret) { 157 if (ret) {
159 dev_err(&pdev->dev, "failed to write\n"); 158 dev_err(&pdev->dev, "failed to write\n");
160 ret = -EIO; 159 return -EIO;
161 goto err1;
162 } 160 }
163 161
164 dev->notifier.notifier_call = adp5520_keys_notifier; 162 dev->notifier.notifier_call = adp5520_keys_notifier;
@@ -166,19 +164,11 @@ static int adp5520_keys_probe(struct platform_device *pdev)
166 ADP5520_KP_IEN | ADP5520_KR_IEN); 164 ADP5520_KP_IEN | ADP5520_KR_IEN);
167 if (ret) { 165 if (ret) {
168 dev_err(&pdev->dev, "failed to register notifier\n"); 166 dev_err(&pdev->dev, "failed to register notifier\n");
169 goto err1; 167 return ret;
170 } 168 }
171 169
172 platform_set_drvdata(pdev, dev); 170 platform_set_drvdata(pdev, dev);
173 return 0; 171 return 0;
174
175err1:
176 input_unregister_device(input);
177 input = NULL;
178err:
179 input_free_device(input);
180 kfree(dev);
181 return ret;
182} 172}
183 173
184static int adp5520_keys_remove(struct platform_device *pdev) 174static int adp5520_keys_remove(struct platform_device *pdev)
@@ -188,8 +178,6 @@ static int adp5520_keys_remove(struct platform_device *pdev)
188 adp5520_unregister_notifier(dev->master, &dev->notifier, 178 adp5520_unregister_notifier(dev->master, &dev->notifier,
189 ADP5520_KP_IEN | ADP5520_KR_IEN); 179 ADP5520_KP_IEN | ADP5520_KR_IEN);
190 180
191 input_unregister_device(dev->input);
192 kfree(dev);
193 return 0; 181 return 0;
194} 182}
195 183