diff options
author | Abraham Arce <x0066660@ti.com> | 2010-09-30 02:35:57 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2010-10-13 10:49:25 -0400 |
commit | f3a1ba60dbdbf46f2715cc4e3f8abc9d65c4d9bf (patch) | |
tree | e6a3a21412ec023e18f8cbea07377b48da4f5f7e /drivers/input/keyboard/omap4-keypad.c | |
parent | 4c61c8457ee92a2afc5a43aa0821971727ebd38c (diff) |
Input: omap4-keypad - use platform device helpers
Get mem and irq resources using platform helpers
- platform_get_base
- platform_get_irq
Signed-off-by: Abraham Arce <x0066660@ti.com>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/keyboard/omap4-keypad.c')
-rw-r--r-- | drivers/input/keyboard/omap4-keypad.c | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index 975f8bbcc69b..788169d3e7c2 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c | |||
@@ -148,7 +148,10 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev) | |||
148 | const struct omap4_keypad_platform_data *pdata; | 148 | const struct omap4_keypad_platform_data *pdata; |
149 | struct omap4_keypad *keypad_data; | 149 | struct omap4_keypad *keypad_data; |
150 | struct input_dev *input_dev; | 150 | struct input_dev *input_dev; |
151 | struct resource *res; | ||
152 | resource_size_t size; | ||
151 | unsigned int row_shift, max_keys; | 153 | unsigned int row_shift, max_keys; |
154 | int irq; | ||
152 | int error; | 155 | int error; |
153 | 156 | ||
154 | /* platform data */ | 157 | /* platform data */ |
@@ -158,12 +161,14 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev) | |||
158 | return -EINVAL; | 161 | return -EINVAL; |
159 | } | 162 | } |
160 | 163 | ||
161 | if (!pdata->base) { | 164 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
165 | if (!res) { | ||
162 | dev_err(&pdev->dev, "no base address specified\n"); | 166 | dev_err(&pdev->dev, "no base address specified\n"); |
163 | return -EINVAL; | 167 | return -EINVAL; |
164 | } | 168 | } |
165 | 169 | ||
166 | if (!pdata->irq) { | 170 | irq = platform_get_irq(pdev, 0); |
171 | if (!irq) { | ||
167 | dev_err(&pdev->dev, "no keyboard irq assigned\n"); | 172 | dev_err(&pdev->dev, "no keyboard irq assigned\n"); |
168 | return -EINVAL; | 173 | return -EINVAL; |
169 | } | 174 | } |
@@ -184,9 +189,23 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev) | |||
184 | return -ENOMEM; | 189 | return -ENOMEM; |
185 | } | 190 | } |
186 | 191 | ||
187 | keypad_data->base = pdata->base; | 192 | size = resource_size(res); |
188 | keypad_data->irq = pdata->irq; | 193 | |
194 | res = request_mem_region(res->start, size, pdev->name); | ||
195 | if (!res) { | ||
196 | dev_err(&pdev->dev, "can't request mem region\n"); | ||
197 | error = -EBUSY; | ||
198 | goto err_free_keypad; | ||
199 | } | ||
189 | 200 | ||
201 | keypad_data->base = ioremap(res->start, resource_size(res)); | ||
202 | if (!keypad_data->base) { | ||
203 | dev_err(&pdev->dev, "can't ioremap mem resource\n"); | ||
204 | error = -ENOMEM; | ||
205 | goto err_release_mem; | ||
206 | } | ||
207 | |||
208 | keypad_data->irq = irq; | ||
190 | keypad_data->row_shift = row_shift; | 209 | keypad_data->row_shift = row_shift; |
191 | keypad_data->rows = pdata->rows; | 210 | keypad_data->rows = pdata->rows; |
192 | keypad_data->cols = pdata->cols; | 211 | keypad_data->cols = pdata->cols; |
@@ -195,7 +214,7 @@ static int __devinit omap4_keypad_probe(struct platform_device *pdev) | |||
195 | keypad_data->input = input_dev = input_allocate_device(); | 214 | keypad_data->input = input_dev = input_allocate_device(); |
196 | if (!input_dev) { | 215 | if (!input_dev) { |
197 | error = -ENOMEM; | 216 | error = -ENOMEM; |
198 | goto err_free_keypad; | 217 | goto err_unmap; |
199 | } | 218 | } |
200 | 219 | ||
201 | input_dev->name = pdev->name; | 220 | input_dev->name = pdev->name; |
@@ -243,6 +262,10 @@ err_free_irq: | |||
243 | free_irq(keypad_data->irq, keypad_data); | 262 | free_irq(keypad_data->irq, keypad_data); |
244 | err_free_input: | 263 | err_free_input: |
245 | input_free_device(input_dev); | 264 | input_free_device(input_dev); |
265 | err_unmap: | ||
266 | iounmap(keypad_data->base); | ||
267 | err_release_mem: | ||
268 | release_mem_region(res->start, size); | ||
246 | err_free_keypad: | 269 | err_free_keypad: |
247 | kfree(keypad_data); | 270 | kfree(keypad_data); |
248 | return error; | 271 | return error; |
@@ -251,9 +274,16 @@ err_free_keypad: | |||
251 | static int __devexit omap4_keypad_remove(struct platform_device *pdev) | 274 | static int __devexit omap4_keypad_remove(struct platform_device *pdev) |
252 | { | 275 | { |
253 | struct omap4_keypad *keypad_data = platform_get_drvdata(pdev); | 276 | struct omap4_keypad *keypad_data = platform_get_drvdata(pdev); |
277 | struct resource *res; | ||
254 | 278 | ||
255 | free_irq(keypad_data->irq, keypad_data); | 279 | free_irq(keypad_data->irq, keypad_data); |
256 | input_unregister_device(keypad_data->input); | 280 | input_unregister_device(keypad_data->input); |
281 | |||
282 | iounmap(keypad_data->base); | ||
283 | |||
284 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
285 | release_mem_region(res->start, resource_size(res)); | ||
286 | |||
257 | kfree(keypad_data); | 287 | kfree(keypad_data); |
258 | platform_set_drvdata(pdev, NULL); | 288 | platform_set_drvdata(pdev, NULL); |
259 | 289 | ||