aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2012-11-10 02:56:59 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-11-10 03:30:48 -0500
commit2bd942f90a6021d5d9f49c28663f38f5b575a818 (patch)
tree62c2205f43471f50c75571ab19a8a0bbfcce4a1e
parentaaa4f2a7f6cce4485dc60063a56e210761f5a0c8 (diff)
Input: stmpe-ts - switch to using managed resources
This patch frees stmpe-ts driver from burden of freeing resources :) devm_* derivatives of multiple routines are used while allocating resources, which would be freed automatically by kernel. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
-rw-r--r--drivers/input/touchscreen/stmpe-ts.c67
1 files changed, 23 insertions, 44 deletions
diff --git a/drivers/input/touchscreen/stmpe-ts.c b/drivers/input/touchscreen/stmpe-ts.c
index 692b685720ce..7d9aadcef154 100644
--- a/drivers/input/touchscreen/stmpe-ts.c
+++ b/drivers/input/touchscreen/stmpe-ts.c
@@ -1,4 +1,5 @@
1/* STMicroelectronics STMPE811 Touchscreen Driver 1/*
2 * STMicroelectronics STMPE811 Touchscreen Driver
2 * 3 *
3 * (C) 2010 Luotao Fu <l.fu@pengutronix.de> 4 * (C) 2010 Luotao Fu <l.fu@pengutronix.de>
4 * All rights reserved. 5 * All rights reserved.
@@ -264,28 +265,24 @@ static void stmpe_ts_close(struct input_dev *dev)
264static int __devinit stmpe_input_probe(struct platform_device *pdev) 265static int __devinit stmpe_input_probe(struct platform_device *pdev)
265{ 266{
266 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent); 267 struct stmpe *stmpe = dev_get_drvdata(pdev->dev.parent);
267 struct stmpe_platform_data *pdata = stmpe->pdata; 268 const struct stmpe_platform_data *pdata = stmpe->pdata;
269 const struct stmpe_ts_platform_data *ts_pdata = NULL;
268 struct stmpe_touch *ts; 270 struct stmpe_touch *ts;
269 struct input_dev *idev; 271 struct input_dev *idev;
270 struct stmpe_ts_platform_data *ts_pdata = NULL; 272 int error;
271 int ret;
272 int ts_irq; 273 int ts_irq;
273 274
274 ts_irq = platform_get_irq_byname(pdev, "FIFO_TH"); 275 ts_irq = platform_get_irq_byname(pdev, "FIFO_TH");
275 if (ts_irq < 0) 276 if (ts_irq < 0)
276 return ts_irq; 277 return ts_irq;
277 278
278 ts = kzalloc(sizeof(*ts), GFP_KERNEL); 279 ts = devm_kzalloc(&pdev->dev, sizeof(*ts), GFP_KERNEL);
279 if (!ts) { 280 if (!ts)
280 ret = -ENOMEM; 281 return -ENOMEM;
281 goto err_out;
282 }
283 282
284 idev = input_allocate_device(); 283 idev = devm_input_allocate_device(&pdev->dev);
285 if (!idev) { 284 if (!idev)
286 ret = -ENOMEM; 285 return -ENOMEM;
287 goto err_free_ts;
288 }
289 286
290 platform_set_drvdata(pdev, ts); 287 platform_set_drvdata(pdev, ts);
291 ts->stmpe = stmpe; 288 ts->stmpe = stmpe;
@@ -309,16 +306,17 @@ static int __devinit stmpe_input_probe(struct platform_device *pdev)
309 306
310 INIT_DELAYED_WORK(&ts->work, stmpe_work); 307 INIT_DELAYED_WORK(&ts->work, stmpe_work);
311 308
312 ret = request_threaded_irq(ts_irq, NULL, stmpe_ts_handler, 309 error = devm_request_threaded_irq(&pdev->dev, ts_irq,
313 IRQF_ONESHOT, STMPE_TS_NAME, ts); 310 NULL, stmpe_ts_handler,
314 if (ret) { 311 IRQF_ONESHOT, STMPE_TS_NAME, ts);
312 if (error) {
315 dev_err(&pdev->dev, "Failed to request IRQ %d\n", ts_irq); 313 dev_err(&pdev->dev, "Failed to request IRQ %d\n", ts_irq);
316 goto err_free_input; 314 return error;
317 } 315 }
318 316
319 ret = stmpe_init_hw(ts); 317 error = stmpe_init_hw(ts);
320 if (ret) 318 if (error)
321 goto err_free_irq; 319 return error;
322 320
323 idev->name = STMPE_TS_NAME; 321 idev->name = STMPE_TS_NAME;
324 idev->id.bustype = BUS_I2C; 322 idev->id.bustype = BUS_I2C;
@@ -334,40 +332,21 @@ static int __devinit stmpe_input_probe(struct platform_device *pdev)
334 input_set_abs_params(idev, ABS_Y, 0, XY_MASK, 0, 0); 332 input_set_abs_params(idev, ABS_Y, 0, XY_MASK, 0, 0);
335 input_set_abs_params(idev, ABS_PRESSURE, 0x0, 0xff, 0, 0); 333 input_set_abs_params(idev, ABS_PRESSURE, 0x0, 0xff, 0, 0);
336 334
337 ret = input_register_device(idev); 335 error = input_register_device(idev);
338 if (ret) { 336 if (error) {
339 dev_err(&pdev->dev, "Could not register input device\n"); 337 dev_err(&pdev->dev, "Could not register input device\n");
340 goto err_free_irq; 338 return error;
341 } 339 }
342 340
343 return ret; 341 return 0;
344
345err_free_irq:
346 free_irq(ts_irq, ts);
347err_free_input:
348 input_free_device(idev);
349 platform_set_drvdata(pdev, NULL);
350err_free_ts:
351 kfree(ts);
352err_out:
353 return ret;
354} 342}
355 343
356static int __devexit stmpe_ts_remove(struct platform_device *pdev) 344static int __devexit stmpe_ts_remove(struct platform_device *pdev)
357{ 345{
358 struct stmpe_touch *ts = platform_get_drvdata(pdev); 346 struct stmpe_touch *ts = platform_get_drvdata(pdev);
359 unsigned int ts_irq = platform_get_irq_byname(pdev, "FIFO_TH");
360 347
361 stmpe_disable(ts->stmpe, STMPE_BLOCK_TOUCHSCREEN); 348 stmpe_disable(ts->stmpe, STMPE_BLOCK_TOUCHSCREEN);
362 349
363 free_irq(ts_irq, ts);
364
365 platform_set_drvdata(pdev, NULL);
366
367 input_unregister_device(ts->idev);
368
369 kfree(ts);
370
371 return 0; 350 return 0;
372} 351}
373 352