lkml.org 
[lkml]   [2014]   [Aug]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] Input: da9052_onkey: convert to use devm_*
Date
Converting to devm functions can make the code smaller and cleaner.

Signed-off-by: Kiran Padwal <kiran.padwal@smartplayin.com>
---
drivers/input/misc/da9052_onkey.c | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/input/misc/da9052_onkey.c b/drivers/input/misc/da9052_onkey.c
index 184c8f2..909441e 100644
--- a/drivers/input/misc/da9052_onkey.c
+++ b/drivers/input/misc/da9052_onkey.c
@@ -84,12 +84,14 @@ static int da9052_onkey_probe(struct platform_device *pdev)
return -EINVAL;
}

- onkey = kzalloc(sizeof(*onkey), GFP_KERNEL);
- input_dev = input_allocate_device();
- if (!onkey || !input_dev) {
- dev_err(&pdev->dev, "Failed to allocate memory\n");
- error = -ENOMEM;
- goto err_free_mem;
+ onkey = devm_kzalloc(&pdev->dev, sizeof(*onkey), GFP_KERNEL);
+ if (!onkey)
+ return -ENOMEM;
+
+ input_dev = devm_input_allocate_device(&pdev->dev);
+ if (!input_dev) {
+ dev_err(&pdev->dev, "Failed to allocate input device\n");
+ return -ENOMEM;
}

onkey->input = input_dev;
@@ -108,7 +110,7 @@ static int da9052_onkey_probe(struct platform_device *pdev)
if (error < 0) {
dev_err(onkey->da9052->dev,
"Failed to register ONKEY IRQ: %d\n", error);
- goto err_free_mem;
+ return error;
}

error = input_register_device(onkey->input);
@@ -124,9 +126,6 @@ static int da9052_onkey_probe(struct platform_device *pdev)
err_free_irq:
da9052_free_irq(onkey->da9052, DA9052_IRQ_NONKEY, onkey);
cancel_delayed_work_sync(&onkey->work);
-err_free_mem:
- input_free_device(input_dev);
- kfree(onkey);

return error;
}
@@ -139,7 +138,6 @@ static int da9052_onkey_remove(struct platform_device *pdev)
cancel_delayed_work_sync(&onkey->work);

input_unregister_device(onkey->input);
- kfree(onkey);

return 0;
}
--
1.7.9.5


\
 
 \ /
  Last update: 2014-08-08 09:41    [W:0.040 / U:0.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site