aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/mms114.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/touchscreen/mms114.c')
-rw-r--r--drivers/input/touchscreen/mms114.c54
1 files changed, 16 insertions, 38 deletions
diff --git a/drivers/input/touchscreen/mms114.c b/drivers/input/touchscreen/mms114.c
index 98841d8aa635..4a29ddf6bf1e 100644
--- a/drivers/input/touchscreen/mms114.c
+++ b/drivers/input/touchscreen/mms114.c
@@ -429,12 +429,12 @@ static int mms114_probe(struct i2c_client *client,
429 return -ENODEV; 429 return -ENODEV;
430 } 430 }
431 431
432 data = kzalloc(sizeof(struct mms114_data), GFP_KERNEL); 432 data = devm_kzalloc(&client->dev, sizeof(struct mms114_data),
433 input_dev = input_allocate_device(); 433 GFP_KERNEL);
434 input_dev = devm_input_allocate_device(&client->dev);
434 if (!data || !input_dev) { 435 if (!data || !input_dev) {
435 dev_err(&client->dev, "Failed to allocate memory\n"); 436 dev_err(&client->dev, "Failed to allocate memory\n");
436 error = -ENOMEM; 437 return -ENOMEM;
437 goto err_free_mem;
438 } 438 }
439 439
440 data->client = client; 440 data->client = client;
@@ -466,57 +466,36 @@ static int mms114_probe(struct i2c_client *client,
466 input_set_drvdata(input_dev, data); 466 input_set_drvdata(input_dev, data);
467 i2c_set_clientdata(client, data); 467 i2c_set_clientdata(client, data);
468 468
469 data->core_reg = regulator_get(&client->dev, "avdd"); 469 data->core_reg = devm_regulator_get(&client->dev, "avdd");
470 if (IS_ERR(data->core_reg)) { 470 if (IS_ERR(data->core_reg)) {
471 error = PTR_ERR(data->core_reg); 471 error = PTR_ERR(data->core_reg);
472 dev_err(&client->dev, 472 dev_err(&client->dev,
473 "Unable to get the Core regulator (%d)\n", error); 473 "Unable to get the Core regulator (%d)\n", error);
474 goto err_free_mem; 474 return error;
475 } 475 }
476 476
477 data->io_reg = regulator_get(&client->dev, "vdd"); 477 data->io_reg = devm_regulator_get(&client->dev, "vdd");
478 if (IS_ERR(data->io_reg)) { 478 if (IS_ERR(data->io_reg)) {
479 error = PTR_ERR(data->io_reg); 479 error = PTR_ERR(data->io_reg);
480 dev_err(&client->dev, 480 dev_err(&client->dev,
481 "Unable to get the IO regulator (%d)\n", error); 481 "Unable to get the IO regulator (%d)\n", error);
482 goto err_core_reg; 482 return error;
483 } 483 }
484 484
485 error = request_threaded_irq(client->irq, NULL, mms114_interrupt, 485 error = devm_request_threaded_irq(&client->dev, client->irq, NULL,
486 IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "mms114", data); 486 mms114_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
487 dev_name(&client->dev), data);
487 if (error) { 488 if (error) {
488 dev_err(&client->dev, "Failed to register interrupt\n"); 489 dev_err(&client->dev, "Failed to register interrupt\n");
489 goto err_io_reg; 490 return error;
490 } 491 }
491 disable_irq(client->irq); 492 disable_irq(client->irq);
492 493
493 error = input_register_device(data->input_dev); 494 error = input_register_device(data->input_dev);
494 if (error) 495 if (error) {
495 goto err_free_irq; 496 dev_err(&client->dev, "Failed to register input device\n");
496 497 return error;
497 return 0; 498 }
498
499err_free_irq:
500 free_irq(client->irq, data);
501err_io_reg:
502 regulator_put(data->io_reg);
503err_core_reg:
504 regulator_put(data->core_reg);
505err_free_mem:
506 input_free_device(input_dev);
507 kfree(data);
508 return error;
509}
510
511static int mms114_remove(struct i2c_client *client)
512{
513 struct mms114_data *data = i2c_get_clientdata(client);
514
515 free_irq(client->irq, data);
516 regulator_put(data->io_reg);
517 regulator_put(data->core_reg);
518 input_unregister_device(data->input_dev);
519 kfree(data);
520 499
521 return 0; 500 return 0;
522} 501}
@@ -590,7 +569,6 @@ static struct i2c_driver mms114_driver = {
590 .of_match_table = of_match_ptr(mms114_dt_match), 569 .of_match_table = of_match_ptr(mms114_dt_match),
591 }, 570 },
592 .probe = mms114_probe, 571 .probe = mms114_probe,
593 .remove = mms114_remove,
594 .id_table = mms114_id, 572 .id_table = mms114_id,
595}; 573};
596 574