Commit 157d45fb authored by Himangi Saraogi's avatar Himangi Saraogi Committed by Dmitry Torokhov

Input: intel-mid-touch - switch to using managed resources

Let's switch the driver to use managed resources, this will simplify
error handling and driver unbinding logic.
Signed-off-by: default avatarHimangi Saraogi <himangi774@gmail.com>
Acked-by: default avatarJulia Lawall <julia.lawall@lip6.fr>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent ac414da3
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/delay.h> #include <linux/delay.h>
#include <asm/intel_scu_ipc.h> #include <asm/intel_scu_ipc.h>
#include <linux/device.h>
/* PMIC Interrupt registers */ /* PMIC Interrupt registers */
#define PMIC_REG_ID1 0x00 /* PMIC ID1 register */ #define PMIC_REG_ID1 0x00 /* PMIC ID1 register */
...@@ -580,12 +581,17 @@ static int mrstouch_probe(struct platform_device *pdev) ...@@ -580,12 +581,17 @@ static int mrstouch_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }
tsdev = kzalloc(sizeof(struct mrstouch_dev), GFP_KERNEL); tsdev = devm_kzalloc(&pdev->dev, sizeof(struct mrstouch_dev),
input = input_allocate_device(); GFP_KERNEL);
if (!tsdev || !input) { if (!tsdev) {
dev_err(&pdev->dev, "unable to allocate memory\n"); dev_err(&pdev->dev, "unable to allocate memory\n");
err = -ENOMEM; return -ENOMEM;
goto err_free_mem; }
input = devm_input_allocate_device(&pdev->dev);
if (!input) {
dev_err(&pdev->dev, "unable to allocate input device\n");
return -ENOMEM;
} }
tsdev->dev = &pdev->dev; tsdev->dev = &pdev->dev;
...@@ -598,7 +604,7 @@ static int mrstouch_probe(struct platform_device *pdev) ...@@ -598,7 +604,7 @@ static int mrstouch_probe(struct platform_device *pdev)
err = mrstouch_adc_init(tsdev); err = mrstouch_adc_init(tsdev);
if (err) { if (err) {
dev_err(&pdev->dev, "ADC initialization failed\n"); dev_err(&pdev->dev, "ADC initialization failed\n");
goto err_free_mem; return err;
} }
input->name = "mrst_touchscreen"; input->name = "mrst_touchscreen";
...@@ -618,38 +624,20 @@ static int mrstouch_probe(struct platform_device *pdev) ...@@ -618,38 +624,20 @@ static int mrstouch_probe(struct platform_device *pdev)
input_set_abs_params(tsdev->input, ABS_PRESSURE, input_set_abs_params(tsdev->input, ABS_PRESSURE,
MRST_PRESSURE_MIN, MRST_PRESSURE_MAX, 0, 0); MRST_PRESSURE_MIN, MRST_PRESSURE_MAX, 0, 0);
err = request_threaded_irq(tsdev->irq, NULL, mrstouch_pendet_irq, err = devm_request_threaded_irq(&pdev->dev, tsdev->irq, NULL,
IRQF_ONESHOT, "mrstouch", tsdev); mrstouch_pendet_irq, IRQF_ONESHOT,
"mrstouch", tsdev);
if (err) { if (err) {
dev_err(tsdev->dev, "unable to allocate irq\n"); dev_err(tsdev->dev, "unable to allocate irq\n");
goto err_free_mem; return err;
} }
err = input_register_device(tsdev->input); err = input_register_device(tsdev->input);
if (err) { if (err) {
dev_err(tsdev->dev, "unable to register input device\n"); dev_err(tsdev->dev, "unable to register input device\n");
goto err_free_irq; return err;
} }
platform_set_drvdata(pdev, tsdev);
return 0;
err_free_irq:
free_irq(tsdev->irq, tsdev);
err_free_mem:
input_free_device(input);
kfree(tsdev);
return err;
}
static int mrstouch_remove(struct platform_device *pdev)
{
struct mrstouch_dev *tsdev = platform_get_drvdata(pdev);
free_irq(tsdev->irq, tsdev);
input_unregister_device(tsdev->input);
kfree(tsdev);
return 0; return 0;
} }
...@@ -659,7 +647,6 @@ static struct platform_driver mrstouch_driver = { ...@@ -659,7 +647,6 @@ static struct platform_driver mrstouch_driver = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}, },
.probe = mrstouch_probe, .probe = mrstouch_probe,
.remove = mrstouch_remove,
}; };
module_platform_driver(mrstouch_driver); module_platform_driver(mrstouch_driver);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment