mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-05-24 10:39:52 +00:00
Input: 88pm860x-ts - 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: Himangi Saraogi <himangi774@gmail.com> Acked-by: Julia Lawall <julia.lawall@lip6.fr> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
This commit is contained in:
parent
cde51e73cb
commit
5ac66de574
1 changed files with 13 additions and 28 deletions
|
@ -16,6 +16,7 @@
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <linux/mfd/88pm860x.h>
|
#include <linux/mfd/88pm860x.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
#include <linux/device.h>
|
||||||
|
|
||||||
#define MEAS_LEN (8)
|
#define MEAS_LEN (8)
|
||||||
#define ACCURATE_BIT (12)
|
#define ACCURATE_BIT (12)
|
||||||
|
@ -234,16 +235,17 @@ static int pm860x_touch_probe(struct platform_device *pdev)
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
touch = kzalloc(sizeof(struct pm860x_touch), GFP_KERNEL);
|
touch = devm_kzalloc(&pdev->dev, sizeof(struct pm860x_touch),
|
||||||
if (touch == NULL)
|
GFP_KERNEL);
|
||||||
|
if (!touch)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
platform_set_drvdata(pdev, touch);
|
platform_set_drvdata(pdev, touch);
|
||||||
|
|
||||||
touch->idev = input_allocate_device();
|
touch->idev = devm_input_allocate_device(&pdev->dev);
|
||||||
if (touch->idev == NULL) {
|
if (!touch->idev) {
|
||||||
dev_err(&pdev->dev, "Failed to allocate input device!\n");
|
dev_err(&pdev->dev, "Failed to allocate input device!\n");
|
||||||
ret = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
touch->idev->name = "88pm860x-touch";
|
touch->idev->name = "88pm860x-touch";
|
||||||
|
@ -258,10 +260,11 @@ static int pm860x_touch_probe(struct platform_device *pdev)
|
||||||
touch->res_x = res_x;
|
touch->res_x = res_x;
|
||||||
input_set_drvdata(touch->idev, touch);
|
input_set_drvdata(touch->idev, touch);
|
||||||
|
|
||||||
ret = request_threaded_irq(touch->irq, NULL, pm860x_touch_handler,
|
ret = devm_request_threaded_irq(&pdev->dev, touch->irq, NULL,
|
||||||
IRQF_ONESHOT, "touch", touch);
|
pm860x_touch_handler, IRQF_ONESHOT,
|
||||||
|
"touch", touch);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto out_irq;
|
return ret;
|
||||||
|
|
||||||
__set_bit(EV_ABS, touch->idev->evbit);
|
__set_bit(EV_ABS, touch->idev->evbit);
|
||||||
__set_bit(ABS_X, touch->idev->absbit);
|
__set_bit(ABS_X, touch->idev->absbit);
|
||||||
|
@ -279,27 +282,10 @@ static int pm860x_touch_probe(struct platform_device *pdev)
|
||||||
ret = input_register_device(touch->idev);
|
ret = input_register_device(touch->idev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(chip->dev, "Failed to register touch!\n");
|
dev_err(chip->dev, "Failed to register touch!\n");
|
||||||
goto out_rg;
|
|
||||||
}
|
|
||||||
|
|
||||||
platform_set_drvdata(pdev, touch);
|
|
||||||
return 0;
|
|
||||||
out_rg:
|
|
||||||
free_irq(touch->irq, touch);
|
|
||||||
out_irq:
|
|
||||||
input_free_device(touch->idev);
|
|
||||||
out:
|
|
||||||
kfree(touch);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int pm860x_touch_remove(struct platform_device *pdev)
|
platform_set_drvdata(pdev, touch);
|
||||||
{
|
|
||||||
struct pm860x_touch *touch = platform_get_drvdata(pdev);
|
|
||||||
|
|
||||||
input_unregister_device(touch->idev);
|
|
||||||
free_irq(touch->irq, touch);
|
|
||||||
kfree(touch);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +295,6 @@ static struct platform_driver pm860x_touch_driver = {
|
||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
},
|
},
|
||||||
.probe = pm860x_touch_probe,
|
.probe = pm860x_touch_probe,
|
||||||
.remove = pm860x_touch_remove,
|
|
||||||
};
|
};
|
||||||
module_platform_driver(pm860x_touch_driver);
|
module_platform_driver(pm860x_touch_driver);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue