linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] input: stmpe-keyboard: Use devm_*() routines
@ 2012-11-09 15:27 Viresh Kumar
  2012-11-09 15:27 ` [PATCH 2/3] input: stmpe-ts: " Viresh Kumar
                   ` (2 more replies)
  0 siblings, 3 replies; 14+ messages in thread
From: Viresh Kumar @ 2012-11-09 15:27 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: linux-input, linux-kernel, spear-devel, Viresh Kumar

This patch frees stmpe-keyboard driver from tension 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>
---
 drivers/input/keyboard/stmpe-keypad.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/drivers/input/keyboard/stmpe-keypad.c b/drivers/input/keyboard/stmpe-keypad.c
index 470a877..6e25497 100644
--- a/drivers/input/keyboard/stmpe-keypad.c
+++ b/drivers/input/keyboard/stmpe-keypad.c
@@ -275,15 +275,14 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
 	if (irq < 0)
 		return irq;
 
-	keypad = kzalloc(sizeof(struct stmpe_keypad), GFP_KERNEL);
+	keypad = devm_kzalloc(&pdev->dev, sizeof(struct stmpe_keypad),
+			GFP_KERNEL);
 	if (!keypad)
 		return -ENOMEM;
 
-	input = input_allocate_device();
-	if (!input) {
-		ret = -ENOMEM;
-		goto out_freekeypad;
-	}
+	input = devm_input_allocate_device(&pdev->dev);
+	if (!input)
+		return -ENOMEM;
 
 	input->name = "STMPE keypad";
 	input->id.bustype = BUS_I2C;
@@ -294,7 +293,7 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
 					 STMPE_KEYPAD_MAX_COLS,
 					 keypad->keymap, input);
 	if (ret)
-		goto out_freeinput;
+		return ret;
 
 	input_set_capability(input, EV_MSC, MSC_SCAN);
 	if (!plat->no_autorepeat)
@@ -314,17 +313,17 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
 
 	ret = stmpe_keypad_chip_init(keypad);
 	if (ret < 0)
-		goto out_freeinput;
+		return ret;
 
 	ret = input_register_device(input);
 	if (ret) {
 		dev_err(&pdev->dev,
 			"unable to register input device: %d\n", ret);
-		goto out_freeinput;
+		return ret;
 	}
 
-	ret = request_threaded_irq(irq, NULL, stmpe_keypad_irq, IRQF_ONESHOT,
-				   "stmpe-keypad", keypad);
+	ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, stmpe_keypad_irq,
+			IRQF_ONESHOT, "stmpe-keypad", keypad);
 	if (ret) {
 		dev_err(&pdev->dev, "unable to get irq: %d\n", ret);
 		goto out_unregisterinput;
@@ -336,11 +335,6 @@ static int __devinit stmpe_keypad_probe(struct platform_device *pdev)
 
 out_unregisterinput:
 	input_unregister_device(input);
-	input = NULL;
-out_freeinput:
-	input_free_device(input);
-out_freekeypad:
-	kfree(keypad);
 	return ret;
 }
 
@@ -348,14 +342,9 @@ static int __devexit stmpe_keypad_remove(struct platform_device *pdev)
 {
 	struct stmpe_keypad *keypad = platform_get_drvdata(pdev);
 	struct stmpe *stmpe = keypad->stmpe;
-	int irq = platform_get_irq(pdev, 0);
 
 	stmpe_disable(stmpe, STMPE_BLOCK_KEYPAD);
-
-	free_irq(irq, keypad);
 	input_unregister_device(keypad->input);
-	platform_set_drvdata(pdev, NULL);
-	kfree(keypad);
 
 	return 0;
 }
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-11-20  7:57 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-09 15:27 [PATCH 1/3] input: stmpe-keyboard: Use devm_*() routines Viresh Kumar
2012-11-09 15:27 ` [PATCH 2/3] input: stmpe-ts: " Viresh Kumar
2012-11-09 17:04   ` Viresh Kumar
2012-11-10  8:00     ` Dmitry Torokhov
2012-11-10  8:03       ` Viresh Kumar
2012-11-10  8:04         ` Viresh Kumar
2012-11-10  8:12           ` Dmitry Torokhov
2012-11-10  8:15           ` Hannes Frederic Sowa
2012-11-09 15:27 ` [PATCH 3/3] input:stmpe-ts:Initialize the phys field for input device Viresh Kumar
2012-11-20  6:58   ` Viresh Kumar
2012-11-20  7:47     ` Dmitry Torokhov
2012-11-20  7:57       ` Viresh Kumar
2012-11-09 16:45 ` [PATCH 1/3] input: stmpe-keyboard: Use devm_*() routines Dmitry Torokhov
2012-11-09 17:03   ` Viresh Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).