All of lore.kernel.org
 help / color / mirror / Atom feed
From: yegorslists@googlemail.com
To: linux-input@vger.kernel.org
Cc: dmitry.torokhov@gmail.com, lee.jones@linaro.org, robh@kernel.org,
	mark.rutland@arm.com, andrej.skvortzov@gmail.com, nsekhar@ti.com,
	khilman@baylibre.com, Yegor Yefremov <yegorslists@googlemail.com>
Subject: [PATCH v2 1/3] tps6507x-ts: update to devm_* API
Date: Thu,  9 Mar 2017 15:31:07 +0100	[thread overview]
Message-ID: <1489069869-3849-2-git-send-email-yegorslists@googlemail.com> (raw)
In-Reply-To: <1489069869-3849-1-git-send-email-yegorslists@googlemail.com>

From: Yegor Yefremov <yegorslists@googlemail.com>

Update the code to use devm_* API so that driver
core will manage resources.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
---
 drivers/input/touchscreen/tps6507x-ts.c | 31 +++++--------------------------
 1 file changed, 5 insertions(+), 26 deletions(-)

diff --git a/drivers/input/touchscreen/tps6507x-ts.c b/drivers/input/touchscreen/tps6507x-ts.c
index a340bfc..fbaa2f68 100644
--- a/drivers/input/touchscreen/tps6507x-ts.c
+++ b/drivers/input/touchscreen/tps6507x-ts.c
@@ -226,7 +226,7 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
 	 */
 	init_data = tps_board->tps6507x_ts_init_data;
 
-	tsc = kzalloc(sizeof(struct tps6507x_ts), GFP_KERNEL);
+	tsc = devm_kzalloc(&pdev->dev, sizeof(struct tps6507x_ts), GFP_KERNEL);
 	if (!tsc) {
 		dev_err(tps6507x_dev->dev, "failed to allocate driver data\n");
 		return -ENOMEM;
@@ -240,11 +240,10 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
 	snprintf(tsc->phys, sizeof(tsc->phys),
 		 "%s/input0", dev_name(tsc->dev));
 
-	poll_dev = input_allocate_polled_device();
+	poll_dev = devm_input_allocate_polled_device(&pdev->dev);
 	if (!poll_dev) {
 		dev_err(tsc->dev, "Failed to allocate polled input device.\n");
-		error = -ENOMEM;
-		goto err_free_mem;
+		return -ENOMEM;
 	}
 
 	tsc->poll_dev = poll_dev;
@@ -274,34 +273,15 @@ static int tps6507x_ts_probe(struct platform_device *pdev)
 
 	error = tps6507x_adc_standby(tsc);
 	if (error)
-		goto err_free_polled_dev;
+		return error;
 
 	error = input_register_polled_device(poll_dev);
 	if (error)
-		goto err_free_polled_dev;
+		return error;
 
 	platform_set_drvdata(pdev, tsc);
 
 	return 0;
-
-err_free_polled_dev:
-	input_free_polled_device(poll_dev);
-err_free_mem:
-	kfree(tsc);
-	return error;
-}
-
-static int tps6507x_ts_remove(struct platform_device *pdev)
-{
-	struct tps6507x_ts *tsc = platform_get_drvdata(pdev);
-	struct input_polled_dev *poll_dev = tsc->poll_dev;
-
-	input_unregister_polled_device(poll_dev);
-	input_free_polled_device(poll_dev);
-
-	kfree(tsc);
-
-	return 0;
 }
 
 static struct platform_driver tps6507x_ts_driver = {
@@ -309,7 +289,6 @@ static struct platform_driver tps6507x_ts_driver = {
 		.name = "tps6507x-ts",
 	},
 	.probe = tps6507x_ts_probe,
-	.remove = tps6507x_ts_remove,
 };
 module_platform_driver(tps6507x_ts_driver);
 
-- 
2.1.4


  reply	other threads:[~2017-03-09 14:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-09 14:31 [PATCH v2 0/3] Add DT support for tps6507x touchscreen yegorslists
2017-03-09 14:31 ` yegorslists [this message]
2017-03-11  0:29   ` [PATCH v2 1/3] tps6507x-ts: update to devm_* API Dmitry Torokhov
2017-03-09 14:31 ` [PATCH v2 2/3] tps6507x-ts: add DT support yegorslists
2017-03-09 15:02   ` Yegor Yefremov
2017-03-09 14:31 ` [PATCH v2 3/3] tps6507x-ts: add DT bindings description yegorslists
2017-03-09 14:49   ` Rob Herring
2017-03-09 15:18     ` Yegor Yefremov
2017-03-09 17:55       ` Dmitry Torokhov
2017-03-10  6:41         ` Sekhar Nori
2017-03-10 18:00           ` Dmitry Torokhov
2017-03-10 19:54             ` Yegor Yefremov
2017-03-10 20:08               ` Dmitry Torokhov
2017-03-13 14:15                 ` Sekhar Nori
2017-03-10 16:26         ` Rob Herring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1489069869-3849-2-git-send-email-yegorslists@googlemail.com \
    --to=yegorslists@googlemail.com \
    --cc=andrej.skvortzov@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=khilman@baylibre.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-input@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=nsekhar@ti.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.